[PATCH] D153330: [include-cleaner] Ignore the ParmVarDecl itself in WalkAST.cpp
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 20 05:33:52 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG149f309f50cd: [include-cleaner] Ignore the ParmVarDecl itself in WalkAST.cpp (authored by hokein).
Changed prior to commit:
https://reviews.llvm.org/D153330?vs=532863&id=532870#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153330/new/
https://reviews.llvm.org/D153330
Files:
clang-tools-extra/include-cleaner/lib/WalkAST.cpp
clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
Index: clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
===================================================================
--- clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
@@ -91,7 +91,8 @@
#include "header.h"
#include "private.h"
- void $bar^bar($private^Private $p^p) {
+ // No reference reported for the Parameter "p".
+ void $bar^bar($private^Private p) {
$foo^foo();
std::$vector^vector $vconstructor^$v^v;
$builtin^__builtin_popcount(1);
@@ -120,7 +121,6 @@
offsetToProviders(AST, SM),
UnorderedElementsAre(
Pair(Code.point("bar"), UnorderedElementsAre(MainFile)),
- Pair(Code.point("p"), UnorderedElementsAre(MainFile)),
Pair(Code.point("private"),
UnorderedElementsAre(PublicFile, PrivateFile)),
Pair(Code.point("foo"), UnorderedElementsAre(HeaderFile)),
Index: clang-tools-extra/include-cleaner/lib/WalkAST.cpp
===================================================================
--- clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -214,6 +214,10 @@
return true;
}
bool VisitVarDecl(VarDecl *VD) {
+ // Ignore the parameter decl itself (its children were handled elsewhere),
+ // as they don't contribute to the main-file #include.
+ if (llvm::isa<ParmVarDecl>(VD))
+ return true;
// Mark declaration from definition as it needs type-checking.
if (VD->isThisDeclarationADefinition())
report(VD->getLocation(), VD);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153330.532870.patch
Type: text/x-patch
Size: 1616 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230620/9484be73/attachment-0001.bin>
More information about the cfe-commits
mailing list