[clang] [clang][Sema] Add noinline check for __builtin_frame_address and __builtin_return_address (PR #82966)

via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 26 00:14:06 PST 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 47aee8b56d65e2bac5c7128424ff06134e454d83 ef4c372a4d9364e6457c88a940c9af8666de0b74 -- clang/lib/Sema/SemaChecking.cpp clang/test/Sema/builtin-returnaddress.c
``````````

</details>

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

``````````diff
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 1861f7dace..cc8ba44f60 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2736,8 +2736,8 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
         TheCall->getArg(0)->EvaluateAsInt(Result, getASTContext())) {
       const char *BuiltinName =
           (BuiltinID == Builtin::BI__builtin_return_address)
-               ? "__builtin_return_address"
-               : "__builtin_frame_address";
+              ? "__builtin_return_address"
+              : "__builtin_frame_address";
 
       if (Result.Val.getInt() != 0) {
         Diag(TheCall->getBeginLoc(), diag::warn_frame_address)
@@ -2748,9 +2748,10 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
       if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurContext)) {
         if (!FD->hasAttr<NoInlineAttr>() && !FD->isMain()) {
           const char *ShortName =
-              (BuiltinID == Builtin::BI__builtin_return_address)
-                  ? "return" : "frame";
-          Diag(TheCall->getBeginLoc(), diag::warn_frame_address_missing_noinline)
+              (BuiltinID == Builtin::BI__builtin_return_address) ? "return"
+                                                                 : "frame";
+          Diag(TheCall->getBeginLoc(),
+               diag::warn_frame_address_missing_noinline)
               << BuiltinName << ShortName << TheCall->getSourceRange();
         }
       }

``````````

</details>


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


More information about the cfe-commits mailing list