[clang] [AST] Fix an assertion failure in TypeName::getFullyQualifiedName (PR #159312)

via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 17 03:23:20 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- clang/unittests/AST/QualTypeNamesTest.cpp clang/lib/AST/QualTypeNames.cpp
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/AST/QualTypeNames.cpp b/clang/lib/AST/QualTypeNames.cpp
index b0e9a600f..a2f930911 100644
--- a/clang/lib/AST/QualTypeNames.cpp
+++ b/clang/lib/AST/QualTypeNames.cpp
@@ -58,7 +58,7 @@ static bool getFullyQualifiedTemplateName(const ASTContext &Ctx,
   NestedNameSpecifier NNS = std::nullopt;
 
   TemplateDecl *ArgTDecl = TName.getAsTemplateDecl();
-  if (!ArgTDecl)  // ArgTDecl can be null in dependent contexts.
+  if (!ArgTDecl) // ArgTDecl can be null in dependent contexts.
     return false;
 
   QualifiedTemplateName *QTName = TName.getAsQualifiedTemplateName();
diff --git a/clang/unittests/AST/QualTypeNamesTest.cpp b/clang/unittests/AST/QualTypeNamesTest.cpp
index 71e4c87ce..5b88391c8 100644
--- a/clang/unittests/AST/QualTypeNamesTest.cpp
+++ b/clang/unittests/AST/QualTypeNamesTest.cpp
@@ -48,7 +48,8 @@ TEST(QualTypeNamesTest, TemplateParameters) {
   auto Type = cast<TypeAliasDecl>(TypeLR.front())->getUnderlyingType();
   ASSERT_TRUE(isa<TemplateSpecializationType>(Type));
 
-  EXPECT_EQ(TypeName::getFullyQualifiedName(Type, Ctx, Ctx.getPrintingPolicy()), "T<int>");
+  EXPECT_EQ(TypeName::getFullyQualifiedName(Type, Ctx, Ctx.getPrintingPolicy()),
+            "T<int>");
 }
 
 } // namespace

``````````

</details>


https://github.com/llvm/llvm-project/pull/159312


More information about the cfe-commits mailing list