Disable the warnings with IWYU pragma: export or begin_exports +
end_exports until we have support for these pragmas. There are too many
false-positive warnings for the headers that have the correct pragmas for now
and it makes the user experience very unpleasant.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/clangd/Headers.cpp | ||
---|---|---|
134 | the split seems to be increasing code duplication (we've already copied a bug with it 😓), what about: bool Err = false; llvm::StringRef Text = SM.getCharacterData(Range.getBegin(), &Err); if (!Err || (!Text.consume_front(IWYUPragmaKeep) && !Text.consume_front(IWYUPragmaExport))) return false; if(inMainFile()) { unsigned Offset = SM.getFileOffset(Range.getBegin()); LastPragmaKeepInMainFileLine = SM.getLineNumber(SM.getMainFileID(), Offset) - 1; } else { Out->HasIWYUPragmas.insert( *Out->getID(SM.getFileEntryForID(SM.getFileID(Range.getBegin())))); } return false; | |
135 | i don't think the asserts carry their weight (here and also in the headerfile comment handler). we're not really performing anything dubious if the asserts don't hold. getCharacterData will return non-sense (but valid) buffers in case of a macroid, and we're already reading data whether we're in the main file or not. moreover these are private and controlled at the entry by the public interface (HandleComment). | |
178 | shouldn't this be if (Err || (!Text.consume ... && !Text.consume...)) return false; ? same above for the main file comment handling | |
clang-tools-extra/clangd/IncludeCleaner.cpp | ||
270–271 | can you also move this comment below, next to the isFileMultipleHeaderGuarded check? | |
clang-tools-extra/clangd/unittests/HeadersTests.cpp | ||
427 | no need for testPaths here and below. | |
438 | this is passing not because you don't have a IWYU pragma comment here, but because you don't have any comments at all. can you try inserting an arbitrary comment into the file? | |
clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp | ||
603 | do you mean just foo.h is unused why are we talking about bar.h also being unused here? |
Address review comments: the structure is a bit different but the bug is now
actually removed.
Great! A few more nits
clang-tools-extra/clangd/Headers.cpp | ||
---|---|---|
151 | you never use Text again, so consume_front is unneccesary and confusing here, we can just use starts_with | |
151 | add a FIXME that begin_export is not handled here (now that the other branch supports it) | |
clang-tools-extra/clangd/Headers.h | ||
148 | hasIWYUExport? | |
clang-tools-extra/clangd/IncludeCleaner.cpp | ||
274 | actual support for export pragmas => more precise tracking of exported headers? (current wording doesn't really say what's missing) |
hasIWYUExport?
(if the file contains non-export pragmas we need to return false)