Skip to content

Commit

Permalink
[Concepts] Fix ast dump for immediately declared constraint.
Browse files Browse the repository at this point in the history
Reviewed By: nridge

Differential Revision: https://reviews.llvm.org/D84461
  • Loading branch information
hokein committed Jul 28, 2020
1 parent 5ee07dc commit c0bd9fa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/AST/TextNodeDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1994,7 +1994,7 @@ void TextNodeDumper::VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D) {
dumpBareDeclRef(TC->getFoundDecl());
OS << ")";
}
Visit(TC->getImmediatelyDeclaredConstraint());
AddChild([=] { Visit(TC->getImmediatelyDeclaredConstraint()); });
} else if (D->wasDeclaredWithTypename())
OS << " typename";
else
Expand Down
19 changes: 19 additions & 0 deletions clang/test/AST/ast-dump-concepts.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++2a -ast-dump -ast-dump-filter Foo %s | FileCheck -strict-whitespace %s

// Test with serialization:
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown -emit-pch -o %t %s
// RUN: %clang_cc1 -x c++ -std=c++20 -triple x86_64-unknown-unknown -include-pch %t \
// RUN: -ast-dump-all -ast-dump-filter Foo /dev/null \
// RUN: | FileCheck --strict-whitespace %s

template <typename T, typename U>
concept binary_concept = true;

template <typename T>
struct Foo {
// CHECK: TemplateTypeParmDecl {{.*}} referenced Concept {{.*}} 'binary_concept'
// CHECK-NEXT: |-ConceptSpecializationExpr {{.*}} 'bool'
// CHECK-NEXT: `-TemplateArgument {{.*}} type 'int'
template <binary_concept<int> R>
Foo(R);
};

0 comments on commit c0bd9fa

Please sign in to comment.