llvm / llvm/llvm-project

[clang-include-cleaner] "// IWYU pragma: export" on non-#include line ends enclosing "// IWYU pragma: begin_exports" block

Open
#200,036 2 comments 0 reactions 0 assignees View on GitHub
clang-include-cleaner clangd
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

include-what-you-use allows the `// IWYU pragma: export` comment to be applied to forward declarations. When the include cleaner comes across such a construct, any `begin_exports` block from an enclosing header file gets closed. I'm not sure if applying exports to forward declarations is supported by the include cleaner, but regardless, it'd be nice if it didn't have this side effect.

A.hpp
```c++
#pragma once
class foo; // IWYU pragma: export
```

B.hpp
```c++
#pragma once
```

C.hpp
```c++
#pragma once
// IWYU pragma: begin_exports
#include "A.hpp"
#include "B.hpp" // "Included header B.hpp is not used directly"
// IWYU pragma: end_exports
```

clangd version 22.1.0-rc1

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.