File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -241,6 +241,11 @@ class ASTWalker : public RecursiveASTVisitor<ASTWalker> {
241
241
return true ;
242
242
}
243
243
244
+ bool VisitConceptReference (const ConceptReference *CR) {
245
+ report (CR->getConceptNameLoc (), CR->getFoundDecl ());
246
+ return true ;
247
+ }
248
+
244
249
// Report a reference from explicit specializations to the specialized
245
250
// template. Implicit ones are filtered out by RAV and explicit instantiations
246
251
// are already traversed through typelocs.
Original file line number Diff line number Diff line change @@ -528,5 +528,16 @@ TEST(WalkAST, InitializerList) {
528
528
const char* s = "";
529
529
auto sx = ^{s};)cpp" );
530
530
}
531
+
532
+ TEST (WalkAST, Concepts) {
533
+ std::string Concept = " template<typename T> concept $explicit^Foo = true;" ;
534
+ testWalk (Concept, " template<typename T>concept Bar = ^Foo<T> && true;" );
535
+ testWalk (Concept, " template<^Foo T>void func() {}" );
536
+ testWalk (Concept, " template<typename T> requires ^Foo<T> void func() {}" );
537
+ testWalk (Concept, " template<typename T> void func() requires ^Foo<T> {}" );
538
+ testWalk (Concept, " void func(^Foo auto x) {}" );
539
+ // FIXME: Foo should be explicitly referenced.
540
+ testWalk (" template<typename T> concept Foo = true;" , " void func() { ^Foo auto x = 1; }" );
541
+ }
531
542
} // namespace
532
543
} // namespace clang::include_cleaner
You can’t perform that action at this time.
0 commit comments