[clang] [clang][Sema] fix crash on invalid expression with trailing return type and template keyword (PR #191972)

via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 14 08:34:49 PDT 2026


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/lib/Sema/SemaExprCXX.cpp clang/test/Modules/cxx20-10-2-ex5.cpp clang/test/SemaCXX/recovery-expr-type.cpp --diff_from_common_commit
``````````

: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/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index e22850a14..3e7ee73a0 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -1513,8 +1513,9 @@ Sema::ActOnCXXTypeConstructExpr(ParsedType TypeRep,
   auto Result = BuildCXXTypeConstructExpr(TInfo, LParenOrBraceLoc, exprs,
                                           RParenOrBraceLoc, ListInitialization);
   if (Result.isInvalid())
-    Result = CreateRecoveryExpr(TInfo->getTypeLoc().getBeginLoc(),
-                                RParenOrBraceLoc, exprs, Ty->isIncompleteType() ? QualType() : Ty);
+    Result =
+        CreateRecoveryExpr(TInfo->getTypeLoc().getBeginLoc(), RParenOrBraceLoc,
+                           exprs, Ty->isIncompleteType() ? QualType() : Ty);
 
   return Result;
 }

``````````

</details>


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


More information about the cfe-commits mailing list