[clang] e8a632d - Revert "[Sema] Fix null pointer dereference handleAlwaysInlineAttr."

Craig Topper via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 16 20:08:38 PDT 2023


Author: Craig Topper
Date: 2023-03-16T20:05:33-07:00
New Revision: e8a632dac2204d66293dd5e0ba92eb65941c4aa3

URL: https://github.com/llvm/llvm-project/commit/e8a632dac2204d66293dd5e0ba92eb65941c4aa3
DIFF: https://github.com/llvm/llvm-project/commit/e8a632dac2204d66293dd5e0ba92eb65941c4aa3.diff

LOG: Revert "[Sema] Fix null pointer dereference handleAlwaysInlineAttr."

This reverts commit 10297470e953f4f3968c54c851c8af82b07af00b.

This is failing on a build bot.

Added: 
    

Modified: 
    clang/lib/Sema/SemaStmtAttr.cpp
    clang/test/Sema/attr-alwaysinline.cpp
    clang/test/Sema/attr-noinline.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaStmtAttr.cpp b/clang/lib/Sema/SemaStmtAttr.cpp
index eeef85373ccb1..6d443837a4c57 100644
--- a/clang/lib/Sema/SemaStmtAttr.cpp
+++ b/clang/lib/Sema/SemaStmtAttr.cpp
@@ -233,8 +233,7 @@ static Attr *handleNoInlineAttr(Sema &S, Stmt *St, const ParsedAttr &A,
 
   for (const auto *CallExpr : CEF.getCallExprs()) {
     const Decl *Decl = CallExpr->getCalleeDecl();
-    if (Decl &&
-        (Decl->hasAttr<AlwaysInlineAttr>() || Decl->hasAttr<FlattenAttr>()))
+    if (Decl->hasAttr<AlwaysInlineAttr>() || Decl->hasAttr<FlattenAttr>())
       S.Diag(St->getBeginLoc(), diag::warn_function_stmt_attribute_precedence)
           << A << (Decl->hasAttr<AlwaysInlineAttr>() ? 0 : 1);
   }
@@ -260,7 +259,7 @@ static Attr *handleAlwaysInlineAttr(Sema &S, Stmt *St, const ParsedAttr &A,
 
   for (const auto *CallExpr : CEF.getCallExprs()) {
     const Decl *Decl = CallExpr->getCalleeDecl();
-    if (Decl && (Decl->hasAttr<NoInlineAttr>() || Decl->hasAttr<FlattenAttr>()))
+    if (Decl->hasAttr<NoInlineAttr>() || Decl->hasAttr<FlattenAttr>())
       S.Diag(St->getBeginLoc(), diag::warn_function_stmt_attribute_precedence)
           << A << (Decl->hasAttr<NoInlineAttr>() ? 2 : 1);
   }

diff  --git a/clang/test/Sema/attr-alwaysinline.cpp b/clang/test/Sema/attr-alwaysinline.cpp
index 213d70407f485..6b8e8f215a4b6 100644
--- a/clang/test/Sema/attr-alwaysinline.cpp
+++ b/clang/test/Sema/attr-alwaysinline.cpp
@@ -25,22 +25,3 @@ void foo() {
 }
 
 [[clang::always_inline]] static int i = bar(); // expected-warning {{'always_inline' attribute only applies to functions and statements}}
-
-// This used to crash the compiler.
-template<int D>
-int foo(int x) {
-    if constexpr (D > 1)
-        [[clang::always_inline]] return foo<D-1>(x + 1);
-    else
-        return x;
-}
-
-// FIXME: This should warn that always_inline statement attribute has higher
-// precedence than the noinline function attribute.
-template<int D> [[gnu::noinline]]
-int bar(int x) {
-    if constexpr (D > 1)
-        [[clang::always_inline]] return bar<D-1>(x + 1);
-    else
-        return x;
-}

diff  --git a/clang/test/Sema/attr-noinline.cpp b/clang/test/Sema/attr-noinline.cpp
index a62ca1debcc5a..d35782f11adbb 100644
--- a/clang/test/Sema/attr-noinline.cpp
+++ b/clang/test/Sema/attr-noinline.cpp
@@ -25,22 +25,3 @@ void foo() {
 }
 
 [[clang::noinline]] static int i = bar(); // expected-warning {{'noinline' attribute only applies to functions and statements}}
-
-// This used to crash the compiler.
-template<int D>
-int foo(int x) {
-    if constexpr (D > 1)
-        [[clang::noinline]] return foo<D-1>(x + 1);
-    else
-        return x;
-}
-
-// FIXME: This should warn that noinline statement attribute has higher
-// precedence than the always_inline function attribute.
-template<int D> [[clang::always_inline]]
-int bar(int x) {
-    if constexpr (D > 1)
-        [[clang::noinline]] return bar<D-1>(x + 1);
-    else
-        return x;
-}


        


More information about the cfe-commits mailing list