Issue 926 in include-what-you-use: False positive when included header has incorrect includes

1 view
Skip to first unread message

notifi...@include-what-you-use.org

unread,
May 30, 2021, 7:32:00 PMMay 30
to include-wh...@googlegroups.com
New issue 926 by ptomato: False positive when included header has incorrect includes
https://github.com/include-what-you-use/include-what-you-use/issues/926

I've found a minimal example for a case where an included header's missing include is reported as an IWYU error in the .cpp file. (In my case, the equivalents of `b.h` and `c.h` are library headers, so I get an IWYU error in my code and can't easily change the library headers to have correct includes.)

**a.cpp**:
```c++
#include "c.h"

void a(C c) {
c.method(42);
}
```

**b.h**:
```c++
#pragma once
#include <utility>
void b(int&& i);
```

**c.h**:
```c++
#pragma once
#include "b.h"

struct C {
template <typename T>
void method(T&& t) {
return b(std::forward<T>(t));
}
};
```

Command line:
```
$ include-what-you-use a.cpp

a.cpp should add these lines:
#include <utility> // for forward

a.cpp should remove these lines:

The full include-list for a.cpp:
#include <utility> // for forward
#include "c.h" // for C
---
```

Here, `c.h` should `#include <utility>` and `b.h` should not, but IWYU should not suggest anything to be changed in `a.cpp`.

Reply all
Reply to author
Forward
0 new messages