[PATCH] D145782: [clangd] Don't ignore headers with IWYU export pragmas for unused-include analysis.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 10 03:44:13 PST 2023
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.
This check was introduced due to the the lack support of the old implementation.
The new include-cleaner-library based implementation doesn't have this
limitation.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D145782
Files:
clang-tools-extra/clangd/IncludeCleaner.cpp
clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -300,10 +300,9 @@
ParsedAST AST = TU.build();
EXPECT_THAT(AST.getDiagnostics(), llvm::ValueIs(IsEmpty()));
- // FIXME: This is not correct: foo.h is unused but is not diagnosed as such
- // because we ignore headers with IWYU export pragmas for now.
IncludeCleanerFindings Findings = computeIncludeCleanerFindings(AST);
- EXPECT_THAT(Findings.UnusedIncludes, IsEmpty());
+ EXPECT_THAT(Findings.UnusedIncludes,
+ ElementsAre(Pointee(writtenInclusion("\"foo.h\""))));
}
TEST(IncludeCleaner, NoDiagsForObjC) {
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===================================================================
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -104,10 +104,6 @@
}
assert(Inc.HeaderID);
auto HID = static_cast<IncludeStructure::HeaderID>(*Inc.HeaderID);
- // FIXME: Ignore the headers with IWYU export pragmas for now, remove this
- // check when we have more precise tracking of exported headers.
- if (AST.getIncludeStructure().hasIWYUExport(HID))
- return false;
auto FE = AST.getSourceManager().getFileManager().getFileRef(
AST.getIncludeStructure().getRealPath(HID));
assert(FE);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145782.504086.patch
Type: text/x-patch
Size: 1488 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230310/528b7b20/attachment-0001.bin>
More information about the cfe-commits
mailing list