[clang] 99df06a - [AST] Dump explicit template arguments for UnreslovedLookupExpr. (#90466)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 29 09:59:08 PDT 2024
Author: Haojian Wu
Date: 2024-04-29T18:59:03+02:00
New Revision: 99df06ac71b12bc5a38240e71cfc37383687b48e
URL: https://github.com/llvm/llvm-project/commit/99df06ac71b12bc5a38240e71cfc37383687b48e
DIFF: https://github.com/llvm/llvm-project/commit/99df06ac71b12bc5a38240e71cfc37383687b48e.diff
LOG: [AST] Dump explicit template arguments for UnreslovedLookupExpr. (#90466)
Having them dump is useful for ad-hoc debugging (context:
https://github.com/llvm/llvm-project/issues/90046)
Added:
Modified:
clang/include/clang/AST/ASTNodeTraverser.h
clang/test/AST/ast-dump-template-json-win32-mangler-crash.cpp
clang/test/AST/ast-dump-templates.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/AST/ASTNodeTraverser.h b/clang/include/clang/AST/ASTNodeTraverser.h
index 216dc9eef08b62..bf7c204e4ad73a 100644
--- a/clang/include/clang/AST/ASTNodeTraverser.h
+++ b/clang/include/clang/AST/ASTNodeTraverser.h
@@ -844,6 +844,12 @@ class ASTNodeTraverser
}
}
+ void VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *E) {
+ if (E->hasExplicitTemplateArgs())
+ for (auto Arg : E->template_arguments())
+ Visit(Arg.getArgument());
+ }
+
void VisitRequiresExpr(const RequiresExpr *E) {
for (auto *D : E->getLocalParameters())
Visit(D);
diff --git a/clang/test/AST/ast-dump-template-json-win32-mangler-crash.cpp b/clang/test/AST/ast-dump-template-json-win32-mangler-crash.cpp
index cf740516db6f4b..5ac55d269dce48 100644
--- a/clang/test/AST/ast-dump-template-json-win32-mangler-crash.cpp
+++ b/clang/test/AST/ast-dump-template-json-win32-mangler-crash.cpp
@@ -1846,6 +1846,42 @@ int main()
// CHECK-NEXT: "kind": "VarTemplateDecl",
// CHECK-NEXT: "name": "is_const_v"
// CHECK-NEXT: }
+// CHECK-NEXT: ],
+// CHECK-NEXT: "inner": [
+// CHECK-NEXT: {
+// CHECK-NEXT: "kind": "TemplateArgument",
+// CHECK-NEXT: "type": {
+// CHECK-NEXT: "qualType": "const _Ty"
+// CHECK-NEXT: },
+// CHECK-NEXT: "inner": [
+// CHECK-NEXT: {
+// CHECK-NEXT: "id": "0x{{.*}}",
+// CHECK-NEXT: "kind": "QualType",
+// CHECK-NEXT: "type": {
+// CHECK-NEXT: "qualType": "const _Ty"
+// CHECK-NEXT: },
+// CHECK-NEXT: "qualifiers": "const",
+// CHECK-NEXT: "inner": [
+// CHECK-NEXT: {
+// CHECK-NEXT: "id": "0x{{.*}}",
+// CHECK-NEXT: "kind": "TemplateTypeParmType",
+// CHECK-NEXT: "type": {
+// CHECK-NEXT: "qualType": "_Ty"
+// CHECK-NEXT: },
+// CHECK-NEXT: "isDependent": true,
+// CHECK-NEXT: "isInstantiationDependent": true,
+// CHECK-NEXT: "depth": 0,
+// CHECK-NEXT: "index": 0,
+// CHECK-NEXT: "decl": {
+// CHECK-NEXT: "id": "0x{{.*}}",
+// CHECK-NEXT: "kind": "TemplateTypeParmDecl",
+// CHECK-NEXT: "name": "_Ty"
+// CHECK-NEXT: }
+// CHECK-NEXT: }
+// CHECK-NEXT: ]
+// CHECK-NEXT: }
+// CHECK-NEXT: ]
+// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: }
// CHECK-NEXT: ]
@@ -1900,6 +1936,32 @@ int main()
// CHECK-NEXT: "kind": "VarTemplateDecl",
// CHECK-NEXT: "name": "is_reference_v"
// CHECK-NEXT: }
+// CHECK-NEXT: ],
+// CHECK-NEXT: "inner": [
+// CHECK-NEXT: {
+// CHECK-NEXT: "kind": "TemplateArgument",
+// CHECK-NEXT: "type": {
+// CHECK-NEXT: "qualType": "_Ty"
+// CHECK-NEXT: },
+// CHECK-NEXT: "inner": [
+// CHECK-NEXT: {
+// CHECK-NEXT: "id": "0x{{.*}}",
+// CHECK-NEXT: "kind": "TemplateTypeParmType",
+// CHECK-NEXT: "type": {
+// CHECK-NEXT: "qualType": "_Ty"
+// CHECK-NEXT: },
+// CHECK-NEXT: "isDependent": true,
+// CHECK-NEXT: "isInstantiationDependent": true,
+// CHECK-NEXT: "depth": 0,
+// CHECK-NEXT: "index": 0,
+// CHECK-NEXT: "decl": {
+// CHECK-NEXT: "id": "0x{{.*}}",
+// CHECK-NEXT: "kind": "TemplateTypeParmDecl",
+// CHECK-NEXT: "name": "_Ty"
+// CHECK-NEXT: }
+// CHECK-NEXT: }
+// CHECK-NEXT: ]
+// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: }
// CHECK-NEXT: ]
@@ -2565,6 +2627,32 @@ int main()
// CHECK-NEXT: "kind": "VarTemplateDecl",
// CHECK-NEXT: "name": "is_function_v"
// CHECK-NEXT: }
+// CHECK-NEXT: ],
+// CHECK-NEXT: "inner": [
+// CHECK-NEXT: {
+// CHECK-NEXT: "kind": "TemplateArgument",
+// CHECK-NEXT: "type": {
+// CHECK-NEXT: "qualType": "_Ty1"
+// CHECK-NEXT: },
+// CHECK-NEXT: "inner": [
+// CHECK-NEXT: {
+// CHECK-NEXT: "id": "0x{{.*}}",
+// CHECK-NEXT: "kind": "TemplateTypeParmType",
+// CHECK-NEXT: "type": {
+// CHECK-NEXT: "qualType": "_Ty1"
+// CHECK-NEXT: },
+// CHECK-NEXT: "isDependent": true,
+// CHECK-NEXT: "isInstantiationDependent": true,
+// CHECK-NEXT: "depth": 0,
+// CHECK-NEXT: "index": 0,
+// CHECK-NEXT: "decl": {
+// CHECK-NEXT: "id": "0x{{.*}}",
+// CHECK-NEXT: "kind": "TemplateTypeParmDecl",
+// CHECK-NEXT: "name": "_Ty1"
+// CHECK-NEXT: }
+// CHECK-NEXT: }
+// CHECK-NEXT: ]
+// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: }
// CHECK-NEXT: ]
diff --git a/clang/test/AST/ast-dump-templates.cpp b/clang/test/AST/ast-dump-templates.cpp
index d25ef36dd4d32c..9fcafbcbcc46b6 100644
--- a/clang/test/AST/ast-dump-templates.cpp
+++ b/clang/test/AST/ast-dump-templates.cpp
@@ -104,3 +104,17 @@ void (*q)() = f<>;
// CHECK1: template<> void f<0L>()
// CHECK1: template<> void f<0U>()
}
+
+namespace test6 {
+template <class D>
+constexpr bool C = true;
+
+template <class Key>
+void func() {
+ C<Key>;
+// DUMP: UnresolvedLookupExpr {{.*}} '<dependent type>' lvalue (no ADL) = 'C'
+// DUMP-NEXT: `-TemplateArgument type 'Key'
+// DUMP-NEXT: `-TemplateTypeParmType {{.*}} 'Key' dependent depth 0 index 0
+// DUMP-NEXT: `-TemplateTypeParm {{.*}} 'Key'
+}
+}
More information about the cfe-commits
mailing list