[clang] [clang codegen] Emit int TBAA metadata on more FP math libcalls (PR #100302)

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


@@ -692,23 +692,22 @@ static RValue emitLibraryCall(CodeGenFunction &CGF, const 
FunctionDecl *FD,
   RValue Call =
   CGF.EmitCall(E->getCallee()->getType(), callee, E, ReturnValueSlot());
 
-  // Check the supported intrinsic.
+  ASTContext &Context = CGF.getContext();
   if (unsigned BuiltinID = FD->getBuiltinID()) {
 auto IsErrnoIntrinsic = [&]() -> unsigned {
-  switch (BuiltinID) {
-  case Builtin::BIexpf:
-  case Builtin::BI__builtin_expf:
-  case Builtin::BI__builtin_expf128:
+  // Check whether a FP math builtin function, such as BI__builtin_expf
+  QualType ResultTy = FD->getReturnType();
+  bool ConstWithoutErrnoAndExceptions =
+  Context.BuiltinInfo.isConstWithoutErrnoAndExceptions(BuiltinID);
+  if (ConstWithoutErrnoAndExceptions &&
+  CGF.ConvertType(ResultTy)->isFloatingPointTy())

arsenm wrote:

The isFloatingPointTy check should be unnecessary. You can then just remove the 
whole lambda and directly check  isConstWithoutErrnoAndExceptions

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


[clang] [clang codegen] Emit int TBAA metadata on more FP math libcalls (PR #100302)

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


@@ -4,37 +4,76 @@
 // RUN:  %clang_cc1 -triple=aarch64-unknown-linux-gnu -fmath-errno -O3 
-new-struct-path-tbaa -emit-llvm -o - -x c++ %s | FileCheck %s 
-check-prefixes=CHECK,NewStructPathTBAA
 
 extern "C" float expf(float);
+extern "C" double remainder(double, double);
+extern "C" double fabs(double);
 
 // Emit int TBAA metadata on FP math libcalls, which is useful for alias 
analysis
 
 // CHECK-LABEL: define dso_local float @foo(
-// CHECK-SAME: ptr nocapture noundef readonly [[NUM:%.*]], float noundef 
[[R2INV:%.*]], i32 noundef [[N:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// CHECK-SAME: ptr nocapture noundef readonly [[NUM:%.*]]) local_unnamed_addr 
#[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i8, ptr [[NUM]], 
i64 40
 // CHECK-NEXT:[[TMP0:%.*]] = load float, ptr [[ARRAYIDX]], align 4, !tbaa 
[[TBAA2:![0-9]+]]
-// CHECK-NEXT:[[CALL:%.*]] = tail call float @expf(float noundef [[TMP0]]) 
#[[ATTR2:[0-9]+]], !tbaa [[TBAA6:![0-9]+]]
+// CHECK-NEXT:[[CALL:%.*]] = tail call float @expf(float noundef [[TMP0]]) 
#[[ATTR4:[0-9]+]], !tbaa [[TBAA6:![0-9]+]]
 // CHECK-NEXT:[[MUL:%.*]] = fmul float [[TMP0]], [[CALL]]
 // CHECK-NEXT:ret float [[MUL]]
 //
-extern "C" float foo (float num[], float r2inv, int n) {
-   const float expm2 =  expf(num[10]);  // Emit TBAA metadata on @expf
+extern "C" float foo (float num[]) {

arsenm wrote:

Could also just make this a C test instead of all the extern Cs? 

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


[clang] [clang codegen] Emit int TBAA metadata on more FP math libcalls (PR #100302)

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


@@ -4,37 +4,76 @@
 // RUN:  %clang_cc1 -triple=aarch64-unknown-linux-gnu -fmath-errno -O3 
-new-struct-path-tbaa -emit-llvm -o - -x c++ %s | FileCheck %s 
-check-prefixes=CHECK,NewStructPathTBAA
 
 extern "C" float expf(float);
+extern "C" double remainder(double, double);
+extern "C" double fabs(double);
 
 // Emit int TBAA metadata on FP math libcalls, which is useful for alias 
analysis
 
 // CHECK-LABEL: define dso_local float @foo(
-// CHECK-SAME: ptr nocapture noundef readonly [[NUM:%.*]], float noundef 
[[R2INV:%.*]], i32 noundef [[N:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// CHECK-SAME: ptr nocapture noundef readonly [[NUM:%.*]]) local_unnamed_addr 
#[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i8, ptr [[NUM]], 
i64 40
 // CHECK-NEXT:[[TMP0:%.*]] = load float, ptr [[ARRAYIDX]], align 4, !tbaa 
[[TBAA2:![0-9]+]]
-// CHECK-NEXT:[[CALL:%.*]] = tail call float @expf(float noundef [[TMP0]]) 
#[[ATTR2:[0-9]+]], !tbaa [[TBAA6:![0-9]+]]
+// CHECK-NEXT:[[CALL:%.*]] = tail call float @expf(float noundef [[TMP0]]) 
#[[ATTR4:[0-9]+]], !tbaa [[TBAA6:![0-9]+]]
 // CHECK-NEXT:[[MUL:%.*]] = fmul float [[TMP0]], [[CALL]]
 // CHECK-NEXT:ret float [[MUL]]
 //
-extern "C" float foo (float num[], float r2inv, int n) {
-   const float expm2 =  expf(num[10]);  // Emit TBAA metadata on @expf
+extern "C" float foo (float num[]) {
+   const float expm2 = expf(num[10]);  // Emit TBAA metadata on @expf
float tmp = expm2 * num[10];
return tmp;
 }
+
+//
+// Negative test: fabs cannot set errno
+// CHECK-LABEL: define dso_local double @foo_fabs(
+// CHECK-SAME: ptr nocapture noundef readonly [[NUM:%.*]]) local_unnamed_addr 
#[[ATTR2:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i8, ptr [[NUM]], 
i64 80
+// CHECK-NEXT:[[TMP0:%.*]] = load double, ptr [[ARRAYIDX]], align 8, !tbaa 
[[TBAA8:![0-9]+]]
+// CHECK-NEXT:[[TMP1:%.*]] = tail call double @llvm.fabs.f64(double 
[[TMP0]])
+// CHECK-NEXT:[[MUL:%.*]] = fmul double [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret double [[MUL]]
+//
+extern "C" double foo_fabs (double num[]) {
+   const double expm2 = fabs(num[10]);  // Don't emit TBAA metadata
+   double tmp = expm2 * num[10];
+   return tmp;
+}
+
+// CHECK-LABEL: define dso_local double @foo_remainder(
+// CHECK-SAME: ptr nocapture noundef readonly [[NUM:%.*]], double noundef 
[[A:%.*]]) local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i8, ptr [[NUM]], 
i64 80
+// CHECK-NEXT:[[TMP0:%.*]] = load double, ptr [[ARRAYIDX]], align 8, !tbaa 
[[TBAA8]]
+// CHECK-NEXT:[[CALL:%.*]] = tail call double @remainder(double noundef 
[[TMP0]], double noundef [[A]]) #[[ATTR4]], !tbaa [[TBAA6]]
+// CHECK-NEXT:[[MUL:%.*]] = fmul double [[TMP0]], [[CALL]]
+// CHECK-NEXT:ret double [[MUL]]
+//
+extern "C" double foo_remainder (double num[], double a) {
+   const double expm2 = remainder(num[10], a);  // Emit TBAA metadata
+   double tmp = expm2 * num[10];
+   return tmp;
+}
+

arsenm wrote:

Test a few more functions for good measure? Also test some cases with out 
arguments, like frexp.

Also test sincos? it has out float arguments so I'm not sure you apply this 

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


[clang] Add a test for #100095 (PR #100556)

2024-07-28 Thread Alexander Kornienko via cfe-commits

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


[clang] [Clang][CTAD][NFC] Unify transformTemplateParameter() (PR #100865)

2024-07-28 Thread via cfe-commits

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


[clang] [Clang][CTAD][NFC] Unify transformTemplateParameter() (PR #100865)

2024-07-28 Thread via cfe-commits

https://github.com/cor3ntin commented:

Thanks for cleaning that up

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


[clang] [Clang][CTAD][NFC] Unify transformTemplateParameter() (PR #100865)

2024-07-28 Thread via cfe-commits


@@ -284,6 +283,42 @@ transformTemplateParam(Sema &SemaRef, DeclContext *DC,
   return NewParam;
 }
 
+NamedDecl *transformTemplateParameter(Sema &SemaRef, DeclContext *DC,
+  NamedDecl *TemplateParam,
+  MultiLevelTemplateArgumentList &Args,
+  unsigned NewIndex, unsigned NewDepth,
+  bool EvaluateConstraint = true) {
+  if (auto *TTP = dyn_cast(TemplateParam))
+return transformTemplateTypeParam(
+SemaRef, DC, TTP, Args, NewDepth, NewIndex,
+/*EvaluateConstraint=*/EvaluateConstraint);
+  if (auto *TTP = dyn_cast(TemplateParam))
+return transformTemplateParam(SemaRef, DC, TTP, Args, NewIndex, NewDepth);
+  if (auto *NTTP = dyn_cast(TemplateParam))
+return transformTemplateParam(SemaRef, DC, NTTP, Args, NewIndex, NewDepth);
+  llvm_unreachable("Unhandled template parameter types");
+}
+
+unsigned getTemplateParameterDepth(NamedDecl *TemplateParam) {
+  if (auto *TTP = dyn_cast(TemplateParam))
+return TTP->getDepth();
+  if (auto *TTP = dyn_cast(TemplateParam))
+return TTP->getDepth();
+  if (auto *NTTP = dyn_cast(TemplateParam))
+return NTTP->getDepth();
+  llvm_unreachable("Unhandled template parameter types");
+}
+
+unsigned getTemplateParameterIndex(NamedDecl *TemplateParam) {
+  if (auto *TTP = dyn_cast(TemplateParam))
+return TTP->getIndex();
+  if (auto *TTP = dyn_cast(TemplateParam))
+return TTP->getIndex();
+  if (auto *NTTP = dyn_cast(TemplateParam))
+return NTTP->getIndex();
+  llvm_unreachable("Unhandled template parameter types");
+}

cor3ntin wrote:

Given we already have `getDepthAndIndex` - we can simplify that further

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


[clang] [Clang][CTAD][NFC] Unify transformTemplateParameter() (PR #100865)

2024-07-28 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 updated 
https://github.com/llvm/llvm-project/pull/100865

>From 13724c6cd47c17b92b57f04436c544bd9d681070 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sat, 27 Jul 2024 18:52:23 +0800
Subject: [PATCH 1/3] [Clang][CTAD][NFC] Unify transformTemplateParameter()

We ended up having two transformTemplateParameter() after CTAD for
type aliases was landed. This patch cleans them up and allows them
to share one implementation.
---
 clang/lib/Sema/SemaTemplateDeductionGuide.cpp | 120 --
 1 file changed, 52 insertions(+), 68 deletions(-)

diff --git a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp 
b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
index 0602d07c6b9b0..2e94e2d5660e5 100644
--- a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
+++ b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
@@ -241,11 +241,10 @@ NamedDecl *buildDeductionGuide(
 }
 
 // Transform a given template type parameter `TTP`.
-TemplateTypeParmDecl *
-transformTemplateTypeParam(Sema &SemaRef, DeclContext *DC,
-   TemplateTypeParmDecl *TTP,
-   MultiLevelTemplateArgumentList &Args,
-   unsigned NewDepth, unsigned NewIndex) {
+TemplateTypeParmDecl *transformTemplateTypeParam(
+Sema &SemaRef, DeclContext *DC, TemplateTypeParmDecl *TTP,
+MultiLevelTemplateArgumentList &Args, unsigned NewDepth, unsigned NewIndex,
+bool EvaluateConstraint) {
   // TemplateTypeParmDecl's index cannot be changed after creation, so
   // substitute it directly.
   auto *NewTTP = TemplateTypeParmDecl::Create(
@@ -257,7 +256,7 @@ transformTemplateTypeParam(Sema &SemaRef, DeclContext *DC,
   : std::nullopt);
   if (const auto *TC = TTP->getTypeConstraint())
 SemaRef.SubstTypeConstraint(NewTTP, TC, Args,
-/*EvaluateConstraint=*/true);
+/*EvaluateConstraint=*/EvaluateConstraint);
   if (TTP->hasDefaultArgument()) {
 TemplateArgumentLoc InstantiatedDefaultArg;
 if (!SemaRef.SubstTemplateArgument(
@@ -284,6 +283,42 @@ transformTemplateParam(Sema &SemaRef, DeclContext *DC,
   return NewParam;
 }
 
+NamedDecl *transformTemplateParameter(Sema &SemaRef, DeclContext *DC,
+  NamedDecl *TemplateParam,
+  MultiLevelTemplateArgumentList &Args,
+  unsigned NewIndex, unsigned NewDepth,
+  bool EvaluateConstraint = true) {
+  if (auto *TTP = dyn_cast(TemplateParam))
+return transformTemplateTypeParam(
+SemaRef, DC, TTP, Args, NewDepth, NewIndex,
+/*EvaluateConstraint=*/EvaluateConstraint);
+  if (auto *TTP = dyn_cast(TemplateParam))
+return transformTemplateParam(SemaRef, DC, TTP, Args, NewIndex, NewDepth);
+  if (auto *NTTP = dyn_cast(TemplateParam))
+return transformTemplateParam(SemaRef, DC, NTTP, Args, NewIndex, NewDepth);
+  llvm_unreachable("Unhandled template parameter types");
+}
+
+unsigned getTemplateParameterDepth(NamedDecl *TemplateParam) {
+  if (auto *TTP = dyn_cast(TemplateParam))
+return TTP->getDepth();
+  if (auto *TTP = dyn_cast(TemplateParam))
+return TTP->getDepth();
+  if (auto *NTTP = dyn_cast(TemplateParam))
+return NTTP->getDepth();
+  llvm_unreachable("Unhandled template parameter types");
+}
+
+unsigned getTemplateParameterIndex(NamedDecl *TemplateParam) {
+  if (auto *TTP = dyn_cast(TemplateParam))
+return TTP->getIndex();
+  if (auto *TTP = dyn_cast(TemplateParam))
+return TTP->getIndex();
+  if (auto *NTTP = dyn_cast(TemplateParam))
+return NTTP->getIndex();
+  llvm_unreachable("Unhandled template parameter types");
+}
+
 /// Transform to convert portions of a constructor declaration into the
 /// corresponding deduction guide, per C++1z [over.match.class.deduct]p1.
 struct ConvertConstructorToDeductionGuideTransform {
@@ -358,21 +393,23 @@ struct ConvertConstructorToDeductionGuideTransform {
 Args.addOuterRetainedLevel();
 if (NestedPattern)
   Args.addOuterRetainedLevels(NestedPattern->getTemplateDepth());
-NamedDecl *NewParam = transformTemplateParameter(Param, Args);
+NamedDecl *NewParam = transformTemplateParameter(
+SemaRef, DC, Param, Args,
+getTemplateParameterIndex(Param) + Depth1IndexAdjustment,
+getTemplateParameterDepth(Param) - 1);
 if (!NewParam)
   return nullptr;
 // Constraints require that we substitute depth-1 arguments
 // to match depths when substituted for evaluation later
 Depth1Args.push_back(SemaRef.Context.getInjectedTemplateArg(NewParam));
 
-if (NestedPattern) {
-  TemplateDeclInstantiator Instantiator(SemaRef, DC,
-OuterInstantiationArgs);
-  Instantiator.setEvaluateConstraints(false);
-  SemaRef.runWithSufficientStackSpace(NewParam-

[clang] [Clang][CTAD][NFC] Unify transformTemplateParameter() (PR #100865)

2024-07-28 Thread Younan Zhang via cfe-commits


@@ -284,6 +283,42 @@ transformTemplateParam(Sema &SemaRef, DeclContext *DC,
   return NewParam;
 }
 
+NamedDecl *transformTemplateParameter(Sema &SemaRef, DeclContext *DC,
+  NamedDecl *TemplateParam,
+  MultiLevelTemplateArgumentList &Args,
+  unsigned NewIndex, unsigned NewDepth,
+  bool EvaluateConstraint = true) {
+  if (auto *TTP = dyn_cast(TemplateParam))
+return transformTemplateTypeParam(
+SemaRef, DC, TTP, Args, NewDepth, NewIndex,
+/*EvaluateConstraint=*/EvaluateConstraint);
+  if (auto *TTP = dyn_cast(TemplateParam))
+return transformTemplateParam(SemaRef, DC, TTP, Args, NewIndex, NewDepth);
+  if (auto *NTTP = dyn_cast(TemplateParam))
+return transformTemplateParam(SemaRef, DC, NTTP, Args, NewIndex, NewDepth);
+  llvm_unreachable("Unhandled template parameter types");
+}
+
+unsigned getTemplateParameterDepth(NamedDecl *TemplateParam) {
+  if (auto *TTP = dyn_cast(TemplateParam))
+return TTP->getDepth();
+  if (auto *TTP = dyn_cast(TemplateParam))
+return TTP->getDepth();
+  if (auto *NTTP = dyn_cast(TemplateParam))
+return NTTP->getDepth();
+  llvm_unreachable("Unhandled template parameter types");
+}
+
+unsigned getTemplateParameterIndex(NamedDecl *TemplateParam) {
+  if (auto *TTP = dyn_cast(TemplateParam))
+return TTP->getIndex();
+  if (auto *TTP = dyn_cast(TemplateParam))
+return TTP->getIndex();
+  if (auto *NTTP = dyn_cast(TemplateParam))
+return NTTP->getIndex();
+  llvm_unreachable("Unhandled template parameter types");
+}

zyn0217 wrote:

Thanks! I should've remembered we have used it in 
`CheckParameterPacksForExpansion()`!

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


[clang] [Clang][CTAD][NFC] Unify transformTemplateParameter() (PR #100865)

2024-07-28 Thread Younan Zhang via cfe-commits

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


[clang] [Clang][CTAD][NFC] Unify transformTemplateParameter() (PR #100865)

2024-07-28 Thread Younan Zhang via cfe-commits

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


[clang] [libcxx] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-07-28 Thread Mark de Wever via cfe-commits
Max =?utf-8?b?8J+RqPCfj73igI3wn5K7?= Copl
Message-ID:
In-Reply-To: 



@@ -3921,7 +3921,7 @@ _ForwardIterator basic_regex<_CharT, 
_Traits>::__parse_character_escape(
   if (__hd == -1)
 __throw_regex_error();
   __sum = 16 * __sum + static_cast(__hd);
-  // fallthrough
+[[clang::fallthrough]];

mordante wrote:

> Sorry, I'm new to contributing to LLVM. 

No problem! Welcome to LLVM!

> I will mark this PR as a Draft until the #100821 lands :)

Thanks!



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


[clang] [Clang][CTAD][NFC] Unify transformTemplateParameter() (PR #100865)

2024-07-28 Thread via cfe-commits

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

I think this looks good, nice cleanup.

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


[clang] 81595e9 - [Clang][Sema] Add a test for move ctor calling for a base class. NFC (#97164)

2024-07-28 Thread via cfe-commits

Author: Pavel Samolysov
Date: 2024-07-28T13:44:57+03:00
New Revision: 81595e9178eedc18dfcace9ac412f20697497f9f

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

LOG: [Clang][Sema] Add a test for move ctor calling for a base class. NFC 
(#97164)

When clang compiles the following expression:

```c++
  return A{B{"Move Ctor"}};
```
(where `B` is a base class for `A`), it adds a call to the move
constructor of `B`. When the code is changed to...

```c++
  return A{{"No Move Ctor"}};
```
... a move constructor is invoked neither for `A` nor for `B`.

The lit test demonstrates the difference in the generated AST.

Added: 
clang/test/AST/explicit-base-class-move-cntr.cpp

Modified: 


Removed: 




diff  --git a/clang/test/AST/explicit-base-class-move-cntr.cpp 
b/clang/test/AST/explicit-base-class-move-cntr.cpp
new file mode 100644
index 0..808af2fc94336
--- /dev/null
+++ b/clang/test/AST/explicit-base-class-move-cntr.cpp
@@ -0,0 +1,171 @@
+// RUN: %clang_cc1 -ast-dump=json %s | FileCheck -strict-whitespace %s
+
+struct ExplicitBase {
+  explicit ExplicitBase(const char *) { }
+  ExplicitBase(const ExplicitBase &) {}
+  ExplicitBase(ExplicitBase &&) {}
+  ExplicitBase &operator=(const ExplicitBase &) { return *this; }
+  ExplicitBase &operator=(ExplicitBase &&) { return *this; }
+  ~ExplicitBase() { }
+};
+
+struct Derived1 : ExplicitBase {};
+
+Derived1 makeDerived1() {
+// CHECK:  "kind": "FunctionDecl",
+// CHECK:  "name": "makeDerived1",
+
+// CHECK:"kind": "CompoundStmt",
+
+// CHECK:  "kind": "ReturnStmt",
+// CHECK:"kind": "ExprWithCleanups",
+// CHECK:"type": {
+// CHECK-NEXT: "qualType": "Derived1"
+// CHECK-NEXT:   },
+
+// CHECK:  "kind": "CXXFunctionalCastExpr",
+// CHECK:  "type": {
+// CHECK-NEXT:   "qualType": "Derived1"
+// CHECK-NEXT: },
+// CHECK-NEXT: "valueCategory": "prvalue",
+// CHECK-NEXT: "castKind": "NoOp",
+
+// CHECK:"kind": "CXXBindTemporaryExpr",
+// CHECK:"type": {
+// CHECK-NEXT: "qualType": "Derived1"
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "valueCategory": "prvalue",
+
+// CHECK:  "kind": "InitListExpr",
+// CHECK:  "type": {
+// CHECK-NEXT:   "qualType": "Derived1"
+// CHECK-NEXT: },
+// CHECK-NEXT: "valueCategory": "prvalue",
+
+// CHECK:"kind": "CXXConstructExpr",
+// CHECK:"type": {
+// CHECK-NEXT: "qualType": "ExplicitBase"
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "valueCategory": "prvalue",
+// CHECK-NEXT:   "ctorType": {
+// CHECK-NEXT: "qualType": "void (ExplicitBase &&)"
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "hadMultipleCandidates": true,
+// CHECK-NEXT:   "constructionKind": "non-virtual base",
+
+// CHECK:  "kind": "MaterializeTemporaryExpr",
+// CHECK:  "type": {
+// CHECK-NEXT:   "qualType": "ExplicitBase"
+// CHECK-NEXT: },
+// CHECK-NEXT: "valueCategory": "xvalue",
+// CHECK-NEXT: "storageDuration": "full expression",
+
+// CHECK:"kind": "CXXBindTemporaryExpr",
+// CHECK:"type": {
+// CHECK-NEXT: "qualType": "ExplicitBase"
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "valueCategory": "prvalue",
+
+// CHECK:  "kind": "CXXTemporaryObjectExpr",
+// CHECK:  "type": {
+// CHECK-NEXT:   "qualType": "ExplicitBase"
+// CHECK-NEXT: },
+// CHECK-NEXT: "valueCategory": "prvalue",
+// CHECK-NEXT: "ctorType": {
+// CHECK-NEXT:   "qualType": "void (const char *)"
+// CHECK-NEXT: },
+// CHECK-NEXT: "list": true,
+// CHECK-NEXT: "hadMultipleCandidates": true,
+// CHECK-NEXT: "constructionKind": "complete",
+
+// CHECK:"kind": "ImplicitCastExpr",
+// CHECK:"type": {
+// CHECK-NEXT: "qualType": "const char *"
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "valueCategory": "prvalue",
+// CHECK-NEXT:   "castKind": "ArrayToPointerDecay",
+
+// CHECK:  "kind": "StringLiteral",
+// CHECK:  "type": {
+// CHECK-NEXT:   "qualType": "const char[10]"
+// CHECK-NEXT: },
+// CHECK-NEXT: "valueCategory": "lvalue",
+// CHECK-NEXT: "value": "\"Move Ctor\""
+  return Derived1{ExplicitBase{"Move Ctor"}};
+}
+
+struct ImplicitBase {
+  ImplicitBase(co

[clang] [Clang][Sema] Add a test for move ctor calling for a base class. NFC (PR #97164)

2024-07-28 Thread Pavel Samolysov via cfe-commits

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


[clang] bb06453 - [Clang][CTAD][NFC] Unify transformTemplateParameter() (#100865)

2024-07-28 Thread via cfe-commits

Author: Younan Zhang
Date: 2024-07-28T19:34:23+08:00
New Revision: bb064535bd071c1bddaf55ff7fe283fc8d23c1fc

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

LOG: [Clang][CTAD][NFC] Unify transformTemplateParameter() (#100865)

We ended up having two transformTemplateParameter() after CTAD for type
aliases was landed. This patch cleans them up and allows them to share
one implementation.

As a bonus, this also uses getDepthAndIndex() in preference to
getTemplateParameter{Depth,Index}().

Added: 


Modified: 
clang/lib/Sema/SemaTemplateDeductionGuide.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp 
b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
index 0602d07c6b9b0..545da21183c3c 100644
--- a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
+++ b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
@@ -39,6 +39,7 @@
 #include "clang/Sema/Overload.h"
 #include "clang/Sema/Ownership.h"
 #include "clang/Sema/Scope.h"
+#include "clang/Sema/SemaInternal.h"
 #include "clang/Sema/Template.h"
 #include "clang/Sema/TemplateDeduction.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -241,11 +242,10 @@ NamedDecl *buildDeductionGuide(
 }
 
 // Transform a given template type parameter `TTP`.
-TemplateTypeParmDecl *
-transformTemplateTypeParam(Sema &SemaRef, DeclContext *DC,
-   TemplateTypeParmDecl *TTP,
-   MultiLevelTemplateArgumentList &Args,
-   unsigned NewDepth, unsigned NewIndex) {
+TemplateTypeParmDecl *transformTemplateTypeParam(
+Sema &SemaRef, DeclContext *DC, TemplateTypeParmDecl *TTP,
+MultiLevelTemplateArgumentList &Args, unsigned NewDepth, unsigned NewIndex,
+bool EvaluateConstraint) {
   // TemplateTypeParmDecl's index cannot be changed after creation, so
   // substitute it directly.
   auto *NewTTP = TemplateTypeParmDecl::Create(
@@ -257,7 +257,7 @@ transformTemplateTypeParam(Sema &SemaRef, DeclContext *DC,
   : std::nullopt);
   if (const auto *TC = TTP->getTypeConstraint())
 SemaRef.SubstTypeConstraint(NewTTP, TC, Args,
-/*EvaluateConstraint=*/true);
+/*EvaluateConstraint=*/EvaluateConstraint);
   if (TTP->hasDefaultArgument()) {
 TemplateArgumentLoc InstantiatedDefaultArg;
 if (!SemaRef.SubstTemplateArgument(
@@ -284,6 +284,22 @@ transformTemplateParam(Sema &SemaRef, DeclContext *DC,
   return NewParam;
 }
 
+NamedDecl *transformTemplateParameter(Sema &SemaRef, DeclContext *DC,
+  NamedDecl *TemplateParam,
+  MultiLevelTemplateArgumentList &Args,
+  unsigned NewIndex, unsigned NewDepth,
+  bool EvaluateConstraint = true) {
+  if (auto *TTP = dyn_cast(TemplateParam))
+return transformTemplateTypeParam(
+SemaRef, DC, TTP, Args, NewDepth, NewIndex,
+/*EvaluateConstraint=*/EvaluateConstraint);
+  if (auto *TTP = dyn_cast(TemplateParam))
+return transformTemplateParam(SemaRef, DC, TTP, Args, NewIndex, NewDepth);
+  if (auto *NTTP = dyn_cast(TemplateParam))
+return transformTemplateParam(SemaRef, DC, NTTP, Args, NewIndex, NewDepth);
+  llvm_unreachable("Unhandled template parameter types");
+}
+
 /// Transform to convert portions of a constructor declaration into the
 /// corresponding deduction guide, per C++1z [over.match.class.deduct]p1.
 struct ConvertConstructorToDeductionGuideTransform {
@@ -358,7 +374,9 @@ struct ConvertConstructorToDeductionGuideTransform {
 Args.addOuterRetainedLevel();
 if (NestedPattern)
   Args.addOuterRetainedLevels(NestedPattern->getTemplateDepth());
-NamedDecl *NewParam = transformTemplateParameter(Param, Args);
+auto [Depth, Index] = getDepthAndIndex(Param);
+NamedDecl *NewParam = transformTemplateParameter(
+SemaRef, DC, Param, Args, Index + Depth1IndexAdjustment, Depth - 
1);
 if (!NewParam)
   return nullptr;
 // Constraints require that we substitute depth-1 arguments
@@ -366,12 +384,11 @@ struct ConvertConstructorToDeductionGuideTransform {
 Depth1Args.push_back(SemaRef.Context.getInjectedTemplateArg(NewParam));
 
 if (NestedPattern) {
-  TemplateDeclInstantiator Instantiator(SemaRef, DC,
-OuterInstantiationArgs);
-  Instantiator.setEvaluateConstraints(false);
-  SemaRef.runWithSufficientStackSpace(NewParam->getLocation(), [&] {
-NewParam = cast(Instantiator.Visit(NewParam));
-  });
+  auto [Depth, Index] = getDepthAndIndex(NewParam);
+  NewParam = transformTemplateParameter(
+  S

[clang] [Clang][CTAD][NFC] Unify transformTemplateParameter() (PR #100865)

2024-07-28 Thread Younan Zhang via cfe-commits

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


[clang] [Clang][CTAD][NFC] Unify transformTemplateParameter() (PR #100865)

2024-07-28 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-buildbot2` while building `clang` at step 2 "annotate".

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

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)
...
[372/377] Generating MSAN_INST_GTEST.gtest-all.cc.x86_64.o
[373/377] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.x86_64-with-call.o
[374/377] Generating Msan-x86_64-with-call-Test
[375/377] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.x86_64.o
[376/377] Generating Msan-x86_64-Test
[376/377] Running compiler_rt regression tests
llvm-lit: 
/b/sanitizer-x86_64-linux/build/llvm-project/llvm/utils/lit/lit/discovery.py:276:
 warning: input 
'/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/rtsan/X86_64LinuxConfig'
 contained no tests
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: 4485 of 10144 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60
FAIL: SanitizerCommon-lsan-i386-Linux :: Linux/soft_rss_limit_mb_test.cpp (2940 
of 4485)
 TEST 'SanitizerCommon-lsan-i386-Linux :: 
Linux/soft_rss_limit_mb_test.cpp' FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 2: /b/sanitizer-x86_64-linux/build/build_default/./bin/clang  
--driver-mode=g++ -gline-tables-only -fsanitize=leak  -m32 -funwind-tables  
-I/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O2 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp
 -o 
/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-i386-Linux/Linux/Output/soft_rss_limit_mb_test.cpp.tmp
+ /b/sanitizer-x86_64-linux/build/build_default/./bin/clang --driver-mode=g++ 
-gline-tables-only -fsanitize=leak -m32 -funwind-tables 
-I/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O2 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp
 -o 
/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-i386-Linux/Linux/Output/soft_rss_limit_mb_test.cpp.tmp
RUN: at line 5: env 
LSAN_OPTIONS=soft_rss_limit_mb=220:quarantine_size=1:allocator_may_return_null=1
  
/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-i386-Linux/Linux/Output/soft_rss_limit_mb_test.cpp.tmp
 2>&1 | FileCheck 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp
 -check-prefix=CHECK_MAY_RETURN_1
+ env 
LSAN_OPTIONS=soft_rss_limit_mb=220:quarantine_size=1:allocator_may_return_null=1
 
/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-i386-Linux/Linux/Output/soft_rss_limit_mb_test.cpp.tmp
+ FileCheck 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp
 -check-prefix=CHECK_MAY_RETURN_1
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp:68:24:
 error: CHECK_MAY_RETURN_1: expected string not found in input
// CHECK_MAY_RETURN_1: allocating 512 times
   ^
:52:44: note: scanning from here
Some of the malloc calls returned non-null: 256
   ^
:53:13: note: possible intended match here
==262935==LeakSanitizer: soft rss limit unexhausted (220Mb vs 28Mb)
^

Input file: 
Check file: 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp

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

Input was:
<<
.
.
.
   47:  [256] 
   48:  [320] 
   49:  [384] 
   50:  [448] 
   51: Some of the malloc calls returned null: 256 
   52: Some of the malloc calls returned non-null: 256 
check:68'0X error: no match 
found
   53: ==262935==LeakSanitizer: soft rss limit unexhausted (220Mb vs 
28Mb) 
Step 11 (test compiler-rt debug) failure: test compiler-rt debug (failure)
...
[372/377] Generating MSAN_INST_GTEST.gtest-all.cc.x86_64.o
[373/377] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.x86_64-with-call.o
[374/377] Generating Msan-x86_64-with-call-Test
[375/377] Generatin

[clang-tools-extra] [clang-tidy] Only expand macros in modernize-use-std-format/print (PR #97911)

2024-07-28 Thread Julian Schmidt via cfe-commits

https://github.com/5chmidti approved this pull request.

Looks good from my side

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


[clang] [sanitizer] Document AddressSanitizer security considerations (PR #100937)

2024-07-28 Thread via cfe-commits

https://github.com/bigb4ng created 
https://github.com/llvm/llvm-project/pull/100937

Follow-up to #92593.

Also makes #92611, https://github.com/google/sanitizers/issues/1130  obsolete.

>From e37995b0c83ee6b090ea7a2042e8a2b82799ac4e Mon Sep 17 00:00:00 2001
From: bigb4ng <130478744+bigb...@users.noreply.github.com>
Date: Sun, 28 Jul 2024 18:26:38 +0300
Subject: [PATCH] [sanitizer] Document AddressSanitizer security considerations

Follow-up to PR #92593
---
 clang/docs/AddressSanitizer.rst | 8 
 1 file changed, 8 insertions(+)

diff --git a/clang/docs/AddressSanitizer.rst b/clang/docs/AddressSanitizer.rst
index e1997153f2037..d543b49d64c05 100644
--- a/clang/docs/AddressSanitizer.rst
+++ b/clang/docs/AddressSanitizer.rst
@@ -313,6 +313,14 @@ Limitations
   usually expected.
 * Static linking of executables is not supported.
 
+Security Considerations
+===
+
+AddressSanitizer is a bug detection tool and is not meant to be linked
+against production executables. While it may be useful for testing,
+AddressSanitizer's runtime was not developed with security-sensitive
+constraints in mind and may compromise the security of the resulting 
executable.
+
 Supported Platforms
 ===
 

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


[clang] [sanitizer] Document AddressSanitizer security considerations (PR #100937)

2024-07-28 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/100937
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [sanitizer] Document AddressSanitizer security considerations (PR #100937)

2024-07-28 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (bigb4ng)


Changes

Follow-up to #92593.

Also makes #92611, https://github.com/google/sanitizers/issues/1130  
obsolete.

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


1 Files Affected:

- (modified) clang/docs/AddressSanitizer.rst (+8) 


``diff
diff --git a/clang/docs/AddressSanitizer.rst b/clang/docs/AddressSanitizer.rst
index e1997153f2037..d543b49d64c05 100644
--- a/clang/docs/AddressSanitizer.rst
+++ b/clang/docs/AddressSanitizer.rst
@@ -313,6 +313,14 @@ Limitations
   usually expected.
 * Static linking of executables is not supported.
 
+Security Considerations
+===
+
+AddressSanitizer is a bug detection tool and is not meant to be linked
+against production executables. While it may be useful for testing,
+AddressSanitizer's runtime was not developed with security-sensitive
+constraints in mind and may compromise the security of the resulting 
executable.
+
 Supported Platforms
 ===
 

``




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


[clang-tools-extra] [clang-tidy] Only expand macros in modernize-use-std-format/print (PR #97911)

2024-07-28 Thread Mike Crowe via cfe-commits

https://github.com/mikecrowe updated 
https://github.com/llvm/llvm-project/pull/97911

>From f7be65b1581e49bb18b3ab613686daedcd71b4d9 Mon Sep 17 00:00:00 2001
From: Mike Crowe 
Date: Wed, 12 Jun 2024 21:06:26 +0100
Subject: [PATCH] [clang-tidy] Only expand  macros in
 modernize-use-std-format/print

Expanding all macros in the printf/absl::StrFormat format string before
conversion could easily break code if those macros are expended to
change their definition between builds. It's important for this check to
expand the  PRI macros though, so let's ensure that the
presence of any other macros in the format string causes the check to
emit a warning and not perform any conversion.
---
 .../modernize/UseStdFormatCheck.cpp   |  7 +-
 .../clang-tidy/modernize/UseStdFormatCheck.h  |  1 +
 .../clang-tidy/modernize/UseStdPrintCheck.cpp |  4 +-
 .../clang-tidy/modernize/UseStdPrintCheck.h   |  1 +
 .../utils/FormatStringConverter.cpp   | 65 +--
 .../clang-tidy/utils/FormatStringConverter.h  |  7 +-
 clang-tools-extra/docs/ReleaseNotes.rst   |  8 ++
 .../checks/modernize/use-std-print.rst| 22 +++---
 .../checkers/Inputs/Headers/inttypes.h| 26 +++---
 .../checkers/modernize/use-std-format.cpp | 79 ---
 .../checkers/modernize/use-std-print.cpp  | 73 -
 11 files changed, 253 insertions(+), 40 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp
index 6cef21f1318a2..6deac7a0b88ec 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp
@@ -44,6 +44,7 @@ void UseStdFormatCheck::registerPPCallbacks(const 
SourceManager &SM,
 Preprocessor *PP,
 Preprocessor *ModuleExpanderPP) {
   IncludeInserter.registerPreprocessor(PP);
+  this->PP = PP;
 }
 
 void UseStdFormatCheck::registerMatchers(MatchFinder *Finder) {
@@ -76,9 +77,9 @@ void UseStdFormatCheck::check(const MatchFinder::MatchResult 
&Result) {
 
   utils::FormatStringConverter::Configuration ConverterConfig;
   ConverterConfig.StrictMode = StrictMode;
-  utils::FormatStringConverter Converter(Result.Context, StrFormat,
- FormatArgOffset, ConverterConfig,
- getLangOpts());
+  utils::FormatStringConverter Converter(
+  Result.Context, StrFormat, FormatArgOffset, ConverterConfig,
+  getLangOpts(), *Result.SourceManager, *PP);
   const Expr *StrFormatCall = StrFormat->getCallee();
   if (!Converter.canApply()) {
 diag(StrFormat->getBeginLoc(),
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h 
b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h
index b59a4708c6e4b..9ac2240212ebf 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h
@@ -44,6 +44,7 @@ class UseStdFormatCheck : public ClangTidyCheck {
   StringRef ReplacementFormatFunction;
   utils::IncludeInserter IncludeInserter;
   std::optional MaybeHeaderToInclude;
+  Preprocessor *PP = nullptr;
 };
 
 } // namespace clang::tidy::modernize
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
index ff990feadc0c1..0ab92d0f05282 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
@@ -68,6 +68,7 @@ void UseStdPrintCheck::registerPPCallbacks(const 
SourceManager &SM,
Preprocessor *PP,
Preprocessor *ModuleExpanderPP) {
   IncludeInserter.registerPreprocessor(PP);
+  this->PP = PP;
 }
 
 static clang::ast_matchers::StatementMatcher
@@ -133,7 +134,8 @@ void UseStdPrintCheck::check(const MatchFinder::MatchResult 
&Result) {
   ConverterConfig.StrictMode = StrictMode;
   ConverterConfig.AllowTrailingNewlineRemoval = true;
   utils::FormatStringConverter Converter(
-  Result.Context, Printf, FormatArgOffset, ConverterConfig, getLangOpts());
+  Result.Context, Printf, FormatArgOffset, ConverterConfig, getLangOpts(),
+  *Result.SourceManager, *PP);
   const Expr *PrintfCall = Printf->getCallee();
   const StringRef ReplacementFunction = Converter.usePrintNewlineFunction()
 ? ReplacementPrintlnFunction
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.h 
b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.h
index 7a06cf38b4264..995c740389e73 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.h
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.h
@@ -36,6 +36,7 @@ class UseStdPrintCheck : public ClangTidyCheck {
   }
 
 

[clang-tools-extra] [clang-tidy] Only expand macros in modernize-use-std-format/print (PR #97911)

2024-07-28 Thread Mike Crowe via cfe-commits

mikecrowe wrote:

@5chmidti wrote:
> Looks good from my side

Thanks. I've squashed and rebased. Since 19 has been branched now and it 
includes *modernize-use-std-format* I've mentioned the improvement as being for 
both *modernize-use-std-print* and *modernize-use-std-format* in the release 
notes whilst I was resolving the conflict.

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


[clang-tools-extra] [clang-tidy] Only expand macros in modernize-use-std-format/print (PR #97911)

2024-07-28 Thread Mike Crowe via cfe-commits

https://github.com/mikecrowe updated 
https://github.com/llvm/llvm-project/pull/97911

>From 71dedefaf4dd8725b9a94e50c8f4d43b0e8bc4b2 Mon Sep 17 00:00:00 2001
From: Mike Crowe 
Date: Wed, 12 Jun 2024 21:06:26 +0100
Subject: [PATCH] [clang-tidy] Only expand  macros in
 modernize-use-std-format/print

Expanding all macros in the printf/absl::StrFormat format string before
conversion could easily break code if those macros are expended to
change their definition between builds. It's important for this check to
expand the  PRI macros though, so let's ensure that the
presence of any other macros in the format string causes the check to
emit a warning and not perform any conversion.
---
 .../modernize/UseStdFormatCheck.cpp   |  7 +-
 .../clang-tidy/modernize/UseStdFormatCheck.h  |  1 +
 .../clang-tidy/modernize/UseStdPrintCheck.cpp |  4 +-
 .../clang-tidy/modernize/UseStdPrintCheck.h   |  1 +
 .../utils/FormatStringConverter.cpp   | 65 +--
 .../clang-tidy/utils/FormatStringConverter.h  |  7 +-
 clang-tools-extra/docs/ReleaseNotes.rst   | 10 +++
 .../checks/modernize/use-std-print.rst| 22 +++---
 .../checkers/Inputs/Headers/inttypes.h| 26 +++---
 .../checkers/modernize/use-std-format.cpp | 79 ---
 .../checkers/modernize/use-std-print.cpp  | 73 -
 11 files changed, 255 insertions(+), 40 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp
index 6cef21f1318a2..6deac7a0b88ec 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp
@@ -44,6 +44,7 @@ void UseStdFormatCheck::registerPPCallbacks(const 
SourceManager &SM,
 Preprocessor *PP,
 Preprocessor *ModuleExpanderPP) {
   IncludeInserter.registerPreprocessor(PP);
+  this->PP = PP;
 }
 
 void UseStdFormatCheck::registerMatchers(MatchFinder *Finder) {
@@ -76,9 +77,9 @@ void UseStdFormatCheck::check(const MatchFinder::MatchResult 
&Result) {
 
   utils::FormatStringConverter::Configuration ConverterConfig;
   ConverterConfig.StrictMode = StrictMode;
-  utils::FormatStringConverter Converter(Result.Context, StrFormat,
- FormatArgOffset, ConverterConfig,
- getLangOpts());
+  utils::FormatStringConverter Converter(
+  Result.Context, StrFormat, FormatArgOffset, ConverterConfig,
+  getLangOpts(), *Result.SourceManager, *PP);
   const Expr *StrFormatCall = StrFormat->getCallee();
   if (!Converter.canApply()) {
 diag(StrFormat->getBeginLoc(),
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h 
b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h
index b59a4708c6e4b..9ac2240212ebf 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.h
@@ -44,6 +44,7 @@ class UseStdFormatCheck : public ClangTidyCheck {
   StringRef ReplacementFormatFunction;
   utils::IncludeInserter IncludeInserter;
   std::optional MaybeHeaderToInclude;
+  Preprocessor *PP = nullptr;
 };
 
 } // namespace clang::tidy::modernize
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
index ff990feadc0c1..0ab92d0f05282 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
@@ -68,6 +68,7 @@ void UseStdPrintCheck::registerPPCallbacks(const 
SourceManager &SM,
Preprocessor *PP,
Preprocessor *ModuleExpanderPP) {
   IncludeInserter.registerPreprocessor(PP);
+  this->PP = PP;
 }
 
 static clang::ast_matchers::StatementMatcher
@@ -133,7 +134,8 @@ void UseStdPrintCheck::check(const MatchFinder::MatchResult 
&Result) {
   ConverterConfig.StrictMode = StrictMode;
   ConverterConfig.AllowTrailingNewlineRemoval = true;
   utils::FormatStringConverter Converter(
-  Result.Context, Printf, FormatArgOffset, ConverterConfig, getLangOpts());
+  Result.Context, Printf, FormatArgOffset, ConverterConfig, getLangOpts(),
+  *Result.SourceManager, *PP);
   const Expr *PrintfCall = Printf->getCallee();
   const StringRef ReplacementFunction = Converter.usePrintNewlineFunction()
 ? ReplacementPrintlnFunction
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.h 
b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.h
index 7a06cf38b4264..995c740389e73 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.h
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.h
@@ -36,6 +36,7 @@ class UseStdPrintCheck : public ClangTidyCheck {
   }
 

[clang] [clang-format] Add ability for clang-format-diff to exit with non-0 status (PR #70883)

2024-07-28 Thread Philip Chimento via cfe-commits


@@ -185,6 +191,8 @@ def main():
 diff_string = "".join(diff)
 if len(diff_string) > 0:
 sys.stdout.write(diff_string)
+if args.non_zero_exit_code:
+sys.exit(1)

ptomato wrote:

A valid use case would be to distinguish errors in the clang-format-diff script 
(e.g., from executing it with incorrect arguments) from formatting changes.

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


[clang] [libclang/python] Export all enums (PR #100941)

2024-07-28 Thread Jannick Kremer via cfe-commits

https://github.com/DeinAlptraum created 
https://github.com/llvm/llvm-project/pull/100941

This resolves #48212 and also adds the remaining unexposed Enums

>From c4007832c8ed7cdb56aceebcf61b24ecb75f2aa4 Mon Sep 17 00:00:00 2001
From: Jannick Kremer 
Date: Sun, 28 Jul 2024 18:30:35 +0100
Subject: [PATCH] [libclang/python] Export all enums

---
 clang/bindings/python/clang/cindex.py | 5 +
 1 file changed, 5 insertions(+)

diff --git a/clang/bindings/python/clang/cindex.py 
b/clang/bindings/python/clang/cindex.py
index be024da5e005c..d9009a8666338 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -4077,6 +4077,7 @@ def function_exists(self, name):
 conf = Config()
 
 __all__ = [
+"AccessSpecifier",
 "AvailabilityKind",
 "BinaryOperator",
 "Config",
@@ -4087,12 +4088,16 @@ def function_exists(self, name):
 "CursorKind",
 "Cursor",
 "Diagnostic",
+"ExceptionSpecificationKind",
 "File",
 "FixIt",
 "Index",
 "LinkageKind",
+"RefQualifierKind",
 "SourceLocation",
 "SourceRange",
+"StorageClass",
+"TemplateArgumentKind",
 "TLSKind",
 "TokenKind",
 "Token",

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


[clang] [libclang/python] Export all enums (PR #100941)

2024-07-28 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Jannick Kremer (DeinAlptraum)


Changes

This resolves #48212 and also adds the remaining unexposed Enums

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


1 Files Affected:

- (modified) clang/bindings/python/clang/cindex.py (+5) 


``diff
diff --git a/clang/bindings/python/clang/cindex.py 
b/clang/bindings/python/clang/cindex.py
index be024da5e005c..d9009a8666338 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -4077,6 +4077,7 @@ def function_exists(self, name):
 conf = Config()
 
 __all__ = [
+"AccessSpecifier",
 "AvailabilityKind",
 "BinaryOperator",
 "Config",
@@ -4087,12 +4088,16 @@ def function_exists(self, name):
 "CursorKind",
 "Cursor",
 "Diagnostic",
+"ExceptionSpecificationKind",
 "File",
 "FixIt",
 "Index",
 "LinkageKind",
+"RefQualifierKind",
 "SourceLocation",
 "SourceRange",
+"StorageClass",
+"TemplateArgumentKind",
 "TLSKind",
 "TokenKind",
 "Token",

``




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


[clang] [libclang/python] Export all enums (PR #100941)

2024-07-28 Thread Jannick Kremer via cfe-commits

DeinAlptraum wrote:

@Endilll can I ask you for a review again?

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


[clang] [clang-format] Rename variable more sensitively (PR #100943)

2024-07-28 Thread Nathan Sidwell via cfe-commits

https://github.com/urnathan created 
https://github.com/llvm/llvm-project/pull/100943

 I noticed the insensitively named `Blacklist` variable when looking at 
https://github.com/llvm/llvm-project/pull/100852. Let's renaming to 
`Disallowed`.

>From 9159beaeec23ea5336e62ba1b7710d784bba17f3 Mon Sep 17 00:00:00 2001
From: Nathan Sidwell 
Date: Sun, 28 Jul 2024 13:59:12 -0400
Subject: [PATCH] [clang-format] Rename variable more sensitively

---
 clang/lib/Format/UnwrappedLineParser.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index d406a531a5c0c..ed056b9dd5b75 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -2554,7 +2554,7 @@ bool UnwrappedLineParser::parseParens(TokenType 
AmpAmpTokenType) {
 const bool DoubleParens =
 Prev && Prev->is(tok::l_paren) && Next && Next->is(tok::r_paren);
 const auto *PrevPrev = Prev ? Prev->getPreviousNonComment() : nullptr;
-const bool Blacklisted =
+const bool Disallowed =
 PrevPrev &&
 (PrevPrev->isOneOf(tok::kw___attribute, tok::kw_decltype) ||
  (SeenEqual &&
@@ -2566,7 +2566,7 @@ bool UnwrappedLineParser::parseParens(TokenType 
AmpAmpTokenType) {
  (!NestedLambdas.empty() && !NestedLambdas.back())) &&
 Prev && Prev->isOneOf(tok::kw_return, tok::kw_co_return) && Next &&
 Next->is(tok::semi);
-if ((DoubleParens && !Blacklisted) || ReturnParens) {
+if ((DoubleParens && !Disallowed) || ReturnParens) {
   LeftParen->Optional = true;
   FormatTok->Optional = true;
 }

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


[clang] [clang-format] Rename variable more sensitively (PR #100943)

2024-07-28 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Nathan Sidwell (urnathan)


Changes

 I noticed the insensitively named `Blacklist` variable when looking at 
https://github.com/llvm/llvm-project/pull/100852. Let's renaming to 
`Disallowed`.

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


1 Files Affected:

- (modified) clang/lib/Format/UnwrappedLineParser.cpp (+2-2) 


``diff
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index d406a531a5c0c..ed056b9dd5b75 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -2554,7 +2554,7 @@ bool UnwrappedLineParser::parseParens(TokenType 
AmpAmpTokenType) {
 const bool DoubleParens =
 Prev && Prev->is(tok::l_paren) && Next && Next->is(tok::r_paren);
 const auto *PrevPrev = Prev ? Prev->getPreviousNonComment() : nullptr;
-const bool Blacklisted =
+const bool Disallowed =
 PrevPrev &&
 (PrevPrev->isOneOf(tok::kw___attribute, tok::kw_decltype) ||
  (SeenEqual &&
@@ -2566,7 +2566,7 @@ bool UnwrappedLineParser::parseParens(TokenType 
AmpAmpTokenType) {
  (!NestedLambdas.empty() && !NestedLambdas.back())) &&
 Prev && Prev->isOneOf(tok::kw_return, tok::kw_co_return) && Next &&
 Next->is(tok::semi);
-if ((DoubleParens && !Blacklisted) || ReturnParens) {
+if ((DoubleParens && !Disallowed) || ReturnParens) {
   LeftParen->Optional = true;
   FormatTok->Optional = true;
 }

``




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


[clang] [analyzer] Avoid crashes in the stream checker (PR #100901)

2024-07-28 Thread via cfe-commits

vabridgers wrote:

A little background on how this was found, and a few debugging notes. 

This was found in a daily static analysis systems level test that we drive 
internally on our daily integrations, on the lz4 project, found here 
https://github.com/lz4/lz4.git. There are a number of open source projects that 
we drive these daily code analysis tests on, and in this case we seemed to have 
caught a regression because previous tests had been passing. 

When I looked at state after a crash through gdb, the crash occurred because 
StateNull in method evalFopen was NULL, and StateNotNull was not NULL - so that 
seemed to indicate the assumeDual(State, RetVal) operation in method evalFopen 
had not returned expected non null states. That led me to look at RetSym and 
it's constraints in Program State. See below.

I suspect the change to add assumeNoAliasingWithStdStreams somehow is causing 
this since when I revert b60fec27fd1bbab8c2c7a77b4be7836a1beb326f ( [analyzer] 
Assume the result of 'fopen' can't alias with 'std{in,out,err}' (#100085) ) I 
do not see this problem.

(gdb) p StateNull
$1 = {Obj = 0x0}
(gdb) p StateNotNull
$2 = {Obj = 0x695e79b0}

(gdb) p RetSym->dump()
conj_$3{FILE *, LC2, S801, #1}$4 = void

(gdb) p State->dump()
"program_state": {
  "store": { "pointer": "0x695d40e0", "items": [
{ "cluster": "SymRegion{conj_$0{int &, LC1, no stmt, #0}}", "pointer": 
"0x695d3f60", "items": [
  { "kind": "Direct", "offset": 0, "value": "0 S32b" }
]}
  ]},
  "environment": { "pointer": "0x695dc890", "items": [
{ "lctx_id": 2, "location_context": "#0 Call", "calling": "b", "location": 
{ "line": 10, "column": 3, "file": "aa.c" }, "items": [
  { "stmt_id": 798, "kind": "ImplicitCastExpr", "pretty": "fopen", "value": 
"&code{fopen}" },
  { "stmt_id": 801, "kind": "CallExpr", "pretty": "fopen(&a, \"\")", 
"value": "&SymRegion{conj_$3{FILE *, LC2, S801, #1}}" },
  { "stmt_id": 807, "kind": "ImplicitCastExpr", "pretty": "&a", "value": 
"&a" },
  { "stmt_id": 813, "kind": "ImplicitCastExpr", "pretty": "\"\"", "value": 
"&Element{\"\",0 S64b,char}" }
]},
{ "lctx_id": 1, "location_context": "#1 Call", "calling": "b", "location": 
null, "items": [
  { "stmt_id": 864, "kind": "ImplicitCastExpr", "pretty": "b", "value": 
"&code{b}" }
]}
  ]},
  "constraints": [
{ "symbol": "conj_$3{FILE *, LC2, S801, #1}", "range": "{ [1, 
18446744073709551615] }" },
{ "symbol": "reg_$2", "range": "{ [0, 0] }" }
  ],


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


[clang] [clang-format] Exit clang-format-diff only after all diffs are printed (PR #86776)

2024-07-28 Thread Philip Chimento via cfe-commits

ptomato wrote:

Could this be backported to clang-format 18.x? It's a really inconvenient 
regression.

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


[clang] [clang-format] Handle parenthesized list in RemoveParentheses (PR #100852)

2024-07-28 Thread Björn Schäpers via cfe-commits

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


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


[clang] [clang-format] Fix the indent of the ternary operator when AlignOperands and BreakBeforeTernaryOperators is specified. (PR #100860)

2024-07-28 Thread Björn Schäpers via cfe-commits

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

You are changing a lot of test cases, that means you will break a lot of 
formattings out there, especially since this is the default behavior of 
clang-format. And someone did intend it that way.

If the change is desired, the `BreakBeforeTernaryOperators` option should be 
expanded to an enum or `AlignOperands` extended.

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


[clang] [flang] [Flang-new][OpenMP] Add bitcode files for AMD GPU OpenMP (PR #96742)

2024-07-28 Thread Andrzej Warzyński via cfe-commits

banach-space wrote:

> > > > Who could be the right person to ask?
> > > 
> > > 
> > > I don't know. Open-source LLVM Flang meetings can be good place to ask 
> > > this question.
> > 
> > 
> > Did you ask? What feedback did you get?
> 
> @banach-space I asked question on flang-slack, I mentioned the issue on the 
> latest Flang technical meeting and I described potential solution here: 
> https://discourse.llvm.org/t/offloading-on-nvptx64-target-with-flang-new-leads-to-undefined-reference-s/80237
>  . I got no feedback.
> 
> Can I merge this PR? The issue with -`fcuda-is-device` is resolved. If you 
> wish I can extend driver checks for `-mlink-builtin-bitcode` as a separate PR.

Thanks for following-up! Overall this looks good to me, but please update the 
summary with some details/context, e.g.
* why are you adding `-nogpulib` in tests?
* "Flang-new needs to add mlink-builtin-bitcode" - please add a note explaining 
that this flag is added by `addClangTargetOptions()` (that wasn't obvious to 
me).

Approving as is, no need to wait for me to take another look.

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


[clang] [flang] [Flang-new][OpenMP] Add bitcode files for AMD GPU OpenMP (PR #96742)

2024-07-28 Thread Andrzej Warzyński via cfe-commits

https://github.com/banach-space approved this pull request.


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


[clang] [flang] [Flang-new][OpenMP] Add bitcode files for AMD GPU OpenMP (PR #96742)

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

jhuber6 wrote:

What are we relying on `-mlink-builtin-bitcode` for right now? IIUC it's mostly 
just math, right?

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


[clang] [llvm] [LLVM][PassBuilder] Extend the function signature of callback for optimizer pipeline extension point (PR #100945)

2024-07-28 Thread Shilei Tian via cfe-commits

https://github.com/shiltian created 
https://github.com/llvm/llvm-project/pull/100945

These callbacks can be invoked in multiple places when building an optimization
pipeline, both in compile time and link time. However, there is no indicator on
what pipeline it is currently building.

In this patch, an extra argument is added to indicate its (Thin)LTO stage such
that the callback can check it if needed. There is no test expected from this,
and the benefit of this change will be demonstrated in 
https://github.com/llvm/llvm-project/pull/66488.

>From 414399bd34076e3efa852d4687f8890d5a6001c4 Mon Sep 17 00:00:00 2001
From: Shilei Tian 
Date: Sun, 28 Jul 2024 15:28:09 -0400
Subject: [PATCH] [LLVM][PassBuilder] Extend the function signature of callback
 for optimizer pipeline extension point

These callbacks can be invoked in multiple places when building an optimization
pipeline, both in compile time and link time. However, there is no indicator on
what pipeline it is currently building.

In this patch, an extra argument is added to indicate its (Thin)LTO stage such
that the callback can check it if needed. There is no test expected from this,
and the benefit of this change will be demonstrated in 
https://github.com/llvm/llvm-project/pull/66488.
---
 clang/lib/CodeGen/BackendUtil.cpp | 30 ++-
 llvm/include/llvm/Passes/PassBuilder.h| 10 +--
 llvm/lib/Passes/PassBuilderPipelines.cpp  | 12 
 llvm/lib/Target/AMDGPU/AMDGPU.h   |  7 -
 llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp   | 11 ---
 .../lib/Target/AMDGPU/AMDGPUTargetMachine.cpp | 15 ++
 llvm/tools/opt/NewPMDriver.cpp|  2 +-
 7 files changed, 53 insertions(+), 34 deletions(-)

diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index e765bbf637a66..e60604155fcde 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -642,12 +642,13 @@ static void addKCFIPass(const Triple &TargetTriple, const 
LangOptions &LangOpts,
 return;
 
   // Ensure we lower KCFI operand bundles with -O0.
-  PB.registerOptimizerLastEPCallback(
-  [&](ModulePassManager &MPM, OptimizationLevel Level) {
-if (Level == OptimizationLevel::O0 &&
-LangOpts.Sanitize.has(SanitizerKind::KCFI))
-  MPM.addPass(createModuleToFunctionPassAdaptor(KCFIPass()));
-  });
+  PB.registerOptimizerLastEPCallback([&](ModulePassManager &MPM,
+ OptimizationLevel Level,
+ ThinOrFullLTOPhase Phase) {
+if (Level == OptimizationLevel::O0 &&
+LangOpts.Sanitize.has(SanitizerKind::KCFI))
+  MPM.addPass(createModuleToFunctionPassAdaptor(KCFIPass()));
+  });
 
   // When optimizations are requested, run KCIFPass after InstCombine to
   // avoid unnecessary checks.
@@ -662,8 +663,8 @@ static void addKCFIPass(const Triple &TargetTriple, const 
LangOptions &LangOpts,
 static void addSanitizers(const Triple &TargetTriple,
   const CodeGenOptions &CodeGenOpts,
   const LangOptions &LangOpts, PassBuilder &PB) {
-  auto SanitizersCallback = [&](ModulePassManager &MPM,
-OptimizationLevel Level) {
+  auto SanitizersCallback = [&](ModulePassManager &MPM, OptimizationLevel 
Level,
+ThinOrFullLTOPhase) {
 if (CodeGenOpts.hasSanitizeCoverage()) {
   auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
   MPM.addPass(SanitizerCoveragePass(
@@ -749,7 +750,7 @@ static void addSanitizers(const Triple &TargetTriple,
 PB.registerOptimizerEarlyEPCallback(
 [SanitizersCallback](ModulePassManager &MPM, OptimizationLevel Level) {
   ModulePassManager NewMPM;
-  SanitizersCallback(NewMPM, Level);
+  SanitizersCallback(NewMPM, Level, ThinOrFullLTOPhase::None);
   if (!NewMPM.isEmpty()) {
 // Sanitizers can abandon.
 NewMPM.addPass(RequireAnalysisPass());
@@ -1018,11 +1019,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 // TODO: Consider passing the MemoryProfileOutput to the pass builder via
 // the PGOOptions, and set this up there.
 if (!CodeGenOpts.MemoryProfileOutput.empty()) {
-  PB.registerOptimizerLastEPCallback(
-  [](ModulePassManager &MPM, OptimizationLevel Level) {
-MPM.addPass(createModuleToFunctionPassAdaptor(MemProfilerPass()));
-MPM.addPass(ModuleMemProfilerPass());
-  });
+  PB.registerOptimizerLastEPCallback([](ModulePassManager &MPM,
+OptimizationLevel Level,
+ThinOrFullLTOPhase) {
+MPM.addPass(createModuleToFunctionPassAdaptor(MemProfilerPass()));
+MPM.addPass(ModuleMemProfilerPass());
+  });
 }
 
 if (CodeGenOpts.FatLTO) {
diff --git a/llvm/include/llvm/Pas

[clang] [llvm] [LLVM][PassBuilder] Extend the function signature of callback for optimizer pipeline extension point (PR #100945)

2024-07-28 Thread Shilei Tian via cfe-commits

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


[clang] [llvm] [LLVM][PassBuilder] Extend the function signature of callback for optimizer pipeline extension point (PR #100945)

2024-07-28 Thread Shilei Tian via cfe-commits

shiltian wrote:

* **#100945** https://app.graphite.dev/github/pr/llvm/llvm-project/100945?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/> 👈
* `main`

This stack of pull requests is managed by Graphite. https://stacking.dev/?utm_source=stack-comment";>Learn more about 
stacking.


 Join @shiltian and the rest of your teammates on https://graphite.dev?utm-source=stack-comment";>https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="11px" height="11px"/> Graphite
  

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


[clang] [llvm] [LLVM][PassBuilder] Extend the function signature of callback for optimizer pipeline extension point (PR #100945)

2024-07-28 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-codegen

Author: Shilei Tian (shiltian)


Changes

These callbacks can be invoked in multiple places when building an optimization
pipeline, both in compile time and link time. However, there is no indicator on
what pipeline it is currently building.

In this patch, an extra argument is added to indicate its (Thin)LTO stage such
that the callback can check it if needed. There is no test expected from this,
and the benefit of this change will be demonstrated in 
https://github.com/llvm/llvm-project/pull/66488.

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


7 Files Affected:

- (modified) clang/lib/CodeGen/BackendUtil.cpp (+16-14) 
- (modified) llvm/include/llvm/Passes/PassBuilder.h (+7-3) 
- (modified) llvm/lib/Passes/PassBuilderPipelines.cpp (+7-5) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPU.h (+6-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp (+7-4) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp (+9-6) 
- (modified) llvm/tools/opt/NewPMDriver.cpp (+1-1) 


``diff
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index e765bbf637a66..e60604155fcde 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -642,12 +642,13 @@ static void addKCFIPass(const Triple &TargetTriple, const 
LangOptions &LangOpts,
 return;
 
   // Ensure we lower KCFI operand bundles with -O0.
-  PB.registerOptimizerLastEPCallback(
-  [&](ModulePassManager &MPM, OptimizationLevel Level) {
-if (Level == OptimizationLevel::O0 &&
-LangOpts.Sanitize.has(SanitizerKind::KCFI))
-  MPM.addPass(createModuleToFunctionPassAdaptor(KCFIPass()));
-  });
+  PB.registerOptimizerLastEPCallback([&](ModulePassManager &MPM,
+ OptimizationLevel Level,
+ ThinOrFullLTOPhase Phase) {
+if (Level == OptimizationLevel::O0 &&
+LangOpts.Sanitize.has(SanitizerKind::KCFI))
+  MPM.addPass(createModuleToFunctionPassAdaptor(KCFIPass()));
+  });
 
   // When optimizations are requested, run KCIFPass after InstCombine to
   // avoid unnecessary checks.
@@ -662,8 +663,8 @@ static void addKCFIPass(const Triple &TargetTriple, const 
LangOptions &LangOpts,
 static void addSanitizers(const Triple &TargetTriple,
   const CodeGenOptions &CodeGenOpts,
   const LangOptions &LangOpts, PassBuilder &PB) {
-  auto SanitizersCallback = [&](ModulePassManager &MPM,
-OptimizationLevel Level) {
+  auto SanitizersCallback = [&](ModulePassManager &MPM, OptimizationLevel 
Level,
+ThinOrFullLTOPhase) {
 if (CodeGenOpts.hasSanitizeCoverage()) {
   auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
   MPM.addPass(SanitizerCoveragePass(
@@ -749,7 +750,7 @@ static void addSanitizers(const Triple &TargetTriple,
 PB.registerOptimizerEarlyEPCallback(
 [SanitizersCallback](ModulePassManager &MPM, OptimizationLevel Level) {
   ModulePassManager NewMPM;
-  SanitizersCallback(NewMPM, Level);
+  SanitizersCallback(NewMPM, Level, ThinOrFullLTOPhase::None);
   if (!NewMPM.isEmpty()) {
 // Sanitizers can abandon.
 NewMPM.addPass(RequireAnalysisPass());
@@ -1018,11 +1019,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 // TODO: Consider passing the MemoryProfileOutput to the pass builder via
 // the PGOOptions, and set this up there.
 if (!CodeGenOpts.MemoryProfileOutput.empty()) {
-  PB.registerOptimizerLastEPCallback(
-  [](ModulePassManager &MPM, OptimizationLevel Level) {
-MPM.addPass(createModuleToFunctionPassAdaptor(MemProfilerPass()));
-MPM.addPass(ModuleMemProfilerPass());
-  });
+  PB.registerOptimizerLastEPCallback([](ModulePassManager &MPM,
+OptimizationLevel Level,
+ThinOrFullLTOPhase) {
+MPM.addPass(createModuleToFunctionPassAdaptor(MemProfilerPass()));
+MPM.addPass(ModuleMemProfilerPass());
+  });
 }
 
 if (CodeGenOpts.FatLTO) {
diff --git a/llvm/include/llvm/Passes/PassBuilder.h 
b/llvm/include/llvm/Passes/PassBuilder.h
index 474a19531ff5d..4c2763404ff05 100644
--- a/llvm/include/llvm/Passes/PassBuilder.h
+++ b/llvm/include/llvm/Passes/PassBuilder.h
@@ -497,7 +497,8 @@ class PassBuilder {
   /// This extension point allows adding optimizations at the very end of the
   /// function optimization pipeline.
   void registerOptimizerLastEPCallback(
-  const std::function &C) {
+  const std::function &C) {
 OptimizerLastEPCallbacks.push_back(C);
   }
 
@@ -630,7 +631,8 @@ class PassBuilder {
   void invokeOptimizerEarlyEPCallbacks(ModulePassManager &MPM,
  

[clang] [llvm] [LLVM][PassBuilder] Extend the function signature of callback for optimizer pipeline extension point (PR #100945)

2024-07-28 Thread Shilei Tian via cfe-commits

https://github.com/shiltian updated 
https://github.com/llvm/llvm-project/pull/100945

>From b8c8357c3724031d85c96e3aa053acf402f3508e Mon Sep 17 00:00:00 2001
From: Shilei Tian 
Date: Sun, 28 Jul 2024 15:28:09 -0400
Subject: [PATCH] [LLVM][PassBuilder] Extend the function signature of callback
 for optimizer pipeline extension point

These callbacks can be invoked in multiple places when building an optimization
pipeline, both in compile time and link time. However, there is no indicator on
what pipeline it is currently building.

In this patch, an extra argument is added to indicate its (Thin)LTO stage such
that the callback can check it if needed. There is no test expected from this,
and the benefit of this change will be demonstrated in 
https://github.com/llvm/llvm-project/pull/66488.
---
 clang/lib/CodeGen/BackendUtil.cpp | 30 ++-
 llvm/include/llvm/Passes/PassBuilder.h| 10 +--
 llvm/lib/Passes/PassBuilderPipelines.cpp  | 12 
 llvm/lib/Target/AMDGPU/AMDGPU.h   |  7 -
 llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp   | 11 ---
 .../lib/Target/AMDGPU/AMDGPUTargetMachine.cpp | 15 ++
 llvm/tools/opt/NewPMDriver.cpp|  2 +-
 7 files changed, 53 insertions(+), 34 deletions(-)

diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index e765bbf637a66..4beec01e2afa0 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -642,12 +642,13 @@ static void addKCFIPass(const Triple &TargetTriple, const 
LangOptions &LangOpts,
 return;
 
   // Ensure we lower KCFI operand bundles with -O0.
-  PB.registerOptimizerLastEPCallback(
-  [&](ModulePassManager &MPM, OptimizationLevel Level) {
-if (Level == OptimizationLevel::O0 &&
-LangOpts.Sanitize.has(SanitizerKind::KCFI))
-  MPM.addPass(createModuleToFunctionPassAdaptor(KCFIPass()));
-  });
+  PB.registerOptimizerLastEPCallback([&](ModulePassManager &MPM,
+ OptimizationLevel Level,
+ ThinOrFullLTOPhase) {
+if (Level == OptimizationLevel::O0 &&
+LangOpts.Sanitize.has(SanitizerKind::KCFI))
+  MPM.addPass(createModuleToFunctionPassAdaptor(KCFIPass()));
+  });
 
   // When optimizations are requested, run KCIFPass after InstCombine to
   // avoid unnecessary checks.
@@ -662,8 +663,8 @@ static void addKCFIPass(const Triple &TargetTriple, const 
LangOptions &LangOpts,
 static void addSanitizers(const Triple &TargetTriple,
   const CodeGenOptions &CodeGenOpts,
   const LangOptions &LangOpts, PassBuilder &PB) {
-  auto SanitizersCallback = [&](ModulePassManager &MPM,
-OptimizationLevel Level) {
+  auto SanitizersCallback = [&](ModulePassManager &MPM, OptimizationLevel 
Level,
+ThinOrFullLTOPhase) {
 if (CodeGenOpts.hasSanitizeCoverage()) {
   auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
   MPM.addPass(SanitizerCoveragePass(
@@ -749,7 +750,7 @@ static void addSanitizers(const Triple &TargetTriple,
 PB.registerOptimizerEarlyEPCallback(
 [SanitizersCallback](ModulePassManager &MPM, OptimizationLevel Level) {
   ModulePassManager NewMPM;
-  SanitizersCallback(NewMPM, Level);
+  SanitizersCallback(NewMPM, Level, ThinOrFullLTOPhase::None);
   if (!NewMPM.isEmpty()) {
 // Sanitizers can abandon.
 NewMPM.addPass(RequireAnalysisPass());
@@ -1018,11 +1019,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 // TODO: Consider passing the MemoryProfileOutput to the pass builder via
 // the PGOOptions, and set this up there.
 if (!CodeGenOpts.MemoryProfileOutput.empty()) {
-  PB.registerOptimizerLastEPCallback(
-  [](ModulePassManager &MPM, OptimizationLevel Level) {
-MPM.addPass(createModuleToFunctionPassAdaptor(MemProfilerPass()));
-MPM.addPass(ModuleMemProfilerPass());
-  });
+  PB.registerOptimizerLastEPCallback([](ModulePassManager &MPM,
+OptimizationLevel Level,
+ThinOrFullLTOPhase) {
+MPM.addPass(createModuleToFunctionPassAdaptor(MemProfilerPass()));
+MPM.addPass(ModuleMemProfilerPass());
+  });
 }
 
 if (CodeGenOpts.FatLTO) {
diff --git a/llvm/include/llvm/Passes/PassBuilder.h 
b/llvm/include/llvm/Passes/PassBuilder.h
index 474a19531ff5d..4c2763404ff05 100644
--- a/llvm/include/llvm/Passes/PassBuilder.h
+++ b/llvm/include/llvm/Passes/PassBuilder.h
@@ -497,7 +497,8 @@ class PassBuilder {
   /// This extension point allows adding optimizations at the very end of the
   /// function optimization pipeline.
   void registerOptimizerLastEPCallback(
-  const std::function &C) {
+  const std::function &C) {
 Optimizer

[clang] [llvm] [LLVM][PassBuilder] Extend the function signature of callback for optimizer pipeline extension point (PR #100945)

2024-07-28 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 44df89cc30fc462dcb821929c6d5459688ffe545 
b8c8357c3724031d85c96e3aa053acf402f3508e --extensions h,cpp -- 
clang/lib/CodeGen/BackendUtil.cpp llvm/include/llvm/Passes/PassBuilder.h 
llvm/lib/Passes/PassBuilderPipelines.cpp llvm/lib/Target/AMDGPU/AMDGPU.h 
llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp 
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp llvm/tools/opt/NewPMDriver.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 4beec01e2a..64f0020a17 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -642,13 +642,12 @@ static void addKCFIPass(const Triple &TargetTriple, const 
LangOptions &LangOpts,
 return;
 
   // Ensure we lower KCFI operand bundles with -O0.
-  PB.registerOptimizerLastEPCallback([&](ModulePassManager &MPM,
- OptimizationLevel Level,
- ThinOrFullLTOPhase) {
-if (Level == OptimizationLevel::O0 &&
-LangOpts.Sanitize.has(SanitizerKind::KCFI))
-  MPM.addPass(createModuleToFunctionPassAdaptor(KCFIPass()));
-  });
+  PB.registerOptimizerLastEPCallback(
+  [&](ModulePassManager &MPM, OptimizationLevel Level, ThinOrFullLTOPhase) 
{
+if (Level == OptimizationLevel::O0 &&
+LangOpts.Sanitize.has(SanitizerKind::KCFI))
+  MPM.addPass(createModuleToFunctionPassAdaptor(KCFIPass()));
+  });
 
   // When optimizations are requested, run KCIFPass after InstCombine to
   // avoid unnecessary checks.

``




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


[clang] [llvm] [LLVM][PassBuilder] Extend the function signature of callback for optimizer pipeline extension point (PR #100945)

2024-07-28 Thread Shilei Tian via cfe-commits

https://github.com/shiltian updated 
https://github.com/llvm/llvm-project/pull/100945

>From d2bea2b14379a7fa2bc8477e97bc29f96aece791 Mon Sep 17 00:00:00 2001
From: Shilei Tian 
Date: Sun, 28 Jul 2024 15:28:09 -0400
Subject: [PATCH] [LLVM][PassBuilder] Extend the function signature of callback
 for optimizer pipeline extension point

These callbacks can be invoked in multiple places when building an optimization
pipeline, both in compile time and link time. However, there is no indicator on
what pipeline it is currently building.

In this patch, an extra argument is added to indicate its (Thin)LTO stage such
that the callback can check it if needed. There is no test expected from this,
and the benefit of this change will be demonstrated in 
https://github.com/llvm/llvm-project/pull/66488.
---
 clang/lib/CodeGen/BackendUtil.cpp | 19 ++-
 llvm/include/llvm/Passes/PassBuilder.h| 10 +++---
 llvm/lib/Passes/PassBuilderPipelines.cpp  | 12 +++-
 llvm/lib/Target/AMDGPU/AMDGPU.h   |  7 ++-
 llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp   | 11 +++
 .../lib/Target/AMDGPU/AMDGPUTargetMachine.cpp | 15 +--
 llvm/tools/opt/NewPMDriver.cpp|  2 +-
 7 files changed, 47 insertions(+), 29 deletions(-)

diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index e765bbf637a66..64f0020a170aa 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -643,7 +643,7 @@ static void addKCFIPass(const Triple &TargetTriple, const 
LangOptions &LangOpts,
 
   // Ensure we lower KCFI operand bundles with -O0.
   PB.registerOptimizerLastEPCallback(
-  [&](ModulePassManager &MPM, OptimizationLevel Level) {
+  [&](ModulePassManager &MPM, OptimizationLevel Level, ThinOrFullLTOPhase) 
{
 if (Level == OptimizationLevel::O0 &&
 LangOpts.Sanitize.has(SanitizerKind::KCFI))
   MPM.addPass(createModuleToFunctionPassAdaptor(KCFIPass()));
@@ -662,8 +662,8 @@ static void addKCFIPass(const Triple &TargetTriple, const 
LangOptions &LangOpts,
 static void addSanitizers(const Triple &TargetTriple,
   const CodeGenOptions &CodeGenOpts,
   const LangOptions &LangOpts, PassBuilder &PB) {
-  auto SanitizersCallback = [&](ModulePassManager &MPM,
-OptimizationLevel Level) {
+  auto SanitizersCallback = [&](ModulePassManager &MPM, OptimizationLevel 
Level,
+ThinOrFullLTOPhase) {
 if (CodeGenOpts.hasSanitizeCoverage()) {
   auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
   MPM.addPass(SanitizerCoveragePass(
@@ -749,7 +749,7 @@ static void addSanitizers(const Triple &TargetTriple,
 PB.registerOptimizerEarlyEPCallback(
 [SanitizersCallback](ModulePassManager &MPM, OptimizationLevel Level) {
   ModulePassManager NewMPM;
-  SanitizersCallback(NewMPM, Level);
+  SanitizersCallback(NewMPM, Level, ThinOrFullLTOPhase::None);
   if (!NewMPM.isEmpty()) {
 // Sanitizers can abandon.
 NewMPM.addPass(RequireAnalysisPass());
@@ -1018,11 +1018,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 // TODO: Consider passing the MemoryProfileOutput to the pass builder via
 // the PGOOptions, and set this up there.
 if (!CodeGenOpts.MemoryProfileOutput.empty()) {
-  PB.registerOptimizerLastEPCallback(
-  [](ModulePassManager &MPM, OptimizationLevel Level) {
-MPM.addPass(createModuleToFunctionPassAdaptor(MemProfilerPass()));
-MPM.addPass(ModuleMemProfilerPass());
-  });
+  PB.registerOptimizerLastEPCallback([](ModulePassManager &MPM,
+OptimizationLevel Level,
+ThinOrFullLTOPhase) {
+MPM.addPass(createModuleToFunctionPassAdaptor(MemProfilerPass()));
+MPM.addPass(ModuleMemProfilerPass());
+  });
 }
 
 if (CodeGenOpts.FatLTO) {
diff --git a/llvm/include/llvm/Passes/PassBuilder.h 
b/llvm/include/llvm/Passes/PassBuilder.h
index 474a19531ff5d..4c2763404ff05 100644
--- a/llvm/include/llvm/Passes/PassBuilder.h
+++ b/llvm/include/llvm/Passes/PassBuilder.h
@@ -497,7 +497,8 @@ class PassBuilder {
   /// This extension point allows adding optimizations at the very end of the
   /// function optimization pipeline.
   void registerOptimizerLastEPCallback(
-  const std::function &C) {
+  const std::function &C) {
 OptimizerLastEPCallbacks.push_back(C);
   }
 
@@ -630,7 +631,8 @@ class PassBuilder {
   void invokeOptimizerEarlyEPCallbacks(ModulePassManager &MPM,
OptimizationLevel Level);
   void invokeOptimizerLastEPCallbacks(ModulePassManager &MPM,
-  OptimizationLevel Level);
+  OptimizationLevel Level,
+

[clang] [libcxx] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-07-28 Thread Max Coplan via cfe-commits
Max =?utf-8?b?8J+RqPCfj73igI3wn5K7?= Copl
Message-ID:
In-Reply-To: 


https://github.com/vegerot updated 
https://github.com/llvm/llvm-project/pull/97926

>From 1f231975f2f6b59375bbe88241e533ec18725aaa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Max=20=F0=9F=91=A8=F0=9F=8F=BD=E2=80=8D=F0=9F=92=BB=20Copl?=
 =?UTF-8?q?an?= 
Date: Fri, 26 Jul 2024 14:56:12 -0700
Subject: [PATCH 1/2] [libcxx][regex] add `[[__fallthrough__]]` to suppress
 fallthrough warning

Summary:
The diff #97926 is stacked on top of this patch because this file
reports an error when enabling `-Wimplicit-fallthrough` in `-Wextra`.

Test plan:

```sh
$ time (mkdir build_runtimes && cd build_runtimes && set -x && 
CC=../build/bin/clang CXX=../build/bin/clang++ cmake -G Ninja ../runtimes 
-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi;libunwind'  
&& ninja && bin/llvm-lit -sv ../libcxx/test/std/re )
```

note: whether I put a `break;` or fallthrough, the tests pass anyways
which is sus.
---
 libcxx/include/regex | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/include/regex b/libcxx/include/regex
index b814135121321..17666fe4eaedf 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -3921,7 +3921,7 @@ _ForwardIterator basic_regex<_CharT, 
_Traits>::__parse_character_escape(
   if (__hd == -1)
 __throw_regex_error();
   __sum = 16 * __sum + static_cast(__hd);
-  // fallthrough
+  [[__fallthrough__]];
 case 'x':
   ++__first;
   if (__first == __last)

>From 5767b5f61d8d7d6272004542d9266acb524c1752 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Max=20=F0=9F=91=A8=F0=9F=8F=BD=E2=80=8D=F0=9F=92=BB=20Copl?=
 =?UTF-8?q?an?= 
Date: Sat, 6 Jul 2024 17:22:55 -0700
Subject: [PATCH 2/2] [clang] Add -Wimplicit-fallthrough to -Wextra

This patch adds -Wimplicit-fallthrough to -Wextra. GCC already includes it in 
-Wextra.

This patch also adds a test to check that -Wimplicit-fallthrough is included in 
-Wextra.

Note: This patch may regress performance when building with -Wextra.
This is because -Wextra requires forming a CFG for every function.
---
 clang/include/clang/Basic/DiagnosticGroups.td| 1 +
 clang/test/Sema/fallthrough-attr.c   | 1 +
 clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp | 1 +
 3 files changed, 3 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 19c3f1e043349..2a307679c9283 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1067,6 +1067,7 @@ def Extra : DiagGroup<"extra", [
 StringConcatation,
 FUseLdPath,
 CastFunctionTypeMismatch,
+ImplicitFallthrough,
   ]>;
 
 def Most : DiagGroup<"most", [
diff --git a/clang/test/Sema/fallthrough-attr.c 
b/clang/test/Sema/fallthrough-attr.c
index de50ebf39d42f..6cc19136f30a7 100644
--- a/clang/test/Sema/fallthrough-attr.c
+++ b/clang/test/Sema/fallthrough-attr.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -fsyntax-only -std=gnu99 -verify -Wimplicit-fallthrough %s
 // RUN: %clang_cc1 -fsyntax-only -std=c99 -verify -Wimplicit-fallthrough %s
 // RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wimplicit-fallthrough %s
+// RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wextra %s
 // RUN: %clang_cc1 -fsyntax-only -std=c2x -DC2X -verify -Wimplicit-fallthrough 
%s
 
 int fallthrough_attribute_spelling(int n) {
diff --git a/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp 
b/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
index 11df2cbfb53f0..cbbff1f1793b8 100644
--- a/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
+++ b/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCLANG_PREFIX -DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCOMMAND_LINE_FALLTHROUGH=[[fallthrough]] -DUNCHOSEN=[[clang::fallthrough]] %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wextra 
-DCOMMAND_LINE_FALLTHROUGH=[[fallthrough]] -DUNCHOSEN=[[clang::fallthrough]] %s
 
 int fallthrough_compatibility_macro_from_command_line(int n) {
   switch (n) {

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


[clang] [clang] check deduction consistency when partial ordering function templates (PR #100692)

2024-07-28 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/100692

>From 89e5db41f3d3bc939078b63d43b7181bfc765fd1 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Wed, 24 Jul 2024 03:59:41 -0300
Subject: [PATCH] [clang] check deduction consistency when partial ordering
 function templates

This makes partial ordering of function templates consistent with
other entities.

Fixes #18291
---
 clang/docs/ReleaseNotes.rst   |   2 +
 clang/include/clang/Sema/Sema.h   |   7 +-
 clang/lib/AST/ExprConstant.cpp|   1 -
 clang/lib/Sema/SemaTemplateDeduction.cpp  | 828 --
 clang/lib/Sema/SemaTemplateInstantiate.cpp|  29 +-
 .../test/CodeCompletion/variadic-template.cpp |   2 +-
 clang/test/Index/complete-call.cpp|   5 +-
 clang/test/SemaTemplate/GH18291.cpp   |  32 +
 clang/test/SemaTemplate/cwg2398.cpp   |  14 +
 clang/test/SemaTemplate/temp_arg_nontype.cpp  |  14 +-
 clang/test/SemaTemplate/temp_arg_type.cpp |   7 +-
 .../Templight/templight-empty-entries-fix.cpp |  92 +-
 12 files changed, 727 insertions(+), 306 deletions(-)
 create mode 100644 clang/test/SemaTemplate/GH18291.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 58f1c5af5..6098101a73a62 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -153,6 +153,8 @@ Bug Fixes to C++ Support
 
 - Fixed a crash when an expression with a dependent ``__typeof__`` type is 
used as the operand of a unary operator. (#GH97646)
 - Fixed a failed assertion when checking invalid delete operator declaration. 
(#GH96191)
+- When performing partial ordering of function templates, clang now checks that
+  the deduction was consistent. Fixes (#GH18291).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 2ec6367eccea0..06a06d7718781 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -13255,6 +13255,10 @@ class Sema final : public SemaBase {
   /// \param AllowDeducedTST Whether a DeducedTemplateSpecializationType is
   /// acceptable as the top level type of the result.
   ///
+  /// \param IsIncompleteSubstitution If provided, the pointee will be set
+  /// whenever substitution would perform a replacement with a null or
+  /// non-existent template argument.
+  ///
   /// \returns If the instantiation succeeds, the instantiated
   /// type. Otherwise, produces diagnostics and returns a NULL type.
   TypeSourceInfo *SubstType(TypeSourceInfo *T,
@@ -13264,7 +13268,8 @@ class Sema final : public SemaBase {
 
   QualType SubstType(QualType T,
  const MultiLevelTemplateArgumentList &TemplateArgs,
- SourceLocation Loc, DeclarationName Entity);
+ SourceLocation Loc, DeclarationName Entity,
+ bool *IsIncompleteSubstitution = nullptr);
 
   TypeSourceInfo *SubstType(TypeLoc TL,
 const MultiLevelTemplateArgumentList &TemplateArgs,
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 558e20ed3e423..2512cd575fbdd 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -5346,7 +5346,6 @@ static EvalStmtResult EvaluateStmt(StmtResult &Result, 
EvalInfo &Info,
 const Expr *RetExpr = cast(S)->getRetValue();
 FullExpressionRAII Scope(Info);
 if (RetExpr && RetExpr->isValueDependent()) {
-  EvaluateDependentExpr(RetExpr, Info);
   // We know we returned, but we don't know what the value is.
   return ESR_Failed;
 }
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index b7b857ebf804b..612c23acffcbf 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -137,7 +137,7 @@ static TemplateDeductionResult 
DeduceTemplateArgumentsByTypeMatch(
 Sema &S, TemplateParameterList *TemplateParams, QualType Param,
 QualType Arg, TemplateDeductionInfo &Info,
 SmallVectorImpl &Deduced, unsigned TDF,
-bool PartialOrdering = false, bool DeducedFromArrayBound = false);
+bool PartialOrdering, bool DeducedFromArrayBound, bool 
*HasDeducedAnyParam);
 
 enum class PackFold { ParameterToArgument, ArgumentToParameter };
 static TemplateDeductionResult
@@ -146,8 +146,8 @@ DeduceTemplateArguments(Sema &S, TemplateParameterList 
*TemplateParams,
 ArrayRef As,
 TemplateDeductionInfo &Info,
 SmallVectorImpl &Deduced,
-bool NumberOfArgumentsMustMatch,
-PackFold PackFold = PackFold::ParameterToArgument);
+bool NumberOfArgumentsMustMatch, PackFold PackFold,
+bool *HasDeducedAnyParam);
 
 static void MarkUsedTemplateParameters(ASTContext &Ctx,

[clang] [llvm] [LLVM][PassBuilder] Extend the function signature of callback for optimizer pipeline extension point (PR #100945)

2024-07-28 Thread Shilei Tian via cfe-commits

https://github.com/shiltian updated 
https://github.com/llvm/llvm-project/pull/100945

>From 76c0d45679bb9ea90f882abc38f52cd05d8b6624 Mon Sep 17 00:00:00 2001
From: Shilei Tian 
Date: Sun, 28 Jul 2024 18:48:54 -0400
Subject: [PATCH 1/2] [Attributor][AMD] Enable AAIndirectCallInfo for
 AMDAttributorPass

---
 llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp|  2 +-
 .../CodeGen/AMDGPU/amdgpu-attributor-no-agpr.ll| 14 +-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
index 9d3c9e1e2ef9f..51968063e8919 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
@@ -1038,7 +1038,7 @@ static bool runImpl(Module &M, AnalysisGetter &AG, 
TargetMachine &TM) {
&AAPotentialValues::ID, &AAAMDFlatWorkGroupSize::ID,
&AAAMDWavesPerEU::ID, &AAAMDGPUNoAGPR::ID, &AACallEdges::ID,
&AAPointerInfo::ID, &AAPotentialConstantValues::ID,
-   &AAUnderlyingObjects::ID});
+   &AAUnderlyingObjects::ID, &AAIndirectCallInfo::ID});
 
   AttributorConfig AC(CGUpdater);
   AC.Allowed = &Allowed;
diff --git a/llvm/test/CodeGen/AMDGPU/amdgpu-attributor-no-agpr.ll 
b/llvm/test/CodeGen/AMDGPU/amdgpu-attributor-no-agpr.ll
index 33b1cc65dc569..e5d440b96349f 100644
--- a/llvm/test/CodeGen/AMDGPU/amdgpu-attributor-no-agpr.ll
+++ b/llvm/test/CodeGen/AMDGPU/amdgpu-attributor-no-agpr.ll
@@ -231,7 +231,19 @@ define amdgpu_kernel void @indirect_calls_none_agpr(i1 
%cond) {
 ; CHECK-LABEL: define amdgpu_kernel void @indirect_calls_none_agpr(
 ; CHECK-SAME: i1 [[COND:%.*]]) #[[ATTR0]] {
 ; CHECK-NEXT:[[FPTR:%.*]] = select i1 [[COND]], ptr @empty, ptr @also_empty
-; CHECK-NEXT:call void [[FPTR]]()
+; CHECK-NEXT:[[TMP1:%.*]] = icmp eq ptr [[FPTR]], @also_empty
+; CHECK-NEXT:br i1 [[TMP1]], label [[TMP2:%.*]], label [[TMP3:%.*]]
+; CHECK:   2:
+; CHECK-NEXT:call void @also_empty()
+; CHECK-NEXT:br label [[TMP6:%.*]]
+; CHECK:   3:
+; CHECK-NEXT:br i1 true, label [[TMP4:%.*]], label [[TMP5:%.*]]
+; CHECK:   4:
+; CHECK-NEXT:call void @empty()
+; CHECK-NEXT:br label [[TMP6]]
+; CHECK:   5:
+; CHECK-NEXT:unreachable
+; CHECK:   6:
 ; CHECK-NEXT:ret void
 ;
   %fptr = select i1 %cond, ptr @empty, ptr @also_empty

>From 1e72ac703166c875ade098fdef12a9fbc63ae37e Mon Sep 17 00:00:00 2001
From: Shilei Tian 
Date: Sun, 28 Jul 2024 15:28:09 -0400
Subject: [PATCH 2/2] [LLVM][PassBuilder] Extend the function signature of
 callback for optimizer pipeline extension point

These callbacks can be invoked in multiple places when building an optimization
pipeline, both in compile time and link time. However, there is no indicator on
what pipeline it is currently building.

In this patch, an extra argument is added to indicate its (Thin)LTO stage such
that the callback can check it if needed. There is no test expected from this,
and the benefit of this change will be demonstrated in 
https://github.com/llvm/llvm-project/pull/66488.
---
 clang/lib/CodeGen/BackendUtil.cpp | 19 ++-
 llvm/include/llvm/Passes/PassBuilder.h| 10 +++---
 llvm/lib/Passes/PassBuilderPipelines.cpp  | 12 +++-
 llvm/lib/Target/AMDGPU/AMDGPU.h   |  7 ++-
 llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp   | 11 +++
 .../lib/Target/AMDGPU/AMDGPUTargetMachine.cpp | 15 +--
 llvm/tools/opt/NewPMDriver.cpp|  2 +-
 7 files changed, 47 insertions(+), 29 deletions(-)

diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index e765bbf637a66..64f0020a170aa 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -643,7 +643,7 @@ static void addKCFIPass(const Triple &TargetTriple, const 
LangOptions &LangOpts,
 
   // Ensure we lower KCFI operand bundles with -O0.
   PB.registerOptimizerLastEPCallback(
-  [&](ModulePassManager &MPM, OptimizationLevel Level) {
+  [&](ModulePassManager &MPM, OptimizationLevel Level, ThinOrFullLTOPhase) 
{
 if (Level == OptimizationLevel::O0 &&
 LangOpts.Sanitize.has(SanitizerKind::KCFI))
   MPM.addPass(createModuleToFunctionPassAdaptor(KCFIPass()));
@@ -662,8 +662,8 @@ static void addKCFIPass(const Triple &TargetTriple, const 
LangOptions &LangOpts,
 static void addSanitizers(const Triple &TargetTriple,
   const CodeGenOptions &CodeGenOpts,
   const LangOptions &LangOpts, PassBuilder &PB) {
-  auto SanitizersCallback = [&](ModulePassManager &MPM,
-OptimizationLevel Level) {
+  auto SanitizersCallback = [&](ModulePassManager &MPM, OptimizationLevel 
Level,
+ThinOrFullLTOPhase) {
 if (CodeGenOpts.hasSanitizeCoverage()) {
   auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
   MPM.addPass(SanitizerCov

[clang] [llvm] [LLVM][PassBuilder] Extend the function signature of callback for optimizer pipeline extension point (PR #100945)

2024-07-28 Thread Shilei Tian via cfe-commits

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


[clang] [llvm] [LLVM][PassBuilder] Extend the function signature of callback for optimizer pipeline extension point (PR #100945)

2024-07-28 Thread Shilei Tian via cfe-commits

shiltian wrote:

Close this one and use https://github.com/llvm/llvm-project/pull/100953 because 
I messed up the stack.

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


[clang] [TableGen] Passing 'Heading' param as const reference (PR #99724)

2024-07-28 Thread Julius Alexandre via cfe-commits

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


[clang] [Modules] Fix using `va_list` with modules and a precompiled header. (PR #100837)

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

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

LGTM.

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


[clang] [Clang][OpenMP] Allow `num_teams` to accept multiple expressions (PR #99732)

2024-07-28 Thread Shilei Tian via cfe-commits


@@ -812,6 +812,7 @@ int bar(int n){
 // CHECK1-NEXT:[[DOTCAPTURE_EXPR__ADDR:%.*]] = alloca i64, align 8
 // CHECK1-NEXT:[[DOTCAPTURE_EXPR__ADDR2:%.*]] = alloca i64, align 8
 // CHECK1-NEXT:[[AA_CASTED:%.*]] = alloca i64, align 8
+// CHECK1-NEXT:[[DOTCAPTURE_EXPR__CASTED:%.*]] = alloca i64, align 8

shiltian wrote:

Hmm, but that is also what was used before. I didn't change anything.

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


[clang] [Clang][OpenMP] Allow `num_teams` to accept multiple expressions (PR #99732)

2024-07-28 Thread Shilei Tian via cfe-commits


@@ -3793,8 +3793,8 @@ bool 
RecursiveASTVisitor::VisitOMPMapClause(OMPMapClause *C) {
 template 
 bool RecursiveASTVisitor::VisitOMPNumTeamsClause(
 OMPNumTeamsClause *C) {
+  TRY_TO(VisitOMPClauseList(C));
   TRY_TO(VisitOMPClauseWithPreInit(C));

shiltian wrote:

We don't need pre init anymore?

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


[clang] [Clang][OpenMP] Allow `num_teams` to accept multiple expressions (PR #99732)

2024-07-28 Thread Shilei Tian via cfe-commits

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


[clang] 0953fb4 - [Driver] Ensure -W gets HelpHidden

2024-07-28 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2024-07-28T20:21:59-07:00
New Revision: 0953fb4c68380760562e61a5a09979359eb498c1

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

LOG: [Driver] Ensure -W gets HelpHidden

Individual groups should not be displayed in --help. Fix two violations
and change the test to prevent regression.

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/immediate-options.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c95148fca..c8c56dbb51b28 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -978,15 +978,15 @@ def Wsystem_headers_in_module_EQ : Joined<["-"], 
"Wsystem-headers-in-module=">,
   HelpText<"Enable -Wsystem-headers when building ">,
   MarshallingInfoStringVector>;
 def Wdeprecated : Flag<["-"], "Wdeprecated">, Group,
-  Visibility<[ClangOption, CC1Option]>,
+  Flags<[HelpHidden]>, Visibility<[ClangOption, CC1Option]>,
   HelpText<"Enable warnings for deprecated constructs and define 
__DEPRECATED">;
 def Wno_deprecated : Flag<["-"], "Wno-deprecated">, Group,
   Visibility<[ClangOption, CC1Option]>;
 defm invalid_constexpr : BoolWOption<"invalid-constexpr",
   LangOpts<"CheckConstexprFunctionBodies">,
   Default,
-  NegFlag,
-  PosFlag,
+  NegFlag,
+  PosFlag,
   BothFlags<[], [ClangOption, CC1Option], " checking of constexpr function 
bodies for validity within a constant expression context">>;
 def Wl_COMMA : CommaJoined<["-"], "Wl,">, Visibility<[ClangOption, 
FlangOption]>,
   Flags<[LinkerInput, RenderAsInput]>,

diff  --git a/clang/test/Driver/immediate-options.c 
b/clang/test/Driver/immediate-options.c
index 77878fe2e9c58..b74f6b41f22a0 100644
--- a/clang/test/Driver/immediate-options.c
+++ b/clang/test/Driver/immediate-options.c
@@ -2,6 +2,8 @@
 // HELP: isystem
 // HELP-NOT: ast-dump
 // HELP-NOT: driver-mode
+// HELP: -Wa,
+// HELP-NOT: -W{{[a-z][a-z]}}
 
 // Make sure that Flang-only options are not available in Clang
 // HELP-NOT: test-io



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


[clang] 73c72f2 - [analyzer] Keep alive short-circuiting condition subexpressions in a conditional (#100745)

2024-07-28 Thread via cfe-commits

Author: Arseniy Zaostrovnykh
Date: 2024-07-29T08:12:22+02:00
New Revision: 73c72f2c6505d5bc8b47bb0420f6cba5b24270fe

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

LOG: [analyzer] Keep alive short-circuiting condition subexpressions in a 
conditional (#100745)

Fix the false negative caused by state merging in the evaluation of a
short-circuiting expression inside the condition of a ternary operator.
The fixed symptom is that CSA always evaluates `(x || x) ? n : m` to
`m`.

This change forces the analyzer to consider all logical expressions
prone to short-circuiting alive until the entire conditional expression
is evaluated. Here is why.

By default, LiveVariables analysis marks only direct subexpressions as
live relative to any expression. So for `a ? b : c` it will consider
`a`, `b`, and `c` alive when evaluating the ternary operator expression.

To explore both possibilities opened by a ternary operator, it is
important to keep something different about the exploded nodes created
after the evaluation of its branches. These two nodes come to the same
location, so they must have different states. Otherwise, they will be
considered identical and can engender only one outcome.
`ExprEngine::visitGuardedExpr` chooses the first predecessor exploded
node to carry the value of the conditional expression. It works well in
the case of a simple condition, because when `a ? b : c` is evaluated,
`a` is kept alive, so the two branches differ in the value of `a`.

However, before this patch is applied, this strategy breaks for `(x ||
x) ? n : m`. `x` is not a direct child of the ternary expression. Due to
short-circuiting, once `x` is assumed to be `true`, evaluation jumps
directly to `n` and then to the result of the entire ternary expression.
Given that the result of the entire condition `(x || x)` is not
constructed, and `x` is not kept alive, the difference between the path
coming through `n` and through `m` disappears. As a result, exploded
nodes coming from the "true expression" and the "false expression"
engender identical successors and merge the execution paths.

Added: 
clang/test/Analysis/short-circuiting-eval.cpp

Modified: 
clang/lib/Analysis/LiveVariables.cpp
clang/test/Analysis/live-stmts.cpp

Removed: 




diff  --git a/clang/lib/Analysis/LiveVariables.cpp 
b/clang/lib/Analysis/LiveVariables.cpp
index 6d03dd05ca3d2..481932ee59c8e 100644
--- a/clang/lib/Analysis/LiveVariables.cpp
+++ b/clang/lib/Analysis/LiveVariables.cpp
@@ -214,6 +214,22 @@ static void AddLiveExpr(llvm::ImmutableSet 
&Set,
   Set = F.add(Set, LookThroughExpr(E));
 }
 
+/// Add as a live expression all individual conditions in a logical expression.
+/// For example, for the expression:
+/// "(a < b) || (c && d && ((e || f) != (g && h)))"
+/// the following expressions will be added as live:
+/// "a < b", "c", "d", "((e || f) != (g && h))"
+static void AddAllConditionalTerms(llvm::ImmutableSet &Set,
+   llvm::ImmutableSet::Factory 
&F,
+   const Expr *Cond) {
+  AddLiveExpr(Set, F, Cond);
+  if (auto const *BO = dyn_cast(Cond->IgnoreParens());
+  BO && BO->isLogicalOp()) {
+AddAllConditionalTerms(Set, F, BO->getLHS());
+AddAllConditionalTerms(Set, F, BO->getRHS());
+  }
+}
+
 void TransferFunctions::Visit(Stmt *S) {
   if (observer)
 observer->observeStmt(S, currentBlock, val);
@@ -313,7 +329,27 @@ void TransferFunctions::Visit(Stmt *S) {
   AddLiveExpr(val.liveExprs, LV.ESetFact, cast(S)->getCond());
   return;
 }
-
+case Stmt::ConditionalOperatorClass: {
+  // Keep not only direct children alive, but also all the short-circuited
+  // parts of the condition. Short-circuiting evaluation may cause the
+  // conditional operator evaluation to skip the evaluation of the entire
+  // condtion expression, so the value of the entire condition expression 
is
+  // never computed.
+  //
+  // This makes a 
diff erence when we compare exploded nodes coming from true
+  // and false expressions with no side effects: the only 
diff erence in the
+  // state is the value of (part of) the condition.
+  //
+  // BinaryConditionalOperatorClass ('x ?: y') is not affected because it
+  // explicitly calculates the value of the entire condition expression (to
+  // possibly use as a value for the "true expr") even if it is
+  // short-circuited.
+  auto const *CO = cast(S);
+  AddAllConditionalTerms(val.liveExprs, LV.ESetFact, CO->getCond());
+  AddLiveExpr(val.liveExprs, LV.ESetFact, CO->getTrueExpr());
+  AddLiveExpr(val.liveExprs, LV.ESetFact, CO->getFalseExpr());
+  return;
+}
   }
 
   // HACK + FIXME: What is this? One could only guess that 

[clang] [analyzer] Keep alive short-circuiting condition subexpressions in a conditional (PR #100745)

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

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


[clang] Fix hasName matcher assertion with inline namespaces (PR #100975)

2024-07-28 Thread Nathan James via cfe-commits

https://github.com/njames93 created 
https://github.com/llvm/llvm-project/pull/100975

Fix handling of nodes which can be skipped in the fast path for the hasName 
matcher

#100973 

>From 8d1aeca42a0d544582823ff2bae0a217e14d1c02 Mon Sep 17 00:00:00 2001
From: Nathan James 
Date: Mon, 29 Jul 2024 07:21:53 +0100
Subject: [PATCH] Fix hasName matcher assertion with inline namespaces

Fix handling of nodes which can be skipped in the fast path for the
hasName matcher
---
 clang/lib/ASTMatchers/ASTMatchersInternal.cpp | 21 ---
 .../ASTMatchers/ASTMatchersNarrowingTest.cpp  |  4 
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp 
b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index bf87b1aa0992a..0556ae7ffae2f 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -537,14 +537,21 @@ class PatternSet {
   /// that didn't match.
   /// Return true if there are still any patterns left.
   bool consumeNameSuffix(StringRef NodeName, bool CanSkip) {
-for (size_t I = 0; I < Patterns.size();) {
-  if (::clang::ast_matchers::internal::consumeNameSuffix(Patterns[I].P,
- NodeName) ||
-  CanSkip) {
-++I;
-  } else {
-Patterns.erase(Patterns.begin() + I);
+if (CanSkip) {
+  // If we can skip the node, then we need to handle the case where a
+  // skipped node has the same name as its parent.
+  // namespace a { inline namespace a { class A; } }
+  // cxxRecordDecl(hasName("::a::A")) 
+  // To do this, any patterns that match should be duplicated in our set, 
one of them with the tail removed.
+  for (size_t I = 0, E = Patterns.size(); I != E; ++I) {
+StringRef Pattern = Patterns[I].P;
+if (ast_matchers::internal::consumeNameSuffix(Patterns[I].P, NodeName))
+  Patterns.push_back({Pattern, Patterns[I].IsFullyQualified});
   }
+} else {
+  llvm::erase_if(Patterns, [&NodeName](auto &Pattern) {
+return !::clang::ast_matchers::internal::consumeNameSuffix(Pattern.P, 
NodeName);
+  });
 }
 return !Patterns.empty();
   }
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index f26140675fd46..611e1f9ba5327 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2552,6 +2552,10 @@ TEST_P(ASTMatchersTest, HasName_MatchesNamespaces) {
  recordDecl(hasName("a+b::C";
   EXPECT_TRUE(notMatches("namespace a { namespace b { class AC; } }",
  recordDecl(hasName("C";
+  EXPECT_TRUE(matches("namespace a { inline namespace a { class C; } }",
+  recordDecl(hasName("::a::C";
+  EXPECT_TRUE(matches("namespace a { inline namespace a { class C; } }",
+  recordDecl(hasName("::a::a::C";
 }
 
 TEST_P(ASTMatchersTest, HasName_MatchesOuterClasses) {

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


[clang] Fix hasName matcher assertion with inline namespaces (PR #100975)

2024-07-28 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Nathan James (njames93)


Changes

Fix handling of nodes which can be skipped in the fast path for the hasName 
matcher

#100973 

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


2 Files Affected:

- (modified) clang/lib/ASTMatchers/ASTMatchersInternal.cpp (+14-7) 
- (modified) clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp (+4) 


``diff
diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp 
b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index bf87b1aa0992a..0556ae7ffae2f 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -537,14 +537,21 @@ class PatternSet {
   /// that didn't match.
   /// Return true if there are still any patterns left.
   bool consumeNameSuffix(StringRef NodeName, bool CanSkip) {
-for (size_t I = 0; I < Patterns.size();) {
-  if (::clang::ast_matchers::internal::consumeNameSuffix(Patterns[I].P,
- NodeName) ||
-  CanSkip) {
-++I;
-  } else {
-Patterns.erase(Patterns.begin() + I);
+if (CanSkip) {
+  // If we can skip the node, then we need to handle the case where a
+  // skipped node has the same name as its parent.
+  // namespace a { inline namespace a { class A; } }
+  // cxxRecordDecl(hasName("::a::A")) 
+  // To do this, any patterns that match should be duplicated in our set, 
one of them with the tail removed.
+  for (size_t I = 0, E = Patterns.size(); I != E; ++I) {
+StringRef Pattern = Patterns[I].P;
+if (ast_matchers::internal::consumeNameSuffix(Patterns[I].P, NodeName))
+  Patterns.push_back({Pattern, Patterns[I].IsFullyQualified});
   }
+} else {
+  llvm::erase_if(Patterns, [&NodeName](auto &Pattern) {
+return !::clang::ast_matchers::internal::consumeNameSuffix(Pattern.P, 
NodeName);
+  });
 }
 return !Patterns.empty();
   }
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index f26140675fd46..611e1f9ba5327 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2552,6 +2552,10 @@ TEST_P(ASTMatchersTest, HasName_MatchesNamespaces) {
  recordDecl(hasName("a+b::C";
   EXPECT_TRUE(notMatches("namespace a { namespace b { class AC; } }",
  recordDecl(hasName("C";
+  EXPECT_TRUE(matches("namespace a { inline namespace a { class C; } }",
+  recordDecl(hasName("::a::C";
+  EXPECT_TRUE(matches("namespace a { inline namespace a { class C; } }",
+  recordDecl(hasName("::a::a::C";
 }
 
 TEST_P(ASTMatchersTest, HasName_MatchesOuterClasses) {

``




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


[clang] Fix hasName matcher assertion with inline namespaces (PR #100975)

2024-07-28 Thread Nathan James via cfe-commits

https://github.com/njames93 updated 
https://github.com/llvm/llvm-project/pull/100975

>From 9e3f5ae48fa75d5db8b132162d96004191618956 Mon Sep 17 00:00:00 2001
From: Nathan James 
Date: Mon, 29 Jul 2024 07:21:53 +0100
Subject: [PATCH] Fix hasName matcher assertion with inline namespaces

Fix handling of nodes which can be skipped in the fast path for the
hasName matcher
---
 clang/lib/ASTMatchers/ASTMatchersInternal.cpp | 23 +--
 .../ASTMatchers/ASTMatchersNarrowingTest.cpp  |  4 
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp 
b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index bf87b1aa0992a..06309d327896b 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -537,14 +537,23 @@ class PatternSet {
   /// that didn't match.
   /// Return true if there are still any patterns left.
   bool consumeNameSuffix(StringRef NodeName, bool CanSkip) {
-for (size_t I = 0; I < Patterns.size();) {
-  if (::clang::ast_matchers::internal::consumeNameSuffix(Patterns[I].P,
- NodeName) ||
-  CanSkip) {
-++I;
-  } else {
-Patterns.erase(Patterns.begin() + I);
+if (CanSkip) {
+  // If we can skip the node, then we need to handle the case where a
+  // skipped node has the same name as its parent.
+  // namespace a { inline namespace a { class A; } }
+  // cxxRecordDecl(hasName("::a::A"))
+  // To do this, any patterns that match should be duplicated in our set,
+  // one of them with the tail removed.
+  for (size_t I = 0, E = Patterns.size(); I != E; ++I) {
+StringRef Pattern = Patterns[I].P;
+if (ast_matchers::internal::consumeNameSuffix(Patterns[I].P, NodeName))
+  Patterns.push_back({Pattern, Patterns[I].IsFullyQualified});
   }
+} else {
+  llvm::erase_if(Patterns, [&NodeName](auto &Pattern) {
+return !::clang::ast_matchers::internal::consumeNameSuffix(Pattern.P,
+   NodeName);
+  });
 }
 return !Patterns.empty();
   }
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index f26140675fd46..611e1f9ba5327 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2552,6 +2552,10 @@ TEST_P(ASTMatchersTest, HasName_MatchesNamespaces) {
  recordDecl(hasName("a+b::C";
   EXPECT_TRUE(notMatches("namespace a { namespace b { class AC; } }",
  recordDecl(hasName("C";
+  EXPECT_TRUE(matches("namespace a { inline namespace a { class C; } }",
+  recordDecl(hasName("::a::C";
+  EXPECT_TRUE(matches("namespace a { inline namespace a { class C; } }",
+  recordDecl(hasName("::a::a::C";
 }
 
 TEST_P(ASTMatchersTest, HasName_MatchesOuterClasses) {

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


[clang] [clang-format] Use double hyphen for multiple-letter flags (PR #100978)

2024-07-28 Thread via cfe-commits

https://github.com/magic-akari created 
https://github.com/llvm/llvm-project/pull/100978

- Closes: #100974 

>From 4c90d85b5edf2ca93fe28e503f3eaa3d6dad4cb3 Mon Sep 17 00:00:00 2001
From: magic-akari 
Date: Mon, 29 Jul 2024 14:30:40 +0800
Subject: [PATCH] [clang-format] Use double hyphen for multiple-letter flags

---
 clang/tools/clang-format/clang-format-diff.py|  8 
 clang/tools/clang-format/clang-format-sublime.py |  8 
 clang/tools/clang-format/clang-format.el | 14 +++---
 clang/tools/clang-format/clang-format.py | 16 
 clang/tools/clang-format/git-clang-format|  6 +++---
 5 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/clang/tools/clang-format/clang-format-diff.py 
b/clang/tools/clang-format/clang-format-diff.py
index 3a74b90e73157..9eec0f3c89de3 100755
--- a/clang/tools/clang-format/clang-format-diff.py
+++ b/clang/tools/clang-format/clang-format-diff.py
@@ -134,7 +134,7 @@ def main():
 if line_count != 0:
 end_line += line_count - 1
 lines_by_file.setdefault(filename, []).extend(
-["-lines", str(start_line) + ":" + str(end_line)]
+["--lines", str(start_line) + ":" + str(end_line)]
 )
 
 # Reformat files containing changes in place.
@@ -146,12 +146,12 @@ def main():
 if args.i:
 command.append("-i")
 if args.sort_includes:
-command.append("-sort-includes")
+command.append("--sort-includes")
 command.extend(lines)
 if args.style:
-command.extend(["-style", args.style])
+command.extend(["--style", args.style])
 if args.fallback_style:
-command.extend(["-fallback-style", args.fallback_style])
+command.extend(["--fallback-style", args.fallback_style])
 
 try:
 p = subprocess.Popen(
diff --git a/clang/tools/clang-format/clang-format-sublime.py 
b/clang/tools/clang-format/clang-format-sublime.py
index dcd72e68e94fa..8d41da332c188 100644
--- a/clang/tools/clang-format/clang-format-sublime.py
+++ b/clang/tools/clang-format/clang-format-sublime.py
@@ -35,18 +35,18 @@ def run(self, edit):
 regions = []
 command = [binary]
 if style:
-command.extend(["-style", style])
+command.extend(["--style", style])
 for region in self.view.sel():
 regions.append(region)
 region_offset = min(region.a, region.b)
 region_length = abs(region.b - region.a)
 command.extend(
 [
-"-offset",
+"--offset",
 str(region_offset),
-"-length",
+"--length",
 str(region_length),
-"-assume-filename",
+"--assume-filename",
 str(self.view.file_name()),
 ]
 )
diff --git a/clang/tools/clang-format/clang-format.el 
b/clang/tools/clang-format/clang-format.el
index f43bf063c6297..f3da5415f8672 100644
--- a/clang/tools/clang-format/clang-format.el
+++ b/clang/tools/clang-format/clang-format.el
@@ -166,19 +166,19 @@ uses the function `buffer-file-name'."
 (let ((status (apply #'call-process-region
  nil nil clang-format-executable
  nil `(,temp-buffer ,temp-file) nil
- `("-output-replacements-xml"
+ `("--output-replacements-xml"
;; Guard against a nil assume-file-name.
;; If the clang-format option -assume-filename
;; is given a blank string it will crash as per
;; the following bug report
;; https://bugs.llvm.org/show_bug.cgi?id=34667
,@(and assume-file-name
-  (list "-assume-filename" 
assume-file-name))
-   ,@(and style (list "-style" style))
-   "-fallback-style" ,clang-format-fallback-style
-   "-offset" ,(number-to-string file-start)
-   "-length" ,(number-to-string (- file-end 
file-start))
-   "-cursor" ,(number-to-string cursor
+  (list "--assume-filename" 
assume-file-name))
+   ,@(and style (list "--style" style))
+   "--fallback-style" ,clang-format-fallback-style
+   "--offset" ,(number-to-string file-start)
+   "--length" ,(number-to-string (- file-end 
file-start))
+   "--cursor" ,(number-to-string cursor
   (stderr (with-temp-buf

[clang] [clang-format] Use double hyphen for multiple-letter flags (PR #100978)

2024-07-28 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/100978
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits