[clang] [clang-tools-extra] [clang] Add formal linkage to textual AST dump (PR #194600)
via cfe-commits
cfe-commits at lists.llvm.org
Fri May 1 09:58:34 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clangd
Author: Vlad Serebrennikov (Endilll)
<details>
<summary>Changes</summary>
This PR adds formal linkage (external, module, internal) to the textual AST dumps. The motivation is to inform users (including ourselves) what Clang thinks the linkage is, and to prevent situations where `extern` is mistaken for an indication of external linkage (see #<!-- -->192116 for an example).
The wording around linkage is known to be defective, but that's the best we have: [[basic.link]](https://eel.is/c++draft/basic.link) paragraphs 3 through 7.
There are enough changes in this PR, so I decided to defer adding formal linkage to JSON dumps to another PR.
---
Patch is 265.38 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/194600.diff
75 Files Affected:
- (modified) clang-tools-extra/clangd/test/ast-no-range.test (+1-1)
- (modified) clang-tools-extra/clangd/test/ast.test (+1-1)
- (modified) clang-tools-extra/clangd/unittests/DumpASTTests.cpp (+1-1)
- (modified) clang/include/clang/AST/TextNodeDumper.h (+1)
- (modified) clang/lib/AST/TextNodeDumper.cpp (+55)
- (modified) clang/test/AST/ast-dump-color.cpp (+2-2)
- (modified) clang/test/AST/ast-dump-constant-expr.cpp (+3-3)
- (modified) clang/test/AST/ast-dump-ctad-alias.cpp (+2-2)
- (modified) clang/test/AST/ast-dump-decl.c (+1-1)
- (modified) clang/test/AST/ast-dump-decl.cpp (+63-63)
- (modified) clang/test/AST/ast-dump-lambda.cpp (+1-1)
- (added) clang/test/AST/ast-dump-linkage-internal.cpp (+477)
- (added) clang/test/AST/ast-dump-linkage.cpp (+485)
- (modified) clang/test/AST/ast-dump-openmp-atomic.c (+1-1)
- (modified) clang/test/AST/ast-dump-openmp-barrier.c (+1-1)
- (modified) clang/test/AST/ast-dump-openmp-cancel.c (+1-1)
- (modified) clang/test/AST/ast-dump-openmp-cancellation-point.c (+1-1)
- (modified) clang/test/AST/ast-dump-openmp-critical.c (+1-1)
- (modified) clang/test/AST/ast-dump-openmp-distribute-parallel-for-simd.c (+5-5)
- (modified) clang/test/AST/ast-dump-openmp-distribute-parallel-for.c (+5-5)
- (modified) clang/test/AST/ast-dump-openmp-distribute-simd.c (+5-5)
- (modified) clang/test/AST/ast-dump-openmp-distribute.c (+5-5)
- (modified) clang/test/AST/ast-dump-openmp-flush.c (+1-1)
- (modified) clang/test/AST/ast-dump-openmp-for-simd.c (+5-5)
- (modified) clang/test/AST/ast-dump-openmp-for.c (+5-5)
- (modified) clang/test/AST/ast-dump-openmp-master.c (+1-1)
- (modified) clang/test/AST/ast-dump-openmp-ordered.c (+3-3)
- (modified) clang/test/AST/ast-dump-openmp-parallel-for-simd.c (+5-5)
- (modified) clang/test/AST/ast-dump-openmp-parallel-for.c (+5-5)
- (modified) clang/test/AST/ast-dump-openmp-parallel-sections.c (+2-2)
- (modified) clang/test/AST/ast-dump-openmp-parallel.c (+1-1)
- (modified) clang/test/AST/ast-dump-openmp-section.c (+1-1)
- (modified) clang/test/AST/ast-dump-openmp-sections.c (+2-2)
- (modified) clang/test/AST/ast-dump-openmp-simd.c (+5-5)
- (modified) clang/test/AST/ast-dump-openmp-single.c (+1-1)
- (modified) clang/test/AST/ast-dump-openmp-target-data.c (+1-1)
- (modified) clang/test/AST/ast-dump-openmp-target-enter-data.c (+1-1)
- (modified) clang/test/AST/ast-dump-openmp-target-exit-data.c (+1-1)
- (modified) clang/test/AST/ast-dump-openmp-target-parallel-for-simd.c (+5-5)
- (modified) clang/test/AST/ast-dump-openmp-target-parallel-for.c (+5-5)
- (modified) clang/test/AST/ast-dump-openmp-target-parallel.c (+1-1)
- (modified) clang/test/AST/ast-dump-openmp-target-simd.c (+5-5)
- (modified) clang/test/AST/ast-dump-openmp-target-teams-distribute-parallel-for-simd.c (+5-5)
- (modified) clang/test/AST/ast-dump-openmp-target-teams-distribute-parallel-for.c (+5-5)
- (modified) clang/test/AST/ast-dump-openmp-target-teams-distribute-simd.c (+5-5)
- (modified) clang/test/AST/ast-dump-openmp-target-teams-distribute.c (+5-5)
- (modified) clang/test/AST/ast-dump-openmp-target-teams.c (+1-1)
- (modified) clang/test/AST/ast-dump-openmp-target-update.c (+1-1)
- (modified) clang/test/AST/ast-dump-openmp-target.c (+1-1)
- (modified) clang/test/AST/ast-dump-openmp-task.c (+1-1)
- (modified) clang/test/AST/ast-dump-openmp-taskgroup.c (+1-1)
- (modified) clang/test/AST/ast-dump-openmp-taskloop-simd.c (+5-5)
- (modified) clang/test/AST/ast-dump-openmp-taskloop.c (+5-5)
- (modified) clang/test/AST/ast-dump-openmp-taskwait.c (+1-1)
- (modified) clang/test/AST/ast-dump-openmp-taskyield.c (+1-1)
- (modified) clang/test/AST/ast-dump-openmp-teams-distribute-parallel-for-simd.c (+5-5)
- (modified) clang/test/AST/ast-dump-openmp-teams-distribute-parallel-for.c (+5-5)
- (modified) clang/test/AST/ast-dump-openmp-teams-distribute-simd.c (+5-5)
- (modified) clang/test/AST/ast-dump-openmp-teams-distribute.c (+5-5)
- (modified) clang/test/AST/ast-dump-openmp-teams.c (+1-1)
- (modified) clang/test/AST/ast-dump-template-name.cpp (+3-3)
- (modified) clang/test/AST/ast-dump-templates-pattern.cpp (+16-16)
- (modified) clang/test/AST/ast-dump-templates.cpp (+15-15)
- (modified) clang/test/AST/ast-dump-type-callingconv.cpp (+3-3)
- (modified) clang/test/AST/attr-lifetime-capture-by.cpp (+5-5)
- (modified) clang/test/AST/multistep-explicit-cast.c (+8-8)
- (modified) clang/test/AST/multistep-explicit-cast.cpp (+16-16)
- (modified) clang/test/ASTSYCL/ast-dump-sycl-kernel-call-stmt.cpp (+13-13)
- (modified) clang/test/ASTSYCL/ast-dump-sycl-kernel-entry-point.cpp (+15-15)
- (modified) clang/test/CXX/class/class.friend/p7-cxx20.cpp (+16-16)
- (modified) clang/test/CXX/class/class.mfct/p1-cxx20.cpp (+16-16)
- (modified) clang/test/ParserHLSL/hlsl_resource_class_attr.hlsl (+1-1)
- (modified) clang/test/ParserHLSL/hlsl_resource_handle_attrs.hlsl (+2-2)
- (modified) clang/test/SemaOpenCL/multistep-explicit-cast.cl (+1-1)
- (modified) clang/test/SemaTemplate/deduction-guide.cpp (+1-1)
``````````diff
diff --git a/clang-tools-extra/clangd/test/ast-no-range.test b/clang-tools-extra/clangd/test/ast-no-range.test
index 34adffefc91f7..2375ca243fbad 100644
--- a/clang-tools-extra/clangd/test/ast-no-range.test
+++ b/clang-tools-extra/clangd/test/ast-no-range.test
@@ -10,7 +10,7 @@
# CHECK-NEXT: "arcana": "{{TranslationUnitDecl.*}}"
# CHECK-NEXT: "children": [
# CHECK-NEXT: {
-# CHECK: "arcana": "VarDecl {{.*}} x 'int'",
+# CHECK: "arcana": "VarDecl {{.*}} x 'int' external-linkage",
# CHECK-NEXT: "children": [
# CHECK-NEXT: {
# CHECK-NEXT: "arcana": "QualType {{.*}} 'int' ",
diff --git a/clang-tools-extra/clangd/test/ast.test b/clang-tools-extra/clangd/test/ast.test
index 2185f14eefb8b..772faaceb41f1 100644
--- a/clang-tools-extra/clangd/test/ast.test
+++ b/clang-tools-extra/clangd/test/ast.test
@@ -10,7 +10,7 @@
# CHECK: "id": 1,
# CHECK-NEXT: "jsonrpc": "2.0",
# CHECK-NEXT: "result": {
-# CHECK-NEXT: "arcana": "VarDecl {{.*}} x 'int'",
+# CHECK-NEXT: "arcana": "VarDecl {{.*}} x 'int' external-linkage",
# CHECK-NEXT: "children": [
# CHECK-NEXT: {
# CHECK-NEXT: "arcana": "QualType {{.*}} 'int' ",
diff --git a/clang-tools-extra/clangd/unittests/DumpASTTests.cpp b/clang-tools-extra/clangd/unittests/DumpASTTests.cpp
index 7b7e8ae000bf0..1ea25d918dad6 100644
--- a/clang-tools-extra/clangd/unittests/DumpASTTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DumpASTTests.cpp
@@ -211,7 +211,7 @@ TEST(DumpASTTests, Arcana) {
auto Node = dumpAST(DynTypedNode::create(findDecl(AST, "x")), AST.getTokens(),
AST.getASTContext());
EXPECT_THAT(Node.arcana, testing::StartsWith("VarDecl "));
- EXPECT_THAT(Node.arcana, testing::EndsWith(" 'int'"));
+ EXPECT_THAT(Node.arcana, testing::EndsWith(" 'int' external-linkage"));
ASSERT_THAT(Node.children, SizeIs(1)) << "Expected one child typeloc";
EXPECT_THAT(Node.children.front().arcana, testing::StartsWith("QualType "));
}
diff --git a/clang/include/clang/AST/TextNodeDumper.h b/clang/include/clang/AST/TextNodeDumper.h
index 6b7ac6fac8111..0c515556a8b84 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -208,6 +208,7 @@ class TextNodeDumper
void dumpType(QualType T);
void dumpBareDeclRef(const Decl *D);
void dumpName(const NamedDecl *ND);
+ void dumpFormalLinkage(const NamedDecl *ND);
void dumpAccessSpecifier(AccessSpecifier AS);
void dumpCleanupObject(const ExprWithCleanups::CleanupObject &C);
void dumpTemplateSpecializationKind(TemplateSpecializationKind TSK);
diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index 53982025dfd4d..50200efc9b93f 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -1429,6 +1429,30 @@ static void dumpBasePath(raw_ostream &OS, const CastExpr *Node) {
OS << ')';
}
+void TextNodeDumper::dumpFormalLinkage(const NamedDecl *ND) {
+ switch (ND->getFormalLinkage()) {
+ case Linkage::None:
+ // A lot of declarations have no linkage, so we only dump linkage if there
+ // is one.
+ break;
+ case Linkage::Internal:
+ OS << " internal-linkage";
+ break;
+ case Linkage::External:
+ OS << " external-linkage";
+ break;
+ case Linkage::Module:
+ OS << " module-linkage";
+ break;
+ case Linkage::Invalid:
+ OS << " invalid-linkage";
+ break;
+ case Linkage::UniqueExternal:
+ case Linkage::VisibleNone:
+ llvm_unreachable("Not a formal linkage!");
+ }
+}
+
void TextNodeDumper::VisitLoopControlStmt(const LoopControlStmt *Node) {
if (!Node->hasLabelTarget())
return;
@@ -2295,6 +2319,11 @@ void TextNodeDumper::VisitTypedefDecl(const TypedefDecl *D) {
dumpType(D->getUnderlyingType());
if (D->isModulePrivate())
OS << " __module_private__";
+
+ const TagDecl *TD = D->getUnderlyingType()->getAsTagDecl();
+ if (TD && TD->getTypedefNameForAnonDecl()) {
+ dumpFormalLinkage(D);
+ }
}
void TextNodeDumper::VisitEnumDecl(const EnumDecl *D) {
@@ -2314,6 +2343,8 @@ void TextNodeDumper::VisitEnumDecl(const EnumDecl *D) {
OS << " instantiated_from";
dumpPointer(Instance);
}
+
+ dumpFormalLinkage(D);
}
void TextNodeDumper::VisitRecordDecl(const RecordDecl *D) {
@@ -2323,6 +2354,10 @@ void TextNodeDumper::VisitRecordDecl(const RecordDecl *D) {
OS << " __module_private__";
if (D->isCompleteDefinition())
OS << " definition";
+
+ if (!D->isImplicit() && !D->getDescribedTemplate()) {
+ dumpFormalLinkage(D);
+ }
}
void TextNodeDumper::VisitEnumConstantDecl(const EnumConstantDecl *D) {
@@ -2420,6 +2455,10 @@ void TextNodeDumper::VisitFunctionDecl(const FunctionDecl *D) {
OS << " instantiated_from";
dumpPointer(Instance);
}
+
+ if (!isa<CXXDeductionGuideDecl>(D) && !D->getDescribedTemplate()) {
+ dumpFormalLinkage(D);
+ }
}
void TextNodeDumper::VisitCXXDeductionGuideDecl(
@@ -2520,6 +2559,10 @@ void TextNodeDumper::VisitVarDecl(const VarDecl *D) {
AddChild("value", [=] { Visit(*Value, E->getType()); });
}
}
+
+ if (!D->getDescribedVarTemplate()) {
+ dumpFormalLinkage(D);
+ }
}
void TextNodeDumper::VisitBindingDecl(const BindingDecl *D) {
@@ -2633,6 +2676,8 @@ void TextNodeDumper::VisitNamespaceDecl(const NamespaceDecl *D) {
OS << " nested";
if (!D->isFirstDecl())
dumpDeclRef(D->getFirstDecl(), "original");
+
+ dumpFormalLinkage(D);
}
void TextNodeDumper::VisitUsingDirectiveDecl(const UsingDirectiveDecl *D) {
@@ -2648,11 +2693,17 @@ void TextNodeDumper::VisitNamespaceAliasDecl(const NamespaceAliasDecl *D) {
void TextNodeDumper::VisitTypeAliasDecl(const TypeAliasDecl *D) {
dumpName(D);
dumpType(D->getUnderlyingType());
+
+ const TagDecl *TD = D->getUnderlyingType()->getAsTagDecl();
+ if (TD && TD->getTypedefNameForAnonDecl()) {
+ dumpFormalLinkage(D);
+ }
}
void TextNodeDumper::VisitTypeAliasTemplateDecl(
const TypeAliasTemplateDecl *D) {
dumpName(D);
+ dumpFormalLinkage(D);
}
void TextNodeDumper::VisitCXXRecordDecl(const CXXRecordDecl *D) {
@@ -2813,14 +2864,17 @@ void TextNodeDumper::VisitCXXRecordDecl(const CXXRecordDecl *D) {
void TextNodeDumper::VisitFunctionTemplateDecl(const FunctionTemplateDecl *D) {
dumpName(D);
+ dumpFormalLinkage(D);
}
void TextNodeDumper::VisitClassTemplateDecl(const ClassTemplateDecl *D) {
dumpName(D);
+ dumpFormalLinkage(D);
}
void TextNodeDumper::VisitVarTemplateDecl(const VarTemplateDecl *D) {
dumpName(D);
+ dumpFormalLinkage(D);
}
void TextNodeDumper::VisitBuiltinTemplateDecl(const BuiltinTemplateDecl *D) {
@@ -3118,6 +3172,7 @@ void TextNodeDumper::VisitBlockDecl(const BlockDecl *D) {
void TextNodeDumper::VisitConceptDecl(const ConceptDecl *D) {
dumpName(D);
+ dumpFormalLinkage(D);
}
void TextNodeDumper::VisitCompoundStmt(const CompoundStmt *S) {
diff --git a/clang/test/AST/ast-dump-color.cpp b/clang/test/AST/ast-dump-color.cpp
index 2e60e760283de..44e79c33ee649 100644
--- a/clang/test/AST/ast-dump-color.cpp
+++ b/clang/test/AST/ast-dump-color.cpp
@@ -43,7 +43,7 @@ struct Invalid {
//CHECK: {{^}}[[Blue]]| |-[[RESET]][[Blue]]HTMLEndTagComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:13[[RESET]], [[Yellow]]col:16[[RESET]]> Name="a"{{$}}
//CHECK: {{^}}[[Blue]]| |-[[RESET]][[Blue]]TextComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:5:4[[RESET]]> Text=" "{{$}}
//CHECK: {{^}}[[Blue]]| `-[[RESET]][[Blue]]HTMLStartTagComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:5[[RESET]], [[Yellow]]col:8[[RESET]]> Name="br" SelfClosing{{$}}
-//CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]FunctionDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:9:1[[RESET]], [[Yellow]]line:16:1[[RESET]]> [[Yellow]]line:9:6[[RESET]][[CYAN]] TestAttributedStmt[[RESET]] [[Green]]'void ()'[[RESET]]{{$}}
+//CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]FunctionDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:9:1[[RESET]], [[Yellow]]line:16:1[[RESET]]> [[Yellow]]line:9:6[[RESET]][[CYAN]] TestAttributedStmt[[RESET]] [[Green]]'void ()'[[RESET]] external-linkage{{$}}
//CHECK: {{^}}[[Blue]]| |-[[RESET]][[MAGENTA:.\[0;1;35m]]CompoundStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:27[[RESET]], [[Yellow]]line:16:1[[RESET]]>{{$}}
//CHECK: {{^}}[[Blue]]| | `-[[RESET]][[MAGENTA]]SwitchStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:10:3[[RESET]], [[Yellow]]line:15:3[[RESET]]>{{$}}
//CHECK: {{^}}[[Blue]]| | |-[[RESET]][[MAGENTA]]IntegerLiteral[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:10:11[[RESET]]> [[Green]]'int'[[RESET]][[Cyan:.\[0;36m]][[RESET]][[Cyan]][[RESET]][[CYAN]] 1[[RESET]]{{$}}
@@ -63,7 +63,7 @@ struct Invalid {
//CHECK: {{^}}[[Blue]]| `-[[RESET]][[Blue]]FullComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:8:4[[RESET]], [[Yellow]]col:11[[RESET]]>{{$}}
//CHECK: {{^}}[[Blue]]| `-[[RESET]][[Blue]]ParagraphComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:4[[RESET]], [[Yellow]]col:11[[RESET]]>{{$}}
//CHECK: {{^}}[[Blue]]| `-[[RESET]][[Blue]]TextComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:4[[RESET]], [[Yellow]]col:11[[RESET]]> Text=" Comment"{{$}}
-//CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]CXXRecordDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:18:1[[RESET]], [[Yellow]]line:25:1[[RESET]]> [[Yellow]]line:18:33[[RESET]] class[[CYAN]] Mutex[[RESET]] definition{{$}}
+//CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]CXXRecordDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:18:1[[RESET]], [[Yellow]]line:25:1[[RESET]]> [[Yellow]]line:18:33[[RESET]] class[[CYAN]] Mutex[[RESET]] definition external-linkage{{$}}
//CHECK: {{^}}[[Blue]]| |-[[RESET]][[BLUE]]CapabilityAttr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:22[[RESET]]> capability "mutex"{{$}}
//CHECK: {{^}}[[Blue]]| |-[[RESET]][[GREEN]]CXXRecordDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:1[[RESET]], [[Yellow]]col:33[[RESET]]> [[Yellow]]col:33[[RESET]] implicit class[[CYAN]] Mutex[[RESET]]{{$}}
//CHECK: {{^}}[[Blue]]| |-[[RESET]][[GREEN]]FieldDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:20:3[[RESET]], [[Yellow]]col:7[[RESET]]> [[Yellow]]col:7[[RESET]][[CYAN]] var1[[RESET]] [[Green]]'int'[[RESET]]{{$}}
diff --git a/clang/test/AST/ast-dump-constant-expr.cpp b/clang/test/AST/ast-dump-constant-expr.cpp
index 302f562eadd96..8edf19431d4d1 100644
--- a/clang/test/AST/ast-dump-constant-expr.cpp
+++ b/clang/test/AST/ast-dump-constant-expr.cpp
@@ -57,8 +57,8 @@ struct Test {
};
// CHECK:Dumping Test:
-// CHECK-NEXT:CXXRecordDecl {{.*}} <{{.*}}ast-dump-constant-expr.cpp:43:1, line:57:1> line:43:8 struct Test definition
-// CHECK:|-CXXMethodDecl {{.*}} <line:44:3, line:54:3> line:44:8 test 'void ()' implicit-inline
+// CHECK-NEXT:CXXRecordDecl {{.*}} <{{.*}}ast-dump-constant-expr.cpp:43:1, line:57:1> line:43:8 struct Test definition external-linkage
+// CHECK:|-CXXMethodDecl {{.*}} <line:44:3, line:54:3> line:44:8 test 'void ()' implicit-inline external-linkage
// CHECK-NEXT:| `-CompoundStmt {{.*}} <col:15, line:54:3>
// CHECK-NEXT:| |-CStyleCastExpr {{.*}} <line:45:5, col:20> 'void' <ToVoid>
// CHECK-NEXT:| | `-ConstantExpr {{.*}} <col:11, col:20> 'int'
@@ -90,4 +90,4 @@ struct Test {
// CHECK-NEXT:| `-CallExpr {{.*}} <col:11, col:23> '__int128'
// CHECK-NEXT:| `-ImplicitCastExpr {{.*}} <col:11> '__int128 (*)()' <FunctionToPointerDecay>
// CHECK-NEXT:| `-DeclRefExpr {{.*}} <col:11> '__int128 ()' lvalue Function {{.*}} 'test_Int128' '__int128 ()'
-// CHECK-NEXT:`-CXXMethodDecl {{.*}} <line:56:3, col:38> col:18 consteval consteval_method 'void ()' implicit-inline
+// CHECK-NEXT:`-CXXMethodDecl {{.*}} <line:56:3, col:38> col:18 consteval consteval_method 'void ()' implicit-inline external-linkage
diff --git a/clang/test/AST/ast-dump-ctad-alias.cpp b/clang/test/AST/ast-dump-ctad-alias.cpp
index 9a3adbcb534e8..ea4b12da8ef78 100644
--- a/clang/test/AST/ast-dump-ctad-alias.cpp
+++ b/clang/test/AST/ast-dump-ctad-alias.cpp
@@ -38,10 +38,10 @@ Out2<double>::AInner t(1.0);
// CHECK-NEXT: | | `-TypeTraitExpr {{.*}} 'bool' __is_deducible
// CHECK-NEXT: | | |-DeducedTemplateSpecializationType {{.*}} 'Out2<double>::AInner' dependent
// CHECK-NEXT: | | | `-name: 'Out2<double>::AInner'
-// CHECK-NEXT: | | | `-TypeAliasTemplateDecl {{.+}} AInner{{$}}
+// CHECK-NEXT: | | | `-TypeAliasTemplateDecl {{.+}} AInner external-linkage{{$}}
// CHECK-NEXT: | | `-TemplateSpecializationType {{.*}} 'Inner<Y>' dependent
// CHECK-NEXT: | | |-name: 'Inner':'Out<int>::Inner' qualified
-// CHECK-NEXT: | | | `-ClassTemplateDecl {{.+}} Inner{{$}}
+// CHECK-NEXT: | | | `-ClassTemplateDecl {{.+}} Inner external-linkage{{$}}
// CHECK-NEXT: | | `-TemplateArgument type 'Y'
// CHECK-NEXT: | | `-SubstTemplateTypeParmType {{.*}} 'Y'
// CHECK-NEXT: | | |-FunctionTemplate {{.*}} '<deduction guide for Inner>'
diff --git a/clang/test/AST/ast-dump-decl.c b/clang/test/AST/ast-dump-decl.c
index 683df50f7e91c..447c2d689cbce 100644
--- a/clang/test/AST/ast-dump-decl.c
+++ b/clang/test/AST/ast-dump-decl.c
@@ -172,7 +172,7 @@ extern int TestVarDeclSC;
// CHECK: VarDecl{{.*}} TestVarDeclSC 'int' extern
__thread int TestVarDeclThread;
-// CHECK: VarDecl{{.*}} TestVarDeclThread 'int' tls{{$}}
+// CHECK: VarDecl{{.*}} TestVarDeclThread 'int' tls external-linkage{{$}}
__module_private__ int TestVarDeclPrivate;
// CHECK-MODULE: VarDecl{{.*}} TestVarDeclPrivate 'int' __module_private__
diff --git a/clang/test/AST/ast-dump-decl.cpp b/clang/test/AST/ast-dump-decl.cpp
index ecbfacaf128e2..b0d53cf1b38ca 100644
--- a/clang/test/AST/ast-dump-decl.cpp
+++ b/clang/test/AST/ast-dump-decl.cpp
@@ -63,19 +63,19 @@ inline namespace TestNamespaceDeclInline {
namespace TestNestedNameSpace::Nested {
}
// CHECK: NamespaceDecl{{.*}} TestNestedNameSpace
-// CHECK: NamespaceDecl{{.*}} Nested nested{{\s*$}}
+// CHECK: NamespaceDecl{{.*}} Nested nested external-linkage{{\s*$}}
namespace TestMultipleNested::SecondLevelNested::Nested {
}
// CHECK: NamespaceDecl{{.*}} TestMultipleNested
// CHECK: NamespaceDecl{{.*}} SecondLevelNested nested
-// CHECK: NamespaceDecl{{.*}} Nested nested{{\s*$}}
+// CHECK: NamespaceDecl{{.*}} Nested nested external-linkage{{\s*$}}
namespace TestInlineNested::inline SecondLevel::inline Nested {
}
// CHECK: NamespaceDecl{{.*}} TestInlineNested
// CHECK: NamespaceDecl{{.*}} SecondLevel inline nested
-// CHECK: NamespaceDecl{{.*}} Nested inline nested{{\s*$}}
+// CHECK: NamespaceDecl{{.*}} Nested inline nested external-linkage{{\s*$}}
namespace testUsingDirectiveDecl {
namespace A {
@@ -318,7 +318,7 @@ namespace testClassTemplateDecl {
template<template<typename> class TT> struct TestTemplateTemplateDefaultType { };
}
-// CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-40]]:3, line:[[@LINE-34]]:3> line:[[@LINE-40]]:30 referenced TestClassTemplate{{$}}
+// CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-40]]:3, line:[[@LINE-34]]:3> line:[[@LINE-40]]:30 referenced TestClassTemplate external-linkage{{$}}
// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 typename depth 0 index 0 T{{$}}
// CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} <col:24, line:[[@LINE-36]]:3> line:[[@LINE-42]]:30 class TestClassTemplate definition{{$}}
// CHECK-NEXT: | |-DefinitionData standard_layout has_user_declared_ctor can_const_default_init{{$}}
@@ -330,11 +330,11 @@ namespace testClassTemplateDecl {
// CHECK-NEXT: | | `-Destructor irrelevant non_trivial user_declared{{$}}
// CHECK-NEXT: | |-CXXRecordDecl 0x{{.+}} <col:24, col:30> col:30 implicit referenced class TestClassTemplate{{$}}
// CHECK-NEXT: | |-AccessSpecDecl 0x{{.+}} <line:[[@LINE-50]]:3, col:9> col:3 public{{$}}
-// CHECK-NEXT: | |-CXXConstructorDecl 0x[[#%x,TEMPLATE_CONSTRUCTOR_DECL:]] <line:[[@LINE-50]]:5, col:23> col:5 TestClassTemplate<T> 'void ()'{{$}}
-// CHECK-NEXT: | |-CXXDestructorDecl 0x[[#%x,TEMPLATE_DESTRUCTOR_DECL:]] <line:[[@LINE-50]]:5, col:24> col:5 ~TestClassTemplate<T> 'void ()' not_selected{{$}}
-// CHECK-NEXT: | |-CXXMethodDecl 0x[[#%x,TEMPLATE_METHOD_DECL:]] <line:[[@LINE-50]]:5, col:11> col:9 j 'int ()'{{$}}
+// CHECK-NEXT: | |-CXXConstructorDecl 0x[[#%x,TEMPLATE_CONSTRUCTOR_DECL:]] <line:[[@LINE-50]]:5, col:23> col:5 TestClassTemplate<T> 'void ()' external-linkage{{$}}
+// CHECK-NEXT: | |-CXXDestructorDecl 0x[[#%x,TEMPLATE_DESTRUCTOR_DECL:]] <line:[[@LINE-50]]:5, col:24> col:5 ~TestClassTemplate<T> 'void ()' not_selected external-linkage{{$}}
+// CHECK-NEXT: | |-CXXMethodDecl 0x[[#%x,TEMPLATE_METHOD_DECL:]] <line:[[@LINE-50]]:5, col:11> col:9 j 'int ()' external-linkage{{$}}
// CHECK-NEXT: | `-FieldDecl 0x{{.+}} <line:[[@LINE-50]]:5, col:9> col:9 i 'int'{{$}}
-// CHECK-NEXT: |-ClassTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-56]]:3, line:[[@LINE-50]]:3> line:[[@LINE-56]]:30 referenced class TestClassTemplate definition instantiated_from 0x{{.+}} implicit_instantiation{{$}}
+// CHECK-NEXT: |-ClassTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-56]]:3, line:[[@LINE-50]]:3> line:[[@LINE-56]]:30 referenced class TestClassTemplate definition external-linkage instantiated_from 0x{{.+}} implicit_instantiation{{$}}
// CHECK-NEXT: | |-DefinitionData standard_layout has_user_declared_ctor can_const_default_init{{$}}
// CHECK-NEXT: | | |-DefaultConstructor exists non_trivial user_provided{{$}}
// CHECK-NEXT: | | |-CopyConstructor simple trivial has_const_param implicit_has_const_param{{$}}
@@ -347,17 +347,17 @@ namespace testClassTemplateDecl {
// CHECK-NEXT: | | `-CXXRecord 0x{{.+}} 'A'{{$}}
// CHECK-NEXT: | |-CXXRecordDecl 0x{{.+}} <col:24, col:30> col:30 implicit class TestClassTemplate{{$}}
// CHECK-NEXT: | |-AccessSpecDecl 0x{{.+}} <line:[[@LINE-67]]:3, col:9> col:3 public{{$}}
-// CHECK-NEXT: | |-CXXConstructorDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:23> col:5 used TestClassTemplate 'void ()' implicit_instantiation instantiated_from 0x[[#TEMPLATE_CONSTRUCTOR_DECL]]{{$}}
-// CHECK-NEXT: | |-CXXDestructorDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:24> col:5 used ~TestClassTemplate 'void () noexcept' implicit_instantiation instantiated_from 0x[[#TEMPLATE_DESTRUCTOR_DECL]]{{$}}
-// CHECK-NEXT: | |-CXXMethodDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:11> col:9 j 'int ()' implicit_instantiation instantiated_from 0x[[#TEMPLATE_METHOD_DECL]]{{$}}
+// CHECK-NEXT: | |-CXXConstructorDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:23> col:5 used TestClassTemplate 'void ()' implicit_instantiation instantiated_from 0x[[#TEMPLATE_CONSTRUCTOR_DECL]] external-linkage{{$}}
+// CHECK-NEXT: | |-CXXDestructorDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:24> col:5 used ~TestClassTemplate 'void () noexcept' implicit_instantiation instantiated_from 0x[[#TEMPLATE_DESTRUCTOR_DECL]] external-linkage{{$}}
+// CHECK-NEXT: | |-CXXMethodDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:11> col:9 j 'int ()' implicit_instantiation instantiated_from 0x[[#TEMPLATE_METHOD_DECL]] external-linkage{{$}}
// CHECK-NEXT: | |-FieldDecl 0x{{.+}} <line:[[@LINE-67]]:5, col:9> col:9 i 'int'{{$}}
-// CHECK-NEXT: | `-CXXConstructorDecl 0x{{.+}} <line:[[@LINE-73]]:30> col:30 implicit constexpr TestClassTemplate 'void (const TestClassTemplate<testClassTemplateDecl::A> &)' inline default trivial noexcept-unevaluated 0x{{.+}}{{$}}
+// CHECK-NEXT: | `-CXXConstructorDecl 0x{{.+}} <line:[[@LINE-73]]:30> col:30 implicit constexpr TestClassTemplate 'void (const TestClassTemplate<testClassTemplateDecl::A> &)' inline default trivial noexcept-unevaluated 0x{{.+}} external-linkage{{$}}
// CHECK-NEXT: | `-ParmVarDecl 0x{{.+}} <col:30> col:30 'const TestClassTemplate<testClassTemplateDecl::A> &'{{$}}
// CHECK-NEXT: |-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate'{{$}}
// CHECK-NEXT: |-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate'{{$}}
// CHECK-NEXT: `-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplate'{{$}}
-// CHECK: ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-67]]:3, line:[[@LINE-65]]:3> line:[[@LINE-67]]:20 class T...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/194600
More information about the cfe-commits
mailing list