diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index d10b284310071e..b8816d7b555e87 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -427,6 +427,8 @@ Miscellaneous Clang Crashes Fixed - Fixed a crash when function has more than 65536 parameters. Now a diagnostic is emitted. (#GH35741) +- Fixed ``-ast-dump`` crashes on codes involving ``concept`` with ``-ast-dump-decl-types``. (#GH94928) + OpenACC Specific Changes ------------------------ diff --git a/clang/lib/Frontend/ASTConsumers.cpp b/clang/lib/Frontend/ASTConsumers.cpp index 7b58eaa04df95a..a6e35452b4fbe6 100644 --- a/clang/lib/Frontend/ASTConsumers.cpp +++ b/clang/lib/Frontend/ASTConsumers.cpp @@ -101,7 +101,8 @@ namespace { if (DumpDeclTypes) { Decl *InnerD = D; if (auto *TD = dyn_cast(D)) - InnerD = TD->getTemplatedDecl(); + if (Decl *TempD = TD->getTemplatedDecl()) + InnerD = TempD; // FIXME: Support OutputFormat in type dumping. // FIXME: Support combining -ast-dump-decl-types with -ast-dump-lookups. diff --git a/clang/test/AST/ast-dump-concepts.cpp b/clang/test/AST/ast-dump-concepts.cpp index a5e0673c241ef4..84d981d2ab8dec 100644 --- a/clang/test/AST/ast-dump-concepts.cpp +++ b/clang/test/AST/ast-dump-concepts.cpp @@ -1,9 +1,9 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++2a -ast-dump -ast-dump-filter Foo %s | FileCheck -strict-whitespace %s +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++2a -ast-dump -ast-dump-decl-types -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: -ast-dump-all -ast-dump-decl-types -ast-dump-filter Foo /dev/null \ // RUN: | FileCheck --strict-whitespace %s template @@ -56,6 +56,9 @@ struct Foo { // CHECK: CXXFoldExpr {{.*}} template ... Ts> Foo(); + + // CHECK:InjectedClassNameType + // CHECK-NEXT: CXXRecord {{.*}} 'Foo' }; namespace GH82628 { @@ -75,20 +78,28 @@ template concept Foo = C; // CHECK: TemplateTypeParmDecl {{.*}} Concept {{.*}} 'C' (UsingShadow {{.*}} 'C') +// CHECK: QualType +// CHECK-NEXT: `-BuiltinType {{.*}} 'bool' template constexpr bool FooVar = false; // CHECK: ConceptSpecializationExpr {{.*}} UsingShadow {{.*}} 'C' +// CHECK: QualType +// CHECK-NEXT: `-BuiltinType {{.*}} 'bool' template requires C constexpr bool FooVar2 = true; // CHECK: SimpleRequirement // CHECK-NEXT: `-ConceptSpecializationExpr {{.*}} UsingShadow {{.*}} 'C' +// CHECK: QualType +// CHECK-NEXT: `-BuiltinType {{.*}} 'bool' template requires requires (T) { C; } constexpr bool FooVar3 = true; // CHECK: NonTypeTemplateParmDecl // CHECK-NEXT: `-ConceptSpecializationExpr {{.*}} UsingShadow {{.*}} 'C' +// CHECK: QualType +// CHECK-NEXT: `-BuiltinType {{.*}} 'bool' template constexpr bool FooVar4 = bool(T()); @@ -97,7 +108,9 @@ constexpr bool FooVar4 = bool(T()); // CHECK: NonTypeTemplateParmDecl {{.*}} depth 0 index 1 U // CHECK-NEXT: `-ConceptSpecializationExpr {{.*}} UsingShadow {{.*}} 'C' // CHECK: |-TemplateTypeParmDecl {{.*}} Concept {{.*}} 'C' (UsingShadow {{.*}} 'C') depth 0 index 2 V:auto - +// CHECK: FunctionProtoType +// CHECK: `-Concept {{.*}} 'C' +// CHECK: `-TemplateTypeParm {{.*}} 'V:auto' template auto FooFunc(C auto V) -> C decltype(auto) { // FIXME: TypeLocs inside of the function body cannot be dumped via -ast-dump for now.