[PATCH] D158842: [include-cleaner] Handle decls/refs to concepts.
Utkarsh Saxena via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 31 03:43:43 PDT 2023
usaxena95 updated this revision to Diff 554962.
usaxena95 marked 2 inline comments as done.
usaxena95 added a comment.
Addressed comments.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D158842/new/
https://reviews.llvm.org/D158842
Files:
clang-tools-extra/include-cleaner/lib/WalkAST.cpp
clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
Index: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
===================================================================
--- clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
@@ -528,5 +528,16 @@
const char* s = "";
auto sx = ^{s};)cpp");
}
+
+TEST(WalkAST, Concepts) {
+ std::string Concept = "template<typename T> concept $explicit^Foo = true;";
+ testWalk(Concept, "template<typename T>concept Bar = ^Foo<T> && true;");
+ testWalk(Concept, "template<^Foo T>void func() {}");
+ testWalk(Concept, "template<typename T> requires ^Foo<T> void func() {}");
+ testWalk(Concept, "template<typename T> void func() requires ^Foo<T> {}");
+ testWalk(Concept, "void func(^Foo auto x) {}");
+ // FIXME: Foo should be explicitly referenced.
+ testWalk("template<typename T> concept Foo = true;", "void func() { ^Foo auto x = 1; }");
+}
} // namespace
} // namespace clang::include_cleaner
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
@@ -241,6 +241,11 @@
return true;
}
+ bool VisitConceptReference(const ConceptReference *CR) {
+ report(CR->getConceptNameLoc(), CR->getFoundDecl());
+ return true;
+ }
+
// Report a reference from explicit specializations to the specialized
// template. Implicit ones are filtered out by RAV and explicit instantiations
// are already traversed through typelocs.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158842.554962.patch
Type: text/x-patch
Size: 1618 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230831/10531135/attachment.bin>
More information about the cfe-commits
mailing list