[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 1 06:24:18 PDT 2024


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 7088a5ed880f29129ec844c66068e8cb61ca98bf 81eeb74c688be76ee61070ba7f237a7117bcdd2c --extensions cpp -- clang/lib/Sema/SemaCoroutine.cpp clang/lib/Sema/SemaStmt.cpp clang/test/SemaCXX/coroutines.cpp
``````````

</details>

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

``````````diff
diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp
index e379987556..fb661bf766 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -687,14 +687,14 @@ bool Sema::checkFinalSuspendNoThrow(const Stmt *FinalSuspend) {
 // [stmt.return.coroutine]p1:
 //   A coroutine shall not enclose a return statement ([stmt.return]).
 static void checkReturnStmtInCoroutine(Sema &S, FunctionScopeInfo *FSI) {
-  assert (!FSI && "FunctionScopeInfo is null");
+  assert(!FSI && "FunctionScopeInfo is null");
   assert(FSI->FirstCoroutineStmtLoc.isValid() &&
-                "first coroutine location not set");
+         "first coroutine location not set");
   if (FSI->FirstReturnLoc.isInvalid())
     return;
   S.Diag(FSI->FirstReturnLoc, diag::err_return_in_coroutine);
   S.Diag(FSI->FirstCoroutineStmtLoc, diag::note_declared_coroutine_here)
-          << FSI->getFirstCoroutineStmtKeyword();
+      << FSI->getFirstCoroutineStmtKeyword();
 }
 
 bool Sema::ActOnCoroutineBodyStart(Scope *SC, SourceLocation KWLoc,
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 7d4fcfbe32..d283eaa511 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3751,10 +3751,10 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
   FunctionScopeInfo *FSI = getCurFunction();
   if (FSI->FirstReturnLoc.isInvalid() && FSI->isCoroutine()) {
     assert(FSI->FirstCoroutineStmtLoc.isValid() &&
-                  "first coroutine location not set");
+           "first coroutine location not set");
     Diag(ReturnLoc, diag::err_return_in_coroutine);
     Diag(FSI->FirstCoroutineStmtLoc, diag::note_declared_coroutine_here)
-            << FSI->getFirstCoroutineStmtKeyword();
+        << FSI->getFirstCoroutineStmtKeyword();
   }
 
   StmtResult R =

``````````

</details>


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


More information about the cfe-commits mailing list