llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Follow IWYU pragma: export transitively

Open VitaNuo opened this issue 3 years ago • 4 comments

At the moment, we only follow one level of IWYU export pragmas (probably due to the way old IWYU tool behaves). We're receiving user complaints because of this, and should consider traversing the pragma transitively. E.g.,

foo.h

#include "bar.h" // IWYU pragma: export

bar.h

#include "baz.h" // IWYU pragma: export

baz.h

#pragma once
void foo();

main.cc

#include "foo.h"
void func() {
  foo();
}

will currently suggest including "baz.h", which is wrong.

VitaNuo avatar Aug 03 '23 10:08 VitaNuo

cc @kadircet

VitaNuo avatar Aug 03 '23 10:08 VitaNuo

@llvm/issue-subscribers-clang-include-cleaner

llvmbot avatar Aug 03 '23 10:08 llvmbot

FWIW, I was checking the behavior in include-what-you-use tool, and it seems to respect these transitively. So we should do that too for compatibility reasons (also I think it's more sensible. IIRC, we didn't do it initially because we thought include-what-you-use didn't treat transitive includes, but apparently we were confused).

kadircet avatar Aug 03 '23 11:08 kadircet

fixed with c3ad4b7636022

kadircet avatar Sep 05 '23 08:09 kadircet