From c0bd9fa137c28a3ef833b46b7f9770b060275281 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Tue, 28 Jul 2020 11:59:49 +0200 Subject: [PATCH] [Concepts] Fix ast dump for immediately declared constraint. Reviewed By: nridge Differential Revision: https://reviews.llvm.org/D84461 --- clang/lib/AST/TextNodeDumper.cpp | 2 +- clang/test/AST/ast-dump-concepts.cpp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 clang/test/AST/ast-dump-concepts.cpp diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp index 91b984820cd2..5b6c6085e02c 100644 --- a/clang/lib/AST/TextNodeDumper.cpp +++ b/clang/lib/AST/TextNodeDumper.cpp @@ -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 diff --git a/clang/test/AST/ast-dump-concepts.cpp b/clang/test/AST/ast-dump-concepts.cpp new file mode 100644 index 000000000000..530c1baeffa7 --- /dev/null +++ b/clang/test/AST/ast-dump-concepts.cpp @@ -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 +concept binary_concept = true; + +template +struct Foo { + // CHECK: TemplateTypeParmDecl {{.*}} referenced Concept {{.*}} 'binary_concept' + // CHECK-NEXT: |-ConceptSpecializationExpr {{.*}} 'bool' + // CHECK-NEXT: `-TemplateArgument {{.*}} type 'int' + template R> + Foo(R); +};