[clang] Fix cycle in importing template specialization on auto type with typename (PR #162514)

via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 8 10:04:13 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,h -- clang/include/clang/AST/ASTImporter.h clang/lib/AST/ASTImporter.cpp clang/unittests/AST/ASTImporterTest.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/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 0dc2e1c3b..0e984fbaf 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -4036,7 +4036,7 @@ ExpectedDecl ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
     // To avoid an infinite recursion when importing, create the FunctionDecl
     // with a simplified return type.
     if (hasReturnTypeDeclaredInside(D) ||
-      Importer.DeclTypeCycles.find(D) != Importer.DeclTypeCycles.end()) {
+        Importer.DeclTypeCycles.find(D) != Importer.DeclTypeCycles.end()) {
       FromReturnTy = Importer.getFromContext().VoidTy;
       UsedDifferentProtoType = true;
     }
diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp
index 5f7fcdf81..ab63ddeb5 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -3249,7 +3249,8 @@ TEST_P(ImportExpr, CycleInAutoTemplateSpec) {
   }
 )";
   // This test reproduces the StrCatT recursion pattern with concepts and span
-  // that may cause infinite recursion during AST import due to circular dependencies
+  // that may cause infinite recursion during AST import due to circular
+  // dependencies
   testImport(Code, Lang_CXX20, "", Lang_CXX20, Verifier,
              functionTemplateDecl(hasName("declToImport")));
 }

``````````

</details>


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


More information about the cfe-commits mailing list