[clang] b2ac7f5 - [clang-format][NFC] Annotate function/ctor/dtor declaration l_paren (#97938)

2024-07-10 Thread via cfe-commits

Author: Owen Pan
Date: 2024-07-10T00:10:24-07:00
New Revision: b2ac7f52fa95ccc478a478910ccd42730e8ea845

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

LOG: [clang-format][NFC] Annotate function/ctor/dtor declaration l_paren 
(#97938)

Added: 


Modified: 
clang/lib/Format/FormatToken.h
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index 4ffd745bf9307..cc45d5a8c5c1e 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -77,6 +77,7 @@ namespace format {
   TYPE(ForEachMacro)   
\
   TYPE(FunctionAnnotationRParen)   
\
   TYPE(FunctionDeclarationName)
\
+  TYPE(FunctionDeclarationLParen)  
\
   TYPE(FunctionLBrace) 
\
   TYPE(FunctionLikeOrFreestandingMacro)
\
   TYPE(FunctionTypeLParen) 
\

diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 0fd0214d16615..1fd309afd697e 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3539,7 +3539,8 @@ static unsigned maxNestingDepth(const AnnotatedLine 
&Line) {
 
 // Returns the name of a function with no return type, e.g. a constructor or
 // destructor.
-static FormatToken *getFunctionName(const AnnotatedLine &Line) {
+static FormatToken *getFunctionName(const AnnotatedLine &Line,
+FormatToken *&OpeningParen) {
   for (FormatToken *Tok = Line.getFirstNonComment(), *Name = nullptr; Tok;
Tok = Tok->getNextNonComment()) {
 // Skip C++11 attributes both before and after the function name.
@@ -3552,10 +3553,12 @@ static FormatToken *getFunctionName(const AnnotatedLine 
&Line) {
 
 // Make sure the name is followed by a pair of parentheses.
 if (Name) {
-  return Tok->is(tok::l_paren) && Tok->isNot(TT_FunctionTypeLParen) &&
- Tok->MatchingParen
- ? Name
- : nullptr;
+  if (Tok->is(tok::l_paren) && Tok->isNot(TT_FunctionTypeLParen) &&
+  Tok->MatchingParen) {
+OpeningParen = Tok;
+return Name;
+  }
+  return nullptr;
 }
 
 // Skip keywords that may precede the constructor/destructor name.
@@ -3632,10 +3635,13 @@ void TokenAnnotator::annotate(AnnotatedLine &Line) {
   ExprParser.parse();
 
   if (IsCpp) {
-auto *Tok = getFunctionName(Line);
+FormatToken *OpeningParen = nullptr;
+auto *Tok = getFunctionName(Line, OpeningParen);
 if (Tok && ((!Scopes.empty() && Scopes.back() == ST_Class) ||
 Line.endsWith(TT_FunctionLBrace) || isCtorOrDtorName(Tok))) {
   Tok->setFinalizedType(TT_CtorDtorDeclName);
+  assert(OpeningParen);
+  OpeningParen->setFinalizedType(TT_FunctionDeclarationLParen);
 }
   }
 
@@ -3864,6 +3870,12 @@ void 
TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
 Tok->setFinalizedType(TT_FunctionDeclarationName);
   LineIsFunctionDeclaration = true;
   SeenName = true;
+  if (ClosingParen) {
+auto *OpeningParen = ClosingParen->MatchingParen;
+assert(OpeningParen);
+if (OpeningParen->is(TT_Unknown))
+  OpeningParen->setType(TT_FunctionDeclarationLParen);
+  }
   break;
 }
   }

diff  --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 5d83d8a0c4429..c5e8aa72cd2cb 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -1037,6 +1037,7 @@ TEST_F(TokenAnnotatorTest, 
UnderstandsRequiresClausesAndConcepts) {
   EXPECT_TOKEN(Tokens[5], tok::kw_requires, TT_RequiresClause);
   EXPECT_TRUE(Tokens[9]->ClosesRequiresClause);
   EXPECT_TOKEN(Tokens[11], tok::identifier, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[12], tok::l_paren, TT_FunctionDeclarationLParen);
 
   Tokens = annotate("template \n"
 "requires Bar\n"
@@ -1045,6 +1046,7 @@ TEST_F(TokenAnnotatorTest, 
UnderstandsRequiresClausesAndConcepts) {
   EXPECT_TOKEN(Tokens[5], tok::kw_requires, TT_RequiresClause);
   EXPECT_TRUE(Tokens[9]->ClosesRequiresClause);
   EXPECT_TOKEN(Tokens[14], tok::identifier, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[15], tok::l_paren, TT_FunctionDeclarationLParen);
 
   Tokens = annotate("template \n"
 "struct S {\n"
@@

[clang] [clang-format][NFC] Annotate function/ctor/dtor declaration l_paren (PR #97938)

2024-07-10 Thread Owen Pan via cfe-commits

https://github.com/owenca closed https://github.com/llvm/llvm-project/pull/97938
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Catch missing format attributes (PR #70024)

2024-07-10 Thread Budimir Aranđelović via cfe-commits

https://github.com/budimirarandjelovicsyrmia updated 
https://github.com/llvm/llvm-project/pull/70024

From 1d184ff69cfdbb94f7b3e829d8f2e7aae13a6aaf Mon Sep 17 00:00:00 2001
From: budimirarandjelovicsyrmia 
Date: Fri, 5 Apr 2024 15:20:37 +0200
Subject: [PATCH] [clang] Catch missing format attributes

---
 clang/docs/ReleaseNotes.rst   |   3 +
 clang/include/clang/Basic/DiagnosticGroups.td |   1 -
 .../clang/Basic/DiagnosticSemaKinds.td|   3 +
 clang/include/clang/Sema/Attr.h   |   7 +
 clang/include/clang/Sema/Sema.h   |   4 +
 clang/lib/Sema/SemaDecl.cpp   |   2 +
 clang/lib/Sema/SemaDeclAttr.cpp   | 219 +-
 clang/test/Sema/attr-format-missing.c | 394 ++
 clang/test/Sema/attr-format-missing.cpp   | 174 
 9 files changed, 804 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Sema/attr-format-missing.c
 create mode 100644 clang/test/Sema/attr-format-missing.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index cd3a4c2b1be1a..3fafaf0a5b2c2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -686,6 +686,9 @@ Improvements to Clang's diagnostics
 - Clang no longer emits a "no previous prototype" warning for Win32 entry 
points under ``-Wmissing-prototypes``.
   Fixes #GH94366.
 
+- Clang now diagnoses missing format attributes for non-template functions and
+  class/struct/union members. Fixes #GH60718
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 2241f8481484e..da6a3b2fe3571 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -525,7 +525,6 @@ def MainReturnType : DiagGroup<"main-return-type">;
 def MaxUnsignedZero : DiagGroup<"max-unsigned-zero">;
 def MissingBraces : DiagGroup<"missing-braces">;
 def MissingDeclarations: DiagGroup<"missing-declarations">;
-def : DiagGroup<"missing-format-attribute">;
 def MissingIncludeDirs : DiagGroup<"missing-include-dirs">;
 def MissingNoreturn : DiagGroup<"missing-noreturn">;
 def MultiChar : DiagGroup<"multichar">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index fa02622f12271..a09bcba217cde 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1028,6 +1028,9 @@ def err_opencl_invalid_param : Error<
 def err_opencl_invalid_return : Error<
   "declaring function return value of type %0 is not allowed %select{; did you 
forget * ?|}1">;
 def warn_enum_value_overflow : Warning<"overflow in enumeration value">;
+def warn_missing_format_attribute : Warning<
+  "diagnostic behavior may be improved by adding the %0 format attribute to 
the declaration of %1">,
+  InGroup>, DefaultIgnore;
 def warn_pragma_options_align_reset_failed : Warning<
   "#pragma options align=reset failed: %0">,
   InGroup;
diff --git a/clang/include/clang/Sema/Attr.h b/clang/include/clang/Sema/Attr.h
index 3f0b10212789a..37c124ca7b454 100644
--- a/clang/include/clang/Sema/Attr.h
+++ b/clang/include/clang/Sema/Attr.h
@@ -123,6 +123,13 @@ inline bool isInstanceMethod(const Decl *D) {
   return false;
 }
 
+inline bool checkIfMethodHasImplicitObjectParameter(const Decl *D) {
+  if (const auto *MethodDecl = dyn_cast(D))
+return MethodDecl->isInstance() &&
+   !MethodDecl->hasCXXExplicitFunctionObjectParameter();
+  return false;
+}
+
 /// Diagnose mutually exclusive attributes when present on a given
 /// declaration. Returns true if diagnosed.
 template 
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 57994f4033922..9022ac86edf81 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -4602,6 +4602,10 @@ class Sema final : public SemaBase {
 
   enum class RetainOwnershipKind { NS, CF, OS };
 
+  void DiagnoseMissingFormatAttributes(Stmt *Body, const FunctionDecl *FDecl);
+  std::vector
+  GetMissingFormatAttributes(Stmt *Body, const FunctionDecl *FDecl);
+
   UuidAttr *mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI,
   StringRef UuidAsWritten, MSGuidDecl *GuidDecl);
 
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index d1c7b9d5ae507..ac31de5ced827 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -15924,6 +15924,8 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt 
*Body,
 }
   }
 
+  DiagnoseMissingFormatAttributes(Body, FD);
+
   // We might not have found a prototype because we didn't wish to warn on
   // the lack of a missing prototype. Try again without the checks for
   // whether we want to warn on the missing prototype.
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/Sema

[clang] [clang] Emit bad shift warnings (PR #70307)

2024-07-10 Thread Budimir Aranđelović via cfe-commits

https://github.com/budimirarandjelovicsyrmia updated 
https://github.com/llvm/llvm-project/pull/70307

From d5f3ea5c5bc3ee94ed72e529482e9df4a8770848 Mon Sep 17 00:00:00 2001
From: budimirarandjelovicsyrmia 
Date: Thu, 26 Oct 2023 10:39:52 +0200
Subject: [PATCH] [clang] Emit bad shift warnings

---
 clang/docs/ReleaseNotes.rst|  2 ++
 clang/lib/AST/ExprConstant.cpp |  7 ++
 clang/lib/Sema/SemaExpr.cpp| 35 +++---
 clang/test/C/drs/dr0xx.c   |  3 ++-
 clang/test/C/drs/dr2xx.c   |  4 ++-
 clang/test/Sema/builtins.c |  4 +--
 clang/test/Sema/constant-builtins-2.c  | 12 ++---
 clang/test/Sema/integer-overflow.c |  2 ++
 clang/test/Sema/shift-count-negative.c |  8 ++
 clang/test/Sema/shift-count-overflow.c |  9 +++
 clang/test/Sema/shift-negative-value.c | 13 ++
 clang/test/Sema/vla-2.c|  6 +++--
 clang/test/SemaCXX/enum.cpp| 16 +++-
 clang/test/SemaCXX/shift.cpp   |  2 +-
 14 files changed, 102 insertions(+), 21 deletions(-)
 create mode 100644 clang/test/Sema/shift-count-negative.c
 create mode 100644 clang/test/Sema/shift-count-overflow.c
 create mode 100644 clang/test/Sema/shift-negative-value.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index cd3a4c2b1be1a..e06de2de9a75d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -686,6 +686,8 @@ Improvements to Clang's diagnostics
 - Clang no longer emits a "no previous prototype" warning for Win32 entry 
points under ``-Wmissing-prototypes``.
   Fixes #GH94366.
 
+- Clang now diagnoses non-C++11 integer constant expressions. Fixes #GH59863
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index e0c9ef68cb448..0aeac9d03eed3 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -2859,6 +2859,9 @@ static bool handleIntIntBinOp(EvalInfo &Info, const 
BinaryOperator *E,
   else if (LHS.countl_zero() < SA)
 Info.CCEDiag(E, diag::note_constexpr_lshift_discards);
 }
+if (Info.EvalStatus.Diag && !Info.EvalStatus.Diag->empty() &&
+Info.getLangOpts().CPlusPlus11)
+  return false;
 Result = LHS << SA;
 return true;
   }
@@ -2882,6 +2885,10 @@ static bool handleIntIntBinOp(EvalInfo &Info, const 
BinaryOperator *E,
 if (SA != RHS)
   Info.CCEDiag(E, diag::note_constexpr_large_shift)
 << RHS << E->getType() << LHS.getBitWidth();
+
+if (Info.EvalStatus.Diag && !Info.EvalStatus.Diag->empty() &&
+Info.getLangOpts().CPlusPlus11)
+  return false;
 Result = LHS >> SA;
 return true;
   }
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 45991e66b3e43..dd1191bef4d3e 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -11084,7 +11084,7 @@ static void DiagnoseBadShiftValues(Sema& S, ExprResult 
&LHS, ExprResult &RHS,
   if (Right.isNegative()) {
 S.DiagRuntimeBehavior(Loc, RHS.get(),
   S.PDiag(diag::warn_shift_negative)
-<< RHS.get()->getSourceRange());
+  << RHS.get()->getSourceRange());
 return;
   }
 
@@ -11099,7 +11099,7 @@ static void DiagnoseBadShiftValues(Sema& S, ExprResult 
&LHS, ExprResult &RHS,
   if (Right.uge(LeftSize)) {
 S.DiagRuntimeBehavior(Loc, RHS.get(),
   S.PDiag(diag::warn_shift_gt_typewidth)
-<< RHS.get()->getSourceRange());
+  << RHS.get()->getSourceRange());
 return;
   }
 
@@ -11132,7 +11132,7 @@ static void DiagnoseBadShiftValues(Sema& S, ExprResult 
&LHS, ExprResult &RHS,
   if (Left.isNegative()) {
 S.DiagRuntimeBehavior(Loc, LHS.get(),
   S.PDiag(diag::warn_shift_lhs_negative)
-<< LHS.get()->getSourceRange());
+  << LHS.get()->getSourceRange());
 return;
   }
 
@@ -16970,11 +16970,38 @@ Sema::VerifyIntegerConstantExpression(Expr *E, 
llvm::APSInt *Result,
   // Circumvent ICE checking in C++11 to avoid evaluating the expression twice
   // in the non-ICE case.
   if (!getLangOpts().CPlusPlus11 && E->isIntegerConstantExpr(Context)) {
+SmallVector Notes;
 if (Result)
-  *Result = E->EvaluateKnownConstIntCheckOverflow(Context);
+  *Result = E->EvaluateKnownConstIntCheckOverflow(Context, &Notes);
 if (!isa(E))
   E = Result ? ConstantExpr::Create(Context, E, APValue(*Result))
  : ConstantExpr::Create(Context, E);
+
+if (Notes.empty())
+  return E;
+
+// If our only note is the usual "invalid subexpression" note, just point
+// the caret at its location rather than producing an essentially
+// redundant note.
+if (Notes.size() == 1 && Notes[0].second.getDiagID(

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Owen Pan via cfe-commits


@@ -146,6 +146,14 @@ static bool startsNextParameter(const FormatToken &Current,
Style.BreakInheritanceList != FormatStyle::BILS_BeforeComma));
 }
 
+// Returns \c true if \c Current starts a new operand in a binary operation.

owenca wrote:

Did you mean `Current is the right operand of a binary operator`?

https://github.com/llvm/llvm-project/pull/95013
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Run PreStmt/PostStmt checker for GCCAsmStmt (PR #95409)

2024-07-10 Thread Balazs Benics via cfe-commits

https://github.com/steakhal requested changes to this pull request.

Thanks for the ping. Looks really nice!
FYI I just came across a case last week w.r.t asm gotos. You can have a read 
[here](https://sonarsource.atlassian.net/browse/CPP-5459) if you are interested 
in the subject.

https://github.com/llvm/llvm-project/pull/95409
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Run PreStmt/PostStmt checker for GCCAsmStmt (PR #95409)

2024-07-10 Thread Balazs Benics via cfe-commits

https://github.com/steakhal edited 
https://github.com/llvm/llvm-project/pull/95409
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Run PreStmt/PostStmt checker for GCCAsmStmt (PR #95409)

2024-07-10 Thread Balazs Benics via cfe-commits


@@ -2057,11 +2057,16 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode 
*Pred,
   llvm_unreachable("Support for MatrixSubscriptExpr is not implemented.");
   break;
 
-case Stmt::GCCAsmStmtClass:
+case Stmt::GCCAsmStmtClass: {
   Bldr.takeNodes(Pred);
-  VisitGCCAsmStmt(cast(S), Pred, Dst);
+  ExplodedNodeSet PreVisit;
+  getCheckerManager().runCheckersForPreStmt(PreVisit, Pred, S, *this);
+  ExplodedNodeSet PostVisit;
+  for (ExplodedNode *const N : PreVisit)
+VisitGCCAsmStmt(cast(S), N, PostVisit);
+  getCheckerManager().runCheckersForPostStmt(Dst, PostVisit, S, *this);
   Bldr.addNodes(Dst);
-  break;
+} break;

steakhal wrote:

Hm, I think it would look better if the break was inside the braces.

https://github.com/llvm/llvm-project/pull/95409
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Run PreStmt/PostStmt checker for GCCAsmStmt (PR #95409)

2024-07-10 Thread Balazs Benics via cfe-commits


@@ -0,0 +1,90 @@
+//===- ExprEngineVisitTest.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "CheckerRegistration.h"
+#include "clang/AST/Stmt.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+
+void emitErrorReport(CheckerContext &C, const BugType &Bug,
+ const std::string &Desc) {
+  if (ExplodedNode *Node = C.generateNonFatalErrorNode(C.getState())) {
+auto Report = std::make_unique(Bug, Desc, Node);
+C.emitReport(std::move(Report));
+  }
+}
+
+class ExprEngineVisitPreChecker : public Checker> {
+public:
+  void checkPreStmt(const GCCAsmStmt *ASM, CheckerContext &C) const {
+emitErrorReport(C, Bug, "PreStmt");
+  }
+
+private:
+  const BugType Bug{this, "GCCAsmStmtBug"};
+};
+
+class ExprEngineVisitPostChecker : public Checker> 
{
+public:
+  void checkPostStmt(const GCCAsmStmt *ASM, CheckerContext &C) const {
+emitErrorReport(C, Bug, "PostStmt");
+  }
+
+private:
+  const BugType Bug{this, "GCCAsmStmtBug"};
+};

steakhal wrote:

I think you could merge these two into a single class.
Similar goes to the other parts. To me `asm stmt` is itself a thing to test.
But it's just a personal preference.
One other way to look at this is basically the combinatorical explosion of the 
tests if we wanted to cover all other statements and different callback kinds. 
The boilerplate to useful code would just blow up.

https://github.com/llvm/llvm-project/pull/95409
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Run PreStmt/PostStmt checker for GCCAsmStmt (PR #95409)

2024-07-10 Thread Balazs Benics via cfe-commits


@@ -0,0 +1,90 @@
+//===- ExprEngineVisitTest.cpp ---===//

steakhal wrote:

I think this should have the same length as the closing one.

https://github.com/llvm/llvm-project/pull/95409
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Owen Pan via cfe-commits


@@ -3153,6 +3153,15 @@ class ExpressionParser {
   parse(Precedence + 1);
 
   int CurrentPrecedence = getCurrentPrecedence();
+  if (!Style.BinPackBinaryOperations &&
+  (CurrentPrecedence > prec::Conditional) &&
+  (CurrentPrecedence < prec::PointerToMember)) {

owenca wrote:

Remove redundant parens.

https://github.com/llvm/llvm-project/pull/95013
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Owen Pan via cfe-commits


@@ -146,6 +146,14 @@ static bool startsNextParameter(const FormatToken &Current,
Style.BreakInheritanceList != FormatStyle::BILS_BeforeComma));
 }
 
+// Returns \c true if \c Current starts a new operand in a binary operation.
+static bool startsNextOperand(const FormatToken &Current) {
+  const FormatToken &Previous = *Current.Previous;

owenca wrote:

Assert `Current.Previous` before dereferencing it.
```suggestion
  const auto &Previous = *Current.Previous;
```

https://github.com/llvm/llvm-project/pull/95013
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Owen Pan via cfe-commits


@@ -146,6 +146,14 @@ static bool startsNextParameter(const FormatToken &Current,
Style.BreakInheritanceList != FormatStyle::BILS_BeforeComma));
 }
 
+// Returns \c true if \c Current starts a new operand in a binary operation.
+static bool startsNextOperand(const FormatToken &Current) {
+  const FormatToken &Previous = *Current.Previous;
+  return Previous.is(TT_BinaryOperator) && !Current.isTrailingComment() &&
+ (Previous.getPrecedence() > prec::Conditional) &&
+ (Previous.getPrecedence() < prec::PointerToMember);

owenca wrote:

Please remove the redundant parens.

https://github.com/llvm/llvm-project/pull/95013
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Owen Pan via cfe-commits


@@ -27628,6 +27628,109 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) {
   verifyFormat("return sizeof \"5\";");
 }
 
+TEST_F(FormatTest, BinPackBinaryOperations) {
+  auto Style = getLLVMStyleWithColumns(60);
+  // Logical operations
+  verifyFormat("if (condition1 && condition2) {\n"
+   "}",
+   Style);
+
+  verifyFormat("if (condition1 && condition2 &&\n"
+   "(condition3 || condition4) && condition5 &&\n"
+   "condition6) {\n"
+   "}",
+   Style);
+
+  verifyFormat("if (loongcondition1 &&\n"
+   "loongcondition2) {\n"
+   "}",
+   Style);
+
+  // Arithmetic
+  verifyFormat("const int result = lhs + rhs;\n", Style);

owenca wrote:

No trailing newline at the end of the test cases here and below.

https://github.com/llvm/llvm-project/pull/95013
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] CTAD: Generate deduction guides for alias templates from non-template explicit deduction guides (PR #96686)

2024-07-10 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `sanitizer-x86_64-linux` 
running on `sanitizer-buildbot1` while building `clang` at step 2 "annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/66/builds/1264

Here is the relevant piece of the build log for the reference:
```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
llvm-lit: 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60:
 warning: Path reported by clang does not exist: 
"/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu".
 This path was found by running 
['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', 
'--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60:
 warning: Path reported by clang does not exist: 
"/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu".
 This path was found by running 
['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', 
'--target=x86_64-unknown-linux-gnu', '-Wthread-safety', 
'-Wthread-safety-reference', '-Wthread-safety-beta', '-print-runtime-dir'].
llvm-lit: 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60:
 warning: Path reported by clang does not exist: 
"/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu".
 This path was found by running 
['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', 
'--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60:
 warning: Path reported by clang does not exist: 
"/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu".
 This path was found by running 
['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', 
'--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60:
 warning: Path reported by clang does not exist: 
"/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu".
 This path was found by running 
['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', 
'--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60:
 warning: Path reported by clang does not exist: 
"/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu".
 This path was found by running 
['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', 
'--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: 
/b/sanitizer-x86_64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:72: 
note: The test suite configuration requested an individual test timeout of 0 
seconds but a timeout of 900 seconds was requested on the command line. Forcing 
timeout to be 900 seconds.
-- Testing: 9996 tests, 80 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
TIMEOUT: SanitizerCommon-hwasan-x86_64-Linux :: Posix/fork_threaded.c (9996 of 
9996)
 TEST 'SanitizerCommon-hwasan-x86_64-Linux :: 
Posix/fork_threaded.c' FAILED 
Exit Code: -9
Timeout: Reached timeout of 900 seconds

Command Output (stderr):
--
RUN: at line 1: /b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang  
-gline-tables-only -fsanitize=hwaddress -fuse-ld=lld 
-fsanitize-hwaddress-experimental-aliasing  -m64 -funwind-tables  
-I/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O0 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c
 -o 
/b/sanitizer-x86_64-linux/build/build_symbolizer/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp
 && env HWASAN_OPTIONS=die_after_fork=0  
/b/sanitizer-x86_64-linux/build/build_symbolizer/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp
+ /b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang 
-gline-tables-only -fsanitize=hwaddress -fuse-ld=lld 
-fsanitize-hwaddress-experimental-aliasing -m64 -funwind-tables 
-I/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O0 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c
 -o 
/b/sanitizer-x86_64-linux/build/build_symbolizer/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp
+ env HWASAN_OPTIONS=die_after_fork=0 
/b/sanitizer-x86_64-linux/build/build_symbolizer/

[clang] [NFCI][clang][analyzer] Make ProgramStatePartialTrait a template definition (PR #98150)

2024-07-10 Thread Balazs Benics via cfe-commits

steakhal wrote:

> N4860 13 [class.derived]/2 mandates that base classes must be complete types. 
> Before this patch, ProgramStatePartialTrait is a forward declaration of a 
> class template, thus an incomplete type. Explicit specializations of forward 
> declared templates are also incomplete types, until the body of the 
> specialization is seen, thus should not appear as a base class. This patch 
> makes ProgramStatePartialTrait a definition with an empty body by default, 
> enabling it to appear in a base-specifier list, and practically eliminating a 
> compiler warning given by GCC13.

Before we would proceed, could you please paste the diagnostic that this PR 
fixes?

https://github.com/llvm/llvm-project/pull/98150
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Splitting TaintPropagation checker into reporting and mode… (PR #98157)

2024-07-10 Thread Balazs Benics via cfe-commits


@@ -2,10 +2,13 @@
 Taint Analysis Configuration
 
 
-The Clang Static Analyzer uses taint analysis to detect security-related 
issues in code.
-The backbone of taint analysis in the Clang SA is the `GenericTaintChecker`, 
which the user can access via the :ref:`alpha-security-taint-TaintPropagation` 
checker alias and this checker has a default taint-related configuration.
-The built-in default settings are defined in code, and they are always in 
effect once the checker is enabled, either directly or via the alias.
-The checker also provides a configuration interface for extending the default 
settings by providing a configuration file in `YAML 
`_ format.
+The Clang Static Analyzer uses taint analysis to detect injection 
vulnerability related issues in code.
+The backbone of taint analysis in the Clang SA is the ``TaintPropagation`` 
modeling checker.

steakhal wrote:

Personally, I'd prefer accepting modeling checkers as a thing and have configs 
for them. I'd rather not make this as an option to the analyzer itself.

https://github.com/llvm/llvm-project/pull/98157
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Splitting TaintPropagation checker into reporting and mode… (PR #98157)

2024-07-10 Thread Balazs Benics via cfe-commits


@@ -1122,10 +1131,20 @@ void 
GenericTaintChecker::taintUnsafeSocketProtocol(const CallEvent &Call,
 }
 
 /// Checker registration
-void ento::registerGenericTaintChecker(CheckerManager &Mgr) {
+void ento::registerTaintPropagationChecker(CheckerManager &Mgr) {
   Mgr.registerChecker();
 }
 
+bool ento::shouldRegisterTaintPropagationChecker(const CheckerManager &mgr) {
+  return true;
+}
+
+void ento::registerGenericTaintChecker(CheckerManager &Mgr) {
+  GenericTaintChecker *checker = Mgr.getChecker();
+  checker->isTaintReporterCheckerEnabled = true;
+  checker->reporterCheckerName = Mgr.getCurrentCheckerName();

steakhal wrote:

Would this make it possible to eliminate the `unique_ptr`? I really liked the 
look without them :)
In other words, what forces us to use `unique_ptrs`?

https://github.com/llvm/llvm-project/pull/98157
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Splitting TaintPropagation checker into reporting and mode… (PR #98157)

2024-07-10 Thread Balazs Benics via cfe-commits

https://github.com/steakhal commented:

I like the separation. Thanks.

https://github.com/llvm/llvm-project/pull/98157
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][doc] Improve error handling for `LibTooling` example code avoiding core dump (PR #98129)

2024-07-10 Thread nick huang via cfe-commits

nickhuang99 wrote:

neither do I.
I guess you need other reviewer approval.

获取Outlook for Android

From: Rajveer Singh Bharadwaj ***@***.***>
Sent: Wednesday, July 10, 2024 2:44:20 PM
To: llvm/llvm-project ***@***.***>
Cc: nick huang ***@***.***>; Mention ***@***.***>
Subject: Re: [llvm/llvm-project] [clang][doc] Improve error handling for 
`LibTooling` example code avoiding core dump (PR #98129)


Sure. Do I need to do anything?

I don't have the access rights to merge yet.

―
Reply to this email directly, view it on 
GitHub,
 or 
unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>


https://github.com/llvm/llvm-project/pull/98129
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Clang][ARM][AArch64] Alway emit protection attributes for functions. (PR #82819)

2024-07-10 Thread Daniel Kiss via cfe-commits

https://github.com/DanielKristofKiss closed 
https://github.com/llvm/llvm-project/pull/82819
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e15d67c - [Clang][ARM][AArch64] Alway emit protection attributes for functions. (#82819)

2024-07-10 Thread via cfe-commits

Author: Daniel Kiss
Date: 2024-07-10T10:06:14+02:00
New Revision: e15d67cfc2e5775cc79281aa860f3ad3be628f39

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

LOG: [Clang][ARM][AArch64] Alway emit protection attributes for functions. 
(#82819)

So far branch protection, sign return address, guarded control stack
attributes are
only emitted as module flags to indicate the functions need to be
generated with
those features.
The problem is in case of an LTO build the module flags are merged with
the `min`
rule which means if one of the module is not build with sign return
address then the features
will be turned off for all functions. Due to the functions take the
branch-protection and
sign-return-address features from the module flags. The
sign-return-address is
function level option therefore it is expected functions from files that
is
compiled with -mbranch-protection=pac-ret to be protected.
The inliner might inline functions with different set of flags as it
doesn't consider
the module flags.
 
This patch adds the attributes to all functions and drops the checking
of the module flags
for the code generation.
Module flag is still used for generating the ELF markers.
Also drops the "true"/"false" values from the
branch-protection-enforcement,
branch-protection-pauth-lr, guarded-control-stack attributes as presence
of the
attribute means it is on absence means off and no other option.

Added: 
clang/test/Frontend/arm-branch-protection-lto.c

Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/CodeGen/Targets/AArch64.cpp
clang/lib/CodeGen/Targets/ARM.cpp
clang/test/CodeGen/aarch64-branch-protection-attr.c
clang/test/CodeGen/aarch64-sign-return-address.c
clang/test/CodeGen/arm-branch-protection-attr-1.c
clang/test/CodeGen/arm-branch-protection-attr-2.c
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp
llvm/lib/Target/ARM/ARMMachineFunctionInfo.cpp
llvm/lib/Transforms/IPO/LowerTypeTests.cpp
llvm/test/CodeGen/AArch64/branch-target-enforcement-indirect-calls.ll
llvm/test/CodeGen/AArch64/bti-branch-relaxation.ll
llvm/test/CodeGen/AArch64/kcfi-bti.ll
llvm/test/CodeGen/AArch64/machine-outliner-2fixup-blr-terminator.mir
llvm/test/CodeGen/AArch64/machine-outliner-bti.mir
llvm/test/CodeGen/AArch64/machine-outliner-outline-bti.ll
llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-0.ll
llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-4.ll
llvm/test/CodeGen/AArch64/pacbti-llvm-generated-funcs-1.ll
llvm/test/CodeGen/AArch64/pacbti-llvm-generated-funcs-2.ll
llvm/test/CodeGen/AArch64/pacbti-module-attrs.ll
llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
llvm/test/CodeGen/AArch64/setjmp-bti-outliner.ll
llvm/test/CodeGen/AArch64/setjmp-bti.ll
llvm/test/CodeGen/AArch64/sign-return-address-pauth-lr.ll
llvm/test/CodeGen/AArch64/sign-return-address.ll
llvm/test/CodeGen/AArch64/wineh-bti.ll
llvm/test/CodeGen/AArch64/wineh-pac.ll
llvm/test/CodeGen/ARM/setjmp-bti-basic.ll
llvm/test/CodeGen/ARM/setjmp-bti-outliner.ll
llvm/test/CodeGen/Thumb2/bti-entry-blocks.ll
llvm/test/CodeGen/Thumb2/bti-indirect-branches.ll
llvm/test/CodeGen/Thumb2/bti-outliner-1.ll
llvm/test/CodeGen/Thumb2/bti-outliner-2.ll
llvm/test/CodeGen/Thumb2/bti-outliner-cost-2.ll
llvm/test/CodeGen/Thumb2/bti-pac-replace-1.mir
llvm/test/CodeGen/Thumb2/bti-pac-replace-2.ll
llvm/test/CodeGen/Thumb2/jump-table-bti.ll
llvm/test/CodeGen/Thumb2/pacbti-m-basic.ll
llvm/test/CodeGen/Thumb2/pacbti-m-indirect-tail-call.ll
llvm/test/CodeGen/Thumb2/pacbti-m-outliner-1.ll
llvm/test/CodeGen/Thumb2/pacbti-m-outliner-3.ll
llvm/test/CodeGen/Thumb2/pacbti-m-outliner-4.ll
llvm/test/CodeGen/Thumb2/pacbti-m-outliner-5.ll
llvm/test/CodeGen/Thumb2/pacbti-m-overalign.ll
llvm/test/CodeGen/Thumb2/pacbti-m-stack-arg.ll
llvm/test/CodeGen/Thumb2/pacbti-m-unsupported-arch.ll
llvm/test/CodeGen/Thumb2/pacbti-m-varargs-1.ll
llvm/test/CodeGen/Thumb2/pacbti-m-varargs-2.ll
llvm/test/CodeGen/Thumb2/pacbti-m-vla.ll
llvm/test/LTO/AArch64/link-branch-target-enforcement.ll
llvm/test/Transforms/Inline/inline-sign-return-address.ll
llvm/test/Transforms/LowerTypeTests/function-arm-thumb.ll
llvm/test/Transforms/LowerTypeTests/function-thumb-bti.ll
llvm/test/Transforms/LowerTypeTests/function.ll
llvm/test/Verifier/branch-prot-attrs.ll

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 9b0ae2102e098..1f208b40f92cb 100644
--- a/clang/include/clang/Basic/

[clang] [Clang][ARM][AArch64] Add branch protection attributes to the defaults. (PR #83277)

2024-07-10 Thread Daniel Kiss via cfe-commits

https://github.com/DanielKristofKiss updated 
https://github.com/llvm/llvm-project/pull/83277

>From c421b6b9c167e82cedc5db2a67f47d3ba12deba9 Mon Sep 17 00:00:00 2001
From: Daniel Kiss 
Date: Wed, 28 Feb 2024 15:18:31 +0100
Subject: [PATCH 1/5] Add branch protection attributes to the defaults.

These attributes are no longer inherited from the module flags,
therefore need to be added for synthetic functions.
---
 clang/lib/CodeGen/CGCall.cpp  | 16 ++
 .../CodeGenCXX/arm64-generated-fn-attr.cpp| 30 +++
 2 files changed, 46 insertions(+)
 create mode 100644 clang/test/CodeGenCXX/arm64-generated-fn-attr.cpp

diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 13f68237b464d..5b59c77353675 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -2022,6 +2022,22 @@ static void getTrivialDefaultFunctionAttributes(
 std::tie(Var, Value) = Attr.split('=');
 FuncAttrs.addAttribute(Var, Value);
   }
+
+  TargetInfo::BranchProtectionInfo BPI(LangOpts);
+
+  if (BPI.SignReturnAddr != LangOptions::SignReturnAddressScopeKind::None) {
+FuncAttrs.addAttribute("sign-return-address", BPI.getSignReturnAddrStr());
+FuncAttrs.addAttribute(
+"sign-return-address-key",
+BPI.SignKey == LangOptions::SignReturnAddressKeyKind::AKey ? "a_key"
+   : "b_key");
+  }
+  if (BPI.BranchTargetEnforcement)
+FuncAttrs.addAttribute("branch-target-enforcement", "true");
+  if (BPI.BranchProtectionPAuthLR)
+FuncAttrs.addAttribute("branch-protection-pauth-lr", "true");
+  if (BPI.GuardedControlStack)
+FuncAttrs.addAttribute("guarded-control-stack", "true");
 }
 
 /// Merges `target-features` from \TargetOpts and \F, and sets the result in
diff --git a/clang/test/CodeGenCXX/arm64-generated-fn-attr.cpp 
b/clang/test/CodeGenCXX/arm64-generated-fn-attr.cpp
new file mode 100644
index 0..8daf44abd4f91
--- /dev/null
+++ b/clang/test/CodeGenCXX/arm64-generated-fn-attr.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -triple aarch64-none-none -mbranch-target-enforce 
-msign-return-address=all -fcxx-exceptions -fexceptions -emit-llvm %s -o - | 
FileCheck %s --check-prefixes=CHECK
+
+// Check that functions generated by clang have the correct attributes
+
+class Example {
+public:
+  Example();
+  int fn();
+};
+
+// Initialization of var1 causes __cxx_global_var_init and __tls_init to be 
generated
+thread_local Example var1;
+extern thread_local Example var2;
+extern void fn();
+
+int testfn() noexcept {
+  // Calling fn in a noexcept function causes __clang_call_terminate to be 
generated
+  fn();
+  // Use of var1 and var2 causes TLS wrapper functions to be generated
+  return var1.fn() + var2.fn();
+}
+
+// CHECK: define {{.*}} @__cxx_global_var_init() [[ATTR1:#[0-9]+]]
+// CHECK: define {{.*}} @__clang_call_terminate({{.*}}) [[ATTR2:#[0-9]+]]
+// CHECK: define {{.*}} @_ZTW4var1() [[ATTR1]]
+// CHECK: define {{.*}} @_ZTW4var2() [[ATTR1]]
+// CHECK: define {{.*}} @__tls_init() [[ATTR1]]
+
+// CHECK: attributes [[ATTR1]] = { 
{{.*}}"branch-target-enforcement"="true"{{.*}}"sign-return-address"="all" 
"sign-return-address-key"="a_key"
+// CHECK: attributes [[ATTR2]] = { 
{{.*}}"branch-target-enforcement"="true"{{.*}}"sign-return-address"="all" 
"sign-return-address-key"="a_key"

>From 3e46bfa6bcd8a0cce142a4e1254c89ff68174117 Mon Sep 17 00:00:00 2001
From: Daniel Kiss 
Date: Wed, 28 Feb 2024 17:38:49 +0100
Subject: [PATCH 2/5] fixup! [Clang][Arm][AArch64] Add branch protection
 attributes to the defaults.

---
 clang/lib/CodeGen/CGCall.cpp | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 5b59c77353675..58ccd3d181ccd 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -2027,10 +2027,7 @@ static void getTrivialDefaultFunctionAttributes(
 
   if (BPI.SignReturnAddr != LangOptions::SignReturnAddressScopeKind::None) {
 FuncAttrs.addAttribute("sign-return-address", BPI.getSignReturnAddrStr());
-FuncAttrs.addAttribute(
-"sign-return-address-key",
-BPI.SignKey == LangOptions::SignReturnAddressKeyKind::AKey ? "a_key"
-   : "b_key");
+FuncAttrs.addAttribute("sign-return-address-key", BPI.getSignKeyStr());
   }
   if (BPI.BranchTargetEnforcement)
 FuncAttrs.addAttribute("branch-target-enforcement", "true");

>From 054515d8b3b50b3efc792db9dfe4c9e61fa2507d Mon Sep 17 00:00:00 2001
From: Daniel Kiss 
Date: Mon, 4 Mar 2024 17:31:31 +0100
Subject: [PATCH 3/5] Move TargetInfo changes over.

Dropping restrictions on the member functions.
---
 clang/include/clang/Basic/TargetInfo.h | 43 +++---
 1 file changed, 39 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 76

[clang] da31b68 - [Coverage] Suppress covmap and profdata for system headers. (#97952)

2024-07-10 Thread via cfe-commits

Author: NAKAMURA Takumi
Date: 2024-07-10T17:11:12+09:00
New Revision: da31b684a57cdc77ad4274fd7d8b47ee27dea6c6

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

LOG: [Coverage] Suppress covmap and profdata for system headers. (#97952)

With `system-headers-coverage=false`, functions defined in system
headers were not instrumented but corresponding covmaps were emitted. It
caused wasting covmap and profraw.

This change improves:

- Reduce object size (due to reduced covmap)
- Reduce size of profraw (uninstrumented system headers occupied
counters)
- Smarter view of coverage report. Stubs of uninstrumented system
headers will be no longer seen.

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenPGO.cpp
clang/test/CoverageMapping/system_macro.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 44bc7fbfdd37e..5c810cd332185 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -7165,6 +7165,9 @@ void CodeGenModule::AddDeferredUnusedCoverageMapping(Decl 
*D) {
 SourceManager &SM = getContext().getSourceManager();
 if (LimitedCoverage && SM.getMainFileID() != 
SM.getFileID(D->getBeginLoc()))
   break;
+if (!llvm::coverage::SystemHeadersCoverage &&
+SM.isInSystemHeader(D->getBeginLoc()))
+  break;
 DeferredEmptyCoverageMappingDecls.try_emplace(D, true);
 break;
   }

diff  --git a/clang/lib/CodeGen/CodeGenPGO.cpp 
b/clang/lib/CodeGen/CodeGenPGO.cpp
index 6e6dfc4d5a642..cfcdb5911b581 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -1044,13 +1044,17 @@ void CodeGenPGO::assignRegionCounters(GlobalDecl GD, 
llvm::Function *Fn) {
   if (Fn->hasFnAttribute(llvm::Attribute::SkipProfile))
 return;
 
+  SourceManager &SM = CGM.getContext().getSourceManager();
+  if (!llvm::coverage::SystemHeadersCoverage &&
+  SM.isInSystemHeader(D->getLocation()))
+return;
+
   setFuncName(Fn);
 
   mapRegionCounters(D);
   if (CGM.getCodeGenOpts().CoverageMapping)
 emitCounterRegionMapping(D);
   if (PGOReader) {
-SourceManager &SM = CGM.getContext().getSourceManager();
 loadRegionCounts(PGOReader, SM.isInMainFile(D->getLocation()));
 computeRegionCounts(D);
 applyFunctionAttributes(PGOReader, Fn);

diff  --git a/clang/test/CoverageMapping/system_macro.cpp 
b/clang/test/CoverageMapping/system_macro.cpp
index 3909c17a9b5c6..38bbb2efb7075 100644
--- a/clang/test/CoverageMapping/system_macro.cpp
+++ b/clang/test/CoverageMapping/system_macro.cpp
@@ -5,9 +5,8 @@
 
 // LL_CHECK: @__covrec_
 // LL_W_SYS: [[PROFC:@.*__profc_.*SysTmpl.*]] =
-// LL_WOSYS: [[PROFC:@.*__profc_.*SysTmpl.*]] =
 // LL_W_SYS: @{{.*}}__profd_{{.*}}SysTmpl{{.*}} =
-// LL_WOSYS: @{{.*}}__profd_{{.*}}SysTmpl{{.*}} =
+// LL_WOSYS-NOT: SysTmpl
 
 // LL_CHECK: @llvm.used =
 
@@ -21,7 +20,7 @@
 template  bool SysTmpl() { return f; }
 // Check SysTmpl() is instrumented or not.
 // LL_W_SYS: load i64, ptr [[PROFC]],
-// LL_WOSYS: load i64, ptr [[PROFC]],
+// LL_WOSYS-NOT: load i64, ptr @__profc_
 
 #else
 



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Coverage] Suppress covmap and profdata for system headers. (PR #97952)

2024-07-10 Thread NAKAMURA Takumi via cfe-commits

https://github.com/chapuni closed 
https://github.com/llvm/llvm-project/pull/97952
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [PAC][Driver] Implement `-mbranch-protection=pauthabi` option (PR #97237)

2024-07-10 Thread Daniil Kovalev via cfe-commits

kovdan01 wrote:

Thanks @smithp35 for a detailed description!

> Use the environment part of the triple

I suppose we should use this this option since it's harder for end users to use 
that incorrectly - it looks like that many real-world code and corresponding 
build environments rely on triple and do not encounter other options (for 
example, as you said, hard/soft float are encoded in triple or normalized to 
triple if passed separately). 

I'll implement initial support for that and update current PR.

> I think we should require the `+pauth` feature (default in armv8.3-A) for 
> `-mabi=pauth` to be accepted.

We actually have a similar issue already opened, see #97332, so yes, it's a 
known feature request.

> If we are being as careful to avoid prematurly fixing a signing schema for 
> the linux target we could use a of test and no `-mabi=pauth` default. For 
> example `-mabi=pauthtest`.

I like this idea. Of course, we can mark functionality as "alpha" or 
"experimental", but just using a different option value makes this more 
explicit and end users will not have a chance to mix "alpha" stuff with 
"released" stuff when we have one.

> I think that this has to be under control of the platform. My intuition is 
> that we trust the user, perhaps with a warning, and
> record the high-level signing schema.

In general, I agree with that point, but for the first "adoption" phase (while 
we have `-mabi=pauthtest` or `-mabi=pauth` marked as "alpha") it might be 
useful to encode the low-level schema - we let users compile with `-fptrauth-*` 
flags if they want (probably with a huge warning that they are using this at 
their own risk), but we do not let them link incompatible binaries. At least, I 
suggest to limit scope of the PR to implementing `-mabi=pauth` (normalizing to 
triple), parsing the triple and enabling proper features correspondingly, while 
leaving low-level encoding of signing schema in pauth core info (inside elf's 
gnu property) already implemented untouched as for now.

https://github.com/llvm/llvm-project/pull/97237
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Do not emit intrinsic math functions on GPU targets (PR #98209)

2024-07-10 Thread Matt Arsenault via cfe-commits


@@ -0,0 +1,51 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa %s -emit-llvm -o - | FileCheck %s 
--check-prefix AMDGPU
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda %s -emit-llvm -o - | FileCheck 
%s --check-prefix NVPTX
+
+double sin(double);
+double cos(double);
+double sqrt(double);
+
+// AMDGPU-LABEL: define dso_local void @libcalls(
+// AMDGPU-SAME: ) #[[ATTR0:[0-9]+]] {
+// AMDGPU-NEXT:  [[ENTRY:.*:]]
+// AMDGPU-NEXT:[[CALL:%.*]] = call double @sin(double noundef 
0.00e+00) #[[ATTR3:[0-9]+]]
+// AMDGPU-NEXT:[[CALL1:%.*]] = call double @cos(double noundef 
0.00e+00) #[[ATTR3]]
+// AMDGPU-NEXT:[[CALL2:%.*]] = call double @sqrt(double noundef 
0.00e+00) #[[ATTR3]]
+// AMDGPU-NEXT:ret void
+//
+// NVPTX-LABEL: define dso_local void @libcalls(
+// NVPTX-SAME: ) #[[ATTR0:[0-9]+]] {
+// NVPTX-NEXT:  [[ENTRY:.*:]]
+// NVPTX-NEXT:[[CALL:%.*]] = call double @sin(double noundef 0.00e+00) 
#[[ATTR3:[0-9]+]]
+// NVPTX-NEXT:[[CALL1:%.*]] = call double @cos(double noundef 
0.00e+00) #[[ATTR3]]
+// NVPTX-NEXT:[[CALL2:%.*]] = call double @sqrt(double noundef 
0.00e+00) #[[ATTR3]]
+// NVPTX-NEXT:ret void
+//
+void libcalls() {
+  (void)sin(0.);
+  (void)cos(0.);
+  (void)sqrt(0.);

arsenm wrote:

This test really ought to be comprehensive and test every single math function, 
and cover the float and double versions 

https://github.com/llvm/llvm-project/pull/98209
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Do not emit intrinsic math functions on GPU targets (PR #98209)

2024-07-10 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm commented:

This is going to break the library build. We use the __builtin functions to 
access the intrinsic in the cases where the llvm intrinsic lowering provides 
the implementation of the function. In a more sensible world, the library would 
not provide the implementations of functions that are implemented by the 
intrinsics in the first place 

https://github.com/llvm/llvm-project/pull/98209
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Do not emit intrinsic math functions on GPU targets (PR #98209)

2024-07-10 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm edited https://github.com/llvm/llvm-project/pull/98209
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Clang][ARM][AArch64] Alway emit protection attributes for functions. (PR #82819)

2024-07-10 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`llvm-clang-x86_64-sie-ubuntu-fast` running on `sie-linux-worker` while 
building `clang,llvm` at step 6 "test-build-unified-tree-check-all".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/144/builds/1938

Here is the relevant piece of the build log for the reference:
```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: CodeGen/aarch64-targetattr.c' FAILED 

Exit Code: 1

Command Output (stderr):
--
RUN: at line 2: 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/clang 
-cc1 -internal-isystem 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/lib/clang/19/include
 -nostdsysteminc -triple aarch64 -emit-llvm 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGen/aarch64-targetattr.c
 -o - | 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck
 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGen/aarch64-targetattr.c
+ 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/clang 
-cc1 -internal-isystem 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/lib/clang/19/include
 -nostdsysteminc -triple aarch64 -emit-llvm 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGen/aarch64-targetattr.c
 -o -
+ 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck
 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGen/aarch64-targetattr.c
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGen/aarch64-targetattr.c:210:11:
 error: CHECK: expected string not found in input
// CHECK: attributes #[[ATTR15]] = { noinline nounwind optnone 
"branch-protection-pauth-lr"="false" "branch-target-enforcement"="true" 
"guarded-control-stack"="true" "no-trapping-math"="true" 
"sign-return-address"="non-leaf" "sign-return-address-key"="a_key" 
"stack-protector-buffer-size"="8" "target-cpu"="neoverse-n1" 
"target-features"="+aes,+bf16,+complxnum,+crc,+dotprod,+fp-armv8,+fullfp16,+i8mm,+jsconv,+lse,+neon,+pauth,+perfmon,+ras,+rcpc,+rdm,+sha2,+spe,+ssbs,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8.5a,+v8.6a,+v8a"
 "tune-cpu"="cortex-a710" }
  ^
:176:367: note: scanning from here
attributes #14 = { noinline nounwind optnone "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-cpu"="neoverse-n1" 
"target-features"="+aes,+bf16,+complxnum,+crc,+dotprod,+fp-armv8,+fullfp16,+i8mm,+jsconv,+lse,+neon,+pauth,+perfmon,+ras,+rcpc,+rdm,+sha2,+spe,+ssbs,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8.5a,+v8.6a,+v8a"
 "tune-cpu"="cortex-a710" }
   



   ^
:176:367: note: with "ATTR15" equal to "15"
attributes #14 = { noinline nounwind optnone "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-cpu"="neoverse-n1" 
"target-features"="+aes,+bf16,+complxnum,+crc,+dotprod,+fp-armv8,+fullfp16,+i8mm,+jsconv,+lse,+neon,+pauth,+perfmon,+ras,+rcpc,+rdm,+sha2,+spe,+ssbs,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8.5a,+v8.6a,+v8a"
 "tune-cpu"="cortex-a710" }
   



   ^

Input file: 
Check file: 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGen/aarch64-targetattr.c

-dump-input=help explains the following input dump.

Input was:
<<
 1: ; ModuleID = 
'/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGen/aarch64-targetattr.c'
 
 2: source_filename = 
"/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGen/aarch64-targetattr.c"
 
 3: target datalayout = 
"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32" 
 4: target triple = "aarch64" 
 5:  
[0

[clang] [llvm] [Clang][ARM][AArch64] Alway emit protection attributes for functions. (PR #82819)

2024-07-10 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `premerge-monolithic-linux` 
running on `premerge-linux-1` while building `clang,llvm` at step 7 
"test-build-unified-tree-check-all".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/153/builds/2482

Here is the relevant piece of the build log for the reference:
```
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: CodeGen/aarch64-targetattr.c' FAILED 

Exit Code: 1

Command Output (stderr):
--
RUN: at line 2: /build/buildbot/premerge-monolithic-linux/build/bin/clang -cc1 
-internal-isystem 
/build/buildbot/premerge-monolithic-linux/build/lib/clang/19/include 
-nostdsysteminc -triple aarch64 -emit-llvm 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CodeGen/aarch64-targetattr.c
 -o - | /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CodeGen/aarch64-targetattr.c
+ /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CodeGen/aarch64-targetattr.c
+ /build/buildbot/premerge-monolithic-linux/build/bin/clang -cc1 
-internal-isystem 
/build/buildbot/premerge-monolithic-linux/build/lib/clang/19/include 
-nostdsysteminc -triple aarch64 -emit-llvm 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CodeGen/aarch64-targetattr.c
 -o -
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CodeGen/aarch64-targetattr.c:210:11:
 error: CHECK: expected string not found in input
// CHECK: attributes #[[ATTR15]] = { noinline nounwind optnone 
"branch-protection-pauth-lr"="false" "branch-target-enforcement"="true" 
"guarded-control-stack"="true" "no-trapping-math"="true" 
"sign-return-address"="non-leaf" "sign-return-address-key"="a_key" 
"stack-protector-buffer-size"="8" "target-cpu"="neoverse-n1" 
"target-features"="+aes,+bf16,+complxnum,+crc,+dotprod,+fp-armv8,+fullfp16,+i8mm,+jsconv,+lse,+neon,+pauth,+perfmon,+ras,+rcpc,+rdm,+sha2,+spe,+ssbs,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8.5a,+v8.6a,+v8a"
 "tune-cpu"="cortex-a710" }
  ^
:176:367: note: scanning from here
attributes #14 = { noinline nounwind optnone "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-cpu"="neoverse-n1" 
"target-features"="+aes,+bf16,+complxnum,+crc,+dotprod,+fp-armv8,+fullfp16,+i8mm,+jsconv,+lse,+neon,+pauth,+perfmon,+ras,+rcpc,+rdm,+sha2,+spe,+ssbs,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8.5a,+v8.6a,+v8a"
 "tune-cpu"="cortex-a710" }




  ^
:176:367: note: with "ATTR15" equal to "15"
attributes #14 = { noinline nounwind optnone "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-cpu"="neoverse-n1" 
"target-features"="+aes,+bf16,+complxnum,+crc,+dotprod,+fp-armv8,+fullfp16,+i8mm,+jsconv,+lse,+neon,+pauth,+perfmon,+ras,+rcpc,+rdm,+sha2,+spe,+ssbs,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8.5a,+v8.6a,+v8a"
 "tune-cpu"="cortex-a710" }




  ^

Input file: 
Check file: 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CodeGen/aarch64-targetattr.c

-dump-input=help explains the following input dump.

Input was:
<<
 .
 .
 .
   171: attributes #9 = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+fullfp16,+sve" "tune-cpu"="cortex-a710" } 
   172: attributes #10 = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-cpu"="neoverse-v1" 
"target-features"="+aes,+bf16,+ccdp,+complxnum,+crc,+dotprod,+fp-armv8,+fp16fml,+fullfp16,+i8mm,+jsconv,+lse,+neon,+pauth,+perfmon,+rand,+ras,+rcpc,+rdm,+sha2,+sha3,+sm4,+spe,+ssbs,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8a"
 } 
   173: attributes #11 = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-cpu"="neoverse-v1" 
"target-features"="+aes,+bf16,+ccdp,+complxnum,+crc,+dotprod,+fp-armv8,+fp16fml,+fullfp16,+i8mm,+jsconv,+lse,+neon,+pauth,+perfmon,+rand,+ras,+rcpc,+rdm,+sha2,+sha3,+sm4,+spe,+ssbs,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8a,-sve"
 } 
   174: attr

[clang] [llvm] [Clang][ARM][AArch64] Alway emit protection attributes for functions. (PR #82819)

2024-07-10 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `llvm-x86_64-debian-dylib` 
running on `gribozavr4` while building `clang,llvm` at step 6 
"test-build-unified-tree-check-clang".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/60/builds/2096

Here is the relevant piece of the build log for the reference:
```
Step 6 (test-build-unified-tree-check-clang) failure: test (failure)
 TEST 'Clang :: CodeGen/aarch64-targetattr.c' FAILED 

Exit Code: 1

Command Output (stderr):
--
RUN: at line 2: /b/1/llvm-x86_64-debian-dylib/build/bin/clang -cc1 
-internal-isystem /b/1/llvm-x86_64-debian-dylib/build/lib/clang/19/include 
-nostdsysteminc -triple aarch64 -emit-llvm 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/CodeGen/aarch64-targetattr.c
 -o - | /b/1/llvm-x86_64-debian-dylib/build/bin/FileCheck 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/CodeGen/aarch64-targetattr.c
+ /b/1/llvm-x86_64-debian-dylib/build/bin/clang -cc1 -internal-isystem 
/b/1/llvm-x86_64-debian-dylib/build/lib/clang/19/include -nostdsysteminc 
-triple aarch64 -emit-llvm 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/CodeGen/aarch64-targetattr.c
 -o -
+ /b/1/llvm-x86_64-debian-dylib/build/bin/FileCheck 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/CodeGen/aarch64-targetattr.c
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/CodeGen/aarch64-targetattr.c:210:11:
 error: CHECK: expected string not found in input
// CHECK: attributes #[[ATTR15]] = { noinline nounwind optnone 
"branch-protection-pauth-lr"="false" "branch-target-enforcement"="true" 
"guarded-control-stack"="true" "no-trapping-math"="true" 
"sign-return-address"="non-leaf" "sign-return-address-key"="a_key" 
"stack-protector-buffer-size"="8" "target-cpu"="neoverse-n1" 
"target-features"="+aes,+bf16,+complxnum,+crc,+dotprod,+fp-armv8,+fullfp16,+i8mm,+jsconv,+lse,+neon,+pauth,+perfmon,+ras,+rcpc,+rdm,+sha2,+spe,+ssbs,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8.5a,+v8.6a,+v8a"
 "tune-cpu"="cortex-a710" }
  ^
:176:367: note: scanning from here
attributes #14 = { noinline nounwind optnone "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-cpu"="neoverse-n1" 
"target-features"="+aes,+bf16,+complxnum,+crc,+dotprod,+fp-armv8,+fullfp16,+i8mm,+jsconv,+lse,+neon,+pauth,+perfmon,+ras,+rcpc,+rdm,+sha2,+spe,+ssbs,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8.5a,+v8.6a,+v8a"
 "tune-cpu"="cortex-a710" }




  ^
:176:367: note: with "ATTR15" equal to "15"
attributes #14 = { noinline nounwind optnone "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-cpu"="neoverse-n1" 
"target-features"="+aes,+bf16,+complxnum,+crc,+dotprod,+fp-armv8,+fullfp16,+i8mm,+jsconv,+lse,+neon,+pauth,+perfmon,+ras,+rcpc,+rdm,+sha2,+spe,+ssbs,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8.5a,+v8.6a,+v8a"
 "tune-cpu"="cortex-a710" }




  ^

Input file: 
Check file: 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/CodeGen/aarch64-targetattr.c

-dump-input=help explains the following input dump.

Input was:
<<
 .
 .
 .
   171: attributes #9 = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+fullfp16,+sve" "tune-cpu"="cortex-a710" } 
   172: attributes #10 = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-cpu"="neoverse-v1" 
"target-features"="+aes,+bf16,+ccdp,+complxnum,+crc,+dotprod,+fp-armv8,+fp16fml,+fullfp16,+i8mm,+jsconv,+lse,+neon,+pauth,+perfmon,+rand,+ras,+rcpc,+rdm,+sha2,+sha3,+sm4,+spe,+ssbs,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8a"
 } 
   173: attributes #11 = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-cpu"="neoverse-v1" 
"target-features"="+aes,+bf16,+ccdp,+complxnum,+crc,+dotprod,+fp-armv8,+fp16fml,+fullfp16,+i8mm,+jsconv,+lse,+neon,+pauth,+perfmon,+rand,+ras,+rcpc,+rdm,+sha2,+sha3,+sm4,+spe,+ssbs,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8a,-sve"
 } 
   174: attributes #12 = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+fullfp16,+sve" } 

[clang] [llvm] Revert "[Clang][ARM][AArch64] Alway emit protection attributes for functions." (PR #98284)

2024-07-10 Thread Daniel Kiss via cfe-commits

https://github.com/DanielKristofKiss created 
https://github.com/llvm/llvm-project/pull/98284

Reverts llvm/llvm-project#82819

>From 74e9e20f0338824eecea0f27d9c1336676a60d3d Mon Sep 17 00:00:00 2001
From: Daniel Kiss 
Date: Wed, 10 Jul 2024 10:21:36 +0200
Subject: [PATCH] =?UTF-8?q?Revert=20"[Clang][ARM][AArch64]=20Alway=20emit?=
 =?UTF-8?q?=20protection=20attributes=20for=20functions.=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit e15d67cfc2e5775cc79281aa860f3ad3be628f39.
---
 clang/include/clang/Basic/TargetInfo.h| 44 ++-
 clang/lib/CodeGen/Targets/AArch64.cpp | 43 --
 clang/lib/CodeGen/Targets/ARM.cpp |  8 ++--
 .../CodeGen/aarch64-branch-protection-attr.c  | 26 +--
 .../CodeGen/aarch64-sign-return-address.c | 12 ++---
 .../CodeGen/arm-branch-protection-attr-1.c| 12 ++---
 .../CodeGen/arm-branch-protection-attr-2.c| 13 ++
 .../test/Frontend/arm-branch-protection-lto.c | 24 --
 .../SelectionDAG/SelectionDAGBuilder.cpp  | 12 -
 llvm/lib/IR/Verifier.cpp  | 20 +
 llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp |  6 +--
 .../AArch64/AArch64MachineFunctionInfo.cpp| 37 ++--
 .../lib/Target/ARM/ARMMachineFunctionInfo.cpp | 22 +-
 llvm/lib/Transforms/IPO/LowerTypeTests.cpp|  6 +--
 ...ranch-target-enforcement-indirect-calls.ll | 18 
 .../CodeGen/AArch64/bti-branch-relaxation.ll  |  2 +-
 llvm/test/CodeGen/AArch64/kcfi-bti.ll |  7 ++-
 ...machine-outliner-2fixup-blr-terminator.mir |  2 +-
 .../CodeGen/AArch64/machine-outliner-bti.mir  |  2 +-
 .../AArch64/machine-outliner-outline-bti.ll   |  4 +-
 .../AArch64/note-gnu-property-pac-bti-0.ll|  2 +-
 .../AArch64/note-gnu-property-pac-bti-4.ll|  4 +-
 .../AArch64/pacbti-llvm-generated-funcs-1.ll  |  4 +-
 .../AArch64/pacbti-llvm-generated-funcs-2.ll  | 10 +++--
 .../CodeGen/AArch64/pacbti-module-attrs.ll| 12 ++---
 .../AArch64/patchable-function-entry-bti.ll   | 10 ++---
 .../CodeGen/AArch64/setjmp-bti-outliner.ll| 15 ---
 llvm/test/CodeGen/AArch64/setjmp-bti.ll   |  6 ++-
 .../AArch64/sign-return-address-pauth-lr.ll   | 36 ---
 .../CodeGen/AArch64/sign-return-address.ll|  8 ++--
 llvm/test/CodeGen/AArch64/wineh-bti.ll|  7 ++-
 llvm/test/CodeGen/AArch64/wineh-pac.ll|  7 ++-
 llvm/test/CodeGen/ARM/setjmp-bti-basic.ll |  5 ++-
 llvm/test/CodeGen/ARM/setjmp-bti-outliner.ll  |  7 ++-
 llvm/test/CodeGen/Thumb2/bti-entry-blocks.ll  |  7 ++-
 .../CodeGen/Thumb2/bti-indirect-branches.ll   |  9 ++--
 llvm/test/CodeGen/Thumb2/bti-outliner-1.ll|  9 ++--
 llvm/test/CodeGen/Thumb2/bti-outliner-2.ll| 12 +++--
 .../CodeGen/Thumb2/bti-outliner-cost-2.ll |  6 ++-
 .../test/CodeGen/Thumb2/bti-pac-replace-1.mir |  8 +++-
 llvm/test/CodeGen/Thumb2/bti-pac-replace-2.ll |  7 ++-
 llvm/test/CodeGen/Thumb2/jump-table-bti.ll| 10 ++---
 llvm/test/CodeGen/Thumb2/pacbti-m-basic.ll|  6 +--
 .../Thumb2/pacbti-m-indirect-tail-call.ll |  2 +-
 .../CodeGen/Thumb2/pacbti-m-outliner-1.ll |  2 +-
 .../CodeGen/Thumb2/pacbti-m-outliner-3.ll |  2 +-
 .../CodeGen/Thumb2/pacbti-m-outliner-4.ll |  6 +--
 .../CodeGen/Thumb2/pacbti-m-outliner-5.ll |  4 +-
 .../test/CodeGen/Thumb2/pacbti-m-overalign.ll |  2 +-
 .../test/CodeGen/Thumb2/pacbti-m-stack-arg.ll |  4 +-
 .../Thumb2/pacbti-m-unsupported-arch.ll   |  8 +++-
 .../test/CodeGen/Thumb2/pacbti-m-varargs-1.ll |  4 +-
 .../test/CodeGen/Thumb2/pacbti-m-varargs-2.ll |  4 +-
 llvm/test/CodeGen/Thumb2/pacbti-m-vla.ll  |  2 +-
 .../AArch64/link-branch-target-enforcement.ll |  2 +-
 .../Inline/inline-sign-return-address.ll  | 13 +++---
 .../LowerTypeTests/function-arm-thumb.ll  |  2 +-
 .../LowerTypeTests/function-thumb-bti.ll  |  4 +-
 .../Transforms/LowerTypeTests/function.ll |  4 +-
 llvm/test/Verifier/branch-prot-attrs.ll   | 16 +--
 60 files changed, 316 insertions(+), 292 deletions(-)
 delete mode 100644 clang/test/Frontend/arm-branch-protection-lto.c

diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 1f208b40f92cb..9b0ae2102e098 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -32,9 +32,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Frontend/OpenMP/OMPGridValues.h"
-#include "llvm/IR/Attributes.h"
 #include "llvm/IR/DerivedTypes.h"
-#include "llvm/IR/Function.h"
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/VersionTuple.h"
@@ -1402,15 +1400,15 @@ class TargetInfo : public TransferrableTargetInfo,
 return true;
   }
 
-  class BranchProtectionInfo {
-  public:
+  struct BranchProtectionInfo {
 LangOptions::SignReturnAddressScopeKind SignReturnAddr;
 LangOptions::SignReturnAddressKeyKind Si

[clang] 4b2daec - Revert "[Clang][ARM][AArch64] Alway emit protection attributes for functions." (#98284)

2024-07-10 Thread via cfe-commits

Author: Daniel Kiss
Date: 2024-07-10T10:22:38+02:00
New Revision: 4b2daeccc765915d50144d03e6354c362436c3b8

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

LOG: Revert "[Clang][ARM][AArch64] Alway emit protection attributes for 
functions." (#98284)

Reverts llvm/llvm-project#82819

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/CodeGen/Targets/AArch64.cpp
clang/lib/CodeGen/Targets/ARM.cpp
clang/test/CodeGen/aarch64-branch-protection-attr.c
clang/test/CodeGen/aarch64-sign-return-address.c
clang/test/CodeGen/arm-branch-protection-attr-1.c
clang/test/CodeGen/arm-branch-protection-attr-2.c
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp
llvm/lib/Target/ARM/ARMMachineFunctionInfo.cpp
llvm/lib/Transforms/IPO/LowerTypeTests.cpp
llvm/test/CodeGen/AArch64/branch-target-enforcement-indirect-calls.ll
llvm/test/CodeGen/AArch64/bti-branch-relaxation.ll
llvm/test/CodeGen/AArch64/kcfi-bti.ll
llvm/test/CodeGen/AArch64/machine-outliner-2fixup-blr-terminator.mir
llvm/test/CodeGen/AArch64/machine-outliner-bti.mir
llvm/test/CodeGen/AArch64/machine-outliner-outline-bti.ll
llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-0.ll
llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-4.ll
llvm/test/CodeGen/AArch64/pacbti-llvm-generated-funcs-1.ll
llvm/test/CodeGen/AArch64/pacbti-llvm-generated-funcs-2.ll
llvm/test/CodeGen/AArch64/pacbti-module-attrs.ll
llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
llvm/test/CodeGen/AArch64/setjmp-bti-outliner.ll
llvm/test/CodeGen/AArch64/setjmp-bti.ll
llvm/test/CodeGen/AArch64/sign-return-address-pauth-lr.ll
llvm/test/CodeGen/AArch64/sign-return-address.ll
llvm/test/CodeGen/AArch64/wineh-bti.ll
llvm/test/CodeGen/AArch64/wineh-pac.ll
llvm/test/CodeGen/ARM/setjmp-bti-basic.ll
llvm/test/CodeGen/ARM/setjmp-bti-outliner.ll
llvm/test/CodeGen/Thumb2/bti-entry-blocks.ll
llvm/test/CodeGen/Thumb2/bti-indirect-branches.ll
llvm/test/CodeGen/Thumb2/bti-outliner-1.ll
llvm/test/CodeGen/Thumb2/bti-outliner-2.ll
llvm/test/CodeGen/Thumb2/bti-outliner-cost-2.ll
llvm/test/CodeGen/Thumb2/bti-pac-replace-1.mir
llvm/test/CodeGen/Thumb2/bti-pac-replace-2.ll
llvm/test/CodeGen/Thumb2/jump-table-bti.ll
llvm/test/CodeGen/Thumb2/pacbti-m-basic.ll
llvm/test/CodeGen/Thumb2/pacbti-m-indirect-tail-call.ll
llvm/test/CodeGen/Thumb2/pacbti-m-outliner-1.ll
llvm/test/CodeGen/Thumb2/pacbti-m-outliner-3.ll
llvm/test/CodeGen/Thumb2/pacbti-m-outliner-4.ll
llvm/test/CodeGen/Thumb2/pacbti-m-outliner-5.ll
llvm/test/CodeGen/Thumb2/pacbti-m-overalign.ll
llvm/test/CodeGen/Thumb2/pacbti-m-stack-arg.ll
llvm/test/CodeGen/Thumb2/pacbti-m-unsupported-arch.ll
llvm/test/CodeGen/Thumb2/pacbti-m-varargs-1.ll
llvm/test/CodeGen/Thumb2/pacbti-m-varargs-2.ll
llvm/test/CodeGen/Thumb2/pacbti-m-vla.ll
llvm/test/LTO/AArch64/link-branch-target-enforcement.ll
llvm/test/Transforms/Inline/inline-sign-return-address.ll
llvm/test/Transforms/LowerTypeTests/function-arm-thumb.ll
llvm/test/Transforms/LowerTypeTests/function-thumb-bti.ll
llvm/test/Transforms/LowerTypeTests/function.ll
llvm/test/Verifier/branch-prot-attrs.ll

Removed: 
clang/test/Frontend/arm-branch-protection-lto.c



diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 1f208b40f92cb..9b0ae2102e098 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -32,9 +32,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Frontend/OpenMP/OMPGridValues.h"
-#include "llvm/IR/Attributes.h"
 #include "llvm/IR/DerivedTypes.h"
-#include "llvm/IR/Function.h"
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/VersionTuple.h"
@@ -1402,15 +1400,15 @@ class TargetInfo : public TransferrableTargetInfo,
 return true;
   }
 
-  class BranchProtectionInfo {
-  public:
+  struct BranchProtectionInfo {
 LangOptions::SignReturnAddressScopeKind SignReturnAddr;
 LangOptions::SignReturnAddressKeyKind SignKey;
 bool BranchTargetEnforcement;
 bool BranchProtectionPAuthLR;
 bool GuardedControlStack;
 
-  protected:
+BranchProtectionInfo() = default;
+
 const char *getSignReturnAddrStr() const {
   switch (SignReturnAddr) {
   case LangOptions::SignReturnAddressScopeKind::None:
@@ -1432,42 +1430,6 @@ class TargetInfo : public TransferrableTargetInfo,
   }
   llvm_unreachable("Unexpected SignReturnAddre

[clang] [llvm] Revert "[Clang][ARM][AArch64] Alway emit protection attributes for functions." (PR #98284)

2024-07-10 Thread Daniel Kiss via cfe-commits

https://github.com/DanielKristofKiss closed 
https://github.com/llvm/llvm-project/pull/98284
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Revert "[Clang][ARM][AArch64] Alway emit protection attributes for functions." (PR #98284)

2024-07-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-transforms

Author: Daniel Kiss (DanielKristofKiss)


Changes

Reverts llvm/llvm-project#82819

---

Patch is 84.10 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/98284.diff


60 Files Affected:

- (modified) clang/include/clang/Basic/TargetInfo.h (+3-41) 
- (modified) clang/lib/CodeGen/Targets/AArch64.cpp (+30-13) 
- (modified) clang/lib/CodeGen/Targets/ARM.cpp (+3-5) 
- (modified) clang/test/CodeGen/aarch64-branch-protection-attr.c (+13-13) 
- (modified) clang/test/CodeGen/aarch64-sign-return-address.c (+3-9) 
- (modified) clang/test/CodeGen/arm-branch-protection-attr-1.c (+6-6) 
- (modified) clang/test/CodeGen/arm-branch-protection-attr-2.c (+4-9) 
- (removed) clang/test/Frontend/arm-branch-protection-lto.c (-24) 
- (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (+11-1) 
- (modified) llvm/lib/IR/Verifier.cpp (+1-19) 
- (modified) llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp (+3-3) 
- (modified) llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp (+33-4) 
- (modified) llvm/lib/Target/ARM/ARMMachineFunctionInfo.cpp (+21-1) 
- (modified) llvm/lib/Transforms/IPO/LowerTypeTests.cpp (+2-4) 
- (modified) 
llvm/test/CodeGen/AArch64/branch-target-enforcement-indirect-calls.ll (+9-9) 
- (modified) llvm/test/CodeGen/AArch64/bti-branch-relaxation.ll (+1-1) 
- (modified) llvm/test/CodeGen/AArch64/kcfi-bti.ll (+3-4) 
- (modified) 
llvm/test/CodeGen/AArch64/machine-outliner-2fixup-blr-terminator.mir (+1-1) 
- (modified) llvm/test/CodeGen/AArch64/machine-outliner-bti.mir (+1-1) 
- (modified) llvm/test/CodeGen/AArch64/machine-outliner-outline-bti.ll (+2-2) 
- (modified) llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-0.ll (+1-1) 
- (modified) llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-4.ll (+2-2) 
- (modified) llvm/test/CodeGen/AArch64/pacbti-llvm-generated-funcs-1.ll (+2-2) 
- (modified) llvm/test/CodeGen/AArch64/pacbti-llvm-generated-funcs-2.ll (+7-3) 
- (modified) llvm/test/CodeGen/AArch64/pacbti-module-attrs.ll (+6-6) 
- (modified) llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll (+5-5) 
- (modified) llvm/test/CodeGen/AArch64/setjmp-bti-outliner.ll (+9-6) 
- (modified) llvm/test/CodeGen/AArch64/setjmp-bti.ll (+4-2) 
- (modified) llvm/test/CodeGen/AArch64/sign-return-address-pauth-lr.ll (+19-17) 
- (modified) llvm/test/CodeGen/AArch64/sign-return-address.ll (+4-4) 
- (modified) llvm/test/CodeGen/AArch64/wineh-bti.ll (+6-1) 
- (modified) llvm/test/CodeGen/AArch64/wineh-pac.ll (+5-2) 
- (modified) llvm/test/CodeGen/ARM/setjmp-bti-basic.ll (+4-1) 
- (modified) llvm/test/CodeGen/ARM/setjmp-bti-outliner.ll (+5-2) 
- (modified) llvm/test/CodeGen/Thumb2/bti-entry-blocks.ll (+5-2) 
- (modified) llvm/test/CodeGen/Thumb2/bti-indirect-branches.ll (+6-3) 
- (modified) llvm/test/CodeGen/Thumb2/bti-outliner-1.ll (+5-4) 
- (modified) llvm/test/CodeGen/Thumb2/bti-outliner-2.ll (+8-4) 
- (modified) llvm/test/CodeGen/Thumb2/bti-outliner-cost-2.ll (+5-1) 
- (modified) llvm/test/CodeGen/Thumb2/bti-pac-replace-1.mir (+7-1) 
- (modified) llvm/test/CodeGen/Thumb2/bti-pac-replace-2.ll (+6-1) 
- (modified) llvm/test/CodeGen/Thumb2/jump-table-bti.ll (+5-5) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-basic.ll (+3-3) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-indirect-tail-call.ll (+1-1) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-outliner-1.ll (+1-1) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-outliner-3.ll (+1-1) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-outliner-4.ll (+3-3) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-outliner-5.ll (+2-2) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-overalign.ll (+1-1) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-stack-arg.ll (+2-2) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-unsupported-arch.ll (+7-1) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-varargs-1.ll (+2-2) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-varargs-2.ll (+2-2) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-vla.ll (+1-1) 
- (modified) llvm/test/LTO/AArch64/link-branch-target-enforcement.ll (+1-1) 
- (modified) llvm/test/Transforms/Inline/inline-sign-return-address.ll (+7-6) 
- (modified) llvm/test/Transforms/LowerTypeTests/function-arm-thumb.ll (+1-1) 
- (modified) llvm/test/Transforms/LowerTypeTests/function-thumb-bti.ll (+2-2) 
- (modified) llvm/test/Transforms/LowerTypeTests/function.ll (+2-2) 
- (modified) llvm/test/Verifier/branch-prot-attrs.ll (+1-15) 


``diff
diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 1f208b40f92cb..9b0ae2102e098 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -32,9 +32,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Frontend/OpenMP/OMPGridValues.h"
-#include "llvm/IR/Attributes.h"
 #include "llvm/IR/DerivedTypes.h"
-#include "llvm/IR/Function.h"
 #include "llvm/Support/DataTypes.h"
 #in

[clang] [llvm] Revert "[Clang][ARM][AArch64] Alway emit protection attributes for functions." (PR #98284)

2024-07-10 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-lto

@llvm/pr-subscribers-clang

Author: Daniel Kiss (DanielKristofKiss)


Changes

Reverts llvm/llvm-project#82819

---

Patch is 84.10 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/98284.diff


60 Files Affected:

- (modified) clang/include/clang/Basic/TargetInfo.h (+3-41) 
- (modified) clang/lib/CodeGen/Targets/AArch64.cpp (+30-13) 
- (modified) clang/lib/CodeGen/Targets/ARM.cpp (+3-5) 
- (modified) clang/test/CodeGen/aarch64-branch-protection-attr.c (+13-13) 
- (modified) clang/test/CodeGen/aarch64-sign-return-address.c (+3-9) 
- (modified) clang/test/CodeGen/arm-branch-protection-attr-1.c (+6-6) 
- (modified) clang/test/CodeGen/arm-branch-protection-attr-2.c (+4-9) 
- (removed) clang/test/Frontend/arm-branch-protection-lto.c (-24) 
- (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (+11-1) 
- (modified) llvm/lib/IR/Verifier.cpp (+1-19) 
- (modified) llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp (+3-3) 
- (modified) llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp (+33-4) 
- (modified) llvm/lib/Target/ARM/ARMMachineFunctionInfo.cpp (+21-1) 
- (modified) llvm/lib/Transforms/IPO/LowerTypeTests.cpp (+2-4) 
- (modified) 
llvm/test/CodeGen/AArch64/branch-target-enforcement-indirect-calls.ll (+9-9) 
- (modified) llvm/test/CodeGen/AArch64/bti-branch-relaxation.ll (+1-1) 
- (modified) llvm/test/CodeGen/AArch64/kcfi-bti.ll (+3-4) 
- (modified) 
llvm/test/CodeGen/AArch64/machine-outliner-2fixup-blr-terminator.mir (+1-1) 
- (modified) llvm/test/CodeGen/AArch64/machine-outliner-bti.mir (+1-1) 
- (modified) llvm/test/CodeGen/AArch64/machine-outliner-outline-bti.ll (+2-2) 
- (modified) llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-0.ll (+1-1) 
- (modified) llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-4.ll (+2-2) 
- (modified) llvm/test/CodeGen/AArch64/pacbti-llvm-generated-funcs-1.ll (+2-2) 
- (modified) llvm/test/CodeGen/AArch64/pacbti-llvm-generated-funcs-2.ll (+7-3) 
- (modified) llvm/test/CodeGen/AArch64/pacbti-module-attrs.ll (+6-6) 
- (modified) llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll (+5-5) 
- (modified) llvm/test/CodeGen/AArch64/setjmp-bti-outliner.ll (+9-6) 
- (modified) llvm/test/CodeGen/AArch64/setjmp-bti.ll (+4-2) 
- (modified) llvm/test/CodeGen/AArch64/sign-return-address-pauth-lr.ll (+19-17) 
- (modified) llvm/test/CodeGen/AArch64/sign-return-address.ll (+4-4) 
- (modified) llvm/test/CodeGen/AArch64/wineh-bti.ll (+6-1) 
- (modified) llvm/test/CodeGen/AArch64/wineh-pac.ll (+5-2) 
- (modified) llvm/test/CodeGen/ARM/setjmp-bti-basic.ll (+4-1) 
- (modified) llvm/test/CodeGen/ARM/setjmp-bti-outliner.ll (+5-2) 
- (modified) llvm/test/CodeGen/Thumb2/bti-entry-blocks.ll (+5-2) 
- (modified) llvm/test/CodeGen/Thumb2/bti-indirect-branches.ll (+6-3) 
- (modified) llvm/test/CodeGen/Thumb2/bti-outliner-1.ll (+5-4) 
- (modified) llvm/test/CodeGen/Thumb2/bti-outliner-2.ll (+8-4) 
- (modified) llvm/test/CodeGen/Thumb2/bti-outliner-cost-2.ll (+5-1) 
- (modified) llvm/test/CodeGen/Thumb2/bti-pac-replace-1.mir (+7-1) 
- (modified) llvm/test/CodeGen/Thumb2/bti-pac-replace-2.ll (+6-1) 
- (modified) llvm/test/CodeGen/Thumb2/jump-table-bti.ll (+5-5) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-basic.ll (+3-3) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-indirect-tail-call.ll (+1-1) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-outliner-1.ll (+1-1) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-outliner-3.ll (+1-1) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-outliner-4.ll (+3-3) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-outliner-5.ll (+2-2) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-overalign.ll (+1-1) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-stack-arg.ll (+2-2) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-unsupported-arch.ll (+7-1) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-varargs-1.ll (+2-2) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-varargs-2.ll (+2-2) 
- (modified) llvm/test/CodeGen/Thumb2/pacbti-m-vla.ll (+1-1) 
- (modified) llvm/test/LTO/AArch64/link-branch-target-enforcement.ll (+1-1) 
- (modified) llvm/test/Transforms/Inline/inline-sign-return-address.ll (+7-6) 
- (modified) llvm/test/Transforms/LowerTypeTests/function-arm-thumb.ll (+1-1) 
- (modified) llvm/test/Transforms/LowerTypeTests/function-thumb-bti.ll (+2-2) 
- (modified) llvm/test/Transforms/LowerTypeTests/function.ll (+2-2) 
- (modified) llvm/test/Verifier/branch-prot-attrs.ll (+1-15) 


``diff
diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 1f208b40f92cb..9b0ae2102e098 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -32,9 +32,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Frontend/OpenMP/OMPGridValues.h"
-#include "llvm/IR/Attributes.h"
 #include "llvm/IR/DerivedTypes.h"
-#include "llvm/IR/Function.h"
 #include "llvm/Support/Da

[clang] [llvm] [Clang][ARM][AArch64] Alway emit protection attributes for functions. (PR #82819)

2024-07-10 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-x86_64-debian-fast` 
running on `gribozavr4` while building `clang,llvm` at step 6 
"test-build-unified-tree-check-all".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/56/builds/1993

Here is the relevant piece of the build log for the reference:
```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: CodeGen/aarch64-targetattr.c' FAILED 

Exit Code: 1

Command Output (stderr):
--
RUN: at line 2: /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang -cc1 
-internal-isystem /b/1/clang-x86_64-debian-fast/llvm.obj/lib/clang/19/include 
-nostdsysteminc -triple aarch64 -emit-llvm 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/CodeGen/aarch64-targetattr.c 
-o - | /b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/CodeGen/aarch64-targetattr.c
+ /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang -cc1 -internal-isystem 
/b/1/clang-x86_64-debian-fast/llvm.obj/lib/clang/19/include -nostdsysteminc 
-triple aarch64 -emit-llvm 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/CodeGen/aarch64-targetattr.c 
-o -
+ /b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/CodeGen/aarch64-targetattr.c
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/CodeGen/aarch64-targetattr.c:210:11:
 error: CHECK: expected string not found in input
// CHECK: attributes #[[ATTR15]] = { noinline nounwind optnone 
"branch-protection-pauth-lr"="false" "branch-target-enforcement"="true" 
"guarded-control-stack"="true" "no-trapping-math"="true" 
"sign-return-address"="non-leaf" "sign-return-address-key"="a_key" 
"stack-protector-buffer-size"="8" "target-cpu"="neoverse-n1" 
"target-features"="+aes,+bf16,+complxnum,+crc,+dotprod,+fp-armv8,+fullfp16,+i8mm,+jsconv,+lse,+neon,+pauth,+perfmon,+ras,+rcpc,+rdm,+sha2,+spe,+ssbs,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8.5a,+v8.6a,+v8a"
 "tune-cpu"="cortex-a710" }
  ^
:176:367: note: scanning from here
attributes #14 = { noinline nounwind optnone "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-cpu"="neoverse-n1" 
"target-features"="+aes,+bf16,+complxnum,+crc,+dotprod,+fp-armv8,+fullfp16,+i8mm,+jsconv,+lse,+neon,+pauth,+perfmon,+ras,+rcpc,+rdm,+sha2,+spe,+ssbs,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8.5a,+v8.6a,+v8a"
 "tune-cpu"="cortex-a710" }




  ^
:176:367: note: with "ATTR15" equal to "15"
attributes #14 = { noinline nounwind optnone "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-cpu"="neoverse-n1" 
"target-features"="+aes,+bf16,+complxnum,+crc,+dotprod,+fp-armv8,+fullfp16,+i8mm,+jsconv,+lse,+neon,+pauth,+perfmon,+ras,+rcpc,+rdm,+sha2,+spe,+ssbs,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8.5a,+v8.6a,+v8a"
 "tune-cpu"="cortex-a710" }




  ^

Input file: 
Check file: 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/CodeGen/aarch64-targetattr.c

-dump-input=help explains the following input dump.

Input was:
<<
 .
 .
 .
   171: attributes #9 = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+fullfp16,+sve" "tune-cpu"="cortex-a710" } 
   172: attributes #10 = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-cpu"="neoverse-v1" 
"target-features"="+aes,+bf16,+ccdp,+complxnum,+crc,+dotprod,+fp-armv8,+fp16fml,+fullfp16,+i8mm,+jsconv,+lse,+neon,+pauth,+perfmon,+rand,+ras,+rcpc,+rdm,+sha2,+sha3,+sm4,+spe,+ssbs,+sve,+sve2,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8a"
 } 
   173: attributes #11 = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-cpu"="neoverse-v1" 
"target-features"="+aes,+bf16,+ccdp,+complxnum,+crc,+dotprod,+fp-armv8,+fp16fml,+fullfp16,+i8mm,+jsconv,+lse,+neon,+pauth,+perfmon,+rand,+ras,+rcpc,+rdm,+sha2,+sha3,+sm4,+spe,+ssbs,+v8.1a,+v8.2a,+v8.3a,+v8.4a,+v8a,-sve"
 } 
   174: attributes #12 = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+fp-armv8,+fullfp16,+sve" } 
 

[clang] 8d17824 - [clang][Driver] Fix Linux/sparc64 -m32 (#98124)

2024-07-10 Thread via cfe-commits

Author: Rainer Orth
Date: 2024-07-10T10:29:00+02:00
New Revision: 8d17824890f668cca654a6b821d642bd3192dc81

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

LOG: [clang][Driver] Fix Linux/sparc64 -m32 (#98124)

`clang` currently fails to find a GCC installation on Linux/sparc64 with
`-m32`. `strace` reveals that `clang` tries to access
`/usr/lib/gcc/sparcv9-linux-gnu` (which doesn't exist) instead of
`/usr/lib/gcc/sparc64-linux-gnu`.

It turns out that 20d497c26fc95c80a1bacb38820d92e5f52bec58 was overeager
in removing some of the necessary directories.

Fixed by reverting the Linux/sparc* part of the patch.

Tested on `sparc64-unknown-linux-gnu`.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index d2a26c8091c48..52c2ee90b1b28 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2564,9 +2564,11 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
"riscv64-unknown-elf"};
 
   static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"};
-  static const char *const SPARCv8Triples[] = {"sparcv8-linux-gnu"};
+  static const char *const SPARCv8Triples[] = {"sparc-linux-gnu",
+   "sparcv8-linux-gnu"};
   static const char *const SPARCv9LibDirs[] = {"/lib64", "/lib"};
-  static const char *const SPARCv9Triples[] = {"sparcv9-linux-gnu"};
+  static const char *const SPARCv9Triples[] = {"sparc64-linux-gnu",
+   "sparcv9-linux-gnu"};
 
   static const char *const SystemZLibDirs[] = {"/lib64", "/lib"};
   static const char *const SystemZTriples[] = {



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Driver] Fix Linux/sparc64 -m32 (PR #98124)

2024-07-10 Thread Rainer Orth via cfe-commits

https://github.com/rorth closed https://github.com/llvm/llvm-project/pull/98124
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libclc] libclc: increase fp16 support (PR #98149)

2024-07-10 Thread Fraser Cormack via cfe-commits

frasercrmck wrote:

> @frasercrmck Could you review it please?

Sure, will do, thanks for this. We've done something similar downstream so I 
can hopefully verify against what we've done.

https://github.com/llvm/llvm-project/pull/98149
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [safestack] Various Solaris fixes (PR #98001)

2024-07-10 Thread Rainer Orth via cfe-commits

rorth wrote:

> They look quite independent. Would be possible to split independent fixed 
> into a separate patches?

With the exception of the `-u` reordering, they are all Solaris-only, so I kept 
them together to avoid tons of micro-patches.  I certainly could split them if 
you prefer, something like
- `-u` reordering
- sparc enabling
- add `sanitizer_common` objects
- `pthread stacksize` quirk
- fix `TgKill`
- switch syscalls to `_REAL*`
- re-enable testing

Just let me know.

https://github.com/llvm/llvm-project/pull/98001
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][AArch64] Add missing SME/SVE2.1 feature macros (PR #98285)

2024-07-10 Thread via cfe-commits

https://github.com/SpencerAbson created 
https://github.com/llvm/llvm-project/pull/98285

The 2022 SME2.1and SVE2.1 feature macros are missing from Clang. Passing 
'-target-feature +sve2p1' and 'target-feature +sme2p1' should prompt Clang to 
define __ARM_FEATURE_SVE2p1 and __ARM_FEATURE_SME2p1 respectively, including 
their prerequisits..

This patch includes __ARM_FEATURE_SVE2p1 and __ARM_FEATURE_SME2p1, plus a clang 
preprocessor test for each. It also ensures that the Clang macro builder is 
used in a consistent fashion across Targets/AArch64.cpp.

>From a2af1d8ebc58b250f3c999a7e561cb8a2210c058 Mon Sep 17 00:00:00 2001
From: Spencer Abson 
Date: Tue, 9 Jul 2024 11:07:03 +
Subject: [PATCH] [Clang][AArch64] Add missing SME/SVE2.1 feature macros

---
 clang/lib/Basic/Targets/AArch64.cpp   | 30 +--
 clang/lib/Basic/Targets/AArch64.h |  2 ++
 .../Preprocessor/aarch64-target-features.c| 15 ++
 3 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 2692ddec26ff4..6349fcf3dadd7 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -449,6 +449,9 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   if (HasSVE2)
 Builder.defineMacro("__ARM_FEATURE_SVE2", "1");
 
+  if (HasSVE2p1)
+Builder.defineMacro("__ARM_FEATURE_SVE2p1", "1");
+
   if (HasSVE2 && HasSVE2AES)
 Builder.defineMacro("__ARM_FEATURE_SVE2_AES", "1");
 
@@ -467,8 +470,15 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   }
 
   if (HasSME2) {
-Builder.defineMacro("__ARM_FEATURE_SME");
-Builder.defineMacro("__ARM_FEATURE_SME2");
+Builder.defineMacro("__ARM_FEATURE_SME", "1");
+Builder.defineMacro("__ARM_FEATURE_SME2", "1");
+Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
+  }
+
+  if (HasSME2p1) {
+Builder.defineMacro("__ARM_FEATURE_SME", "1");
+Builder.defineMacro("__ARM_FEATURE_SME2", "1");
+Builder.defineMacro("__ARM_FEATURE_SME2p1", "1");
 Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
   }
 
@@ -739,8 +749,10 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) 
const {
   .Case("sve2-bitperm", FPU & SveMode && HasSVE2BitPerm)
   .Case("sve2-sha3", FPU & SveMode && HasSVE2SHA3)
   .Case("sve2-sm4", FPU & SveMode && HasSVE2SM4)
+  .Case("sve2p1", FPU & SveMode && HasSVE2p1)
   .Case("sme", HasSME)
   .Case("sme2", HasSME2)
+  .Case("sme2p1", HasSME2p1)
   .Case("sme-f64f64", HasSMEF64F64)
   .Case("sme-i16i64", HasSMEI16I64)
   .Case("sme-fa64", HasSMEFA64)
@@ -816,6 +828,13 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
   HasFullFP16 = true;
   HasSVE2 = true;
 }
+if (Feature == "+sve2p1") {
+  FPU |= NeonMode;
+  FPU |= SveMode;
+  HasFullFP16 = true;
+  HasSVE2 = true;
+  HasSVE2p1 = true;
+}
 if (Feature == "+sve2-aes") {
   FPU |= NeonMode;
   FPU |= SveMode;
@@ -867,6 +886,13 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
   HasBFloat16 = true;
   HasFullFP16 = true;
 }
+if (Feature == "+sme2p1") {
+  HasSME = true;
+  HasSME2 = true;
+  HasSME2p1 = true;
+  HasBFloat16 = true;
+  HasFullFP16 = true;
+}
 if (Feature == "+sme-f64f64") {
   HasSME = true;
   HasSMEF64F64 = true;
diff --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index 71510fe289510..7bdf5a2b4106e 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -49,6 +49,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
   bool HasMatMul = false;
   bool HasBFloat16 = false;
   bool HasSVE2 = false;
+  bool HasSVE2p1 = false;
   bool HasSVE2AES = false;
   bool HasSVE2SHA3 = false;
   bool HasSVE2SM4 = false;
@@ -70,6 +71,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
   bool HasSME2 = false;
   bool HasSMEF64F64 = false;
   bool HasSMEI16I64 = false;
+  bool HasSME2p1 = false;
   bool HasSB = false;
   bool HasPredRes = false;
   bool HasSSBS = false;
diff --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index 71cc36acf3f0e..87bd3e142d2c4 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -236,6 +236,15 @@
 // RUN: %clang -target aarch64-none-linux-gnu -march=armv9-a+sve2-bitperm -x c 
-E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE2BITPERM %s
 // CHECK-SVE2BITPERM: __ARM_FEATURE_SVE2_BITPERM 1
 
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv9-a+sve2p1 -x c -E 
-dM %s -o - | FileCheck --check-prefix=CHECK-SVE2p1 %s
+// CHECK-SVE2p1: __ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1
+// CHECK-SVE2p1: __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 1
+//

[clang] [Clang][AArch64] Add missing SME/SVE2.1 feature macros (PR #98285)

2024-07-10 Thread via cfe-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from 
other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

https://github.com/llvm/llvm-project/pull/98285
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Clang][ARM][AArch64] Alway emit protection attributes for functions. (PR #82819)

2024-07-10 Thread Nico Weber via cfe-commits

nico wrote:

In addition to the test failures, this apparently also breaks building lldb on 
windows and Mac:
http://45.33.8.238/macm1/88231/step_3.txt
http://45.33.8.238/win/91235/step_3.txt

Please check if that's something real or if my bots are being silly before 
relanding.

https://github.com/llvm/llvm-project/pull/82819
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Run PreStmt/PostStmt checker for GCCAsmStmt (PR #95409)

2024-07-10 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 22ff7c5dc96828aba967fb3bcb3f929ea4509783 
28b646792249bad0a01d9724cc538df5d41736da -- 
clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp 
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp 
b/clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp
index e0006597f2..2d18922e4b 100644
--- a/clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp
+++ b/clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp
@@ -6,7 +6,6 @@
 //
 
//===--===//
 
-
 #include "CheckerRegistration.h"
 #include "clang/AST/Stmt.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"

``




https://github.com/llvm/llvm-project/pull/95409
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Run PreStmt/PostStmt checker for GCCAsmStmt (PR #95409)

2024-07-10 Thread via cfe-commits

T-Gruber wrote:

> Thanks for the ping. Looks really nice! FYI I just came across a case last 
> week w.r.t asm gotos. You can have a read 
> [here](https://sonarsource.atlassian.net/browse/CPP-5459) if you are 
> interested in the subject.

Thank you! Looks interesting. Does this mean that the linked problem would also 
benefit from this PR?

https://github.com/llvm/llvm-project/pull/95409
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-07-10 Thread Yingwei Zheng via cfe-commits

https://github.com/dtcxzyw updated 
https://github.com/llvm/llvm-project/pull/94352

>From ff839bef048a65760f4cd0e9abafe11cfebd9362 Mon Sep 17 00:00:00 2001
From: Yingwei Zheng 
Date: Tue, 4 Jun 2024 21:08:27 +0800
Subject: [PATCH 01/16] [RISCV] Add support for getHostCPUFeatures using
 hwprobe

Co-authored-by: Yangyu Chen 
---
 llvm/lib/TargetParser/Host.cpp | 68 ++
 1 file changed, 68 insertions(+)

diff --git a/llvm/lib/TargetParser/Host.cpp b/llvm/lib/TargetParser/Host.cpp
index 68155acd9e5bc..b4a13b38eb380 100644
--- a/llvm/lib/TargetParser/Host.cpp
+++ b/llvm/lib/TargetParser/Host.cpp
@@ -1998,6 +1998,74 @@ bool sys::getHostCPUFeatures(StringMap &Features) {
 
   return true;
 }
+#elif defined(__linux__) && defined(__riscv)
+#ifdef __has_include
+#if __has_include()
+#include 
+#endif
+#endif
+bool sys::getHostCPUFeatures(StringMap &Features) {
+#ifdef RISCV_HWPROBE_KEY_MVENDORID
+  riscv_hwprobe Query[2]{
+  {RISCV_HWPROBE_KEY_IMA_EXT_0, 0},
+  {RISCV_HWPROBE_KEY_CPUPERF_0, 0},
+  };
+  int Ret = syscall(/*__NR_riscv_hwprobe=*/258, /*pairs=*/&Query,
+/*pair_count=*/1, /*cpu_count=*/0, /*cpus=*/0, 
/*flags=*/0);
+  if (Ret != 0)
+return false;
+
+  uint64_t ExtMask = Query[0].value;
+  Features["f"] = ExtMask & RISCV_HWPROBE_IMA_FD;
+  Features["d"] = ExtMask & RISCV_HWPROBE_IMA_FD;
+  Features["c"] = ExtMask & RISCV_HWPROBE_IMA_C;
+  Features["v"] = ExtMask & RISCV_HWPROBE_IMA_V;
+  Features["zba"] = ExtMask & RISCV_HWPROBE_IMA_ZBA;
+  Features["zbb"] = ExtMask & RISCV_HWPROBE_IMA_ZBB;
+  Features["zbs"] = ExtMask & RISCV_HWPROBE_IMA_ZBS;
+  Features["zicboz"] = ExtMask & RISCV_HWPROBE_IMA_ZICBOZ;
+  Features["zbc"] = ExtMask & RISCV_HWPROBE_IMA_ZBC;
+  Features["zbkb"] = ExtMask & RISCV_HWPROBE_IMA_ZBKB;
+  Features["zbkc"] = ExtMask & RISCV_HWPROBE_IMA_ZBKC;
+  Features["zbkx"] = ExtMask & RISCV_HWPROBE_IMA_ZBKX;
+  Features["zknd"] = ExtMask & RISCV_HWPROBE_IMA_ZKND;
+  Features["zkne"] = ExtMask & RISCV_HWPROBE_IMA_ZKNE;
+  Features["zknh"] = ExtMask & RISCV_HWPROBE_IMA_ZKNH;
+  Features["zksed"] = ExtMask & RISCV_HWPROBE_IMA_ZKSED;
+  Features["zksh"] = ExtMask & RISCV_HWPROBE_IMA_ZKSH;
+  Features["zkt"] = ExtMask & RISCV_HWPROBE_IMA_ZKT;
+  Features["zvbb"] = ExtMask & RISCV_HWPROBE_IMA_ZVBB;
+  Features["zvbc"] = ExtMask & RISCV_HWPROBE_IMA_ZVBC;
+  Features["zvkb"] = ExtMask & RISCV_HWPROBE_IMA_ZVKB;
+  Features["zvkg"] = ExtMask & RISCV_HWPROBE_IMA_ZVKG;
+  Features["zvkned"] = ExtMask & RISCV_HWPROBE_IMA_ZVKNED;
+  Features["zvknha"] = ExtMask & RISCV_HWPROBE_IMA_ZVKNHA;
+  Features["zvknhb"] = ExtMask & RISCV_HWPROBE_IMA_ZVKNHB;
+  Features["zvksed"] = ExtMask & RISCV_HWPROBE_IMA_ZVKSED;
+  Features["zvksh"] = ExtMask & RISCV_HWPROBE_IMA_ZVKSH;
+  Features["zvkt"] = ExtMask & RISCV_HWPROBE_IMA_ZVKT;
+  Features["zfh"] = ExtMask & RISCV_HWPROBE_IMA_ZFH;
+  Features["zfhmin"] = ExtMask & RISCV_HWPROBE_IMA_ZFHMIN;
+  Features["zihintntl"] = ExtMask & RISCV_HWPROBE_IMA_ZIHINTNTL;
+  Features["zvfh"] = ExtMask & RISCV_HWPROBE_IMA_ZVFH;
+  Features["zvfhmin"] = ExtMask & RISCV_HWPROBE_IMA_ZVFHMIN;
+  Features["zfa"] = ExtMask & RISCV_HWPROBE_IMA_ZFA;
+  Features["ztso"] = ExtMask & RISCV_HWPROBE_IMA_ZTSO;
+  Features["zacas"] = ExtMask & RISCV_HWPROBE_IMA_ZACAS;
+  Features["zicond"] = ExtMask & RISCV_HWPROBE_IMA_ZICOND;
+  Features["zihintpause"] = ExtMask & RISCV_HWPROBE_IMA_ZIHINTPAUSE;
+
+  uint64_t MisalignedMask = Query[1].value;
+  if (MisalignedMask == RISCV_HWPROBE_MISALIGNED_FAST) {
+Features["unaligned-scalar-mem"] = true;
+Features["unaligned-vector-mem"] = true;
+  }
+
+  return true;
+#else
+  return false;
+#endif
+}
 #else
 bool sys::getHostCPUFeatures(StringMap &Features) { return false; }
 #endif

>From a2fa6e3d64d3a1e2a8e3a7af91068bdb1fda28b1 Mon Sep 17 00:00:00 2001
From: Yingwei Zheng 
Date: Tue, 4 Jun 2024 22:10:55 +0800
Subject: [PATCH 02/16] [RISCV] Address review comments.

---
 llvm/lib/TargetParser/Host.cpp | 112 +++--
 1 file changed, 52 insertions(+), 60 deletions(-)

diff --git a/llvm/lib/TargetParser/Host.cpp b/llvm/lib/TargetParser/Host.cpp
index b4a13b38eb380..ec275c0a7fded 100644
--- a/llvm/lib/TargetParser/Host.cpp
+++ b/llvm/lib/TargetParser/Host.cpp
@@ -1999,72 +1999,64 @@ bool sys::getHostCPUFeatures(StringMap &Features) 
{
   return true;
 }
 #elif defined(__linux__) && defined(__riscv)
-#ifdef __has_include
-#if __has_include()
-#include 
-#endif
-#endif
+// struct riscv_hwprobe
+struct RISCVHwProbe {
+  int64_t Key;
+  uint64_t Value;
+};
 bool sys::getHostCPUFeatures(StringMap &Features) {
-#ifdef RISCV_HWPROBE_KEY_MVENDORID
-  riscv_hwprobe Query[2]{
-  {RISCV_HWPROBE_KEY_IMA_EXT_0, 0},
-  {RISCV_HWPROBE_KEY_CPUPERF_0, 0},
-  };
-  int Ret = syscall(/*__NR_riscv_hwprobe=*/258, /*pairs=*/&Query,
-/*pair_count=*/1, /*cpu_count=*/0, /*cpus=*/0, 
/*flags=*/0);
+  RISCVHwProbe Query[]{{/*RISCV_HWPROBE_KEY_IMA_EXT_0=*/4, 0}};
+  i

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-07-10 Thread Yingwei Zheng via cfe-commits

https://github.com/dtcxzyw updated 
https://github.com/llvm/llvm-project/pull/94352

>From ff839bef048a65760f4cd0e9abafe11cfebd9362 Mon Sep 17 00:00:00 2001
From: Yingwei Zheng 
Date: Tue, 4 Jun 2024 21:08:27 +0800
Subject: [PATCH 01/17] [RISCV] Add support for getHostCPUFeatures using
 hwprobe

Co-authored-by: Yangyu Chen 
---
 llvm/lib/TargetParser/Host.cpp | 68 ++
 1 file changed, 68 insertions(+)

diff --git a/llvm/lib/TargetParser/Host.cpp b/llvm/lib/TargetParser/Host.cpp
index 68155acd9e5bc..b4a13b38eb380 100644
--- a/llvm/lib/TargetParser/Host.cpp
+++ b/llvm/lib/TargetParser/Host.cpp
@@ -1998,6 +1998,74 @@ bool sys::getHostCPUFeatures(StringMap &Features) {
 
   return true;
 }
+#elif defined(__linux__) && defined(__riscv)
+#ifdef __has_include
+#if __has_include()
+#include 
+#endif
+#endif
+bool sys::getHostCPUFeatures(StringMap &Features) {
+#ifdef RISCV_HWPROBE_KEY_MVENDORID
+  riscv_hwprobe Query[2]{
+  {RISCV_HWPROBE_KEY_IMA_EXT_0, 0},
+  {RISCV_HWPROBE_KEY_CPUPERF_0, 0},
+  };
+  int Ret = syscall(/*__NR_riscv_hwprobe=*/258, /*pairs=*/&Query,
+/*pair_count=*/1, /*cpu_count=*/0, /*cpus=*/0, 
/*flags=*/0);
+  if (Ret != 0)
+return false;
+
+  uint64_t ExtMask = Query[0].value;
+  Features["f"] = ExtMask & RISCV_HWPROBE_IMA_FD;
+  Features["d"] = ExtMask & RISCV_HWPROBE_IMA_FD;
+  Features["c"] = ExtMask & RISCV_HWPROBE_IMA_C;
+  Features["v"] = ExtMask & RISCV_HWPROBE_IMA_V;
+  Features["zba"] = ExtMask & RISCV_HWPROBE_IMA_ZBA;
+  Features["zbb"] = ExtMask & RISCV_HWPROBE_IMA_ZBB;
+  Features["zbs"] = ExtMask & RISCV_HWPROBE_IMA_ZBS;
+  Features["zicboz"] = ExtMask & RISCV_HWPROBE_IMA_ZICBOZ;
+  Features["zbc"] = ExtMask & RISCV_HWPROBE_IMA_ZBC;
+  Features["zbkb"] = ExtMask & RISCV_HWPROBE_IMA_ZBKB;
+  Features["zbkc"] = ExtMask & RISCV_HWPROBE_IMA_ZBKC;
+  Features["zbkx"] = ExtMask & RISCV_HWPROBE_IMA_ZBKX;
+  Features["zknd"] = ExtMask & RISCV_HWPROBE_IMA_ZKND;
+  Features["zkne"] = ExtMask & RISCV_HWPROBE_IMA_ZKNE;
+  Features["zknh"] = ExtMask & RISCV_HWPROBE_IMA_ZKNH;
+  Features["zksed"] = ExtMask & RISCV_HWPROBE_IMA_ZKSED;
+  Features["zksh"] = ExtMask & RISCV_HWPROBE_IMA_ZKSH;
+  Features["zkt"] = ExtMask & RISCV_HWPROBE_IMA_ZKT;
+  Features["zvbb"] = ExtMask & RISCV_HWPROBE_IMA_ZVBB;
+  Features["zvbc"] = ExtMask & RISCV_HWPROBE_IMA_ZVBC;
+  Features["zvkb"] = ExtMask & RISCV_HWPROBE_IMA_ZVKB;
+  Features["zvkg"] = ExtMask & RISCV_HWPROBE_IMA_ZVKG;
+  Features["zvkned"] = ExtMask & RISCV_HWPROBE_IMA_ZVKNED;
+  Features["zvknha"] = ExtMask & RISCV_HWPROBE_IMA_ZVKNHA;
+  Features["zvknhb"] = ExtMask & RISCV_HWPROBE_IMA_ZVKNHB;
+  Features["zvksed"] = ExtMask & RISCV_HWPROBE_IMA_ZVKSED;
+  Features["zvksh"] = ExtMask & RISCV_HWPROBE_IMA_ZVKSH;
+  Features["zvkt"] = ExtMask & RISCV_HWPROBE_IMA_ZVKT;
+  Features["zfh"] = ExtMask & RISCV_HWPROBE_IMA_ZFH;
+  Features["zfhmin"] = ExtMask & RISCV_HWPROBE_IMA_ZFHMIN;
+  Features["zihintntl"] = ExtMask & RISCV_HWPROBE_IMA_ZIHINTNTL;
+  Features["zvfh"] = ExtMask & RISCV_HWPROBE_IMA_ZVFH;
+  Features["zvfhmin"] = ExtMask & RISCV_HWPROBE_IMA_ZVFHMIN;
+  Features["zfa"] = ExtMask & RISCV_HWPROBE_IMA_ZFA;
+  Features["ztso"] = ExtMask & RISCV_HWPROBE_IMA_ZTSO;
+  Features["zacas"] = ExtMask & RISCV_HWPROBE_IMA_ZACAS;
+  Features["zicond"] = ExtMask & RISCV_HWPROBE_IMA_ZICOND;
+  Features["zihintpause"] = ExtMask & RISCV_HWPROBE_IMA_ZIHINTPAUSE;
+
+  uint64_t MisalignedMask = Query[1].value;
+  if (MisalignedMask == RISCV_HWPROBE_MISALIGNED_FAST) {
+Features["unaligned-scalar-mem"] = true;
+Features["unaligned-vector-mem"] = true;
+  }
+
+  return true;
+#else
+  return false;
+#endif
+}
 #else
 bool sys::getHostCPUFeatures(StringMap &Features) { return false; }
 #endif

>From a2fa6e3d64d3a1e2a8e3a7af91068bdb1fda28b1 Mon Sep 17 00:00:00 2001
From: Yingwei Zheng 
Date: Tue, 4 Jun 2024 22:10:55 +0800
Subject: [PATCH 02/17] [RISCV] Address review comments.

---
 llvm/lib/TargetParser/Host.cpp | 112 +++--
 1 file changed, 52 insertions(+), 60 deletions(-)

diff --git a/llvm/lib/TargetParser/Host.cpp b/llvm/lib/TargetParser/Host.cpp
index b4a13b38eb380..ec275c0a7fded 100644
--- a/llvm/lib/TargetParser/Host.cpp
+++ b/llvm/lib/TargetParser/Host.cpp
@@ -1999,72 +1999,64 @@ bool sys::getHostCPUFeatures(StringMap &Features) 
{
   return true;
 }
 #elif defined(__linux__) && defined(__riscv)
-#ifdef __has_include
-#if __has_include()
-#include 
-#endif
-#endif
+// struct riscv_hwprobe
+struct RISCVHwProbe {
+  int64_t Key;
+  uint64_t Value;
+};
 bool sys::getHostCPUFeatures(StringMap &Features) {
-#ifdef RISCV_HWPROBE_KEY_MVENDORID
-  riscv_hwprobe Query[2]{
-  {RISCV_HWPROBE_KEY_IMA_EXT_0, 0},
-  {RISCV_HWPROBE_KEY_CPUPERF_0, 0},
-  };
-  int Ret = syscall(/*__NR_riscv_hwprobe=*/258, /*pairs=*/&Query,
-/*pair_count=*/1, /*cpu_count=*/0, /*cpus=*/0, 
/*flags=*/0);
+  RISCVHwProbe Query[]{{/*RISCV_HWPROBE_KEY_IMA_EXT_0=*/4, 0}};
+  i

[clang] [clang][ARM] Fix warning for using VFP from interrupts. (PR #91870)

2024-07-10 Thread David Spickett via cfe-commits


@@ -1329,6 +1329,11 @@ void SemaARM::handleInterruptAttr(Decl *D, const 
ParsedAttr &AL) {
 return;
   }
 
+  const TargetInfo &TI = getASTContext().getTargetInfo();
+  if (TI.hasFeature("vfp")) {
+Diag(D->getLocation(), diag::warn_arm_interrupt_vfp_clobber);
+  }

DavidSpickett wrote:

https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements

https://github.com/llvm/llvm-project/pull/91870
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][ARM] Fix warning for using VFP from interrupts. (PR #91870)

2024-07-10 Thread David Spickett via cfe-commits

DavidSpickett wrote:

Everything LGTM but I'd like someone who works on Arm's downstream compiler to 
approve. @ostannard perhaps? 

(thanks for your patience @chrisnc)

https://github.com/llvm/llvm-project/pull/91870
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][ARM] Fix warning for using VFP from interrupts. (PR #91870)

2024-07-10 Thread David Spickett via cfe-commits


@@ -492,6 +495,13 @@ Modified Compiler Flags
   now include dianostics about C++26 features that are not present in older
   versions.
 
+- Removed the "arm interrupt calling convention" warning that was included in
+  ``-Wextra`` without its own flag. This warning suggested adding
+  ``__attribute__((interrupt))`` to functions that are called from interrupt
+  handlers to prevent clobbering VFP registers. Following this suggestion leads
+  to unpredictable behavior by causing multiple exception returns from one
+  exception. Fixes #GH34876.
+

DavidSpickett wrote:

Note to other reviewers: This is in the modified flags section because -wextra 
itself is being modified. A part of it was removed but that part was never a 
separate flag so this doesn't need to go in the "removed compiler flags" 
section.

https://github.com/llvm/llvm-project/pull/91870
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Sema] Fix crash in Sema::FindInstantiatedDecl (PR #96509)

2024-07-10 Thread Alejandro Álvarez Ayllón via cfe-commits


@@ -6300,7 +6300,7 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, 
NamedDecl *D,
   getTrivialTemplateArgumentLoc(UnpackedArg, QualType(), Loc));
   }
   QualType T = CheckTemplateIdType(TemplateName(TD), Loc, Args);
-  if (T.isNull())
+  if (T.isNull() || T->containsErrors())

alejandro-alvarez-sonarsource wrote:

I have checked the other places where `CheckTemplateIdType` is used, and 
indeed, I can not (easily, at least) find any reason why we would have a crash 
in those places. For instance, in 
[`SemaTemplate.cpp`](https://github.com/llvm/llvm-project/blob/9ae24c9ac94017e15eb827e25c5693418e6cdb4b/clang/lib/Sema/SemaTemplate.cpp#L5072)
 there is a similar pattern (as @Sirraide was concerned),  but there a null 
`RecordType` is appropriately handled.

While looking at it, I realized that the null pointer dereference we had fixed 
downstream was fixed upstream [four months 
ago](https://github.com/llvm/llvm-project/commit/7415524b45392651969374c067041daa82dc89e7#diff-761c59b5215d832845bd988566c7d0abaa1cc6294cb8ea90f32e33d15bfccf28R6290)
 in #77890. The introduced assertions trigger, though, throwing me off (since 
the stack trace is almost identical).

I have gone back to the original commit and added a comment. I will also rework 
the PR title and description.

https://github.com/llvm/llvm-project/pull/96509
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Sema] Fix assertion error in Sema::FindInstantiatedDecl (PR #96509)

2024-07-10 Thread Alejandro Álvarez Ayllón via cfe-commits

https://github.com/alejandro-alvarez-sonarsource edited 
https://github.com/llvm/llvm-project/pull/96509
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Sema] Fix assertion error in Sema::FindInstantiatedDecl (PR #96509)

2024-07-10 Thread Alejandro Álvarez Ayllón via cfe-commits

https://github.com/alejandro-alvarez-sonarsource updated 
https://github.com/llvm/llvm-project/pull/96509

From 96b0c2c18c197a1ce03d31b01c14d1b18348e9ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
 
Date: Thu, 1 Jun 2023 16:30:54 +0200
Subject: [PATCH 1/5] [Sema] Fix crash in Sema::FindInstantiatedDecl

when looking for a template instantiation with a non-type
parameter of unknown type and with a default value.

This can happen when a template non-type parameter has a broken
expression that gets replaced by a `RecoveryExpr`.
---
 clang/lib/Sema/SemaTemplateInstantiateDecl.cpp   |  2 +-
 .../instantiate-template-broken-nontype-default.cpp  | 12 
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 
clang/test/SemaCXX/instantiate-template-broken-nontype-default.cpp

diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 0681520764d9a..999fec0ebb259 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -6300,7 +6300,7 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, 
NamedDecl *D,
   getTrivialTemplateArgumentLoc(UnpackedArg, QualType(), Loc));
   }
   QualType T = CheckTemplateIdType(TemplateName(TD), Loc, Args);
-  if (T.isNull())
+  if (T.isNull() || T->containsErrors())
 return nullptr;
   CXXRecordDecl *SubstRecord = T->getAsCXXRecordDecl();
 
diff --git a/clang/test/SemaCXX/instantiate-template-broken-nontype-default.cpp 
b/clang/test/SemaCXX/instantiate-template-broken-nontype-default.cpp
new file mode 100644
index 0..a644cc3d057cb
--- /dev/null
+++ b/clang/test/SemaCXX/instantiate-template-broken-nontype-default.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+
+constexpr Missing a = 0; // expected-error {{unknown type name 'Missing'}}
+
+template < typename T, Missing b = a> // expected-error {{unknown type name 
'Missing'}}
+class Klass { // expected-note {{candidate template ignored: could not match 
'Klass' against 'int'}}
+  Klass(T);   // expected-note {{candidate template ignored: substitution 
failure [with T = int, b = ()]}}
+};
+
+Klass foo{5}; // no-crash \
+ expected-error {{no viable constructor or deduction guide for 
deduction of template arguments of 'Klass'}}
+

From 9111797355ba860d0c6b62fde3a7b1e347a71dc6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
 
Date: Fri, 5 Jul 2024 15:12:47 +0200
Subject: [PATCH 2/5] Move the check to `CheckTemplateIdType()`

---
 clang/lib/Sema/SemaTemplate.cpp| 3 ++-
 clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index a032e3ec6f635..2ea18ec82b958 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -4700,7 +4700,8 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
 //   template struct A;
 CanonType = Context.getCanonicalTemplateSpecializationType(
 Name, CanonicalConverted);
-
+if (CanonType->containsErrors())
+  return QualType();
 // This might work out to be a current instantiation, in which
 // case the canonical type needs to be the InjectedClassNameType.
 //
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 999fec0ebb259..0681520764d9a 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -6300,7 +6300,7 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, 
NamedDecl *D,
   getTrivialTemplateArgumentLoc(UnpackedArg, QualType(), Loc));
   }
   QualType T = CheckTemplateIdType(TemplateName(TD), Loc, Args);
-  if (T.isNull() || T->containsErrors())
+  if (T.isNull())
 return nullptr;
   CXXRecordDecl *SubstRecord = T->getAsCXXRecordDecl();
 

From cf315c17ac5221e683af1260ef429c4b13fb5715 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alejandro=20=C3=81lvarez=20Ayll=C3=B3n?=
 
Date: Tue, 9 Jul 2024 11:21:44 +0200
Subject: [PATCH 3/5] Revert "Move the check to `CheckTemplateIdType()`"

This reverts commit 9111797355ba860d0c6b62fde3a7b1e347a71dc6.
---
 clang/lib/Sema/SemaTemplate.cpp| 3 +--
 clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 2ea18ec82b958..a032e3ec6f635 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -4700,8 +4700,7 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
 //   template struct A;
 CanonType = Context.getCanonicalTemplateSpecializationType(
   

[clang] [clang][ARM] Fix warning for using VFP from interrupts. (PR #91870)

2024-07-10 Thread Oliver Stannard via cfe-commits

https://github.com/ostannard approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/91870
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1782810 - [Clang][ARM][AArch64] Alway emit protection attributes for functions. (#82819)

2024-07-10 Thread Daniel Kiss via cfe-commits

Author: Daniel Kiss
Date: 2024-07-10T11:32:41+02:00
New Revision: 1782810b8440144a0141c24192acbaeb55a1545d

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

LOG: [Clang][ARM][AArch64] Alway emit protection attributes for functions. 
(#82819)

So far branch protection, sign return address, guarded control stack
attributes are
only emitted as module flags to indicate the functions need to be
generated with
those features.
The problem is in case of an LTO build the module flags are merged with
the `min`
rule which means if one of the module is not build with sign return
address then the features
will be turned off for all functions. Due to the functions take the
branch-protection and
sign-return-address features from the module flags. The
sign-return-address is
function level option therefore it is expected functions from files that
is
compiled with -mbranch-protection=pac-ret to be protected.
The inliner might inline functions with different set of flags as it
doesn't consider
the module flags.

This patch adds the attributes to all functions and drops the checking
of the module flags
for the code generation.
Module flag is still used for generating the ELF markers.
Also drops the "true"/"false" values from the
branch-protection-enforcement,
branch-protection-pauth-lr, guarded-control-stack attributes as presence
of the
attribute means it is on absence means off and no other option.

Releand with test fixes.

Added: 
clang/test/Frontend/arm-branch-protection-lto.c

Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/CodeGen/Targets/AArch64.cpp
clang/lib/CodeGen/Targets/ARM.cpp
clang/test/CodeGen/aarch64-branch-protection-attr.c
clang/test/CodeGen/aarch64-sign-return-address.c
clang/test/CodeGen/aarch64-targetattr.c
clang/test/CodeGen/arm-branch-protection-attr-1.c
clang/test/CodeGen/arm-branch-protection-attr-2.c
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp
llvm/lib/Target/ARM/ARMMachineFunctionInfo.cpp
llvm/lib/Transforms/IPO/LowerTypeTests.cpp
llvm/test/CodeGen/AArch64/branch-target-enforcement-indirect-calls.ll
llvm/test/CodeGen/AArch64/bti-branch-relaxation.ll
llvm/test/CodeGen/AArch64/kcfi-bti.ll
llvm/test/CodeGen/AArch64/machine-outliner-2fixup-blr-terminator.mir
llvm/test/CodeGen/AArch64/machine-outliner-bti.mir
llvm/test/CodeGen/AArch64/machine-outliner-outline-bti.ll
llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-0.ll
llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-4.ll
llvm/test/CodeGen/AArch64/pacbti-llvm-generated-funcs-1.ll
llvm/test/CodeGen/AArch64/pacbti-llvm-generated-funcs-2.ll
llvm/test/CodeGen/AArch64/pacbti-module-attrs.ll
llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
llvm/test/CodeGen/AArch64/setjmp-bti-outliner.ll
llvm/test/CodeGen/AArch64/setjmp-bti.ll
llvm/test/CodeGen/AArch64/sign-return-address-pauth-lr.ll
llvm/test/CodeGen/AArch64/sign-return-address.ll
llvm/test/CodeGen/AArch64/wineh-bti.ll
llvm/test/CodeGen/AArch64/wineh-pac.ll
llvm/test/CodeGen/ARM/setjmp-bti-basic.ll
llvm/test/CodeGen/ARM/setjmp-bti-outliner.ll
llvm/test/CodeGen/Thumb2/bti-entry-blocks.ll
llvm/test/CodeGen/Thumb2/bti-indirect-branches.ll
llvm/test/CodeGen/Thumb2/bti-outliner-1.ll
llvm/test/CodeGen/Thumb2/bti-outliner-2.ll
llvm/test/CodeGen/Thumb2/bti-outliner-cost-2.ll
llvm/test/CodeGen/Thumb2/bti-pac-replace-1.mir
llvm/test/CodeGen/Thumb2/bti-pac-replace-2.ll
llvm/test/CodeGen/Thumb2/jump-table-bti.ll
llvm/test/CodeGen/Thumb2/pacbti-m-basic.ll
llvm/test/CodeGen/Thumb2/pacbti-m-indirect-tail-call.ll
llvm/test/CodeGen/Thumb2/pacbti-m-outliner-1.ll
llvm/test/CodeGen/Thumb2/pacbti-m-outliner-3.ll
llvm/test/CodeGen/Thumb2/pacbti-m-outliner-4.ll
llvm/test/CodeGen/Thumb2/pacbti-m-outliner-5.ll
llvm/test/CodeGen/Thumb2/pacbti-m-overalign.ll
llvm/test/CodeGen/Thumb2/pacbti-m-stack-arg.ll
llvm/test/CodeGen/Thumb2/pacbti-m-unsupported-arch.ll
llvm/test/CodeGen/Thumb2/pacbti-m-varargs-1.ll
llvm/test/CodeGen/Thumb2/pacbti-m-varargs-2.ll
llvm/test/CodeGen/Thumb2/pacbti-m-vla.ll
llvm/test/LTO/AArch64/link-branch-target-enforcement.ll
llvm/test/Transforms/Inline/inline-sign-return-address.ll
llvm/test/Transforms/LowerTypeTests/function-arm-thumb.ll
llvm/test/Transforms/LowerTypeTests/function-thumb-bti.ll
llvm/test/Transforms/LowerTypeTests/function.ll
llvm/test/Verifier/branch-prot-attrs.ll

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index

[clang] [clang][CGRecordLayout] Remove dependency on isZeroSize (PR #96422)

2024-07-10 Thread Michael Buch via cfe-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/96422

>From 07e603f7afc98e5af31962a5b1f44f4e4c079ebb Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 21 Jun 2024 12:15:07 +0100
Subject: [PATCH 01/13] [clang][CGRecordLayout] Remove dependency on isZeroSize

This is a follow-up from the conversation starting at
https://github.com/llvm/llvm-project/pull/93809#issuecomment-2173729801

The root problem that motivated the change are external AST
sources that compute `ASTRecordLayout`s themselves instead of
letting Clang compute them from the AST. One such examples is
LLDB using DWARF to get the definitive offsets and sizes of C++
structures. Such layouts should be considered correct (modulo
buggy DWARF), but various assertions and lowering logic around
the `CGRecordLayoutBuilder` relies on the AST having
`[[no_unique_address]]` attached to them. This is a layout-altering
attribute which is not encoded in DWARF. This causes us LLDB to trip
over the various LLVM<->Clang layout consistency checks. There has been
precedent for avoiding such layout-altering attributes to affect
lowering with externally-provided layouts (e.g., packed structs).

This patch proposes to replace the `isZeroSize` checks in
`CGRecordLayoutBuilder` (which roughly means "empty field
with [[no_unique_address]]") with checks for
`CodeGen::isEmptyField`/`CodeGen::isEmptyRecord`.
---
 clang/lib/CodeGen/ABIInfoImpl.cpp |  6 ++---
 clang/lib/CodeGen/ABIInfoImpl.h   |  6 ++---
 clang/lib/CodeGen/CGExpr.cpp  |  3 ++-
 clang/lib/CodeGen/CGRecordLayoutBuilder.cpp   | 14 ++--
 clang/test/CodeGen/X86/x86_64-vaarg.c |  3 ++-
 clang/test/CodeGen/debug-info-packed-struct.c |  2 +-
 clang/test/CodeGen/paren-list-agg-init.cpp| 15 +
 .../CodeGenCXX/2011-12-19-init-list-ctor.cpp  |  6 ++---
 clang/test/CodeGenCXX/auto-var-init.cpp   | 10 -
 .../test/CodeGenCXX/bitfield-access-empty.cpp | 16 +++---
 clang/test/CodeGenCXX/class-layout.cpp|  2 +-
 clang/test/CodeGenCXX/compound-literals.cpp   |  2 +-
 clang/test/CodeGenCXX/exceptions.cpp  |  7 +++---
 .../lambda-deterministic-captures.cpp |  4 +---
 clang/test/CodeGenCXX/ms_struct.cpp   |  4 +---
 clang/test/CodeGenCXX/partial-destruction.cpp | 11 --
 clang/test/CodeGenCXX/pr18962.cpp |  5 ++---
 clang/test/CodeGenCXX/references.cpp  |  4 +---
 clang/test/CodeGenCXX/temporaries.cpp | 12 +-
 clang/test/CodeGenObjCXX/lambda-to-block.mm   |  9 
 clang/test/OpenMP/irbuilder_for_iterator.cpp  | 10 -
 clang/test/OpenMP/irbuilder_for_rangefor.cpp  | 14 +---
 .../test/OpenMP/task_member_call_codegen.cpp  | 22 ---
 clang/test/Sema/ms_class_layout.cpp   | 14 ++--
 24 files changed, 85 insertions(+), 116 deletions(-)

diff --git a/clang/lib/CodeGen/ABIInfoImpl.cpp 
b/clang/lib/CodeGen/ABIInfoImpl.cpp
index e9a26abb77837..92fcc3bc2c5f4 100644
--- a/clang/lib/CodeGen/ABIInfoImpl.cpp
+++ b/clang/lib/CodeGen/ABIInfoImpl.cpp
@@ -248,7 +248,7 @@ Address CodeGen::emitMergePHI(CodeGenFunction &CGF, Address 
Addr1,
   return Address(PHI, Addr1.getElementType(), Align);
 }
 
-bool CodeGen::isEmptyField(ASTContext &Context, const FieldDecl *FD,
+bool CodeGen::isEmptyField(const ASTContext &Context, const FieldDecl *FD,
bool AllowArrays, bool AsIfNoUniqueAddr) {
   if (FD->isUnnamedBitField())
 return true;
@@ -289,8 +289,8 @@ bool CodeGen::isEmptyField(ASTContext &Context, const 
FieldDecl *FD,
   return isEmptyRecord(Context, FT, AllowArrays, AsIfNoUniqueAddr);
 }
 
-bool CodeGen::isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays,
-bool AsIfNoUniqueAddr) {
+bool CodeGen::isEmptyRecord(const ASTContext &Context, QualType T,
+bool AllowArrays, bool AsIfNoUniqueAddr) {
   const RecordType *RT = T->getAs();
   if (!RT)
 return false;
diff --git a/clang/lib/CodeGen/ABIInfoImpl.h b/clang/lib/CodeGen/ABIInfoImpl.h
index 92986fb431646..e3f373e39c35a 100644
--- a/clang/lib/CodeGen/ABIInfoImpl.h
+++ b/clang/lib/CodeGen/ABIInfoImpl.h
@@ -126,15 +126,15 @@ Address emitMergePHI(CodeGenFunction &CGF, Address Addr1,
 /// is an unnamed bit-field or an (array of) empty record(s). If
 /// AsIfNoUniqueAddr is true, then C++ record fields are considered empty if
 /// the [[no_unique_address]] attribute would have made them empty.
-bool isEmptyField(ASTContext &Context, const FieldDecl *FD, bool AllowArrays,
-  bool AsIfNoUniqueAddr = false);
+bool isEmptyField(const ASTContext &Context, const FieldDecl *FD,
+  bool AllowArrays, bool AsIfNoUniqueAddr = false);
 
 /// isEmptyRecord - Return true iff a structure contains only empty
 /// fields. Note that a structure with a flexible array member is not
 /// considered empty. If AsIfNoUniqueAddr is true, then C++

[clang] [llvm] [Clang][ARM][AArch64] Alway emit protection attributes for functions. (PR #82819)

2024-07-10 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-x86_64-debian` 
running on `lldb-x86_64-debian` while building `clang,llvm` at step 6 "test".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/162/builds/1714

Here is the relevant piece of the build log for the reference:
```
Step 6 (test) failure: build (failure)
...
7.024 [11/22/38] Building CXX object 
tools/lldb/unittests/Thread/CMakeFiles/ThreadTests.dir/ThreadTest.cpp.o
7.052 [10/22/39] Building CXX object 
tools/lldb/unittests/Target/CMakeFiles/TargetTests.dir/StackFrameRecognizerTest.cpp.o
7.139 [10/21/40] Building CXX object 
tools/lldb/unittests/Target/CMakeFiles/TargetTests.dir/ExecutionContextTest.cpp.o
7.661 [10/20/41] Building CXX object 
tools/lldb/unittests/SymbolFile/DWARF/CMakeFiles/SymbolFileDWARFTests.dir/XcodeSDKModuleTests.cpp.o
7.851 [10/19/42] Building CXX object 
tools/lldb/unittests/SymbolFile/DWARF/CMakeFiles/SymbolFileDWARFTests.dir/DWARFDebugNamesIndexTest.cpp.o
7.865 [10/18/43] Building CXX object 
tools/lldb/unittests/SymbolFile/DWARF/CMakeFiles/SymbolFileDWARFTests.dir/DWARFIndexCachingTest.cpp.o
7.980 [10/17/44] Building CXX object 
tools/lldb/unittests/TestingSupport/Symbol/CMakeFiles/lldbSymbolHelpers.dir/YAMLModuleTester.cpp.o
8.037 [9/17/45] Linking CXX static library lib/liblldbSymbolHelpers.a
8.139 [9/16/46] Building CXX object 
tools/lldb/unittests/Symbol/CMakeFiles/SymbolTests.dir/SymtabTest.cpp.o
8.170 [9/15/47] Building CXX object 
tools/lldb/tools/lldb-test/CMakeFiles/lldb-test.dir/lldb-test.cpp.o
FAILED: tools/lldb/tools/lldb-test/CMakeFiles/lldb-test.dir/lldb-test.cpp.o 
/usr/bin/clang++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -D_DEBUG -D_GLIBCXX_ASSERTIONS 
-D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS 
-I/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/tools/lldb-test 
-I/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/tools/lldb-test 
-I/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/include 
-I/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/include 
-I/home/worker/2.0.1/lldb-x86_64-debian/build/include 
-I/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/llvm/include 
-I/usr/include/python3.11 
-I/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/llvm/../clang/include 
-I/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/../clang/include 
-I/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/source 
-I/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/source -isystem 
/usr/include/libxml2 -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -Wno-deprecated-declarations 
-Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register 
-Wno-vla-extension -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti 
-UNDEBUG -std=c++17 -MD -MT 
tools/lldb/tools/lldb-test/CMakeFiles/lldb-test.dir/lldb-test.cpp.o -MF 
tools/lldb/tools/lldb-test/CMakeFiles/lldb-test.dir/lldb-test.cpp.o.d -o 
tools/lldb/tools/lldb-test/CMakeFiles/lldb-test.dir/lldb-test.cpp.o -c 
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/tools/lldb-test/lldb-test.cpp
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/tools/lldb-test/lldb-test.cpp:512:5:
 error: reference to 'Module' is ambiguous
Module::LookupInfo lookup_info(ConstString(Name), getFunctionNameFlags(),
^
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/include/lldb/Core/Module.h:87:7:
 note: candidate found by name lookup is 'lldb_private::Module'
class Module : public std::enable_shared_from_this,
  ^
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/llvm/include/llvm/IR/Function.h:55:7:
 note: candidate found by name lookup is 'llvm::Module'
class Module;
  ^
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/tools/lldb-test/lldb-test.cpp:514:27:
 error: use of undeclared identifier 'lookup_info'
Symfile.FindFunctions(lookup_info, ContextPtr, true, List);
  ^
2 errors generated.
8.271 [9/14/48] Building CXX object 
tools/lldb/unittests/Platform/CMakeFiles/LLDBPlatformTests.dir/PlatformSiginfoTest.cpp.o
8.322 [9/13/49] Building CXX object 
tools/lldb/unittests/SymbolFile/DWARF/CMakeFiles/SymbolFileDWARFTests.dir/DWARFUnitTest.cpp.o
8.481 [9/12/50] Building CXX object 
tools/lldb/unittests/SymbolFile/DWARF/CMakeFiles/SymbolFileDWARFTests.dir/DWARFDIETest.cpp.o
8.887 [9/11/51] Building CXX object 
tools/lldb/unittests/ValueObject/CMakeFiles/LLDBValueObjectTests.dir/DumpValueObjectOptionsTests.cpp.o
8.947 [9/10/52] Building CXX o

[clang] [clang][CGRecordLayout] Remove dependency on isZeroSize (PR #96422)

2024-07-10 Thread Michael Buch via cfe-commits


@@ -1,7 +1,19 @@
-// RUN: %clang_cc1 -emit-llvm < %s | grep "zeroinitializer, i16 16877"
+// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s 
--check-prefixes=CHECK,EMPTY
+// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-windows-msvc -o - | FileCheck 
%s --check-prefixes=CHECK,EMPTY-MSVC
 // PR4390
 struct sysfs_dirent {
- union { struct sysfs_elem_dir {} s_dir; };
+ union { struct sysfs_elem_dir { int x; } s_dir; };
  unsigned short s_mode;
 };
 struct sysfs_dirent sysfs_root = { {}, 16877 };
+
+// CHECK: @sysfs_root = {{.*}}global %struct.sysfs_dirent { %union.anon 
zeroinitializer, i16 16877 }
+
+struct Foo {
+ union { struct empty {} x; };
+ unsigned short s_mode;
+};
+struct Foo foo = { {}, 16877 };
+
+// EMPTY:  @foo = {{.*}}global %struct.Foo { i16 16877 }
+// EMPTY-MSVC: @foo = {{.*}}global %struct.Foo { [4 x i8] undef, i16 16877 }

Michael137 wrote:

@efriedma-quic For MSVC targets we don't emit a zeroinitializer here now 
despite the empty union occupying some storage. Do we expect there to be a 
zeroinitializer here?

https://github.com/llvm/llvm-project/pull/96422
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CGRecordLayout] Remove dependency on isZeroSize (PR #96422)

2024-07-10 Thread Michael Buch via cfe-commits

https://github.com/Michael137 edited 
https://github.com/llvm/llvm-project/pull/96422
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CGRecordLayout] Remove dependency on isZeroSize (PR #96422)

2024-07-10 Thread Michael Buch via cfe-commits

https://github.com/Michael137 edited 
https://github.com/llvm/llvm-project/pull/96422
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] D41416: [modules] [pch] Do not deserialize all lazy template specializations when looking for one. (PR #83108)

2024-07-10 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 updated 
https://github.com/llvm/llvm-project/pull/83108

>From 1f7c6650f739092a1b8908de3793aa8bbdc7de34 Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Sun, 7 Jan 2018 15:16:11 +0200
Subject: [PATCH 1/2] D41416: [modules] [pch] Do not deserialize all lazy
 template specializations when looking for one.

---
 clang/include/clang/AST/DeclTemplate.h|  36 +++-
 clang/lib/AST/DeclTemplate.cpp| 100 +-
 clang/lib/AST/ODRHash.cpp |  15 
 clang/lib/Serialization/ASTReader.cpp |  25 --
 clang/lib/Serialization/ASTReaderDecl.cpp |  46 ++
 clang/lib/Serialization/ASTWriter.cpp |  21 -
 clang/lib/Serialization/ASTWriterDecl.cpp |  76 +---
 clang/test/Modules/cxx-templates.cpp  |   8 +-
 clang/test/Modules/odr_hash.cpp   |   4 +-
 9 files changed, 255 insertions(+), 76 deletions(-)

diff --git a/clang/include/clang/AST/DeclTemplate.h 
b/clang/include/clang/AST/DeclTemplate.h
index 5b6a6b40b28ef..d76c293706369 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -256,6 +256,9 @@ class TemplateArgumentList final
   TemplateArgumentList(const TemplateArgumentList &) = delete;
   TemplateArgumentList &operator=(const TemplateArgumentList &) = delete;
 
+  /// Create hash for the given arguments.
+  static unsigned ComputeODRHash(ArrayRef Args);
+
   /// Create a new template argument list that copies the given set of
   /// template arguments.
   static TemplateArgumentList *CreateCopy(ASTContext &Context,
@@ -729,6 +732,26 @@ class RedeclarableTemplateDecl : public TemplateDecl,
   }
 
   void anchor() override;
+  struct LazySpecializationInfo {
+GlobalDeclID DeclID = GlobalDeclID();
+unsigned ODRHash = ~0U;
+bool IsPartial = false;
+LazySpecializationInfo(GlobalDeclID ID, unsigned Hash = ~0U,
+   bool Partial = false)
+  : DeclID(ID), ODRHash(Hash), IsPartial(Partial) { }
+LazySpecializationInfo() { }
+bool operator<(const LazySpecializationInfo &Other) const {
+  return DeclID < Other.DeclID;
+}
+bool operator==(const LazySpecializationInfo &Other) const {
+  assert((DeclID != Other.DeclID || ODRHash == Other.ODRHash) &&
+ "Hashes differ!");
+  assert((DeclID != Other.DeclID || IsPartial == Other.IsPartial) &&
+ "Both must be the same kinds!");
+  return DeclID == Other.DeclID;
+}
+  };
+
 protected:
   template  struct SpecEntryTraits {
 using DeclType = EntryType;
@@ -769,7 +792,12 @@ class RedeclarableTemplateDecl : public TemplateDecl,
 return SpecIterator(isEnd ? Specs.end() : Specs.begin());
   }
 
-  void loadLazySpecializationsImpl() const;
+  void loadLazySpecializationsImpl(bool OnlyPartial = false) const;
+
+  void loadLazySpecializationsImpl(llvm::ArrayRef Args,
+   TemplateParameterList *TPL = nullptr) const;
+
+  Decl *loadLazySpecializationImpl(LazySpecializationInfo &LazySpecInfo) const;
 
   template 
   typename SpecEntryTraits::DeclType*
@@ -796,7 +824,7 @@ class RedeclarableTemplateDecl : public TemplateDecl,
 ///
 /// The first value in the array is the number of specializations/partial
 /// specializations that follow.
-GlobalDeclID *LazySpecializations = nullptr;
+LazySpecializationInfo *LazySpecializations = nullptr;
 
 /// The set of "injected" template arguments used within this
 /// template.
@@ -2279,7 +2307,7 @@ class ClassTemplateDecl : public RedeclarableTemplateDecl 
{
   friend class TemplateDeclInstantiator;
 
   /// Load any lazily-loaded specializations from the external source.
-  void LoadLazySpecializations() const;
+  void LoadLazySpecializations(bool OnlyPartial = false) const;
 
   /// Get the underlying class declarations of the template.
   CXXRecordDecl *getTemplatedDecl() const {
@@ -3023,7 +3051,7 @@ class VarTemplateDecl : public RedeclarableTemplateDecl {
   friend class ASTDeclWriter;
 
   /// Load any lazily-loaded specializations from the external source.
-  void LoadLazySpecializations() const;
+  void LoadLazySpecializations(bool OnlyPartial = false) const;
 
   /// Get the underlying variable declarations of the template.
   VarDecl *getTemplatedDecl() const {
diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index 722c7fcf0b0df..021454c770741 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -20,6 +20,8 @@
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
+#include "clang/AST/ODRHash.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/TypeLoc.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/LLVM.h"
@@ -331,17 +333,46 @@ RedeclarableTemplateDecl::CommonBase 
*RedeclarableTemplateDecl::getCommonPtr() c
   return Common;
 }
 
-void RedeclarableTemplateDecl::loadLazySpecializationsIm

[clang] [clang] fix sema init crash for not checking a ExprResult (PR #98102)

2024-07-10 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

> @Endilll you are able to reduce that further?

I don't see the original reproducer anywhere. Snippet in the description is 
already reduced (and got quite damaged in the process). I can reduce it myself 
if someone point me out to the original reproducer

https://github.com/llvm/llvm-project/pull/98102
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][C++26] Implement "Ordering of constraints involving fold expressions (PR #98160)

2024-07-10 Thread via cfe-commits

https://github.com/cor3ntin updated 
https://github.com/llvm/llvm-project/pull/98160

>From ba2b6ab4fd0aa5a79a849d71f2857256f8fc1c73 Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Tue, 9 Jul 2024 16:08:44 +0200
Subject: [PATCH 1/6] [Clang][C++26] Implement "Ordering of constraints
 involving fold expressions"

Implement https://isocpp.org/files/papers/P2963R3.pdf
---
 clang/docs/ReleaseNotes.rst |   3 +
 clang/include/clang/Sema/Sema.h |   5 +
 clang/include/clang/Sema/SemaConcept.h  | 142 +-
 clang/lib/Sema/SemaConcept.cpp  | 604 
 clang/lib/Sema/SemaTemplateVariadic.cpp |   4 +
 clang/test/SemaCXX/cxx2c-fold-exprs.cpp | 239 ++
 clang/www/cxx_status.html   |   2 +-
 7 files changed, 781 insertions(+), 218 deletions(-)
 create mode 100644 clang/test/SemaCXX/cxx2c-fold-exprs.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 838cb69f647ee..7d0b2115f8e53 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -271,6 +271,9 @@ C++2c Feature Support
 
 - Implemented `P3144R2 Deleting a Pointer to an Incomplete Type Should be 
Ill-formed `_.
 
+- Implemented `P2963R3 Ordering of constraints involving fold expressions 
`_.
+
+
 Resolutions to C++ Defect Reports
 ^
 - Substitute template parameter pack, when it is not explicitly specified
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 75a80540dbcbf..4a07da6b7bfd9 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -14062,6 +14062,11 @@ class Sema final : public SemaBase {
   const DeclarationNameInfo &NameInfo,
   SmallVectorImpl &Unexpanded);
 
+  /// Collect the set of unexpanded parameter packs within the given
+  /// expression.
+  static void collectUnexpandedParameterPacks(
+  Expr *E, SmallVectorImpl &Unexpanded);
+
   /// Invoked when parsing a template argument followed by an
   /// ellipsis, which creates a pack expansion.
   ///
diff --git a/clang/include/clang/Sema/SemaConcept.h 
b/clang/include/clang/Sema/SemaConcept.h
index 711443505174f..b6327e729768b 100644
--- a/clang/include/clang/Sema/SemaConcept.h
+++ b/clang/include/clang/Sema/SemaConcept.h
@@ -75,6 +75,17 @@ struct AtomicConstraint {
   }
 };
 
+struct FoldExpandedConstraint;
+
+using NormalFormConstraint =
+llvm::PointerUnion;
+struct NormalizedConstraint;
+using NormalForm =
+llvm::SmallVector, 4>;
+
+NormalForm makeCNF(const NormalizedConstraint &Normalized);
+NormalForm makeDNF(const NormalizedConstraint &Normalized);
+
 /// \brief A normalized constraint, as defined in C++ [temp.constr.normal], is
 /// either an atomic constraint, a conjunction of normalized constraints or a
 /// disjunction of normalized constraints.
@@ -87,26 +98,17 @@ struct NormalizedConstraint {
   std::pair *, 1,
   CompoundConstraintKind>;
 
-  llvm::PointerUnion Constraint;
+  llvm::PointerUnion
+  Constraint;
 
   NormalizedConstraint(AtomicConstraint *C): Constraint{C} { };
+  NormalizedConstraint(FoldExpandedConstraint *C) : Constraint{C} {};
+
   NormalizedConstraint(ASTContext &C, NormalizedConstraint LHS,
-   NormalizedConstraint RHS, CompoundConstraintKind Kind)
-  : Constraint{CompoundConstraint{
-new (C) std::pair{
-std::move(LHS), std::move(RHS)}, Kind}} { };
-
-  NormalizedConstraint(ASTContext &C, const NormalizedConstraint &Other) {
-if (Other.isAtomic()) {
-  Constraint = new (C) AtomicConstraint(*Other.getAtomicConstraint());
-} else {
-  Constraint = CompoundConstraint(
-  new (C) std::pair{
-  NormalizedConstraint(C, Other.getLHS()),
-  NormalizedConstraint(C, Other.getRHS())},
-  Other.getCompoundKind());
-}
-  }
+   NormalizedConstraint RHS, CompoundConstraintKind Kind);
+
+  NormalizedConstraint(ASTContext &C, const NormalizedConstraint &Other);
   NormalizedConstraint(NormalizedConstraint &&Other):
   Constraint(Other.Constraint) {
 Other.Constraint = nullptr;
@@ -126,6 +128,9 @@ struct NormalizedConstraint {
   }
 
   bool isAtomic() const { return Constraint.is(); }
+  bool isFoldExpanded() const {
+return Constraint.is();
+  }
 
   NormalizedConstraint &getLHS() const {
 assert(!isAtomic() && "getLHS called on atomic constraint.");
@@ -143,6 +148,12 @@ struct NormalizedConstraint {
 return Constraint.get();
   }
 
+  FoldExpandedConstraint *getFoldExpandedConstraint() const {
+assert(isFoldExpanded() &&
+   "getFoldExpandedConstraint called on non-fold-expanded 
constraint.");
+return Constraint.get();
+  }
+
 private:
   static std::optional
   fromConstraintExprs(Sema &S, NamedDecl *D, ArrayRef E);
@@ -150,6 +161,103 @@ struct NormalizedConstraint {
   fromConstraintExpr(Sema &S, NamedDecl *D, cons

[clang] [WIP][CLANG][AArch64] Add the modal 8 bit floating-point scalar type (PR #97277)

2024-07-10 Thread via cfe-commits

https://github.com/CarolineConcatto updated 
https://github.com/llvm/llvm-project/pull/97277

>From fbeca5c357b1a5589757bbb2cac8208f8c9027ab Mon Sep 17 00:00:00 2001
From: Caroline Concatto 
Date: Mon, 24 Jun 2024 09:59:24 +
Subject: [PATCH 1/2] [WIP][CLANG][AArch64] Add the  modal 8 bit floating-point
 scalar type

ARM ACLE PR#323[1] adds new modal types for 8-bit floating point intrinsic.

>From the PR#323:
```
ACLE defines the `__fpm8` type, which can be used for the E5M2 and E4M3
8-bit floating-point formats. It is a storage and interchange only type
with no arithmetic operations other than intrinsic calls.


The type should be an opaque type and its format in undefined in Clang.
Only defined in the backend by a status/format register, for AArch64 the FPMR.

This patch is an attempt to the add the fpm8_t scalar type.
It has a parser and codegen for the new scalar type.

The patch it is lowering to and 8bit unsigned as it has no format.
But maybe we should add another opaque type.

[1]  https://github.com/ARM-software/acle/pull/323
---
 clang/include/clang/AST/ASTContext.h  |  1 +
 clang/include/clang/AST/BuiltinTypes.def  |  4 +
 clang/include/clang/AST/Type.h|  5 +
 clang/include/clang/Basic/Specifiers.h|  1 +
 clang/include/clang/Basic/TokenKinds.def  |  1 +
 clang/include/clang/Sema/DeclSpec.h   |  1 +
 .../include/clang/Serialization/ASTBitCodes.h |  4 +-
 clang/lib/AST/ASTContext.cpp  |  7 ++
 clang/lib/AST/ItaniumMangle.cpp   |  1 +
 clang/lib/AST/Type.cpp|  2 +
 clang/lib/AST/TypeLoc.cpp |  1 +
 clang/lib/CodeGen/CodeGenTypes.cpp|  4 +-
 clang/lib/CodeGen/ItaniumCXXABI.cpp   |  1 +
 clang/lib/Index/USRGeneration.cpp |  1 +
 clang/lib/Lex/Lexer.cpp   |  1 +
 clang/lib/Parse/ParseDecl.cpp |  7 ++
 clang/lib/Parse/ParseExpr.cpp |  1 +
 clang/lib/Parse/ParseExprCXX.cpp  |  3 +
 clang/lib/Parse/ParseTentative.cpp|  2 +
 clang/lib/Sema/DeclSpec.cpp   |  3 +
 clang/lib/Sema/SemaTemplateVariadic.cpp   |  1 +
 clang/lib/Sema/SemaType.cpp   |  3 +
 clang/lib/Serialization/ASTCommon.cpp |  3 +
 clang/test/AST/fpm8_opaque.cpp| 91 +++
 clang/test/CodeGen/fpm8_opaque.c  | 24 +
 25 files changed, 171 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/AST/fpm8_opaque.cpp
 create mode 100644 clang/test/CodeGen/fpm8_opaque.c

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 53ece996769a8..532ec05ab90a6 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1115,6 +1115,7 @@ class ASTContext : public RefCountedBase {
   CanQualType SatShortFractTy, SatFractTy, SatLongFractTy;
   CanQualType SatUnsignedShortFractTy, SatUnsignedFractTy,
   SatUnsignedLongFractTy;
+  CanQualType Fpm8Ty;
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
   CanQualType BFloat16Ty;
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
diff --git a/clang/include/clang/AST/BuiltinTypes.def 
b/clang/include/clang/AST/BuiltinTypes.def
index 444be4311a743..0c1cccf4f73b8 100644
--- a/clang/include/clang/AST/BuiltinTypes.def
+++ b/clang/include/clang/AST/BuiltinTypes.def
@@ -221,6 +221,10 @@ FLOATING_TYPE(Float128, Float128Ty)
 // '__ibm128'
 FLOATING_TYPE(Ibm128, Ibm128Ty)
 
+
+// '__fpm8'
+UNSIGNED_TYPE(Fpm8, Fpm8Ty)
+
 //===- Language-specific types 
===//
 
 // This is the type of C++0x 'nullptr'.
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index fab233b62d8d1..9f835b8459847 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2492,6 +2492,7 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   bool isDoubleType() const;
   bool isBFloat16Type() const;
   bool isFloat128Type() const;
+  bool isFpm8Type() const;
   bool isIbm128Type() const;
   bool isRealType() const; // C99 6.2.5p17 (real floating + integer)
   bool isArithmeticType() const;   // C99 6.2.5p18 (integer + floating)
@@ -7944,6 +7945,10 @@ inline bool Type::isBFloat16Type() const {
   return isSpecificBuiltinType(BuiltinType::BFloat16);
 }
 
+inline bool Type::isFpm8Type() const {
+  return isSpecificBuiltinType(BuiltinType::Fpm8);
+}
+
 inline bool Type::isFloat128Type() const {
   return isSpecificBuiltinType(BuiltinType::Float128);
 }
diff --git a/clang/include/clang/Basic/Specifiers.h 
b/clang/include/clang/Basic/Specifiers.h
index fb11e8212f8b6..b4db94d273949 100644
--- a/clang/include/clang/Basic/Specifiers.h
+++ b/clang/include/clang/Basic/Specifiers.h
@@ -68,6 +68,7 @@ namespace clang {
 TST_Accum,   // ISO/IEC JTC1 SC22 WG14 N1169 Extension
 TST_Fract,
 TST_BFloat16,
+TST_Fpm8,
   

[clang] e464684 - [Clang] Allow raw string literals in C as an extension (#88265)

2024-07-10 Thread via cfe-commits

Author: Sirraide
Date: 2024-07-10T12:10:44+02:00
New Revision: e46468407a7bb7f8b2fe13675a5a1c32b85f8cad

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

LOG: [Clang] Allow raw string literals in C as an extension (#88265)

This enables raw R"" string literals in C in some language modes
and adds an option to disable or enable them explicitly as an
extension.

Background: GCC supports raw string literals in C in `-gnuXY` modes
starting with gnu99. This pr both enables raw string literals in gnu99 
mode and later in C and adds an `-f[no-]raw-string-literals` flag to override 
this behaviour. The decision not to enable raw string literals in gnu89
mode, according to the GCC devs, is intentional as that mode is supposed
to be used for ‘old code’ that they don’t want to break; we’ve decided to
match GCC’s behaviour here as well.

The `-fraw-string-literals`  flag can additionally be used to enable raw string 
literals in modes where they aren’t enabled by default (such as c99—as 
opposed to gnu99—or even e.g. C++03); conversely, the negated flag can 
be used to disable them in any gnuXY modes that *do* provide them by 
default, or to override a previous flag. However, we do *not*  support 
disabling raw string literals (or indeed either of these two options) in 
C++11 mode and later, because we don’t want to just start supporting 
disabling features that are actually part of the language in the general case.

This fixes #85703.

Added: 
clang/test/Driver/fraw-string-literals-cxx.cpp
clang/test/Lexer/raw-string-ext.c

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangStandard.h
clang/include/clang/Driver/Options.td
clang/lib/Basic/LangOptions.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Lex/DependencyDirectivesScanner.cpp
clang/lib/Lex/Lexer.cpp
clang/unittests/Lex/DependencyDirectivesScannerTest.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index cd3a4c2b1be1a..ebaa8773a262f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -43,6 +43,10 @@ code bases.
 C/C++ Language Potentially Breaking Changes
 ---
 
+- Clang now supports raw string literals in ``-std=gnuXY`` mode as an 
extension in
+  C99 and later. This behaviour can also be overridden using 
``-f[no-]raw-string-literals``.
+  Support of raw string literals in C++ is not affected. Fixes (#GH85703).
+
 C++ Specific Potentially Breaking Changes
 -
 - Clang now diagnoses function/variable templates that shadow their own 
template parameters, e.g. ``template void T();``.

diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 243d88d53d664..359c0de7f811c 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -375,6 +375,9 @@ def err_drv_negative_columns : Error<
   "invalid value '%1' in '%0', value must be 'none' or a positive integer">;
 def err_drv_small_columns : Error<
   "invalid value '%1' in '%0', value must be '%2' or greater">;
+def warn_drv_fraw_string_literals_in_cxx11 : Warning<
+  "ignoring '-f%select{no-|}0raw-string-literals', which is only valid for C 
and C++ standards before C++11">,
+  InGroup;
 
 def err_drv_invalid_malign_branch_EQ : Error<
   "invalid argument '%0' to -malign-branch=; each element must be one of: %1">;

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 491759e2fcdbb..d806b917432ad 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -465,6 +465,8 @@ LANGOPT(MatrixTypes, 1, 0, "Enable or disable the builtin 
matrix type")
 
 LANGOPT(CXXAssumptions, 1, 1, "Enable or disable codegen and compile-time 
checks for C++23's [[assume]] attribute")
 
+LANGOPT(RawStringLiterals, 1, 1, "Enable or disable raw string literals")
+
 ENUM_LANGOPT(StrictFlexArraysLevel, StrictFlexArraysLevelKind, 2,
  StrictFlexArraysLevelKind::Default,
  "Rely on strict definition of flexible arrays")

diff  --git a/clang/include/clang/Basic/LangStandard.h 
b/clang/include/clang/Basic/LangStandard.h
index f79b4aafb0b26..56a0d2c95e2b1 100644
--- a/clang/include/clang/Basic/LangStandard.h
+++ b/clang/include/clang/Basic/LangStandard.h
@@ -134,6 +134,13 @@ struct LangStandard {
   /// hasDigraphs - Language supports digraphs.
   bool hasDigraphs() const { return Flags & Digraphs; }
 
+  /// hasRawStringLitera

[clang] [Clang] Allow raw string literals in C as an extension (PR #88265)

2024-07-10 Thread via cfe-commits

https://github.com/Sirraide closed 
https://github.com/llvm/llvm-project/pull/88265
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86][MC] Added support for -msse2avx option in llvm-mc (PR #96860)

2024-07-10 Thread via cfe-commits

https://github.com/JaydeepChauhan14 updated 
https://github.com/llvm/llvm-project/pull/96860

>From b4a534ad6f811cf0868b7fd1ee641fae8502e171 Mon Sep 17 00:00:00 2001
From: Chauhan Jaydeep Ashwinbhai 
Date: Thu, 27 Jun 2024 15:17:50 +0800
Subject: [PATCH 01/10] [X86][MC] Added support for -msse2avx option in llvm-mc

---
 llvm/include/llvm/MC/MCTargetOptions.h|  1 +
 .../llvm/MC/MCTargetOptionsCommandFlags.h |  2 +
 llvm/lib/MC/MCTargetOptions.cpp   |  2 +-
 llvm/lib/MC/MCTargetOptionsCommandFlags.cpp   |  6 ++
 .../lib/Target/X86/AsmParser/X86AsmParser.cpp | 20 +
 llvm/test/MC/AsmParser/sse2avx.s  | 74 +++
 .../utils/TableGen/X86InstrMappingEmitter.cpp | 28 +++
 7 files changed, 132 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/MC/AsmParser/sse2avx.s

diff --git a/llvm/include/llvm/MC/MCTargetOptions.h 
b/llvm/include/llvm/MC/MCTargetOptions.h
index 0cf2806bd4804..90fe356d47077 100644
--- a/llvm/include/llvm/MC/MCTargetOptions.h
+++ b/llvm/include/llvm/MC/MCTargetOptions.h
@@ -55,6 +55,7 @@ class MCTargetOptions {
   bool ShowMCEncoding : 1;
   bool ShowMCInst : 1;
   bool AsmVerbose : 1;
+  bool SSE2AVX : 1;
 
   /// Preserve Comments in Assembly.
   bool PreserveAsmComments : 1;
diff --git a/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h 
b/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
index dc33f7461ab28..2b5f74fc6c1d8 100644
--- a/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
+++ b/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
@@ -41,6 +41,8 @@ bool getEmitCompactUnwindNonCanonical();
 
 bool getShowMCInst();
 
+bool getSSE2AVX();
+
 bool getFatalWarnings();
 
 bool getNoWarn();
diff --git a/llvm/lib/MC/MCTargetOptions.cpp b/llvm/lib/MC/MCTargetOptions.cpp
index bff4b8da2fb1b..227d9fc347e71 100644
--- a/llvm/lib/MC/MCTargetOptions.cpp
+++ b/llvm/lib/MC/MCTargetOptions.cpp
@@ -16,7 +16,7 @@ MCTargetOptions::MCTargetOptions()
   MCNoWarn(false), MCNoDeprecatedWarn(false), MCNoTypeCheck(false),
   MCSaveTempLabels(false), MCIncrementalLinkerCompatible(false),
   FDPIC(false), ShowMCEncoding(false), ShowMCInst(false), 
AsmVerbose(false),
-  PreserveAsmComments(true), Dwarf64(false),
+  SSE2AVX(false), PreserveAsmComments(true), Dwarf64(false),
   EmitDwarfUnwind(EmitDwarfUnwindType::Default),
   MCUseDwarfDirectory(DefaultDwarfDirectory),
   EmitCompactUnwindNonCanonical(false), PPCUseFullRegisterNames(false) {}
diff --git a/llvm/lib/MC/MCTargetOptionsCommandFlags.cpp 
b/llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
index 2c378643797da..6de42fa981e6d 100644
--- a/llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
+++ b/llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
@@ -42,6 +42,7 @@ MCOPT(bool, Dwarf64)
 MCOPT(EmitDwarfUnwindType, EmitDwarfUnwind)
 MCOPT(bool, EmitCompactUnwindNonCanonical)
 MCOPT(bool, ShowMCInst)
+MCOPT(bool, SSE2AVX)
 MCOPT(bool, FatalWarnings)
 MCOPT(bool, NoWarn)
 MCOPT(bool, NoDeprecatedWarn)
@@ -107,6 +108,10 @@ 
llvm::mc::RegisterMCTargetOptionsFlags::RegisterMCTargetOptionsFlags() {
   cl::desc("Emit internal instruction representation to assembly file"));
   MCBINDOPT(ShowMCInst);
 
+  static cl::opt SSE2AVX(
+  "msse2avx", cl::desc("Convert SSE Instructions to AVX Instructions"));
+  MCBINDOPT(SSE2AVX);
+
   static cl::opt FatalWarnings("fatal-warnings",
  cl::desc("Treat warnings as errors"));
   MCBINDOPT(FatalWarnings);
@@ -156,6 +161,7 @@ MCTargetOptions llvm::mc::InitMCTargetOptionsFromFlags() {
   Options.Dwarf64 = getDwarf64();
   Options.DwarfVersion = getDwarfVersion();
   Options.ShowMCInst = getShowMCInst();
+  Options.SSE2AVX = getSSE2AVX();
   Options.ABIName = getABIName();
   Options.MCFatalWarnings = getFatalWarnings();
   Options.MCNoWarn = getNoWarn();
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp 
b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index dbea42d55b5fc..ab70fdbc70caa 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -58,6 +58,10 @@ static bool checkScale(unsigned Scale, StringRef &ErrMsg) {
 
 namespace {
 
+// Including the generated SSE2AVX compression tables.
+#define GET_X86_SSE2AVX_TABLE
+#include "X86GenInstrMapping.inc"
+
 static const char OpPrecedence[] = {
 0,  // IC_OR
 1,  // IC_XOR
@@ -4141,6 +4145,15 @@ unsigned X86AsmParser::checkTargetMatchPredicate(MCInst 
&Inst) {
   return Match_Success;
 }
 
+void ReplaceSSE2AVXOpcode(llvm::MCInst &Inst) {
+  ArrayRef Table{X86SSE2AVXTable};
+  unsigned Opcode = Inst.getOpcode();
+  const auto I = llvm::lower_bound(Table, Opcode);
+  if (I != Table.end() && I->OldOpc == Opcode) {
+Inst.setOpcode(I->NewOpc);
+  }
+}
+
 bool X86AsmParser::matchAndEmitATTInstruction(
 SMLoc IDLoc, unsigned &Opcode, MCInst &Inst, OperandVector &Operands,
 MCStreamer &Out, uint64_t &ErrorInfo, bool MatchingInlineAsm) {
@@ -4159,6 +4172,13 @@ bool X86AsmParser::mat

[clang] [analyzer] Splitting TaintPropagation checker into reporting and mode… (PR #98157)

2024-07-10 Thread Donát Nagy via cfe-commits


@@ -1122,10 +1131,20 @@ void 
GenericTaintChecker::taintUnsafeSocketProtocol(const CallEvent &Call,
 }
 
 /// Checker registration
-void ento::registerGenericTaintChecker(CheckerManager &Mgr) {
+void ento::registerTaintPropagationChecker(CheckerManager &Mgr) {
   Mgr.registerChecker();
 }
 
+bool ento::shouldRegisterTaintPropagationChecker(const CheckerManager &mgr) {
+  return true;
+}
+
+void ento::registerGenericTaintChecker(CheckerManager &Mgr) {
+  GenericTaintChecker *checker = Mgr.getChecker();
+  checker->isTaintReporterCheckerEnabled = true;
+  checker->reporterCheckerName = Mgr.getCurrentCheckerName();

NagyDonat wrote:

We only use that `unique_ptr` has a null / empty state in addition to 
representing the "real" `BugType` values. However, `std::optional` would be 
completely sufficient for this goal (here and AFAIK in every checker that uses 
`unique_ptr`s to juggle multiple `BugType`s).

If we really want, in _this_ checker we could use a "bare" `BugType` data 
member if we leave it uninitialized in the constructor of the checker class (or 
initialize it with dummy values) and then unconditionally overwrite it with the 
"real" `BugType` in this `register...` function. (Other checkers have lazy 
initialization patterns that check the nullness of the `BugType`.)

https://github.com/llvm/llvm-project/pull/98157
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][doc] Improve error handling for `LibTooling` example code avoiding core dump (PR #98129)

2024-07-10 Thread via cfe-commits

https://github.com/Sirraide approved this pull request.

`toString(...)` does indeed seem to be the idiomatic way of doing it, but I do 
wonder if this is intentional: is there ever a reason to log an error but not 
mark it as handled? I’ll look into this a bit more, but other than that this 
change seems fine.

https://github.com/llvm/llvm-project/pull/98129
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][doc] Improve error handling for `LibTooling` example code avoiding core dump (PR #98129)

2024-07-10 Thread via cfe-commits

Sirraide wrote:

> I do wonder if this is intentional

(Will merge this later after I figure this out)

https://github.com/llvm/llvm-project/pull/98129
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Sema] Fix assertion error in Sema::FindInstantiatedDecl (PR #96509)

2024-07-10 Thread via cfe-commits
Alejandro =?utf-8?q?Álvarez_Ayllón?=,
Alejandro =?utf-8?q?Álvarez_Ayllón?=,
Alejandro =?utf-8?q?Álvarez_Ayllón?=,
Alejandro =?utf-8?q?Álvarez_Ayllón?Message-ID:
In-Reply-To: 



@@ -6300,7 +6300,7 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, 
NamedDecl *D,
   getTrivialTemplateArgumentLoc(UnpackedArg, QualType(), Loc));
   }
   QualType T = CheckTemplateIdType(TemplateName(TD), Loc, Args);
-  if (T.isNull())
+  if (T.isNull() || T->containsErrors())

Sirraide wrote:

Hmm, yeah, if every other place where this is used can already deal with a type 
that contains errors, then that makes sense.

https://github.com/llvm/llvm-project/pull/96509
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix null pointer dereference in VisitUsingEnumDecl (PR #97910)

2024-07-10 Thread via cfe-commits

https://github.com/Sirraide approved this pull request.

LGTM

Looks like we’re doing this null check pretty much in every other place 
`SubstType` is used, so this makes sense.

https://github.com/llvm/llvm-project/pull/97910
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86][MC] Added support for -msse2avx option in llvm-mc (PR #96860)

2024-07-10 Thread Simon Pilgrim via cfe-commits

RKSimon wrote:

> > How easy would it be to add an option for this to update inline asm? I'm 
> > not asking you to do this here, I just want to know if this approach would 
> > make it straightforward to add in the future.
> 
> Should we touch the inline asm? (GCC doesn't https://godbolt.org/z/o9MM9br95.

Definitely not be default, but I know of cases (old math libs with sse inline 
asm) that I'd like to build specific files/libs with this switched on to remove 
SSE-AVX stalls.

https://github.com/llvm/llvm-project/pull/96860
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] [NFC] Mark `UnresolvedSetImpl`'s move operations as defaulted (PR #97930)

2024-07-10 Thread via cfe-commits

https://github.com/Sirraide approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/97930
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fix bug that undefined internal is a warning only for -pedantic-errors (PR #98016)

2024-07-10 Thread via cfe-commits

https://github.com/Sirraide approved this pull request.

Thanks for the fix! 

The changes LGTM, but you should also add a release note about this (in 
`clang/docs/ReleaseNotes.rst`, probably in the ‘Improvements to Clang’s 
Diagnostics’ section).

https://github.com/llvm/llvm-project/pull/98016
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Splitting TaintPropagation checker into reporting and mode… (PR #98157)

2024-07-10 Thread Balazs Benics via cfe-commits


@@ -1122,10 +1131,20 @@ void 
GenericTaintChecker::taintUnsafeSocketProtocol(const CallEvent &Call,
 }
 
 /// Checker registration
-void ento::registerGenericTaintChecker(CheckerManager &Mgr) {
+void ento::registerTaintPropagationChecker(CheckerManager &Mgr) {
   Mgr.registerChecker();
 }
 
+bool ento::shouldRegisterTaintPropagationChecker(const CheckerManager &mgr) {
+  return true;
+}
+
+void ento::registerGenericTaintChecker(CheckerManager &Mgr) {
+  GenericTaintChecker *checker = Mgr.getChecker();
+  checker->isTaintReporterCheckerEnabled = true;
+  checker->reporterCheckerName = Mgr.getCurrentCheckerName();

steakhal wrote:

Why can't we initialize it regardless if the given checker is enabled or not?

https://github.com/llvm/llvm-project/pull/98157
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Run PreStmt/PostStmt checker for GCCAsmStmt (PR #95409)

2024-07-10 Thread Balazs Benics via cfe-commits

steakhal wrote:

> > Thanks for the ping. Looks really nice! FYI I just came across a case last 
> > week w.r.t asm gotos. You can have a read 
> > [here](https://sonarsource.atlassian.net/browse/CPP-5459) if you are 
> > interested in the subject.
> 
> Thank you! Looks interesting. Does this mean that the linked problem would 
> also benefit from this PR?

I haven't if this PR would help or not. My guess would be that this wouldn't 
help. 

Please fix the formatting. After that we can merge this PR.

https://github.com/llvm/llvm-project/pull/95409
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer][docs] Add clang-19 release notes for CSA (PR #97418)

2024-07-10 Thread Balazs Benics via cfe-commits

https://github.com/steakhal updated 
https://github.com/llvm/llvm-project/pull/97418

>From 69f2b22cf5dc7a3a5b45c00cc867685dc66b397f Mon Sep 17 00:00:00 2001
From: Balazs Benics 
Date: Tue, 2 Jul 2024 15:01:22 +0200
Subject: [PATCH] [analyzer][docs] Add clang-19 release notes for CSA

---
 clang/docs/ReleaseNotes.rst | 92 +
 1 file changed, 84 insertions(+), 8 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9741730604441..1d9f8b40419ec 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1151,32 +1151,108 @@ libclang
 Static Analyzer
 ---
 
+New features
+
+
+- The attribute ``[[clang::suppress]]`` can now be applied to declarations.
+  (#GH80371)
+
+- Support C++23 static operator calls. (#GH84972)
+
+Crash and bug fixes
+^^^
+
 - Fixed crashing on loops if the loop variable was declared in switch blocks
   but not under any case blocks if ``unroll-loops=true`` analyzer config is
   set. (#GH68819)
-- Support C++23 static operator calls. (#GH84972)
+
 - Fixed a crash in ``security.cert.env.InvalidPtr`` checker when accidentally
-  matched user-defined ``strerror`` and similar library functions. (GH#88181)
-- Fixed a crash when storing through an address that refers to the address of
-  a label. (GH#89185)
+  matched user-defined ``strerror`` and similar library functions. (#GH88181)
 
-New features
-
+- Fixed a crash when storing through an address that refers to the address of
+  a label. (#GH89185)
 
-Crash and bug fixes
-^^^
+- Z3 crosschecking (aka. Z3 refutation) is now bounded, and can't consume
+  more total time than the eymbolic execution itself. (#GH97298)
 
 Improvements
 
 
+- Many improvements for the ``unix.Stream`` checker, by modeling more functions
+  and improving overall diagnostic quality.
+
+  `Documentation 
`__.
+
+- Microsoft ``__assume`` is now recognized as ``__builtin_assume``. (#GH80456)
+
+- ``unix.Malloc`` suppresses false-positives involving ``std::atomic`` values.
+  (#GH90918)
+
+- Improved modeling of ``execv``, ``execvp``, ``popen``, ``pclose`` and
+  ``realpath`` in the ``unix.StdCLibraryFunctions`` checker.
+  `Documentation 
`__.
+
+- Many improvements were made to make function matching more accurate,
+  leading to fewer false positives.
+
+- Small improvements to ``optin.portability.UnixAPI``, ``core.VLASize``,
+  ``unix.BlockInCriticalSection``, ``core.NullDereference``, ``unix.Malloc``,
+  ``alpha.deadcode.UnreachableCode``, ``alpha.core.PointerSub``,
+  ``alpha.security.ArrayBoundV2`` checkers.
+
+- Many ``alpha.WebKit.*`` improvements.
+
 - Support importing C++20 modules in clang-repl.
 
 - Added support for ``TypeLoc::dump()`` for easier debugging, and improved
   textual and JSON dumping for various ``TypeLoc``-related nodes.
 
+New checkers or configuration values
+
+
+- Added a new checker ``security.SetgidSetuidOrder`` which checks correct
+  usages of ``setuid`` and ``setguid`` call sequences to drop superuser
+  privileges. (#GH91445)
+  `Documentation 
`__.
+
+- Added a new checker ``optin.taint.TaintedAlloc`` which reports for passing
+  tainted ``size`` parameter to ``malloc``, ``calloc``, ``realloc``, ``alloca``
+  or to the C++ new operator. (#GH92420)
+  `Documentation 
`__.
+
+- The ``unix.Stream`` gained the ``pedantic`` configuration option to warn for
+  not checking the return value of write operations for success or failure.
+  Enabling this may introduce a signifficant amount of false-positives.
+  (#GH87322)
+  `Documentation 
`__.
+
+- The configuration value ``ModelPosix`` now defaults to ``true`` in the
+  ``unix.StdCLibraryFunctions`` checker. (#GH80457)
+  `Documentation 
`__.
+
 Moved checkers
 ^^
 
+- Moved ``alpha.cplusplus.ArrayDelete`` out of the ``alpha`` package
+  to ``cplusplus.ArrayDelete``. (#GH83985)
+  `Documentation 
`__.
+
+- Moved ``alpha.unix.Stream`` out of the ``alpha`` package to
+  ``unix.Stream``. (#GH89247)
+  `Documentation 
`__.
+
+- Moved ``alpha.unix.BlockInCriticalSection`` out of the ``alpha`` package to
+  ``unix.BlockInCriticalSection``. (#GH93815)
+  `Documentation 
`__.
+
+- Moved ``alpha.security.cert.pos.

[clang] [llvm] Assume (PR #97535)

2024-07-10 Thread Alexey Bataev via cfe-commits


@@ -1759,8 +1759,35 @@ void 
Parser::ParseOpenMPAssumesDirective(OpenMPDirectiveKind DKind,
 Assumptions.push_back(Assumption);
   }
 
+  StmtResult AssociatedStmt;
+
+  // Begin marking the scope for assume.
+  if (DKind == llvm::omp::Directive::OMPD_assume) {
+
+if (Tok.getKind() == clang::tok::annot_pragma_openmp_end)
+  ConsumeAnyToken();
+
+DeclarationNameInfo DirName;
+Actions.OpenMP().StartOpenMPDSABlock(DKind, DirName, Actions.getCurScope(),
+ Loc);
+  }

alexey-bataev wrote:

Introduce RAAI class for this and use it instead

https://github.com/llvm/llvm-project/pull/97535
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Assume (PR #97535)

2024-07-10 Thread Alexey Bataev via cfe-commits


@@ -7323,6 +7324,69 @@ void 
SemaOpenMP::ActOnFinishedFunctionDefinitionInOpenMPAssumeScope(Decl *D) {
 FD->addAttr(AA);
 }
 
+class OMPAssumeStmtVisitor : public StmtVisitor {
+  SmallVector *OMPAssumeScoped;
+
+public:
+  OMPAssumeStmtVisitor(SmallVector *OMPAssumeScoped) {
+this->OMPAssumeScoped = OMPAssumeScoped;
+  }
+
+  void VisitCapturedStmt(CapturedStmt *CS) {
+// To find the CaptureDecl for the CaptureStmt
+CapturedDecl *CD = CS->getCapturedDecl();
+if (CD) {
+  for (OMPAssumeAttr *AA : *OMPAssumeScoped)
+CD->addAttr(AA);
+}
+  }
+
+  void VisitCompoundStmt(CompoundStmt *CS) {
+// Handle CompoundStmt
+// Visit each statement in the CompoundStmt
+for (Stmt *SubStmt : CS->body()) {
+  if (Expr *CE = dyn_cast(SubStmt)) {
+// If the statement is a Expr, process it
+VisitExpr(CE);
+  }
+}
+  }
+
+  void VisitExpr(Expr *CE) {
+// Handle all Expr
+for (auto *Child : CE->children()) {
+  Visit(Child);
+}
+  }
+
+  void Visit(Stmt *S) {
+const char *CName = S->getStmtClassName();
+if ((strstr(CName, "OMP") != NULL) &&
+(strstr(CName, "Directive") != NULL)) {
+  for (Stmt *Child : S->children()) {
+auto *CS = dyn_cast(Child);
+if (CS)
+  VisitCapturedStmt(CS);
+else
+  StmtVisitor::Visit(Child);
+  }
+} else {
+  StmtVisitor::Visit(S);
+}
+  }
+};
+
+StmtResult
+SemaOpenMP::ActOnFinishedStatementInOpenMPAssumeScope(Stmt *AssociatedStmt) {
+
+  if (AssociatedStmt) {
+// Add the AssumeAttr to the Directive associated with the Assume 
Directive.
+OMPAssumeStmtVisitor Visitor(&OMPAssumeScoped);
+Visitor.Visit(AssociatedStmt);

alexey-bataev wrote:

Why it is not enough to mark just the outer region? The fact that it is applied 
to nested regions can be hanf]dled in the codegen

https://github.com/llvm/llvm-project/pull/97535
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] [WIP] Added builtin_alloca right Address Space for OpenCL (PR #95750)

2024-07-10 Thread Matt Arsenault via cfe-commits


@@ -1981,6 +1981,26 @@ static bool OpenCLBuiltinToAddr(Sema &S, unsigned 
BuiltinID, CallExpr *Call) {
   return false;
 }
 
+// In OpenCL, __builtin_alloca_* should return a pointer to address space
+// that corresponds to the stack address space i.e private address space.
+static bool OpenCLBuiltinAllocaAddrSpace(Sema &S, CallExpr *TheCall) {
+  QualType RT = TheCall->getType();
+  if (!RT->isPointerType() || RT->getPointeeType().hasAddressSpace())
+return true;
+
+  if (S.getLangOpts().OpenCL) {
+RT = RT->getPointeeType();
+
+// Stack Address space corresponds to private address space.
+LangAS openCLStackAS = LangAS::opencl_private;

arsenm wrote:

Don't need this variable or name, just directly pass LangAs::opencl_private to 
getAddrSpaceQualType 

https://github.com/llvm/llvm-project/pull/95750
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Emit bad shift warnings (PR #70307)

2024-07-10 Thread Budimir Aranđelović via cfe-commits

budimirarandjelovicsyrmia wrote:

Ping @AaronBallman @shafik @tbaederr 

https://github.com/llvm/llvm-project/pull/70307
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Do not emit intrinsic math functions on GPU targets (PR #98209)

2024-07-10 Thread Joseph Huber via cfe-commits

jhuber6 wrote:

> This is going to break the library build. We use the __builtin functions to 
> access the intrinsic in the cases where the llvm intrinsic lowering provides 
> the implementation of the function. In a more sensible world, the library 
> would not provide the implementations of functions that are implemented by 
> the intrinsics in the first place

Well, the `libm` just provides the symbols as the builtins. But if we wanted to 
do that we'd need a list somewhere. That was the more complicated option, but I 
wasn't sure how to handle it. Since we could potentially have a pass that does 
the intrinsic lowering in LLVM-IR for the ones we know aren't handled.

https://github.com/llvm/llvm-project/pull/98209
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Catch missing format attributes (PR #70024)

2024-07-10 Thread Budimir Aranđelović via cfe-commits

https://github.com/budimirarandjelovicsyrmia updated 
https://github.com/llvm/llvm-project/pull/70024

From 30d1b5012de980b0933011881fd44edc367082af Mon Sep 17 00:00:00 2001
From: budimirarandjelovicsyrmia 
Date: Fri, 5 Apr 2024 15:20:37 +0200
Subject: [PATCH] [clang] Catch missing format attributes

---
 clang/docs/ReleaseNotes.rst   |   3 +
 clang/include/clang/Basic/DiagnosticGroups.td |   1 -
 .../clang/Basic/DiagnosticSemaKinds.td|   3 +
 clang/include/clang/Sema/Attr.h   |   7 +
 clang/include/clang/Sema/Sema.h   |   4 +
 clang/lib/Sema/SemaDecl.cpp   |   2 +
 clang/lib/Sema/SemaDeclAttr.cpp   | 219 +-
 clang/test/Sema/attr-format-missing.c | 400 ++
 clang/test/Sema/attr-format-missing.cpp   | 174 
 9 files changed, 810 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Sema/attr-format-missing.c
 create mode 100644 clang/test/Sema/attr-format-missing.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index cd3a4c2b1be1a..3fafaf0a5b2c2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -686,6 +686,9 @@ Improvements to Clang's diagnostics
 - Clang no longer emits a "no previous prototype" warning for Win32 entry 
points under ``-Wmissing-prototypes``.
   Fixes #GH94366.
 
+- Clang now diagnoses missing format attributes for non-template functions and
+  class/struct/union members. Fixes #GH60718
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 2241f8481484e..da6a3b2fe3571 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -525,7 +525,6 @@ def MainReturnType : DiagGroup<"main-return-type">;
 def MaxUnsignedZero : DiagGroup<"max-unsigned-zero">;
 def MissingBraces : DiagGroup<"missing-braces">;
 def MissingDeclarations: DiagGroup<"missing-declarations">;
-def : DiagGroup<"missing-format-attribute">;
 def MissingIncludeDirs : DiagGroup<"missing-include-dirs">;
 def MissingNoreturn : DiagGroup<"missing-noreturn">;
 def MultiChar : DiagGroup<"multichar">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index fa02622f12271..a09bcba217cde 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1028,6 +1028,9 @@ def err_opencl_invalid_param : Error<
 def err_opencl_invalid_return : Error<
   "declaring function return value of type %0 is not allowed %select{; did you 
forget * ?|}1">;
 def warn_enum_value_overflow : Warning<"overflow in enumeration value">;
+def warn_missing_format_attribute : Warning<
+  "diagnostic behavior may be improved by adding the %0 format attribute to 
the declaration of %1">,
+  InGroup>, DefaultIgnore;
 def warn_pragma_options_align_reset_failed : Warning<
   "#pragma options align=reset failed: %0">,
   InGroup;
diff --git a/clang/include/clang/Sema/Attr.h b/clang/include/clang/Sema/Attr.h
index 3f0b10212789a..37c124ca7b454 100644
--- a/clang/include/clang/Sema/Attr.h
+++ b/clang/include/clang/Sema/Attr.h
@@ -123,6 +123,13 @@ inline bool isInstanceMethod(const Decl *D) {
   return false;
 }
 
+inline bool checkIfMethodHasImplicitObjectParameter(const Decl *D) {
+  if (const auto *MethodDecl = dyn_cast(D))
+return MethodDecl->isInstance() &&
+   !MethodDecl->hasCXXExplicitFunctionObjectParameter();
+  return false;
+}
+
 /// Diagnose mutually exclusive attributes when present on a given
 /// declaration. Returns true if diagnosed.
 template 
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 57994f4033922..9022ac86edf81 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -4602,6 +4602,10 @@ class Sema final : public SemaBase {
 
   enum class RetainOwnershipKind { NS, CF, OS };
 
+  void DiagnoseMissingFormatAttributes(Stmt *Body, const FunctionDecl *FDecl);
+  std::vector
+  GetMissingFormatAttributes(Stmt *Body, const FunctionDecl *FDecl);
+
   UuidAttr *mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI,
   StringRef UuidAsWritten, MSGuidDecl *GuidDecl);
 
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index d1c7b9d5ae507..ac31de5ced827 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -15924,6 +15924,8 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt 
*Body,
 }
   }
 
+  DiagnoseMissingFormatAttributes(Body, FD);
+
   // We might not have found a prototype because we didn't wish to warn on
   // the lack of a missing prototype. Try again without the checks for
   // whether we want to warn on the missing prototype.
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/Sema

[clang] Run PreStmt/PostStmt checker for GCCAsmStmt (PR #95409)

2024-07-10 Thread via cfe-commits

T-Gruber wrote:

> > > Thanks for the ping. Looks really nice! FYI I just came across a case 
> > > last week w.r.t asm gotos. You can have a read 
> > > [here](https://sonarsource.atlassian.net/browse/CPP-5459) if you are 
> > > interested in the subject.
> > 
> > 
> > Thank you! Looks interesting. Does this mean that the linked problem would 
> > also benefit from this PR?
> 
> I haven't if this PR would help or not. My guess would be that this wouldn't 
> help.
> 
> Please fix the 
> [formatting](https://github.com/llvm/llvm-project/pull/95409#issuecomment-2219921933).
>  After that we can merge this PR.

I reworked the unittest and fixed the format as well. Thanks for your help!

https://github.com/llvm/llvm-project/pull/95409
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [C23] Add *_NORM_MAX macros to (PR #96643)

2024-07-10 Thread Aaron Ballman via cfe-commits


@@ -113,7 +113,11 @@ static T PickFP(const llvm::fltSemantics *Sem, T 
IEEEHalfVal, T IEEESingleVal,
 
 static void DefineFloatMacros(MacroBuilder &Builder, StringRef Prefix,
   const llvm::fltSemantics *Sem, StringRef Ext) {
-  const char *DenormMin, *Epsilon, *Max, *Min;
+  const char *DenormMin, *NormMax, *Epsilon, *Max, *Min;
+  NormMax = PickFP(Sem, "6.5504e+4", "3.40282347e+38",
+   "1.7976931348623157e+308", "1.18973149535723176502e+4932",
+   "1.79769313486231580793728971405301e+308",

AaronBallman wrote:

Thank you Hubert!

https://github.com/llvm/llvm-project/pull/96643
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fix bug that undefined internal is a warning only for -pedantic-errors (PR #98016)

2024-07-10 Thread Constantin Kronbichler via cfe-commits

ccrownhill wrote:

Ok I just added a commit with the addition to `clang/docs/ReleaseNotes.rst`.

https://github.com/llvm/llvm-project/pull/98016
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Run PreStmt/PostStmt checker for GCCAsmStmt (PR #95409)

2024-07-10 Thread Balazs Benics via cfe-commits

https://github.com/steakhal approved this pull request.


https://github.com/llvm/llvm-project/pull/95409
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][ARM] Call constructor on BranchTargetInfo. (PR #98307)

2024-07-10 Thread Daniel Kiss via cfe-commits

https://github.com/DanielKristofKiss created 
https://github.com/llvm/llvm-project/pull/98307

Otherwise members will be uninitialised.

>From 4e10c95c390e519853428f424cd655379d99c61c Mon Sep 17 00:00:00 2001
From: Daniel Kiss 
Date: Wed, 10 Jul 2024 13:58:52 +0200
Subject: [PATCH] [Clang][ARM] Call constructor on BranchTargetInfo.

Otherwise members will be uninitialised.
---
 clang/lib/CodeGen/Targets/ARM.cpp | 2 +-
 clang/lib/Sema/SemaDeclAttr.cpp   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/CodeGen/Targets/ARM.cpp 
b/clang/lib/CodeGen/Targets/ARM.cpp
index d449b97cdc685..93fea94a77248 100644
--- a/clang/lib/CodeGen/Targets/ARM.cpp
+++ b/clang/lib/CodeGen/Targets/ARM.cpp
@@ -141,7 +141,7 @@ class ARMTargetCodeGenInfo : public TargetCodeGenInfo {
   ParsedTargetAttr Attr =
   CGM.getTarget().parseTargetAttr(TA->getFeaturesStr());
   if (!Attr.BranchProtection.empty()) {
-TargetInfo::BranchProtectionInfo BPI;
+TargetInfo::BranchProtectionInfo BPI{};
 StringRef DiagMsg;
 StringRef Arch =
 Attr.CPU.empty() ? CGM.getTarget().getTargetOpts().CPU : Attr.CPU;
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 73a85ff39667b..f2cd46d1e7c93 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -2991,7 +2991,7 @@ bool Sema::checkTargetAttr(SourceLocation LiteralLoc, 
StringRef AttrStr) {
  << Unsupported << None << CurFeature << Target;
   }
 
-  TargetInfo::BranchProtectionInfo BPI;
+  TargetInfo::BranchProtectionInfo BPI{};
   StringRef DiagMsg;
   if (ParsedAttrs.BranchProtection.empty())
 return false;

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][ARM] Call constructor on BranchTargetInfo. (PR #98307)

2024-07-10 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-backend-arm

@llvm/pr-subscribers-clang

Author: Daniel Kiss (DanielKristofKiss)


Changes

Otherwise members will be uninitialised.

---
Full diff: https://github.com/llvm/llvm-project/pull/98307.diff


2 Files Affected:

- (modified) clang/lib/CodeGen/Targets/ARM.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaDeclAttr.cpp (+1-1) 


``diff
diff --git a/clang/lib/CodeGen/Targets/ARM.cpp 
b/clang/lib/CodeGen/Targets/ARM.cpp
index d449b97cdc685..93fea94a77248 100644
--- a/clang/lib/CodeGen/Targets/ARM.cpp
+++ b/clang/lib/CodeGen/Targets/ARM.cpp
@@ -141,7 +141,7 @@ class ARMTargetCodeGenInfo : public TargetCodeGenInfo {
   ParsedTargetAttr Attr =
   CGM.getTarget().parseTargetAttr(TA->getFeaturesStr());
   if (!Attr.BranchProtection.empty()) {
-TargetInfo::BranchProtectionInfo BPI;
+TargetInfo::BranchProtectionInfo BPI{};
 StringRef DiagMsg;
 StringRef Arch =
 Attr.CPU.empty() ? CGM.getTarget().getTargetOpts().CPU : Attr.CPU;
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 73a85ff39667b..f2cd46d1e7c93 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -2991,7 +2991,7 @@ bool Sema::checkTargetAttr(SourceLocation LiteralLoc, 
StringRef AttrStr) {
  << Unsupported << None << CurFeature << Target;
   }
 
-  TargetInfo::BranchProtectionInfo BPI;
+  TargetInfo::BranchProtectionInfo BPI{};
   StringRef DiagMsg;
   if (ParsedAttrs.BranchProtection.empty())
 return false;

``




https://github.com/llvm/llvm-project/pull/98307
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 87c51e2 - Run PreStmt/PostStmt checker for GCCAsmStmt (#95409)

2024-07-10 Thread via cfe-commits

Author: T-Gruber
Date: 2024-07-10T14:15:53+02:00
New Revision: 87c51e2af006b96d928d55b077c8bb510c4b6e33

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

LOG: Run PreStmt/PostStmt checker for GCCAsmStmt (#95409)

Fixes #94940

Run PreStmt and PostStmt checker for GCCAsmStmt.
Unittest to validate that corresponding callback functions are triggered.

Added: 
clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp

Modified: 
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/unittests/StaticAnalyzer/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp 
b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 977deb3182deb..19c85352a6144 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -2057,11 +2057,17 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode 
*Pred,
   llvm_unreachable("Support for MatrixSubscriptExpr is not implemented.");
   break;
 
-case Stmt::GCCAsmStmtClass:
+case Stmt::GCCAsmStmtClass: {
   Bldr.takeNodes(Pred);
-  VisitGCCAsmStmt(cast(S), Pred, Dst);
+  ExplodedNodeSet PreVisit;
+  getCheckerManager().runCheckersForPreStmt(PreVisit, Pred, S, *this);
+  ExplodedNodeSet PostVisit;
+  for (ExplodedNode *const N : PreVisit)
+VisitGCCAsmStmt(cast(S), N, PostVisit);
+  getCheckerManager().runCheckersForPostStmt(Dst, PostVisit, S, *this);
   Bldr.addNodes(Dst);
   break;
+}
 
 case Stmt::MSAsmStmtClass:
   Bldr.takeNodes(Pred);

diff  --git a/clang/unittests/StaticAnalyzer/CMakeLists.txt 
b/clang/unittests/StaticAnalyzer/CMakeLists.txt
index dcc557b44fb31..5ef72cfaea401 100644
--- a/clang/unittests/StaticAnalyzer/CMakeLists.txt
+++ b/clang/unittests/StaticAnalyzer/CMakeLists.txt
@@ -10,6 +10,7 @@ add_clang_unittest(StaticAnalysisTests
   CallDescriptionTest.cpp
   CallEventTest.cpp
   ConflictingEvalCallsTest.cpp
+  ExprEngineVisitTest.cpp
   FalsePositiveRefutationBRVisitorTest.cpp
   IsCLibraryFunctionTest.cpp
   MemRegionDescriptiveNameTest.cpp

diff  --git a/clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp 
b/clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp
new file mode 100644
index 0..a8579f9d0f90c
--- /dev/null
+++ b/clang/unittests/StaticAnalyzer/ExprEngineVisitTest.cpp
@@ -0,0 +1,87 @@
+//===- ExprEngineVisitTest.cpp 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "CheckerRegistration.h"
+#include "clang/AST/Stmt.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+
+void emitErrorReport(CheckerContext &C, const BugType &Bug,
+ const std::string &Desc) {
+  if (ExplodedNode *Node = C.generateNonFatalErrorNode(C.getState())) {
+auto Report = std::make_unique(Bug, Desc, Node);
+C.emitReport(std::move(Report));
+  }
+}
+
+#define CREATE_EXPR_ENGINE_CHECKER(CHECKER_NAME, CALLBACK, STMT_TYPE,  
\
+   BUG_NAME)   
\
+  class CHECKER_NAME : public Checker> {
\
+  public:  
\
+void check##CALLBACK(const STMT_TYPE *ASM, CheckerContext &C) const {  
\
+  emitErrorReport(C, Bug, "check" #CALLBACK "<" #STMT_TYPE ">");   
\
+}  
\
+   
\
+  private: 
\
+const BugType Bug{this, BUG_NAME}; 
\
+  };
+
+CREATE_EXPR_ENGINE_CHECKER(ExprEngineVisitPreChecker, PreStmt, GCCAsmStmt,
+   "GCCAsmStmtBug")
+CREATE_EXPR_ENGINE_CHECKER(ExprEngineVisitPostChecker, PostStmt, GCCAsmStmt,
+   "GCCAsmStmtBug")
+
+void addExprEngineVisitPreChecker(AnalysisASTConsumer &AnalysisConsumer,
+  AnalyzerOptions &AnOpts) {
+  AnOpts.CheckersAndPackages = {{"ExprEngineVisitPreChecker", true}};
+  AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
+Registry.addChecker(

[clang] Run PreStmt/PostStmt checker for GCCAsmStmt (PR #95409)

2024-07-10 Thread Balazs Benics via cfe-commits

https://github.com/steakhal closed 
https://github.com/llvm/llvm-project/pull/95409
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][ARM] Call constructor on BranchTargetInfo. (PR #98307)

2024-07-10 Thread Jonathan Thackray via cfe-commits

https://github.com/jthackray approved this pull request.


https://github.com/llvm/llvm-project/pull/98307
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][ARM] Call constructor on BranchTargetInfo. (PR #98307)

2024-07-10 Thread Tomas Matheson via cfe-commits

tmatheson-arm wrote:

Can something be done to prevent this happening accidentally again?

https://github.com/llvm/llvm-project/pull/98307
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin, fmax and frexp. (PR #88978)

2024-07-10 Thread Zahira Ammarguellat via cfe-commits

zahiraam wrote:

> > All the LIT tests failing are due to the latest changes I made. I will edit 
> > them once I know that the latest implementation is correct.
> 
> Thanks. I may be delayed in reviewing this as the C++ committee meeting is 
> the week after next.

Ping @hubert-reinterpretcast 

https://github.com/llvm/llvm-project/pull/88978
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Splitting TaintPropagation checker into reporting and mode… (PR #98157)

2024-07-10 Thread Donát Nagy via cfe-commits


@@ -1122,10 +1131,20 @@ void 
GenericTaintChecker::taintUnsafeSocketProtocol(const CallEvent &Call,
 }
 
 /// Checker registration
-void ento::registerGenericTaintChecker(CheckerManager &Mgr) {
+void ento::registerTaintPropagationChecker(CheckerManager &Mgr) {
   Mgr.registerChecker();
 }
 
+bool ento::shouldRegisterTaintPropagationChecker(const CheckerManager &mgr) {
+  return true;
+}
+
+void ento::registerGenericTaintChecker(CheckerManager &Mgr) {
+  GenericTaintChecker *checker = Mgr.getChecker();
+  checker->isTaintReporterCheckerEnabled = true;
+  checker->reporterCheckerName = Mgr.getCurrentCheckerName();

NagyDonat wrote:

Because this way we can access the checker name specified in `Checkers.td` via 
the function `Mgr.getCurrentCheckerName();`.

When the checker class corresponds to just one checker defined in `Checkers.td` 
we can use the alternative constructor of `BugType` that takes the checker 
object (`this`) as a first argument and then queries the name from the checker 
object (which can save a _single_ name automatically).

When a single class implements multiple checkers, we need to explicitly pass 
the right name to the `BugType` constructor, and so we need to either (1) 
postpone the construction of the `BugType` to a point after the registration or 
(2) duplicate the checker name between `Checkers.td` and the source file.

AFAIK we always choose option (1), but I didn't check this systematically.

https://github.com/llvm/llvm-project/pull/98157
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Assume (PR #97535)

2024-07-10 Thread via cfe-commits

cor3ntin wrote:

Can we get a more specific title for this PR? thanks!

https://github.com/llvm/llvm-project/pull/97535
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [C++20][Modules] static data members of template classes should be allowed in header units (PR #98309)

2024-07-10 Thread Dmitry Polukhin via cfe-commits

https://github.com/dmpolukhin created 
https://github.com/llvm/llvm-project/pull/98309

Summary:
These is no sense to report this cases as an error or add `inline` explicitly 
in this cases. If it is not required in normal headers. Similar to #60079.

Test Plan: check-clang

>From 7fd31fea6d4a3003ca5c05be722bf42390ac5eb9 Mon Sep 17 00:00:00 2001
From: Dmitry Polukhin 
Date: Wed, 10 Jul 2024 05:13:09 -0700
Subject: [PATCH] [C++20][Modules] static data mebers of template classes
 should be allowed in header units

Summary:
These is no sense to report this cases as an error or add `inline`
explicitly in this cases. If it is not required in normal headers.
Similar to #60079.

Test Plan: check-clang

Reviewers: @kaimfrai, @ChuanqiXu9

Subscribers: @iains, @EugeneZelenko, @dwblaikie, @Arthapz
---
 clang/lib/Sema/SemaDecl.cpp|  3 ++-
 clang/test/CXX/module/module.import/p6.cpp | 10 ++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index b3bfdacb01790..7d810b895f9e8 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -13305,7 +13305,8 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr 
*Init, bool DirectInit) {
   if (getLangOpts().CPlusPlusModules && currentModuleIsHeaderUnit() &&
   !VDecl->isInvalidDecl() && VDecl->isThisDeclarationADefinition() &&
   VDecl->getFormalLinkage() == Linkage::External && !VDecl->isInline() &&
-  !VDecl->isTemplated() && !isa(VDecl)) {
+  !VDecl->isTemplated() && !isa(VDecl) &&
+  !VDecl->getInstantiatedFromStaticDataMember()) {
 Diag(VDecl->getLocation(), diag::err_extern_def_in_header_unit);
 VDecl->setInvalidDecl();
   }
diff --git a/clang/test/CXX/module/module.import/p6.cpp 
b/clang/test/CXX/module/module.import/p6.cpp
index 0ed8b5958dffe..cb2d799e5b565 100644
--- a/clang/test/CXX/module/module.import/p6.cpp
+++ b/clang/test/CXX/module/module.import/p6.cpp
@@ -67,3 +67,13 @@ void* tmpl_fn_ok
 inline int foo (int a) {
   return tmpl_OK (a);
 }
+
+template  struct S2 { static int v; };
+template  int S2::v = 10;
+
+template  bool b() {
+bool b1 = S2::v == 10;
+return b1 && true;
+}
+
+inline bool B = b();

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   5   >