[clang] [llvm] target ABI: improve call parameters extensions handling (PR #100757)

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


@@ -1185,6 +1189,9 @@ Currently, only the following parameter attributes are 
defined:
 value should be sign-extended to the extent required by the target's
 ABI (which is usually 32-bits) by the caller (for a parameter) or
 the callee (for a return value).
+``noext`` This indicates to the code generator that the parameter or return
+value has the high bits undefined, as for a struct in register, and
+therefore does not need to be sign or zero extended.

arsenm wrote:

I don't understand how this improves the situation, or how the IR can 
"understand the ABI". The IR has its own ABI. This may or may not match the C 
ABI, the IR ABI is not really defined in terms of C 

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


[clang] [Clang][Sema] Disallow applying `onwership_returns` to functions that return non-pointers (PR #99564)

2024-07-27 Thread Pavel Skripkin via cfe-commits

pskrgag wrote:

@AaronBallman sorry for Saturday ping, but could you, please, take a look?

https://github.com/llvm/llvm-project/pull/99564
___
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-27 Thread via cfe-commits

https://github.com/vfdff updated 
https://github.com/llvm/llvm-project/pull/100302

>From c750234674531788ee26958954a5f9a6b59ea866 Mon Sep 17 00:00:00 2001
From: zhongyunde 00443407 
Date: Tue, 23 Jul 2024 23:10:42 -0400
Subject: [PATCH 1/3] [clang codegen] Emit int TBAA metadata on more FP math
 libcalls

Follow PR96025, except expf, more FP math libcalls in libm
should also be supported.

Fix https://github.com/llvm/llvm-project/issues/86635
---
 clang/lib/CodeGen/CGBuiltin.cpp | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index a0d03b87ccdc9..a9696ebe61e3a 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -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 IsMathLibCall =
+  Context.BuiltinInfo.isLibFunction(BuiltinID) ||
+  Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID);
+  if (IsMathLibCall && CGF.ConvertType(ResultTy)->isFloatingPointTy())
 return true;
-  }
-  // TODO: support more FP math libcalls
   return false;
 }();
 
 // Restrict to target with errno, for example, MacOS doesn't set errno.
 if (IsErrnoIntrinsic && CGF.CGM.getLangOpts().MathErrno &&
 !CGF.Builder.getIsFPConstrained()) {
-  ASTContext &Context = CGF.getContext();
   // Emit "int" TBAA metadata on FP math libcalls.
   clang::QualType IntTy = Context.IntTy;
   TBAAAccessInfo TBAAInfo = CGF.CGM.getTBAAAccessInfo(IntTy);

>From fb81f300280582b2e820e32094dee9e6ed1da75f Mon Sep 17 00:00:00 2001
From: zhongyunde 00443407 
Date: Wed, 24 Jul 2024 03:38:42 -0400
Subject: [PATCH 2/3] Add a new test calls fabs

---
 clang/test/CodeGen/math-libcalls-tbaa.cpp | 29 +++
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/clang/test/CodeGen/math-libcalls-tbaa.cpp 
b/clang/test/CodeGen/math-libcalls-tbaa.cpp
index f15938dee0272..2812e82abe652 100644
--- a/clang/test/CodeGen/math-libcalls-tbaa.cpp
+++ b/clang/test/CodeGen/math-libcalls-tbaa.cpp
@@ -4,23 +4,40 @@
 // 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 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;
 }
+
+// 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]);  // Emit TBAA metadata on @fabs
+   double tmp = expm2 * num[10];
+   return tmp;
+}
+
 //.
 // NoNewStructPathTBAA: [[TBAA2]] = !{[[META3:![0-9]+]], [[META3]], i6

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

2024-07-27 Thread Hirofumi Nakamura via cfe-commits

https://github.com/hnakamura5 created 
https://github.com/llvm/llvm-project/pull/100860

Trying to fix https://github.com/llvm/llvm-project/issues/98559 .

This PR modifies the ad-hoc tweaks introduced by 
https://reviews.llvm.org/D50078 .
The change is limited to the case `AlignOperands ` and 
`BreakBeforeTernaryOperators`  are specified (default in LLVM style).

```
int foo = bar > baz
  ? 42
  : 99;
```

↓ This PR makes,

```
int foo = bar > baz
  ? 42
  : 99;
```

For the case `BreakBeforeTernaryOperators` is not specified, I'm not sure such 
style is desirable.
```
int foo = bar > baz ?
  42 :
  99;
```
So I did not touch the case at first. It may be a point of discussion.

>From 2d2695767cbd853bc2327b2f640fdeeeb41f43f6 Mon Sep 17 00:00:00 2001
From: hnakamura5 
Date: Mon, 22 Jul 2024 23:00:45 +0900
Subject: [PATCH] [clang-format] Fix the indent of the ternary operator when
 AlignOperands and  BreakBeforeTernaryOperators is specified.

---
 clang/lib/Format/ContinuationIndenter.cpp |  11 +-
 clang/unittests/Format/FormatTest.cpp | 138 +-
 .../unittests/Format/FormatTestRawStrings.cpp |  15 +-
 3 files changed, 84 insertions(+), 80 deletions(-)

diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index b07360425ca6e..c01fe6940bf22 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1347,8 +1347,14 @@ unsigned ContinuationIndenter::getNewLineColumn(const 
LineState &State) {
   //* always un-indent by the operator when
   //BreakBeforeTernaryOperators=true
   unsigned Indent = CurrentState.Indent;
-  if (Style.AlignOperands != FormatStyle::OAS_DontAlign)
+  if (Style.AlignOperands != FormatStyle::OAS_DontAlign &&
+  !Style.BreakBeforeTernaryOperators) {
 Indent -= Style.ContinuationIndentWidth;
+  }
+  if (Style.BreakBeforeTernaryOperators &&
+  CurrentState.IsChainedConditional) {
+Indent -= 2;
+  }
   if (Style.BreakBeforeTernaryOperators && CurrentState.UnindentOperator)
 Indent -= 2;
   return Indent;
@@ -1773,7 +1779,8 @@ void 
ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
 !CurrentState.IsWrappedConditional) {
   NewParenState.IsChainedConditional = true;
   NewParenState.UnindentOperator = State.Stack.back().UnindentOperator;
-} else if (PrecedenceLevel == prec::Conditional ||
+} else if ((PrecedenceLevel == prec::Conditional &&
+!Style.BreakBeforeTernaryOperators) ||
(!SkipFirstExtraIndent && PrecedenceLevel > prec::Assignment &&
 !Current.isTrailingComment())) {
   NewParenState.Indent += Style.ContinuationIndentWidth;
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index d01ce137b8fcb..bdd657db06712 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -7332,12 +7332,11 @@ TEST_F(FormatTest, 
ExpressionIndentationBreakingBeforeOperators) {
"};",
Style);
   verifyFormat("return abc\n"
-   " ? foo(\n"
-   " a,\n"
-   " b,\n"
-   " bar(\n"
-   "   abc))\n"
-   " : g(abc);",
+   "   ? foo(\n"
+   "   a,\n"
+   "   b,\n"
+   "   bar(abc))\n"
+   "   : g(abc);",
Style);
 }
 
@@ -9410,20 +9409,20 @@ TEST_F(FormatTest, BreaksConditionalExpressions) {
": aaa;");
   verifyFormat("a aa =\n"
"\n"
-   "? aa\n"
-   ": ;");
+   "? aa\n"
+   ": ;");
   verifyFormat(
   "aa == aa\n"
   "? aaa\n"
   ": aaa;");
   verifyFormat("f( == // force break\n"
-   "  a\n"
-   "  ? b\n"
-   "  : c);");
+   "  a\n"
+   "  ? b\n"
+   "  : c);");
   verifyFormat("return  == \n"
-   "   // comment\n"
-   "   ? \n"
-   "   : ;");
+   "   // comment\n"
+   "   ? \n"
+   "   : ;");
   verifyFormat("unsigned Indent =\n"
"format(TheLine.First,\n"
"   IndentForLevel[TheLine.Level] >= 0\n"
@@ -9432,21 +9431,20

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

2024-07-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Hirofumi Nakamura (hnakamura5)


Changes

Trying to fix https://github.com/llvm/llvm-project/issues/98559 .

This PR modifies the ad-hoc tweaks introduced by 
https://reviews.llvm.org/D50078 .
The change is limited to the case `AlignOperands ` and 
`BreakBeforeTernaryOperators`  are specified (default in LLVM style).

```
int foo = bar > baz
  ? 42
  : 99;
```

↓ This PR makes,

```
int foo = bar > baz
  ? 42
  : 99;
```

For the case `BreakBeforeTernaryOperators` is not specified, I'm not sure such 
style is desirable.
```
int foo = bar > baz ?
  42 :
  99;
```
So I did not touch the case at first. It may be a point of discussion.

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


3 Files Affected:

- (modified) clang/lib/Format/ContinuationIndenter.cpp (+9-2) 
- (modified) clang/unittests/Format/FormatTest.cpp (+68-70) 
- (modified) clang/unittests/Format/FormatTestRawStrings.cpp (+7-8) 


``diff
diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index b07360425ca6e..c01fe6940bf22 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1347,8 +1347,14 @@ unsigned ContinuationIndenter::getNewLineColumn(const 
LineState &State) {
   //* always un-indent by the operator when
   //BreakBeforeTernaryOperators=true
   unsigned Indent = CurrentState.Indent;
-  if (Style.AlignOperands != FormatStyle::OAS_DontAlign)
+  if (Style.AlignOperands != FormatStyle::OAS_DontAlign &&
+  !Style.BreakBeforeTernaryOperators) {
 Indent -= Style.ContinuationIndentWidth;
+  }
+  if (Style.BreakBeforeTernaryOperators &&
+  CurrentState.IsChainedConditional) {
+Indent -= 2;
+  }
   if (Style.BreakBeforeTernaryOperators && CurrentState.UnindentOperator)
 Indent -= 2;
   return Indent;
@@ -1773,7 +1779,8 @@ void 
ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
 !CurrentState.IsWrappedConditional) {
   NewParenState.IsChainedConditional = true;
   NewParenState.UnindentOperator = State.Stack.back().UnindentOperator;
-} else if (PrecedenceLevel == prec::Conditional ||
+} else if ((PrecedenceLevel == prec::Conditional &&
+!Style.BreakBeforeTernaryOperators) ||
(!SkipFirstExtraIndent && PrecedenceLevel > prec::Assignment &&
 !Current.isTrailingComment())) {
   NewParenState.Indent += Style.ContinuationIndentWidth;
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index d01ce137b8fcb..bdd657db06712 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -7332,12 +7332,11 @@ TEST_F(FormatTest, 
ExpressionIndentationBreakingBeforeOperators) {
"};",
Style);
   verifyFormat("return abc\n"
-   " ? foo(\n"
-   " a,\n"
-   " b,\n"
-   " bar(\n"
-   "   abc))\n"
-   " : g(abc);",
+   "   ? foo(\n"
+   "   a,\n"
+   "   b,\n"
+   "   bar(abc))\n"
+   "   : g(abc);",
Style);
 }
 
@@ -9410,20 +9409,20 @@ TEST_F(FormatTest, BreaksConditionalExpressions) {
": aaa;");
   verifyFormat("a aa =\n"
"\n"
-   "? aa\n"
-   ": ;");
+   "? aa\n"
+   ": ;");
   verifyFormat(
   "aa == aa\n"
   "? aaa\n"
   ": aaa;");
   verifyFormat("f( == // force break\n"
-   "  a\n"
-   "  ? b\n"
-   "  : c);");
+   "  a\n"
+   "  ? b\n"
+   "  : c);");
   verifyFormat("return  == \n"
-   "   // comment\n"
-   "   ? \n"
-   "   : ;");
+   "   // comment\n"
+   "   ? \n"
+   "   : ;");
   verifyFormat("unsigned Indent =\n"
"format(TheLine.First,\n"
"   IndentForLevel[TheLine.Level] >= 0\n"
@@ -9432,21 +9431,20 @@ TEST_F(FormatTest, BreaksConditionalExpressions) {
"   TheLine.InPPDirective, PreviousEndOfLineColumn);",
getLLVMStyleWithColumns(60));
   verifyForm

[clang] [llvm] target ABI: improve call parameters extensions handling (PR #100757)

2024-07-27 Thread Phoebe Wang via cfe-commits


@@ -1185,6 +1189,9 @@ Currently, only the following parameter attributes are 
defined:
 value should be sign-extended to the extent required by the target's
 ABI (which is usually 32-bits) by the caller (for a parameter) or
 the callee (for a return value).
+``noext`` This indicates to the code generator that the parameter or return
+value has the high bits undefined, as for a struct in register, and
+therefore does not need to be sign or zero extended.

phoebewang wrote:

There doesn't exist an "IR ABI". If you don't specify a calling convention in 
IR, [it must be C calling 
convention](https://llvm.org/docs/LangRef.html#calling-conventions).
Or you want to call representations out of C ABI definition "IR ABI"? I cannot 
agree with either. A typical ABI has two merits: well documented and stable. 
Neither do they have. They are almost exceptions unconsciously generated front 
end or written by hand. They exist just because we lack a verifier for them.
My suggestion is to introduce ABI verification code for each target in the IR 
verifier like 
[this](https://github.com/llvm/llvm-project/blob/main/llvm/lib/IR/Verifier.cpp#L2333-L2339).
 We may start from cases we care most and gradually check all rules followed by 
clang front end.

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


[clang] [llvm] target ABI: improve call parameters extensions handling (PR #100757)

2024-07-27 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang edited 
https://github.com/llvm/llvm-project/pull/100757
___
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-27 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/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.

>From 13724c6cd47c17b92b57f04436c544bd9d681070 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sat, 27 Jul 2024 18:52:23 +0800
Subject: [PATCH] [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,
-  

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

2024-07-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Younan Zhang (zyn0217)


Changes

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.

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


1 Files Affected:

- (modified) clang/lib/Sema/SemaTemplateDeductionGuide.cpp (+52-68) 


``diff
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->getLocation(), [&] {
-NewParam = cast(Instantiator.Visit(NewParam));
-  });
-}
+if (NestedPattern)
+  NewPa

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

2024-07-27 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/2] [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-27 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

The flaky test `basic-project.test` failure is unrelated -- I didn't rebase my 
branch onto 88549cf4

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][ARM64EC] Add support for hybrid_patchable attribute. (PR #99478)

2024-07-27 Thread Jacek Caban via cfe-commits

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


[clang] ea98dc8 - [clang][ARM64EC] Add support for hybrid_patchable attribute. (#99478)

2024-07-27 Thread via cfe-commits

Author: Jacek Caban
Date: 2024-07-27T14:29:05+02:00
New Revision: ea98dc8b8f508b8393651992830e5e51d3876728

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

LOG: [clang][ARM64EC] Add support for hybrid_patchable attribute. (#99478)

Added: 
clang/test/CodeGen/arm64ec-hybrid-patchable.c

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4f1a916aad9d2..ddad083571eb1 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -116,6 +116,9 @@ Attribute Changes in Clang
 
 - Introduced a new format attribute ``__attribute__((format(syslog, 1, 2)))`` 
from OpenBSD.
 
+- The ``hybrid_patchable`` attribute is now supported on ARM64EC targets. It 
can be used to specify
+  that a function requires an additional x86-64 thunk, which may be patched at 
runtime.
+
 Improvements to Clang's diagnostics
 ---
 

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 4825979a974d2..46d0a66d59c37 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -477,6 +477,9 @@ def TargetELF : TargetSpec {
 def TargetELFOrMachO : TargetSpec {
   let ObjectFormats = ["ELF", "MachO"];
 }
+def TargetWindowsArm64EC : TargetSpec {
+  let CustomCode = [{ Target.getTriple().isWindowsArm64EC() }];
+}
 
 def TargetSupportsInitPriority : TargetSpec {
   let CustomCode = [{ !Target.getTriple().isOSzOS() }];
@@ -4027,6 +4030,12 @@ def SelectAny : InheritableAttr {
   let SimpleHandler = 1;
 }
 
+def HybridPatchable : InheritableAttr, 
TargetSpecificAttr {
+  let Spellings = [Declspec<"hybrid_patchable">, Clang<"hybrid_patchable">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [HybridPatchableDocs];
+}
+
 def Thread : Attr {
   let Spellings = [Declspec<"thread">];
   let LangOpts = [MicrosoftExt];

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 99738812c8157..b5d468eb5ec95 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -5985,6 +5985,16 @@ For more information see
 or `msvc documentation `_.
 }]; }
 
+def HybridPatchableDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``hybrid_patchable`` attribute declares an ARM64EC function with an 
additional
+x86-64 thunk, which may be patched at runtime.
+
+For more information see
+`ARM64EC ABI documentation 
`_.
+}]; }
+
 def WebAssemblyExportNameDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e768151ce23c1..9e6d85c469d64 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3681,6 +3681,9 @@ def err_attribute_weak_static : Error<
   "weak declaration cannot have internal linkage">;
 def err_attribute_selectany_non_extern_data : Error<
   "'selectany' can only be applied to data items with external linkage">;
+def warn_attribute_hybrid_patchable_non_extern : Warning<
+  "'hybrid_patchable' is ignored on functions without external linkage">,
+  InGroup;
 def err_declspec_thread_on_thread_variable : Error<
   "'__declspec(thread)' applied to variable that already has a "
   "thread-local storage specifier">;

diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index d6078696a7d91..af201554898f3 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -991,6 +991,9 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType 
RetTy,
   if (D && D->hasAttr())
 Fn->addFnAttr(llvm::Attribute::NoProfile);
 
+  if (D && D->hasAttr())
+Fn->addFnAttr(llvm::Attribute::HybridPatchable);
+
   if (D) {
 // Function attributes take precedence over command line flags.
 if (auto *A = D->getAttr()) {

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 7bdecb2546f30..694a754646f27 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6890,6 +6890,11 @@ static void checkAttributesAfterMerging(Sema &S, 
NamedDecl &ND) {
 }
   }
 
+  if (HybridPatchableAttr *Attr = 

[clang-tools-extra] Create a new check to look for mis-use in calls that take iterators (PR #99917)

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

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

>From bbf32f3ca89e8950d82fe920b232fee4b82cb43e Mon Sep 17 00:00:00 2001
From: Nathan James 
Date: Tue, 23 Jul 2024 10:59:45 +0100
Subject: [PATCH] Create a new check to look for mis-use in calls that take
 iterators

Looks for various patterns of functions that take arguments calling
begin/end or similar for common mistakes
---
 .../bugprone/BugproneTidyModule.cpp   |   3 +
 .../clang-tidy/bugprone/CMakeLists.txt|   1 +
 .../bugprone/IncorrectIteratorsCheck.cpp  | 765 ++
 .../bugprone/IncorrectIteratorsCheck.h|  45 ++
 clang-tools-extra/docs/ReleaseNotes.rst   |   6 +
 .../checks/bugprone/incorrect-iterators.rst   | 122 +++
 .../docs/clang-tidy/checks/list.rst   |   1 +
 .../checkers/bugprone/incorrect-iterators.cpp | 239 ++
 8 files changed, 1182 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/bugprone/incorrect-iterators.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/incorrect-iterators.cpp

diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 689eb92a3d8d1..cea040b81878a 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -33,6 +33,7 @@
 #include "InaccurateEraseCheck.h"
 #include "IncDecInConditionsCheck.h"
 #include "IncorrectEnableIfCheck.h"
+#include "IncorrectIteratorsCheck.h"
 #include "IncorrectRoundingsCheck.h"
 #include "InfiniteLoopCheck.h"
 #include "IntegerDivisionCheck.h"
@@ -139,6 +140,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-inaccurate-erase");
 CheckFactories.registerCheck(
 "bugprone-incorrect-enable-if");
+CheckFactories.registerCheck(
+"bugprone-incorrect-iterators");
 CheckFactories.registerCheck(
 "bugprone-return-const-ref-from-parameter");
 CheckFactories.registerCheck(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index cb0d8ae98bac5..8425dbed0505a 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -26,6 +26,7 @@ add_clang_library(clangTidyBugproneModule
   ImplicitWideningOfMultiplicationResultCheck.cpp
   InaccurateEraseCheck.cpp
   IncorrectEnableIfCheck.cpp
+  IncorrectIteratorsCheck.cpp
   ReturnConstRefFromParameterCheck.cpp
   SuspiciousStringviewDataUsageCheck.cpp
   SwitchMissingDefaultCaseCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.cpp
new file mode 100644
index 0..2203004d709c9
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.cpp
@@ -0,0 +1,765 @@
+//===--- IncorrectIteratorsCheck.cpp - clang-tidy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "IncorrectIteratorsCheck.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTTypeTraits.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/ASTMatchers/ASTMatchersInternal.h"
+#include "clang/ASTMatchers/ASTMatchersMacros.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/ErrorHandling.h"
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+namespace {
+using SVU = llvm::SmallVector;
+/// Checks to see if a all the parameters of a template function with a given
+/// index refer to the same type.
+AST_MATCHER_P(FunctionDecl, areParametersSameTemplateType, SVU, Indexes) {
+  const FunctionTemplateDecl *TemplateDecl = Node.getPrimaryTemplate();
+  if (!TemplateDecl)
+return false;
+  const FunctionDecl *FuncDecl = TemplateDecl->getTemplatedDecl();
+  if (!FuncDecl)
+return false;
+  assert(!Indexes.empty());
+  if (llvm::any_of(Indexes, [Count(FuncDecl->getNumParams())](unsigned Index) {
+return Index >= Count;
+  }))
+return false;

[clang-tools-extra] Create a new check to look for mis-use in calls that take iterators (PR #99917)

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


@@ -0,0 +1,756 @@
+//===--- IncorrectIteratorsCheck.cpp - clang-tidy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "IncorrectIteratorsCheck.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTTypeTraits.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/ASTMatchers/ASTMatchersMacros.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/ErrorHandling.h"
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+namespace {
+using SVU = llvm::SmallVector;
+/// Checks to see if a all the parameters of a template function with a given
+/// index refer to the same type.
+AST_MATCHER_P(FunctionDecl, areParametersSameTemplateType, SVU, Indexes) {
+  const FunctionTemplateDecl *TemplateDecl = Node.getPrimaryTemplate();
+  if (!TemplateDecl)
+return false;
+  const FunctionDecl *FuncDecl = TemplateDecl->getTemplatedDecl();
+  if (!FuncDecl)
+return false;
+  assert(!Indexes.empty());
+  if (llvm::any_of(Indexes, [Count(FuncDecl->getNumParams())](unsigned Index) {
+return Index >= Count;
+  }))
+return false;
+  const ParmVarDecl *FirstParam = FuncDecl->getParamDecl(Indexes.front());
+  if (!FirstParam)
+return false;
+  QualType Type = FirstParam->getOriginalType();
+  for (auto Item : llvm::drop_begin(Indexes)) {
+const ParmVarDecl *Param = FuncDecl->getParamDecl(Item);
+if (!Param)
+  return false;
+if (Param->getOriginalType() != Type)
+  return false;
+  }
+  return true;
+}
+AST_MATCHER_P(FunctionDecl, isParameterTypeUnique, unsigned, Index) {
+  const FunctionTemplateDecl *TemplateDecl = Node.getPrimaryTemplate();
+  if (!TemplateDecl)
+return false;
+  const FunctionDecl *FuncDecl = TemplateDecl->getTemplatedDecl();
+  if (!FuncDecl)
+return false;
+  if (Index >= FuncDecl->getNumParams())
+return false;
+  const ParmVarDecl *MainParam = FuncDecl->getParamDecl(Index);
+  if (!MainParam)
+return false;
+  QualType Type = MainParam->getOriginalType();
+  for (unsigned I = 0, E = FuncDecl->getNumParams(); I != E; ++I) {
+if (I == Index)
+  continue;
+const ParmVarDecl *Param = FuncDecl->getParamDecl(I);
+if (!Param)
+  continue;
+if (Param->getOriginalType() == Type)
+  return false;
+  }
+  return true;
+}
+struct NameMatchers {
+  ArrayRef FreeNames;
+  ArrayRef MethodNames;
+};
+
+struct NamePairs {
+  NameMatchers BeginNames;
+  NameMatchers EndNames;
+};
+
+struct FullState {
+  NamePairs Forward;
+  NamePairs Reversed;
+  NamePairs Combined;
+  NameMatchers All;
+  ArrayRef MakeReverseIterator;
+};
+
+} // namespace
+
+static constexpr char FirstRangeArg[] = "FirstRangeArg";
+static constexpr char FirstRangeArgExpr[] = "FirstRangeArgExpr";
+static constexpr char ReverseBeginBind[] = "ReverseBeginBind";
+static constexpr char ReverseEndBind[] = "ReverseEndBind";
+static constexpr char SecondRangeArg[] = "SecondRangeArg";
+static constexpr char SecondRangeArgExpr[] = "SecondRangeArgExpr";
+static constexpr char ArgMismatchBegin[] = "ArgMismatchBegin";
+static constexpr char ArgMismatchEnd[] = "ArgMismatchEnd";
+static constexpr char ArgMismatchExpr[] = "ArgMismatchExpr";
+static constexpr char ArgMismatchRevBind[] = "ArgMismatchRevBind";
+static constexpr char Callee[] = "Callee";
+static constexpr char Internal[] = "Internal";
+static constexpr char InternalOther[] = "InternalOther";
+static constexpr char InternalArgument[] = "InternalArgument";
+static constexpr char OutputRangeEnd[] = "OutputRangeEnd";
+static constexpr char OutputRangeBegin[] = "OutputRangeBegin";
+
+static auto
+makeExprMatcher(ast_matchers::internal::Matcher ArgumentMatcher,
+const NameMatchers &Names, ArrayRef MakeReverse,
+const NameMatchers &RevNames, StringRef RevBind) {
+  return expr(anyOf(
+  cxxMemberCallExpr(argumentCountIs(0),
+callee(cxxMethodDecl(hasAnyName(Names.MethodNames))),
+on(ArgumentMatcher)),
+  callExpr(argumentCountIs(1),
+   hasDeclaration(functionDecl(hasAnyName(Names.FreeNames))),
+   hasArgument(0, ArgumentMatcher)),
+  callExpr(
+  callee(functionDecl(hasAnyName(MakeReverse))), argumentCountIs(1),
+  hasArgument(
+  

[clang-tools-extra] Extend support for specifying languages and version in add_new_check.py (PR #100129)

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

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

>From b76a506ad12f3923dbca13063b66bb83a336f0c2 Mon Sep 17 00:00:00 2001
From: Nathan James 
Date: Tue, 23 Jul 2024 15:24:52 +0100
Subject: [PATCH] Extend support for specifying languages and version in
 add_new_check.py

- Allow specifying a language standard when adding a new check
- Simplify the language standards(and or-later) handlnig in
check_clang_tidy
---
 clang-tools-extra/clang-tidy/add_new_check.py | 118 +++---
 .../test/clang-tidy/check_clang_tidy.py   |  50 +---
 2 files changed, 137 insertions(+), 31 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/add_new_check.py 
b/clang-tools-extra/clang-tidy/add_new_check.py
index 1ce2019ee33fe..bd69bddcc6825 100755
--- a/clang-tools-extra/clang-tidy/add_new_check.py
+++ b/clang-tools-extra/clang-tidy/add_new_check.py
@@ -13,11 +13,13 @@
 
 import argparse
 import io
+import itertools
 import os
 import re
 import sys
 import textwrap
 
+
 # Adapts the module's CMakelist file. Returns 'True' if it could add a new
 # entry and 'False' if the entry already existed.
 def adapt_cmake(module_path, check_name_camel):
@@ -55,13 +57,28 @@ def adapt_cmake(module_path, check_name_camel):
 
 # Adds a header for the new check.
 def write_header(
-module_path, module, namespace, check_name, check_name_camel, description
+module_path,
+module,
+namespace,
+check_name,
+check_name_camel,
+description,
+lang_restrict,
 ):
 wrapped_desc = "\n".join(
 textwrap.wrap(
 description, width=80, initial_indent="/// ", 
subsequent_indent="/// "
 )
 )
+if lang_restrict:
+override_supported = """
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
+return %s;
+  }""" % (
+lang_restrict % {"lang": "LangOpts"}
+)
+else:
+override_supported = ""
 filename = os.path.join(module_path, check_name_camel) + ".h"
 print("Creating %s..." % filename)
 with io.open(filename, "w", encoding="utf8", newline="\n") as f:
@@ -102,7 +119,7 @@ class %(check_name_camel)s : public ClangTidyCheck {
   %(check_name_camel)s(StringRef Name, ClangTidyContext *Context)
   : ClangTidyCheck(Name, Context) {}
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
-  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) 
override;%(override_supported)s
 };
 
 } // namespace clang::tidy::%(namespace)s
@@ -116,6 +133,7 @@ class %(check_name_camel)s : public ClangTidyCheck {
 "module": module,
 "namespace": namespace,
 "description": wrapped_desc,
+"override_supported": override_supported,
 }
 )
 
@@ -306,7 +324,9 @@ def add_release_notes(module_path, module, check_name, 
description):
 
 
 # Adds a test for the check.
-def write_test(module_path, module, check_name, test_extension):
+def write_test(module_path, module, check_name, test_extension, test_standard):
+if test_standard:
+test_standard = f"-std={test_standard}-or-later "
 check_name_dashes = module + "-" + check_name
 filename = os.path.normpath(
 os.path.join(
@@ -323,7 +343,7 @@ def write_test(module_path, module, check_name, 
test_extension):
 print("Creating %s..." % filename)
 with io.open(filename, "w", encoding="utf8", newline="\n") as f:
 f.write(
-"""// RUN: %%check_clang_tidy %%s %(check_name_dashes)s %%t
+"""// RUN: %%check_clang_tidy %(standard)s%%s 
%(check_name_dashes)s %%t
 
 // FIXME: Add something that triggers the check here.
 void f();
@@ -338,7 +358,7 @@ def write_test(module_path, module, check_name, 
test_extension):
 // FIXME: Add something that doesn't trigger the check here.
 void awesome_f2();
 """
-% {"check_name_dashes": check_name_dashes}
+% {"check_name_dashes": check_name_dashes, "standard": 
test_standard}
 )
 
 
@@ -511,7 +531,10 @@ def format_link_alias(doc_file):
 if (match or (check_name.startswith("clang-analyzer-"))) and 
check_name:
 module = doc_file[0]
 check_file = doc_file[1].replace(".rst", "")
-if not match or match.group(1) == 
"https://clang.llvm.org/docs/analyzer/checkers":
+if (
+not match
+or match.group(1) == 
"https://clang.llvm.org/docs/analyzer/checkers";
+):
 title = "Clang Static Analyzer " + check_file
 # Preserve the anchor in checkers.html from group 2.
 target = "" if not match else match.group(1) + ".html" + 
match.group(2)
@@ -529,7 +552,7 @@ def format_link_alias(doc_file):
 if target:
 # The checker is just a redirect.
 return (
- 

[clang-tools-extra] 154d00d - Extend support for specifying languages and version in add_new_check.py (#100129)

2024-07-27 Thread via cfe-commits

Author: Nathan James
Date: 2024-07-27T14:13:21+01:00
New Revision: 154d00d5d0416c42388d6e82cac96fbc091101d2

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

LOG: Extend support for specifying languages and version in add_new_check.py 
(#100129)

- Allow specifying a language standard when adding a new check
- Simplify the language standards(and or-later) handlnig in
check_clang_tidy

Added: 


Modified: 
clang-tools-extra/clang-tidy/add_new_check.py
clang-tools-extra/test/clang-tidy/check_clang_tidy.py

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/add_new_check.py 
b/clang-tools-extra/clang-tidy/add_new_check.py
index 1ce2019ee33fe..bd69bddcc6825 100755
--- a/clang-tools-extra/clang-tidy/add_new_check.py
+++ b/clang-tools-extra/clang-tidy/add_new_check.py
@@ -13,11 +13,13 @@
 
 import argparse
 import io
+import itertools
 import os
 import re
 import sys
 import textwrap
 
+
 # Adapts the module's CMakelist file. Returns 'True' if it could add a new
 # entry and 'False' if the entry already existed.
 def adapt_cmake(module_path, check_name_camel):
@@ -55,13 +57,28 @@ def adapt_cmake(module_path, check_name_camel):
 
 # Adds a header for the new check.
 def write_header(
-module_path, module, namespace, check_name, check_name_camel, description
+module_path,
+module,
+namespace,
+check_name,
+check_name_camel,
+description,
+lang_restrict,
 ):
 wrapped_desc = "\n".join(
 textwrap.wrap(
 description, width=80, initial_indent="/// ", 
subsequent_indent="/// "
 )
 )
+if lang_restrict:
+override_supported = """
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
+return %s;
+  }""" % (
+lang_restrict % {"lang": "LangOpts"}
+)
+else:
+override_supported = ""
 filename = os.path.join(module_path, check_name_camel) + ".h"
 print("Creating %s..." % filename)
 with io.open(filename, "w", encoding="utf8", newline="\n") as f:
@@ -102,7 +119,7 @@ class %(check_name_camel)s : public ClangTidyCheck {
   %(check_name_camel)s(StringRef Name, ClangTidyContext *Context)
   : ClangTidyCheck(Name, Context) {}
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
-  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) 
override;%(override_supported)s
 };
 
 } // namespace clang::tidy::%(namespace)s
@@ -116,6 +133,7 @@ class %(check_name_camel)s : public ClangTidyCheck {
 "module": module,
 "namespace": namespace,
 "description": wrapped_desc,
+"override_supported": override_supported,
 }
 )
 
@@ -306,7 +324,9 @@ def add_release_notes(module_path, module, check_name, 
description):
 
 
 # Adds a test for the check.
-def write_test(module_path, module, check_name, test_extension):
+def write_test(module_path, module, check_name, test_extension, test_standard):
+if test_standard:
+test_standard = f"-std={test_standard}-or-later "
 check_name_dashes = module + "-" + check_name
 filename = os.path.normpath(
 os.path.join(
@@ -323,7 +343,7 @@ def write_test(module_path, module, check_name, 
test_extension):
 print("Creating %s..." % filename)
 with io.open(filename, "w", encoding="utf8", newline="\n") as f:
 f.write(
-"""// RUN: %%check_clang_tidy %%s %(check_name_dashes)s %%t
+"""// RUN: %%check_clang_tidy %(standard)s%%s 
%(check_name_dashes)s %%t
 
 // FIXME: Add something that triggers the check here.
 void f();
@@ -338,7 +358,7 @@ def write_test(module_path, module, check_name, 
test_extension):
 // FIXME: Add something that doesn't trigger the check here.
 void awesome_f2();
 """
-% {"check_name_dashes": check_name_dashes}
+% {"check_name_dashes": check_name_dashes, "standard": 
test_standard}
 )
 
 
@@ -511,7 +531,10 @@ def format_link_alias(doc_file):
 if (match or (check_name.startswith("clang-analyzer-"))) and 
check_name:
 module = doc_file[0]
 check_file = doc_file[1].replace(".rst", "")
-if not match or match.group(1) == 
"https://clang.llvm.org/docs/analyzer/checkers":
+if (
+not match
+or match.group(1) == 
"https://clang.llvm.org/docs/analyzer/checkers";
+):
 title = "Clang Static Analyzer " + check_file
 # Preserve the anchor in checkers.html from group 2.
 target = "" if not match else match.group(1) + ".html" + 
match.group(2)
@@ -529,7 +552,7 @@ def format_link_alias(doc_file):
  

[clang-tools-extra] Extend support for specifying languages and version in add_new_check.py (PR #100129)

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

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


[clang] [clang][ARM64EC] Add support for hybrid_patchable attribute. (PR #99478)

2024-07-27 Thread Jacek Caban via cfe-commits

cjacek wrote:

/cherry-pick ea98dc8b8f508b8393651992830e5e51d3876728

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


[clang] [clang][ARM64EC] Add support for hybrid_patchable attribute. (PR #99478)

2024-07-27 Thread Jacek Caban via cfe-commits

cjacek wrote:

Thanks. I created #100872 for dllexport fix.

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


[clang] [clang][ARM64EC] Add support for hybrid_patchable attribute. (PR #99478)

2024-07-27 Thread via cfe-commits

llvmbot wrote:


>/cherry-pick ea98dc8b8f508b8393651992830e5e51d3876728

Error: Command failed due to missing milestone.

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


[clang] [clang][ARM64EC] Add support for hybrid_patchable attribute. (PR #99478)

2024-07-27 Thread Jacek Caban via cfe-commits

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


[clang] [clang][ARM64EC] Add support for hybrid_patchable attribute. (PR #99478)

2024-07-27 Thread Jacek Caban via cfe-commits

cjacek wrote:

/cherry-pick ea98dc8b8f508b8393651992830e5e51d3876728

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


[clang] [clang][ARM64EC] Add support for hybrid_patchable attribute. (PR #99478)

2024-07-27 Thread via cfe-commits

llvmbot wrote:

/pull-request llvm/llvm-project#100873

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


[clang] [clang][dataflow] Fix bug in `buildContainsExprConsumedInDifferentBlock()`. (PR #100874)

2024-07-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (martinboehme)


Changes

This was missing a call to `ignoreCFGOmittedNodes()`. As a result, the function
would erroneously conclude that a block did not contain an expression consumed
in a different block if the expression in question was surrounded by a
`ParenExpr` in the consuming block. The patch adds a test that triggers this
scenario (and fails without the fix).

To prevent this kind of bug in the future, the patch also adds a new method
`blockForStmt()` to `AdornedCFG` that calls `ignoreCFGOmittedNodes()` and is
preferred over accessing `getStmtToBlock()` directly.


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


5 Files Affected:

- (modified) clang/include/clang/Analysis/FlowSensitive/AdornedCFG.h (+31-4) 
- (modified) clang/lib/Analysis/FlowSensitive/AdornedCFG.cpp (+11-5) 
- (modified) clang/lib/Analysis/FlowSensitive/Transfer.cpp (+5-6) 
- (modified) clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp 
(+5-4) 
- (modified) 
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp 
(+38-1) 


``diff
diff --git a/clang/include/clang/Analysis/FlowSensitive/AdornedCFG.h 
b/clang/include/clang/Analysis/FlowSensitive/AdornedCFG.h
index 420f13ce11bfd..5de66fcb0e3af 100644
--- a/clang/include/clang/Analysis/FlowSensitive/AdornedCFG.h
+++ b/clang/include/clang/Analysis/FlowSensitive/AdornedCFG.h
@@ -18,6 +18,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/Stmt.h"
 #include "clang/Analysis/CFG.h"
+#include "clang/Analysis/FlowSensitive/ASTOps.h"
 #include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/Support/Error.h"
@@ -27,6 +28,24 @@
 namespace clang {
 namespace dataflow {
 
+namespace internal {
+class StmtToBlockMap {
+public:
+  StmtToBlockMap(const CFG &Cfg);
+
+  const CFGBlock *lookup(const Stmt &S) const {
+return StmtToBlock.lookup(&ignoreCFGOmittedNodes(S));
+  }
+
+  const llvm::DenseMap &getMap() const {
+return StmtToBlock;
+  }
+
+private:
+  llvm::DenseMap StmtToBlock;
+};
+} // namespace internal
+
 /// Holds CFG with additional information derived from it that is needed to
 /// perform dataflow analysis.
 class AdornedCFG {
@@ -49,8 +68,17 @@ class AdornedCFG {
   const CFG &getCFG() const { return *Cfg; }
 
   /// Returns a mapping from statements to basic blocks that contain them.
+  /// Deprecated. Use `blockForStmt()` instead (which prevents the potential
+  /// error of forgetting to call `ignoreCFGOmittedNodes()` on the statement to
+  /// look up).
   const llvm::DenseMap &getStmtToBlock() const 
{
-return StmtToBlock;
+return StmtToBlock.getMap();
+  }
+
+  /// Returns the basic block that contains `S`, or null if no basic block
+  /// containing `S` is found.
+  const CFGBlock *blockForStmt(const Stmt &S) const {
+return StmtToBlock.lookup(S);
   }
 
   /// Returns whether `B` is reachable from the entry block.
@@ -73,8 +101,7 @@ class AdornedCFG {
 private:
   AdornedCFG(
   const Decl &D, std::unique_ptr Cfg,
-  llvm::DenseMap StmtToBlock,
-  llvm::BitVector BlockReachable,
+  internal::StmtToBlockMap StmtToBlock, llvm::BitVector BlockReachable,
   llvm::DenseSet ContainsExprConsumedInDifferentBlock)
   : ContainingDecl(D), Cfg(std::move(Cfg)),
 StmtToBlock(std::move(StmtToBlock)),
@@ -85,7 +112,7 @@ class AdornedCFG {
   /// The `Decl` containing the statement used to construct the CFG.
   const Decl &ContainingDecl;
   std::unique_ptr Cfg;
-  llvm::DenseMap StmtToBlock;
+  internal::StmtToBlockMap StmtToBlock;
   llvm::BitVector BlockReachable;
   llvm::DenseSet ContainsExprConsumedInDifferentBlock;
 };
diff --git a/clang/lib/Analysis/FlowSensitive/AdornedCFG.cpp 
b/clang/lib/Analysis/FlowSensitive/AdornedCFG.cpp
index 255543021a998..876b5a3db5249 100644
--- a/clang/lib/Analysis/FlowSensitive/AdornedCFG.cpp
+++ b/clang/lib/Analysis/FlowSensitive/AdornedCFG.cpp
@@ -16,6 +16,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/Stmt.h"
 #include "clang/Analysis/CFG.h"
+#include "clang/Analysis/FlowSensitive/ASTOps.h"
 #include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/Support/Error.h"
@@ -96,8 +97,7 @@ static llvm::BitVector findReachableBlocks(const CFG &Cfg) {
 
 static llvm::DenseSet
 buildContainsExprConsumedInDifferentBlock(
-const CFG &Cfg,
-const llvm::DenseMap &StmtToBlock) {
+const CFG &Cfg, const internal::StmtToBlockMap &StmtToBlock) {
   llvm::DenseSet Result;
 
   auto CheckChildExprs = [&Result, &StmtToBlock](const Stmt *S,
@@ -105,7 +105,7 @@ buildContainsExprConsumedInDifferentBlock(
 for (const Stmt *Child : S->children()) {
   if (!isa_and_nonnull(Child))
 continue;
-  const CFGBlock *ChildBlock = StmtToBlock.lookup(Child);
+  const CFGBlock *ChildBlock = StmtToBlock.lookup(*Child);
   if (ChildBlock != Block)
 Result.insert(ChildBlock);
 }
@@ -126,6 +126,13 @@ buildContains

[clang] [clang][dataflow] Fix bug in `buildContainsExprConsumedInDifferentBlock()`. (PR #100874)

2024-07-27 Thread via cfe-commits

https://github.com/martinboehme created 
https://github.com/llvm/llvm-project/pull/100874

This was missing a call to `ignoreCFGOmittedNodes()`. As a result, the function
would erroneously conclude that a block did not contain an expression consumed
in a different block if the expression in question was surrounded by a
`ParenExpr` in the consuming block. The patch adds a test that triggers this
scenario (and fails without the fix).

To prevent this kind of bug in the future, the patch also adds a new method
`blockForStmt()` to `AdornedCFG` that calls `ignoreCFGOmittedNodes()` and is
preferred over accessing `getStmtToBlock()` directly.


>From 8df9b292cebd658c3d305a3e03d8df1e779d2d1a Mon Sep 17 00:00:00 2001
From: Martin Braenne 
Date: Sat, 27 Jul 2024 13:47:44 +
Subject: [PATCH] [clang][dataflow] Fix bug in
 `buildContainsExprConsumedInDifferentBlock()`.

This was missing a call to `ignoreCFGOmittedNodes()`. As a result, the function
would erroneously conclude that a block did not contain an expression consumed
in a different block if the expression in question was surrounded by a
`ParenExpr` in the consuming block. The patch adds a test that triggers this
scenario (and fails without the fix).

To prevent this kind of bug in the future, the patch also adds a new method
`blockForStmt()` to `AdornedCFG` that calls `ignoreCFGOmittedNodes()` and is
preferred over accessing `getStmtToBlock()` directly.
---
 .../clang/Analysis/FlowSensitive/AdornedCFG.h | 35 +++--
 .../lib/Analysis/FlowSensitive/AdornedCFG.cpp | 16 +---
 clang/lib/Analysis/FlowSensitive/Transfer.cpp | 11 +++---
 .../TypeErasedDataflowAnalysis.cpp|  9 +++--
 .../TypeErasedDataflowAnalysisTest.cpp| 39 ++-
 5 files changed, 90 insertions(+), 20 deletions(-)

diff --git a/clang/include/clang/Analysis/FlowSensitive/AdornedCFG.h 
b/clang/include/clang/Analysis/FlowSensitive/AdornedCFG.h
index 420f13ce11bfd..5de66fcb0e3af 100644
--- a/clang/include/clang/Analysis/FlowSensitive/AdornedCFG.h
+++ b/clang/include/clang/Analysis/FlowSensitive/AdornedCFG.h
@@ -18,6 +18,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/Stmt.h"
 #include "clang/Analysis/CFG.h"
+#include "clang/Analysis/FlowSensitive/ASTOps.h"
 #include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/Support/Error.h"
@@ -27,6 +28,24 @@
 namespace clang {
 namespace dataflow {
 
+namespace internal {
+class StmtToBlockMap {
+public:
+  StmtToBlockMap(const CFG &Cfg);
+
+  const CFGBlock *lookup(const Stmt &S) const {
+return StmtToBlock.lookup(&ignoreCFGOmittedNodes(S));
+  }
+
+  const llvm::DenseMap &getMap() const {
+return StmtToBlock;
+  }
+
+private:
+  llvm::DenseMap StmtToBlock;
+};
+} // namespace internal
+
 /// Holds CFG with additional information derived from it that is needed to
 /// perform dataflow analysis.
 class AdornedCFG {
@@ -49,8 +68,17 @@ class AdornedCFG {
   const CFG &getCFG() const { return *Cfg; }
 
   /// Returns a mapping from statements to basic blocks that contain them.
+  /// Deprecated. Use `blockForStmt()` instead (which prevents the potential
+  /// error of forgetting to call `ignoreCFGOmittedNodes()` on the statement to
+  /// look up).
   const llvm::DenseMap &getStmtToBlock() const 
{
-return StmtToBlock;
+return StmtToBlock.getMap();
+  }
+
+  /// Returns the basic block that contains `S`, or null if no basic block
+  /// containing `S` is found.
+  const CFGBlock *blockForStmt(const Stmt &S) const {
+return StmtToBlock.lookup(S);
   }
 
   /// Returns whether `B` is reachable from the entry block.
@@ -73,8 +101,7 @@ class AdornedCFG {
 private:
   AdornedCFG(
   const Decl &D, std::unique_ptr Cfg,
-  llvm::DenseMap StmtToBlock,
-  llvm::BitVector BlockReachable,
+  internal::StmtToBlockMap StmtToBlock, llvm::BitVector BlockReachable,
   llvm::DenseSet ContainsExprConsumedInDifferentBlock)
   : ContainingDecl(D), Cfg(std::move(Cfg)),
 StmtToBlock(std::move(StmtToBlock)),
@@ -85,7 +112,7 @@ class AdornedCFG {
   /// The `Decl` containing the statement used to construct the CFG.
   const Decl &ContainingDecl;
   std::unique_ptr Cfg;
-  llvm::DenseMap StmtToBlock;
+  internal::StmtToBlockMap StmtToBlock;
   llvm::BitVector BlockReachable;
   llvm::DenseSet ContainsExprConsumedInDifferentBlock;
 };
diff --git a/clang/lib/Analysis/FlowSensitive/AdornedCFG.cpp 
b/clang/lib/Analysis/FlowSensitive/AdornedCFG.cpp
index 255543021a998..876b5a3db5249 100644
--- a/clang/lib/Analysis/FlowSensitive/AdornedCFG.cpp
+++ b/clang/lib/Analysis/FlowSensitive/AdornedCFG.cpp
@@ -16,6 +16,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/Stmt.h"
 #include "clang/Analysis/CFG.h"
+#include "clang/Analysis/FlowSensitive/ASTOps.h"
 #include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/Support/Error.h"
@@ -96,8 +97,7 @@ static llvm::BitVector findReachableBlocks(const CFG &Cfg) {
 
 static llvm::DenseSet
 buildContain

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-27 Thread Doug Wyatt via cfe-commits


@@ -4699,7 +4699,7 @@ class FunctionEffect {
 
 private:
   LLVM_PREFERRED_TYPE(Kind)
-  unsigned FKind : 3;
+  uint8_t FKind : 3;

dougsonos wrote:

That PR has been merged.

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


[clang] [HLSL][NFC] Initialize DiagnoseHLSLAvailability members (PR #100778)

2024-07-27 Thread Xiang Li via cfe-commits

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


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


[clang] [Clang][Sema] Disallow applying `onwership_returns` to functions that return non-pointers (PR #99564)

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

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


[clang] [Clang][Sema] Disallow applying `onwership_returns` to functions that return non-pointers (PR #99564)

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


@@ -3330,6 +3330,8 @@ def err_attribute_invalid_implicit_this_argument : Error<
   "%0 attribute is invalid for the implicit this argument">;
 def err_ownership_type : Error<
   "%0 attribute only applies to %select{pointer|integer}1 arguments">;
+def err_ownership_takes_return_type : Error<
+  "'ownership_returns' attribute only applies to functions that return 
pointers">;

AaronBallman wrote:

```suggestion
  "'ownership_returns' attribute only applies to functions that return a 
pointer">;
```

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


[clang] [Clang][Sema] Disallow applying `onwership_returns` to functions that return non-pointers (PR #99564)

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


@@ -1481,6 +1481,15 @@ static void handleOwnershipAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 break;
   }
 
+  // Allow only pointers to be return type for functions with ownership_returns
+  // attribute. This matches with current OwnershipAttr::Takes semantics
+  if (K == OwnershipAttr::Returns) {
+if (!getFunctionOrMethodResultType(D)->isPointerType()) {
+  S.Diag(AL.getLoc(), diag::err_ownership_takes_return_type) << AL;
+  return;
+}
+  }

AaronBallman wrote:

```suggestion
  if (K == OwnershipAttr::Returns && 
 !getFunctionOrMethodResultType(D)->isPointerType()) {
S.Diag(AL.getLoc(), diag::err_ownership_takes_return_type) << AL;
return;
  }
```
(combining the two predicates, may need reformatting.)

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


[clang] [Clang][Sema] Disallow applying `onwership_returns` to functions that return non-pointers (PR #99564)

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

https://github.com/AaronBallman commented:

Just a few minor nits, otherwise LGTM

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


[clang] [Clang][Sema] Disallow applying `onwership_returns` to functions that return non-pointers (PR #99564)

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


@@ -231,6 +231,10 @@ Crash and bug fixes
 Improvements
 
 
+- Improved the handling of the `ownership_returns` attribute. Now, Clang 
reports an
+  error if the attribute is attached to a function that returns a non-pointer 
value.

AaronBallman wrote:

```suggestion
- Improved the handling of the ``ownership_returns`` attribute. Now, Clang 
reports an
  error if the attribute is attached to a function that returns a non-pointer 
value.
```

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


[clang] [Clang][Sema] Disallow applying `onwership_returns` to functions that return non-pointers (PR #99564)

2024-07-27 Thread Pavel Skripkin via cfe-commits

https://github.com/pskrgag updated 
https://github.com/llvm/llvm-project/pull/99564

>From 6b7ec7c95df16de5eb0fecf2d69befb5461d98a5 Mon Sep 17 00:00:00 2001
From: Pavel Skripkin 
Date: Thu, 18 Jul 2024 18:48:47 +0300
Subject: [PATCH 1/6] clang/sema: disallow ownership_returns for functions that
 return non-pointers

ownership_takes expects an argument to a pointer and clang reports an
error if it is not the case.

Since pointers consumed by ownership_takes are produced by functions
with ownership_returns attribute, it make sence to report an error
if function does not return a pointer type.
---
 clang/include/clang/Basic/DiagnosticSemaKinds.td |  2 ++
 clang/lib/Sema/SemaDeclAttr.cpp  | 11 +++
 clang/test/AST/attr-print-emit.cpp   |  4 ++--
 clang/test/Sema/attr-ownership.c |  5 -
 clang/test/Sema/attr-ownership.cpp   |  6 +++---
 5 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 810abe4f23e31..9e6ea80ac4e40 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3330,6 +3330,8 @@ def err_attribute_invalid_implicit_this_argument : Error<
   "%0 attribute is invalid for the implicit this argument">;
 def err_ownership_type : Error<
   "%0 attribute only applies to %select{pointer|integer}1 arguments">;
+def err_ownership_takes_return_type : Error<
+  "'ownership_returns' attribute only applies to functions that return 
pointers">;
 def err_ownership_returns_index_mismatch : Error<
   "'ownership_returns' attribute index does not match; here it is %0">;
 def note_ownership_returns_index_mismatch : Note<
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 39675422e3f9f..810f0ddfa06fd 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1481,6 +1481,17 @@ static void handleOwnershipAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 break;
   }
 
+  // Allow only pointers to be return type for functions with ownership_takes
+  // attribute. This matches with current OwnershipAttr::Takes semantics
+  if (K == OwnershipAttr::Returns) {
+QualType RetType = getFunctionOrMethodResultType(D);
+
+if (!RetType->isPointerType()) {
+  S.Diag(AL.getLoc(), diag::err_ownership_takes_return_type) << AL;
+  return;
+}
+  }
+
   IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
 
   StringRef ModuleName = Module->getName();
diff --git a/clang/test/AST/attr-print-emit.cpp 
b/clang/test/AST/attr-print-emit.cpp
index 8c8a2b2080599..9c89764a3cac2 100644
--- a/clang/test/AST/attr-print-emit.cpp
+++ b/clang/test/AST/attr-print-emit.cpp
@@ -33,7 +33,7 @@ void ownt(int *, int *) __attribute__((ownership_takes(foo, 
1, 2)));
 // CHECK: void ownh(int *, int *) __attribute__((ownership_holds(foo, 1, 2)));
 void ownh(int *, int *) __attribute__((ownership_holds(foo, 1, 2)));
 // CHECK: void ownr(int) __attribute__((ownership_returns(foo, 1)));
-void ownr(int) __attribute__((ownership_returns(foo, 1)));
+void *ownr(int) __attribute__((ownership_returns(foo, 1)));
 
 // CHECK: void awtt(int, int, ...) __attribute__((argument_with_type_tag(foo, 
3, 2)));
 void awtt(int, int, ...) __attribute__((argument_with_type_tag(foo, 3, 2)));
@@ -66,7 +66,7 @@ class C {
   // CHECK: void ownh(int *, int *) __attribute__((ownership_holds(foo, 2, 
3)));
   void ownh(int *, int *) __attribute__((ownership_holds(foo, 2, 3)));
   // CHECK: void ownr(int) __attribute__((ownership_returns(foo, 2)));
-  void ownr(int) __attribute__((ownership_returns(foo, 2)));
+  void *ownr(int) __attribute__((ownership_returns(foo, 2)));
 
   // CHECK: void awtt(int, int, ...) 
__attribute__((argument_with_type_tag(foo, 4, 3)));
   void awtt(int, int, ...) __attribute__((argument_with_type_tag(foo, 4, 3)));
diff --git a/clang/test/Sema/attr-ownership.c b/clang/test/Sema/attr-ownership.c
index 084624353315c..5fb28a1b4e66f 100644
--- a/clang/test/Sema/attr-ownership.c
+++ b/clang/test/Sema/attr-ownership.c
@@ -18,7 +18,7 @@ void *f12(float i, int k, int f, int *j) 
__attribute__((ownership_returns(foo, 4
 void f13(int *i, int *j) __attribute__((ownership_holds(foo, 1))) 
__attribute__((ownership_takes(foo, 2)));
 void f14(int i, int j, int *k) __attribute__((ownership_holds(foo, 3))) 
__attribute__((ownership_takes(foo, 3)));  // expected-error 
{{'ownership_takes' and 'ownership_holds' attributes are not compatible}}
 
-void f15(int, int)
+void *f15(int, int)
   __attribute__((ownership_returns(foo, 1)))  // expected-error 
{{'ownership_returns' attribute index does not match; here it is 1}}
   __attribute__((ownership_returns(foo, 2))); // expected-note {{declared with 
index 2 here}}
 void f16(int *i, int *j) __attribute__((ownership_holds(foo, 1))) 
__attribute__((ownership_holds(foo, 1))); // OK, same index
@@ -28,3 +28,6 @@ void f1

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

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

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

>From f6c1a231681092189a621e2bc6af97300b2a7bfa Mon Sep 17 00:00:00 2001
From: Mike Crowe 
Date: Wed, 12 Jun 2024 21:06:26 +0100
Subject: [PATCH 1/6] [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   | 52 --
 .../clang-tidy/utils/FormatStringConverter.h  |  6 ++-
 clang-tools-extra/docs/ReleaseNotes.rst   |  3 +-
 .../checks/modernize/use-std-print.rst| 22 
 .../checkers/Inputs/Headers/inttypes.h| 26 +
 .../checkers/modernize/use-std-format.cpp | 53 +++
 .../checkers/modernize/use-std-print.cpp  | 47 +++-
 11 files changed, 181 insertions(+), 41 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp
index d082faa786b37..7e8cbd40fe07a 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) {
@@ -78,9 +79,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 1ea170c3cd310..69136c10d927b 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
@@ -137,7 +138,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 ClangTidyChe

[clang] [Clang][Interp] Fix the location of uninitialized base warning (PR #100761)

2024-07-27 Thread via cfe-commits

https://github.com/yronglin updated 
https://github.com/llvm/llvm-project/pull/100761

>From eb237d1b6434c16366f8095f47af1456cb776a27 Mon Sep 17 00:00:00 2001
From: yronglin 
Date: Fri, 26 Jul 2024 23:09:42 +0800
Subject: [PATCH 1/2] [Clang][Interp] Fix the location of uninitialized base
 warning

Signed-off-by: yronglin 
---
 clang/lib/AST/Interp/EvaluationResult.cpp | 20 +--
 .../constexpr-subobj-initialization.cpp   | 18 +++--
 .../constexpr-subobj-initialization.cpp   |  7 ---
 3 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/clang/lib/AST/Interp/EvaluationResult.cpp 
b/clang/lib/AST/Interp/EvaluationResult.cpp
index 1b255711c7b36..57e12598d12e4 100644
--- a/clang/lib/AST/Interp/EvaluationResult.cpp
+++ b/clang/lib/AST/Interp/EvaluationResult.cpp
@@ -122,22 +122,20 @@ static bool CheckFieldsInitialized(InterpState &S, 
SourceLocation Loc,
   }
 
   // Check Fields in all bases
-  for (const Record::Base &B : R->bases()) {
+  unsigned BaseIndex = 0;
+  const CXXRecordDecl *CD = dyn_cast(R->getDecl());
+  for (const CXXBaseSpecifier &BS : CD->bases()) {
+const Record::Base &B = *R->getBase(BaseIndex);
 Pointer P = BasePtr.atField(B.Offset);
 if (!P.isInitialized()) {
-  const Descriptor *Desc = BasePtr.getDeclDesc();
-  if (Desc->asDecl())
-S.FFDiag(BasePtr.getDeclDesc()->asDecl()->getLocation(),
- diag::note_constexpr_uninitialized_base)
-<< B.Desc->getType();
-  else
-S.FFDiag(BasePtr.getDeclDesc()->asExpr()->getExprLoc(),
- diag::note_constexpr_uninitialized_base)
-<< B.Desc->getType();
-
+  SourceLocation TypeBeginLoc = BS.getBaseTypeLoc();
+  SourceRange Range(TypeBeginLoc, BS.getEndLoc());
+  S.FFDiag(TypeBeginLoc, diag::note_constexpr_uninitialized_base)
+  << B.Desc->getType() << Range;
   return false;
 }
 Result &= CheckFieldsInitialized(S, Loc, P, B.R);
+BaseIndex++;
   }
 
   // TODO: Virtual bases
diff --git a/clang/test/AST/Interp/constexpr-subobj-initialization.cpp 
b/clang/test/AST/Interp/constexpr-subobj-initialization.cpp
index 4976b165468bd..4c067423aedfd 100644
--- a/clang/test/AST/Interp/constexpr-subobj-initialization.cpp
+++ b/clang/test/AST/Interp/constexpr-subobj-initialization.cpp
@@ -14,33 +14,29 @@ struct DelBase {
   constexpr DelBase() = delete; // expected-note {{'DelBase' has been 
explicitly marked deleted here}}
 };
 
-struct Foo : DelBase {
+struct Foo : DelBase { // expected-note 2{{constructor of base class 
'baseclass_uninit::DelBase' is not called}}
   constexpr Foo() {}; // expected-error {{call to deleted constructor of 
'DelBase'}}
 };
-constexpr Foo f; // expected-error {{must be initialized by a constant 
expression}} \
- // expected-note {{constructor of base class 
'baseclass_uninit::DelBase' is not called}}
+constexpr Foo f; // expected-error {{must be initialized by a constant 
expression}}
 
 struct Bar : Foo {
   constexpr Bar() {};
 };
-constexpr Bar bar; // expected-error {{must be initialized by a constant 
expression}} \
-   // expected-note {{constructor of base class 
'baseclass_uninit::DelBase' is not called}}
+constexpr Bar bar; // expected-error {{must be initialized by a constant 
expression}}
 
 struct Base {};
-struct A : Base {
+struct A : Base { // expected-note {{constructor of base class 
'baseclass_uninit::Base' is not called}}
   constexpr A() : value() {} // expected-error {{member initializer 'value' 
does not name a non-static data member or base class}}
 };
 
-constexpr A a; // expected-error {{must be initialized by a constant 
expression}} \
-   // expected-note {{constructor of base class 
'baseclass_uninit::Base' is not called}}
+constexpr A a; // expected-error {{must be initialized by a constant 
expression}}
 
 
-struct B : Base {
+struct B : Base { // expected-note {{constructor of base class 
'baseclass_uninit::Base' is not called}}
   constexpr B() : {} // expected-error {{expected class member or base class 
name}}
 };
 
-constexpr B b; // expected-error {{must be initialized by a constant 
expression}} \
-   // expected-note {{constructor of base class 
'baseclass_uninit::Base' is not called}}
+constexpr B b; // expected-error {{must be initialized by a constant 
expression}}
 } // namespace baseclass_uninit
 
 
diff --git a/clang/test/SemaCXX/constexpr-subobj-initialization.cpp 
b/clang/test/SemaCXX/constexpr-subobj-initialization.cpp
index cd096a9270937..f0252df1e2ce1 100644
--- a/clang/test/SemaCXX/constexpr-subobj-initialization.cpp
+++ b/clang/test/SemaCXX/constexpr-subobj-initialization.cpp
@@ -1,11 +1,12 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify 
-fexperimental-new-constant-interpreter %s
 
 namespace baseclass_uninit {
 struct DelBase {
   constexpr DelBase() = delete; // expected-note {{'DelBase' has been 
explicitly mark

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

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

mikecrowe wrote:

@5chmidti wrote:
> It'll be 1 week+ before I am back at my main machine to take a better look at 
> the macro question. Maybe this can just be landed, without that distinction.

Thanks for letting me know and thanks for the review.

I've pushed a new version to this PR with the typo you spotted fixed and 
removing the commit containing the debug output for exploring the macro 
detection (the version with the extra debug is at 
https://github.com/mikecrowe/clang-tidy-fmt/commits/mac/fix-use-std-print-macro-expansion-investigation/
 if you still need it).

I'll let you and @PiotrZSL decide whether you want to land this PR as it is 
since I don't have permission to do so myself.

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] [Clang][Interp] Fix the location of uninitialized base warning (PR #100761)

2024-07-27 Thread via cfe-commits


@@ -122,22 +122,20 @@ static bool CheckFieldsInitialized(InterpState &S, 
SourceLocation Loc,
   }
 
   // Check Fields in all bases
-  for (const Record::Base &B : R->bases()) {
+  unsigned BaseIndex = 0;
+  const CXXRecordDecl *CD = dyn_cast(R->getDecl());

yronglin wrote:

Done.

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


[clang] [Clang][Interp] Fix the location of uninitialized base warning (PR #100761)

2024-07-27 Thread via cfe-commits


@@ -122,22 +122,20 @@ static bool CheckFieldsInitialized(InterpState &S, 
SourceLocation Loc,
   }
 
   // Check Fields in all bases
-  for (const Record::Base &B : R->bases()) {
+  unsigned BaseIndex = 0;
+  const CXXRecordDecl *CD = dyn_cast(R->getDecl());
+  for (const CXXBaseSpecifier &BS : CD->bases()) {
+const Record::Base &B = *R->getBase(BaseIndex);
 Pointer P = BasePtr.atField(B.Offset);
 if (!P.isInitialized()) {
-  const Descriptor *Desc = BasePtr.getDeclDesc();
-  if (Desc->asDecl())
-S.FFDiag(BasePtr.getDeclDesc()->asDecl()->getLocation(),
- diag::note_constexpr_uninitialized_base)
-<< B.Desc->getType();
-  else
-S.FFDiag(BasePtr.getDeclDesc()->asExpr()->getExprLoc(),
- diag::note_constexpr_uninitialized_base)
-<< B.Desc->getType();
-
+  SourceLocation TypeBeginLoc = BS.getBaseTypeLoc();
+  SourceRange Range(TypeBeginLoc, BS.getEndLoc());

yronglin wrote:

Yeah, they are same, I've dumped 2 source ranges in my local.

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


[clang] [Clang][Interp] Fix the location of uninitialized base warning (PR #100761)

2024-07-27 Thread via cfe-commits

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


[clang] [Clang][Interp] Fix the location of uninitialized base warning (PR #100761)

2024-07-27 Thread via cfe-commits


@@ -122,22 +122,20 @@ static bool CheckFieldsInitialized(InterpState &S, 
SourceLocation Loc,
   }
 
   // Check Fields in all bases
-  for (const Record::Base &B : R->bases()) {
+  unsigned BaseIndex = 0;
+  const CXXRecordDecl *CD = dyn_cast(R->getDecl());
+  for (const CXXBaseSpecifier &BS : CD->bases()) {
+const Record::Base &B = *R->getBase(BaseIndex);
 Pointer P = BasePtr.atField(B.Offset);
 if (!P.isInitialized()) {
-  const Descriptor *Desc = BasePtr.getDeclDesc();
-  if (Desc->asDecl())
-S.FFDiag(BasePtr.getDeclDesc()->asDecl()->getLocation(),
- diag::note_constexpr_uninitialized_base)
-<< B.Desc->getType();
-  else
-S.FFDiag(BasePtr.getDeclDesc()->asExpr()->getExprLoc(),
- diag::note_constexpr_uninitialized_base)
-<< B.Desc->getType();
-
+  SourceLocation TypeBeginLoc = BS.getBaseTypeLoc();
+  SourceRange Range(TypeBeginLoc, BS.getEndLoc());
+  S.FFDiag(TypeBeginLoc, diag::note_constexpr_uninitialized_base)
+  << B.Desc->getType() << Range;
   return false;
 }
 Result &= CheckFieldsInitialized(S, Loc, P, B.R);
+BaseIndex++;

yronglin wrote:

Done.

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


[clang] [Clang][Interp] Fix the location of uninitialized base warning (PR #100761)

2024-07-27 Thread via cfe-commits


@@ -14,33 +14,29 @@ struct DelBase {
   constexpr DelBase() = delete; // expected-note {{'DelBase' has been 
explicitly marked deleted here}}

yronglin wrote:

Removed 2nd bullet.

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


[clang] [Clang][Interp] Fix the location of uninitialized base warning (PR #100761)

2024-07-27 Thread via cfe-commits

yronglin wrote:

Thanks for the review! Yes, there are three regressions, I've revert back the 
handling of an expression, and enable new interpreter in these three test.

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


[clang-tools-extra] Create a new check to look for mis-use in calls that take iterators (PR #99917)

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

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

>From e1c3086cf28f7c075d631c128c984bc25109cd81 Mon Sep 17 00:00:00 2001
From: Nathan James 
Date: Tue, 23 Jul 2024 10:59:45 +0100
Subject: [PATCH] Create a new check to look for mis-use in calls that take
 iterators

Looks for various patterns of functions that take arguments calling
begin/end or similar for common mistakes
---
 .../bugprone/BugproneTidyModule.cpp   |   3 +
 .../clang-tidy/bugprone/CMakeLists.txt|   1 +
 .../bugprone/IncorrectIteratorsCheck.cpp  | 829 ++
 .../bugprone/IncorrectIteratorsCheck.h|  45 +
 clang-tools-extra/docs/ReleaseNotes.rst   |   6 +
 .../checks/bugprone/incorrect-iterators.rst   | 131 +++
 .../docs/clang-tidy/checks/list.rst   |   1 +
 .../checkers/bugprone/incorrect-iterators.cpp | 282 ++
 8 files changed, 1298 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/bugprone/incorrect-iterators.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/incorrect-iterators.cpp

diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 689eb92a3d8d1..cea040b81878a 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -33,6 +33,7 @@
 #include "InaccurateEraseCheck.h"
 #include "IncDecInConditionsCheck.h"
 #include "IncorrectEnableIfCheck.h"
+#include "IncorrectIteratorsCheck.h"
 #include "IncorrectRoundingsCheck.h"
 #include "InfiniteLoopCheck.h"
 #include "IntegerDivisionCheck.h"
@@ -139,6 +140,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-inaccurate-erase");
 CheckFactories.registerCheck(
 "bugprone-incorrect-enable-if");
+CheckFactories.registerCheck(
+"bugprone-incorrect-iterators");
 CheckFactories.registerCheck(
 "bugprone-return-const-ref-from-parameter");
 CheckFactories.registerCheck(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index cb0d8ae98bac5..8425dbed0505a 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -26,6 +26,7 @@ add_clang_library(clangTidyBugproneModule
   ImplicitWideningOfMultiplicationResultCheck.cpp
   InaccurateEraseCheck.cpp
   IncorrectEnableIfCheck.cpp
+  IncorrectIteratorsCheck.cpp
   ReturnConstRefFromParameterCheck.cpp
   SuspiciousStringviewDataUsageCheck.cpp
   SwitchMissingDefaultCaseCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.cpp
new file mode 100644
index 0..222bad836c9da
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.cpp
@@ -0,0 +1,829 @@
+//===--- IncorrectIteratorsCheck.cpp - clang-tidy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "IncorrectIteratorsCheck.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTTypeTraits.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/ASTMatchers/ASTMatchersInternal.h"
+#include "clang/ASTMatchers/ASTMatchersMacros.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/ErrorHandling.h"
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+namespace {
+using SVU = llvm::SmallVector;
+/// Checks to see if a all the parameters of a template function with a given
+/// index refer to the same type.
+AST_MATCHER_P(FunctionDecl, areParametersSameTemplateType, SVU, Indexes) {
+  const FunctionTemplateDecl *TemplateDecl = Node.getPrimaryTemplate();
+  if (!TemplateDecl)
+return false;
+  const FunctionDecl *FuncDecl = TemplateDecl->getTemplatedDecl();
+  if (!FuncDecl)
+return false;
+  assert(!Indexes.empty());
+  if (llvm::any_of(Indexes, [Cou

[clang-tools-extra] Create a new check to look for mis-use in calls that take iterators (PR #99917)

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

njames93 wrote:

Added some detection for trying to advance past the end or before the start of 
a range.

https://github.com/llvm/llvm-project/pull/99917
___
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-27 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:

Can you remove this change, since you've already created a separate PR for it?

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] Implement P2280R4 Using unknown pointers and references in constant expressions (PR #95474)

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

Endilll wrote:

Shafik contacted me offline about a libc++ test failure this PR causes. The 
test in question is `mem.res.eq/not_equal_pass.cpp`.
I reduced it down to the following:
```cpp
struct memory_resource {
  virtual ~memory_resource();
  bool is_equal(const memory_resource &) const noexcept;
};

inline bool operator==(const memory_resource &__lhs, const memory_resource 
&__rhs) {
  return &__lhs == &__rhs || __lhs.is_equal(__rhs);
  //  frontend built from this branch believes that this is 
never true 
}

void __assert_fail();

struct TestResourceImp : memory_resource {
  memory_resource do_is_equal_other;

  virtual bool do_is_equal() noexcept {
return dynamic_cast(&do_is_equal_other);
  }
};

int main() {
  memory_resource mr1, mr2;
  mr1 != mr2 ? void() : __assert_fail();
}
```
Clang built from this branch produces the following IR for `operator==`
```llvm
; Function Attrs: mustprogress noinline nounwind optnone uwtable
define linkonce_odr dso_local noundef zeroext i1 
@_ZeqRK15memory_resourceS1_(ptr noundef nonnull align 8 dereferenceable(8) 
%__lhs, ptr noundef nonnull align 8 dereferenceable(8) %__rhs) #1 comdat {
entry:
  %__lhs.addr = alloca ptr, align 8
  %__rhs.addr = alloca ptr, align 8
  store ptr %__lhs, ptr %__lhs.addr, align 8
  store ptr %__rhs, ptr %__rhs.addr, align 8
  %0 = load ptr, ptr %__lhs.addr, align 8
  %1 = load ptr, ptr %__rhs.addr, align 8
  %call = call noundef zeroext i1 @_ZNK15memory_resource8is_equalERKS_(ptr 
noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 8 
dereferenceable(8) %1) #4
  ret i1 %call
}
```
Whereas a recent nighly build 
(`++20240704100628+b298e2d2d225-1~exp1~20240704220819.2190`) properly lowers 
the LHS of the logical OR:
```llvm
; Function Attrs: mustprogress noinline nounwind optnone uwtable
define linkonce_odr dso_local noundef zeroext i1 
@_ZeqRK15memory_resourceS1_(ptr noundef nonnull align 8 dereferenceable(8) 
%__lhs, ptr noundef nonnull align 8 dereferenceable(8) %__rhs) #1 comdat {
entry:
  %__lhs.addr = alloca ptr, align 8
  %__rhs.addr = alloca ptr, align 8
  store ptr %__lhs, ptr %__lhs.addr, align 8
  store ptr %__rhs, ptr %__rhs.addr, align 8
  %0 = load ptr, ptr %__lhs.addr, align 8
  %1 = load ptr, ptr %__rhs.addr, align 8
  %cmp = icmp eq ptr %0, %1
  br i1 %cmp, label %lor.end, label %lor.rhs

lor.rhs:  ; preds = %entry
  %2 = load ptr, ptr %__lhs.addr, align 8
  %3 = load ptr, ptr %__rhs.addr, align 8
  %call = call noundef zeroext i1 @_ZNK15memory_resource8is_equalERKS_(ptr 
noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 
dereferenceable(8) %3) #4
  br label %lor.end

lor.end:  ; preds = %lor.rhs, %entry
  %4 = phi i1 [ true, %entry ], [ %call, %lor.rhs ]
  ret i1 %4
}
```

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


[clang] [llvm] target ABI: improve call parameters extensions handling (PR #100757)

2024-07-27 Thread Eli Friedman via cfe-commits


@@ -1185,6 +1189,9 @@ Currently, only the following parameter attributes are 
defined:
 value should be sign-extended to the extent required by the target's
 ABI (which is usually 32-bits) by the caller (for a parameter) or
 the callee (for a return value).
+``noext`` This indicates to the code generator that the parameter or return
+value has the high bits undefined, as for a struct in register, and
+therefore does not need to be sign or zero extended.

efriedma-quic wrote:

"Skipped ABI computations", meaning code that assumes that C int(int) can be 
blindly translated to i32(i32).  Like https://reviews.llvm.org/D133949.  The 
goal is to get some sort of error from code like that, instead of an obscure 
miscompile.

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


[clang-tools-extra] Create a new check to look for mis-use in calls that take iterators (PR #99917)

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

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

>From c79951fdc4f866413f83a94b1eaa16f3ffb10aa4 Mon Sep 17 00:00:00 2001
From: Nathan James 
Date: Tue, 23 Jul 2024 10:59:45 +0100
Subject: [PATCH] Create a new check to look for mis-use in calls that take
 iterators

Looks for various patterns of functions that take arguments calling
begin/end or similar for common mistakes
---
 .../bugprone/BugproneTidyModule.cpp   |   3 +
 .../clang-tidy/bugprone/CMakeLists.txt|   1 +
 .../bugprone/IncorrectIteratorsCheck.cpp  | 838 ++
 .../bugprone/IncorrectIteratorsCheck.h|  45 +
 clang-tools-extra/docs/ReleaseNotes.rst   |   6 +
 .../checks/bugprone/incorrect-iterators.rst   | 131 +++
 .../docs/clang-tidy/checks/list.rst   |   1 +
 .../checkers/bugprone/incorrect-iterators.cpp | 282 ++
 8 files changed, 1307 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/bugprone/incorrect-iterators.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/incorrect-iterators.cpp

diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 689eb92a3d8d1..cea040b81878a 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -33,6 +33,7 @@
 #include "InaccurateEraseCheck.h"
 #include "IncDecInConditionsCheck.h"
 #include "IncorrectEnableIfCheck.h"
+#include "IncorrectIteratorsCheck.h"
 #include "IncorrectRoundingsCheck.h"
 #include "InfiniteLoopCheck.h"
 #include "IntegerDivisionCheck.h"
@@ -139,6 +140,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-inaccurate-erase");
 CheckFactories.registerCheck(
 "bugprone-incorrect-enable-if");
+CheckFactories.registerCheck(
+"bugprone-incorrect-iterators");
 CheckFactories.registerCheck(
 "bugprone-return-const-ref-from-parameter");
 CheckFactories.registerCheck(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index cb0d8ae98bac5..8425dbed0505a 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -26,6 +26,7 @@ add_clang_library(clangTidyBugproneModule
   ImplicitWideningOfMultiplicationResultCheck.cpp
   InaccurateEraseCheck.cpp
   IncorrectEnableIfCheck.cpp
+  IncorrectIteratorsCheck.cpp
   ReturnConstRefFromParameterCheck.cpp
   SuspiciousStringviewDataUsageCheck.cpp
   SwitchMissingDefaultCaseCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.cpp
new file mode 100644
index 0..3054720522756
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.cpp
@@ -0,0 +1,838 @@
+//===--- IncorrectIteratorsCheck.cpp - clang-tidy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "IncorrectIteratorsCheck.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTTypeTraits.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/ASTMatchers/ASTMatchersInternal.h"
+#include "clang/ASTMatchers/ASTMatchersMacros.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/ErrorHandling.h"
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+namespace {
+using SVU = llvm::SmallVector;
+/// Checks to see if a all the parameters of a template function with a given
+/// index refer to the same type.
+AST_MATCHER_P(FunctionDecl, areParametersSameTemplateType, SVU, Indexes) {
+  const FunctionTemplateDecl *TemplateDecl = Node.getPrimaryTemplate();
+  if (!TemplateDecl)
+return false;
+  const FunctionDecl *FuncDecl = TemplateDecl->getTemplatedDecl();
+  if (!FuncDecl)
+return false;
+  assert(!Indexes.empty());
+  if (llvm::any_of(Indexes, [Cou

[clang-tools-extra] Create a new check to look for mis-use in calls that take iterators (PR #99917)

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

njames93 wrote:

@5chmidti I decided to run this version of the check on llvm and clang
https://gist.github.com/njames93/6f8863573972cb07c388ac19e8a20467

Seems like most of the warnings detected are when we are deliberately exceeding 
the bounds of a range when we know its a slice of a bigger range. Some of them 
are potentially cases where code could be refactored to better express it's 
intent, other instances already have comments to explain why we are exceeding 
the bounds

There were also some cases where classes had begin/end pairs that didn't return 
iterators, instead [just integral 
types](https://github.com/llvm/llvm-project/blob/main/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp#L682).
These cases could be silenced by changing the check to ensure we aren't looking 
for integral types, but I feel that's such an unlikely case that there's no 
need to worry about it

https://github.com/llvm/llvm-project/pull/99917
___
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-27 Thread Matheus Izvekov via cfe-commits

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

>From 89e016886fd87ab54856ed61a0a419d25f7df9e5 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/lib/AST/ExprConstant.cpp|   1 -
 clang/lib/Sema/SemaTemplateDeduction.cpp  | 826 --
 .../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 +-
 10 files changed, 695 insertions(+), 300 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/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..727c7d2e01641 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,
const TemplateArgument &TemplateArg,
@@ -395,12 +395,13 @@ checkDeducedTemplateArguments(ASTContext &Context,
 /// Deduce the value of the given non-type template parameter
 /// as the given deduced template argument. All non-type template parameter
 /// deduction is funneled through here.
-static TemplateDeductionResult DeduceNonTypeTemplateArgument(
-Sema &S, TemplateParameterList *TemplateParams,
-const NonTypeTemplateParmDecl *NTTP,
-const DeducedTemplateArgument &NewDeduced, QualType ValueType,
-TemplateDeductionInfo &Info,
-SmallVectorImpl &Deduced) {
+static TemplateDeductionResult
+DeduceNonTypeTemplateArgument(Sema &S, TemplateParameterList *TemplateParams,
+  const NonTypeTemplateParmDecl *NTTP,
+  const DeducedTemplateArgument &NewDeduced,
+  QualType ValueType, TemplateDeductionInfo &Info,
+  SmallVectorImpl 
&Deduced,
+  bool *HasDeducedAnyParam) {
   assert(NTTP->getDepth() == Info.getDeducedDepth() &&
  "deducing non-type template argument with wrong depth");
 
@@ -444,7 +445,7 @@ static TemplateDeductionResult 
DeduceNonTypeTemplateArgument(
   return DeduceTemplateArgumentsByTypeMatch(
   S, TemplateParams, ParamType, ValueType, Info, Deduced,

[clang] [Clang][Sema] Disallow applying `onwership_returns` to functions that return non-pointers (PR #99564)

2024-07-27 Thread Pavel Skripkin via cfe-commits

https://github.com/pskrgag updated 
https://github.com/llvm/llvm-project/pull/99564

>From 6b7ec7c95df16de5eb0fecf2d69befb5461d98a5 Mon Sep 17 00:00:00 2001
From: Pavel Skripkin 
Date: Thu, 18 Jul 2024 18:48:47 +0300
Subject: [PATCH 1/7] clang/sema: disallow ownership_returns for functions that
 return non-pointers

ownership_takes expects an argument to a pointer and clang reports an
error if it is not the case.

Since pointers consumed by ownership_takes are produced by functions
with ownership_returns attribute, it make sence to report an error
if function does not return a pointer type.
---
 clang/include/clang/Basic/DiagnosticSemaKinds.td |  2 ++
 clang/lib/Sema/SemaDeclAttr.cpp  | 11 +++
 clang/test/AST/attr-print-emit.cpp   |  4 ++--
 clang/test/Sema/attr-ownership.c |  5 -
 clang/test/Sema/attr-ownership.cpp   |  6 +++---
 5 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 810abe4f23e31..9e6ea80ac4e40 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3330,6 +3330,8 @@ def err_attribute_invalid_implicit_this_argument : Error<
   "%0 attribute is invalid for the implicit this argument">;
 def err_ownership_type : Error<
   "%0 attribute only applies to %select{pointer|integer}1 arguments">;
+def err_ownership_takes_return_type : Error<
+  "'ownership_returns' attribute only applies to functions that return 
pointers">;
 def err_ownership_returns_index_mismatch : Error<
   "'ownership_returns' attribute index does not match; here it is %0">;
 def note_ownership_returns_index_mismatch : Note<
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 39675422e3f9f..810f0ddfa06fd 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1481,6 +1481,17 @@ static void handleOwnershipAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 break;
   }
 
+  // Allow only pointers to be return type for functions with ownership_takes
+  // attribute. This matches with current OwnershipAttr::Takes semantics
+  if (K == OwnershipAttr::Returns) {
+QualType RetType = getFunctionOrMethodResultType(D);
+
+if (!RetType->isPointerType()) {
+  S.Diag(AL.getLoc(), diag::err_ownership_takes_return_type) << AL;
+  return;
+}
+  }
+
   IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;
 
   StringRef ModuleName = Module->getName();
diff --git a/clang/test/AST/attr-print-emit.cpp 
b/clang/test/AST/attr-print-emit.cpp
index 8c8a2b2080599..9c89764a3cac2 100644
--- a/clang/test/AST/attr-print-emit.cpp
+++ b/clang/test/AST/attr-print-emit.cpp
@@ -33,7 +33,7 @@ void ownt(int *, int *) __attribute__((ownership_takes(foo, 
1, 2)));
 // CHECK: void ownh(int *, int *) __attribute__((ownership_holds(foo, 1, 2)));
 void ownh(int *, int *) __attribute__((ownership_holds(foo, 1, 2)));
 // CHECK: void ownr(int) __attribute__((ownership_returns(foo, 1)));
-void ownr(int) __attribute__((ownership_returns(foo, 1)));
+void *ownr(int) __attribute__((ownership_returns(foo, 1)));
 
 // CHECK: void awtt(int, int, ...) __attribute__((argument_with_type_tag(foo, 
3, 2)));
 void awtt(int, int, ...) __attribute__((argument_with_type_tag(foo, 3, 2)));
@@ -66,7 +66,7 @@ class C {
   // CHECK: void ownh(int *, int *) __attribute__((ownership_holds(foo, 2, 
3)));
   void ownh(int *, int *) __attribute__((ownership_holds(foo, 2, 3)));
   // CHECK: void ownr(int) __attribute__((ownership_returns(foo, 2)));
-  void ownr(int) __attribute__((ownership_returns(foo, 2)));
+  void *ownr(int) __attribute__((ownership_returns(foo, 2)));
 
   // CHECK: void awtt(int, int, ...) 
__attribute__((argument_with_type_tag(foo, 4, 3)));
   void awtt(int, int, ...) __attribute__((argument_with_type_tag(foo, 4, 3)));
diff --git a/clang/test/Sema/attr-ownership.c b/clang/test/Sema/attr-ownership.c
index 084624353315c..5fb28a1b4e66f 100644
--- a/clang/test/Sema/attr-ownership.c
+++ b/clang/test/Sema/attr-ownership.c
@@ -18,7 +18,7 @@ void *f12(float i, int k, int f, int *j) 
__attribute__((ownership_returns(foo, 4
 void f13(int *i, int *j) __attribute__((ownership_holds(foo, 1))) 
__attribute__((ownership_takes(foo, 2)));
 void f14(int i, int j, int *k) __attribute__((ownership_holds(foo, 3))) 
__attribute__((ownership_takes(foo, 3)));  // expected-error 
{{'ownership_takes' and 'ownership_holds' attributes are not compatible}}
 
-void f15(int, int)
+void *f15(int, int)
   __attribute__((ownership_returns(foo, 1)))  // expected-error 
{{'ownership_returns' attribute index does not match; here it is 1}}
   __attribute__((ownership_returns(foo, 2))); // expected-note {{declared with 
index 2 here}}
 void f16(int *i, int *j) __attribute__((ownership_holds(foo, 1))) 
__attribute__((ownership_holds(foo, 1))); // OK, same index
@@ -28,3 +28,6 @@ void f1

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

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

mizvekov wrote:

@MaskRay the latest version fixes libc++ regressions.
Also abseil-cpp builds correctly on MacOS, according to those instructions.

https://github.com/llvm/llvm-project/pull/100692
___
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-27 Thread Matheus Izvekov via cfe-commits


@@ -5399,11 +5434,85 @@ static QualType 
GetImplicitObjectParameterType(ASTContext &Context,
   return Context.getLValueReferenceType(RawType);
 }
 
+static TemplateDeductionResult FinishTemplateArgumentDeduction(
+Sema &S, FunctionTemplateDecl *FTD, int ArgIdx, QualType P, QualType A,
+SmallVectorImpl &Deduced,
+TemplateDeductionInfo &Info) {
+  // Unevaluated SFINAE context.
+  EnterExpressionEvaluationContext Unevaluated(
+  S, Sema::ExpressionEvaluationContext::Unevaluated);
+  Sema::SFINAETrap Trap(S);
+
+  Sema::ContextRAII SavedContext(S, getAsDeclContextOrEnclosing(FTD));
+
+  // C++ [temp.deduct.type]p2:
+  //   [...] or if any template argument remains neither deduced nor
+  //   explicitly specified, template argument deduction fails.
+  bool IsIncomplete = false;
+  SmallVector SugaredBuilder, CanonicalBuilder;
+  if (auto Result = ConvertDeducedTemplateArguments(
+  S, FTD, /*IsDeduced=*/true, Deduced, Info, SugaredBuilder,
+  CanonicalBuilder, /*CurrentInstantiationScope=*/nullptr,
+  /*NumAlreadyConverted=*/0, &IsIncomplete);
+  Result != TemplateDeductionResult::Success)
+return Result;
+
+  // Form the template argument list from the deduced template arguments.
+  TemplateArgumentList *SugaredDeducedArgumentList =
+  TemplateArgumentList::CreateCopy(S.Context, SugaredBuilder);
+  TemplateArgumentList *CanonicalDeducedArgumentList =
+  TemplateArgumentList::CreateCopy(S.Context, CanonicalBuilder);
+
+  Info.reset(SugaredDeducedArgumentList, CanonicalDeducedArgumentList);
+
+  // Substitute the deduced template arguments into the argument
+  // and verify that the instantiated argument is both valid
+  // and equivalent to the parameter.
+  LocalInstantiationScope InstScope(S);
+
+  QualType InstP;
+  {
+MultiLevelTemplateArgumentList MLTAL(FTD, SugaredBuilder,
+ /*Final=*/true);
+if (ArgIdx != -1)
+  if (auto *MD = dyn_cast(FTD->getTemplatedDecl());
+  MD && MD->isImplicitObjectMemberFunction())
+ArgIdx -= 1;
+Sema::ArgumentPackSubstitutionIndexRAII PackIndex(
+S, ArgIdx != -1 ? ::getPackIndexForParam(S, FTD, MLTAL, ArgIdx) : -1);
+InstP = S.SubstType(P, MLTAL, FTD->getLocation(), FTD->getDeclName());
+if (InstP.isNull())
+  return TemplateDeductionResult::SubstitutionFailure;
+  }
+
+  if (auto *PA = dyn_cast(A);
+  PA && !isa(InstP))
+A = PA->getPattern();
+  if (!S.Context.hasSameType(
+  S.Context.getUnqualifiedArrayType(InstP.getNonReferenceType()),
+  S.Context.getUnqualifiedArrayType(A.getNonReferenceType(
+return TemplateDeductionResult::NonDeducedMismatch;
+
+  // C++20 [temp.deduct]p5 - Only check constraints when all parameters have
+  // been deduced.
+  if (!IsIncomplete) {
+if (auto Result = CheckDeducedArgumentConstraints(S, FTD, SugaredBuilder,
+  CanonicalBuilder, Info);
+Result != TemplateDeductionResult::Success)
+  return Result;
+  }

mizvekov wrote:

According to our side discussions, you think `[temp.deduct]p5` should not apply 
during partial ordering in any case.

But clang follows the opposite consistently.

I think we should leave this as is, and then make a separate patch to fix 
everywhere at the same time.

Please let me know if you would prefer to remove on this patch.

https://github.com/llvm/llvm-project/pull/100692
___
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-27 Thread via cfe-commits

https://github.com/vabridgers created 
https://github.com/llvm/llvm-project/pull/100901

This change avoids crashes in the stream checker when bifurcating the analysis 
state produces a non-null return value for opening a stream and does not 
produces a null return value because of constraints found during an analysis 
path.

A snippet of the crash stack seen is shown here.

...
 #6 __restore_rt sigaction.c:0:0
 #7 clang::ento::ProgramState::getStateManager() const
 clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h:148:13
 #8 llvm::IntrusiveRefCntPtr
 clang::ento::ProgramState::set<(anonymous 
namespace)::StreamMap>(clang::ento::ProgramStateTrait<(
 anonymous 
namespace)::StreamMap>::key_type,clang::ento::ProgramStateTrait<(anonymous 
namespace)::StreamMap>::value_type) const
 clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h:864:10
 #9 (anonymous namespace)::StreamChecker::evalFopen((anonymous 
namespace)::FnDescription const*,
clang::ento::CallEvent const&, clang::ento::CheckerContext&) const
 clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:951:13
...

>From ab047fb7bd9ddc0f58d4652fe63c80738d60e8c4 Mon Sep 17 00:00:00 2001
From: Vince Bridgers 
Date: Sat, 27 Jul 2024 23:41:17 +0200
Subject: [PATCH] [analyzer] Avoid crashes in the stream checker

This change avoids crashes in the stream checker when bifurcating the
analysis state produces a non-null return value for opening a stream and
does not produces a null return value because of constraints found
during an analysis path.

A snippet of the crash stack seen is shown here.

...
 #6 __restore_rt sigaction.c:0:0
 #7 clang::ento::ProgramState::getStateManager() const
 clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h:148:13
 #8 llvm::IntrusiveRefCntPtr
 clang::ento::ProgramState::set<(anonymous 
namespace)::StreamMap>(clang::ento::ProgramStateTrait<(
 anonymous 
namespace)::StreamMap>::key_type,clang::ento::ProgramStateTrait<(anonymous 
namespace)::StreamMap>::value_type) const
 clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h:864:10
 #9 (anonymous namespace)::StreamChecker::evalFopen((anonymous 
namespace)::FnDescription const*,
clang::ento::CallEvent const&, clang::ento::CheckerContext&) const
 clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:951:13
...
---
 .../StaticAnalyzer/Checkers/StreamChecker.cpp | 20 +--
 clang/test/Analysis/stream-no-crash.c | 25 +++
 2 files changed, 37 insertions(+), 8 deletions(-)
 create mode 100644 clang/test/Analysis/stream-no-crash.c

diff --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index 53770532609d5..c34c6b9fc6c0d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -946,14 +946,18 @@ void StreamChecker::evalFopen(const FnDescription *Desc, 
const CallEvent &Call,
   std::tie(StateNotNull, StateNull) =
   C.getConstraintManager().assumeDual(State, RetVal);
 
-  StateNotNull =
-  StateNotNull->set(RetSym, StreamState::getOpened(Desc));
-  StateNull =
-  StateNull->set(RetSym, StreamState::getOpenFailed(Desc));
-
-  C.addTransition(StateNotNull,
-  constructLeakNoteTag(C, RetSym, "Stream opened here"));
-  C.addTransition(StateNull);
+  if (StateNotNull)
+StateNotNull =
+StateNotNull->set(RetSym, StreamState::getOpened(Desc));
+  if (StateNull)
+StateNull =
+StateNull->set(RetSym, StreamState::getOpenFailed(Desc));
+
+  if (StateNotNull)
+C.addTransition(StateNotNull,
+constructLeakNoteTag(C, RetSym, "Stream opened here"));
+  if (StateNull)
+C.addTransition(StateNull);
 }
 
 void StreamChecker::preFreopen(const FnDescription *Desc, const CallEvent 
&Call,
diff --git a/clang/test/Analysis/stream-no-crash.c 
b/clang/test/Analysis/stream-no-crash.c
new file mode 100644
index 0..7a4922c8a35c2
--- /dev/null
+++ b/clang/test/Analysis/stream-no-crash.c
@@ -0,0 +1,25 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Stream -verify %s
+
+// This test is isolate since it uses line markers to repro the problem.
+// The test is expected to find the issues noted below without crashing.
+
+# 1 "" 1
+# 1 "" 1
+# 1 "" 1
+# 1 "" 1 3
+typedef FILE;
+extern *stdout;
+char a;
+*fopen();
+# 0 "" 2
+# 7 "" 2
+# 7 "" 2
+# 7 "" 2
+void b() {
+  fopen(&a, "");
+  int c = stdout && c;
+  b();
+}
+// expected-warning@-3{{Assigned value is garbage or undefined}}
+// expected-warning@-4{{Opened stream never closed. Potential resource leak}}
+

___
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-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (vabridgers)


Changes

This change avoids crashes in the stream checker when bifurcating the analysis 
state produces a non-null return value for opening a stream and does not 
produces a null return value because of constraints found during an analysis 
path.

A snippet of the crash stack seen is shown here.

...
 #6 __restore_rt sigaction.c:0:0
 #7 clang::ento::ProgramState::getStateManager() const
 clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h:148:13
 #8 llvm::IntrusiveRefCntPtr
 clang::ento::ProgramState::set<(anonymous 
namespace)::StreamMap>(clang::ento::ProgramStateTrait<(
 anonymous 
namespace)::StreamMap>::key_type,clang::ento::ProgramStateTrait<(anonymous
 namespace)::StreamMap>::value_type) const
 clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h:864:10
 #9 (anonymous namespace)::StreamChecker::evalFopen((anonymous 
namespace)::FnDescription const*,
clang::ento::CallEvent const&, clang::ento::CheckerContext&) const
 clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:951:13
...

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


2 Files Affected:

- (modified) clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp (+12-8) 
- (added) clang/test/Analysis/stream-no-crash.c (+25) 


``diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index 53770532609d5..c34c6b9fc6c0d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -946,14 +946,18 @@ void StreamChecker::evalFopen(const FnDescription *Desc, 
const CallEvent &Call,
   std::tie(StateNotNull, StateNull) =
   C.getConstraintManager().assumeDual(State, RetVal);
 
-  StateNotNull =
-  StateNotNull->set(RetSym, StreamState::getOpened(Desc));
-  StateNull =
-  StateNull->set(RetSym, StreamState::getOpenFailed(Desc));
-
-  C.addTransition(StateNotNull,
-  constructLeakNoteTag(C, RetSym, "Stream opened here"));
-  C.addTransition(StateNull);
+  if (StateNotNull)
+StateNotNull =
+StateNotNull->set(RetSym, StreamState::getOpened(Desc));
+  if (StateNull)
+StateNull =
+StateNull->set(RetSym, StreamState::getOpenFailed(Desc));
+
+  if (StateNotNull)
+C.addTransition(StateNotNull,
+constructLeakNoteTag(C, RetSym, "Stream opened here"));
+  if (StateNull)
+C.addTransition(StateNull);
 }
 
 void StreamChecker::preFreopen(const FnDescription *Desc, const CallEvent 
&Call,
diff --git a/clang/test/Analysis/stream-no-crash.c 
b/clang/test/Analysis/stream-no-crash.c
new file mode 100644
index 0..7a4922c8a35c2
--- /dev/null
+++ b/clang/test/Analysis/stream-no-crash.c
@@ -0,0 +1,25 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Stream -verify %s
+
+// This test is isolate since it uses line markers to repro the problem.
+// The test is expected to find the issues noted below without crashing.
+
+# 1 "" 1
+# 1 "" 1
+# 1 "" 1
+# 1 "" 1 3
+typedef FILE;
+extern *stdout;
+char a;
+*fopen();
+# 0 "" 2
+# 7 "" 2
+# 7 "" 2
+# 7 "" 2
+void b() {
+  fopen(&a, "");
+  int c = stdout && c;
+  b();
+}
+// expected-warning@-3{{Assigned value is garbage or undefined}}
+// expected-warning@-4{{Opened stream never closed. Potential resource leak}}
+

``




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] [analyzer] Avoid crashes in the stream checker (PR #100901)

2024-07-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-static-analyzer-1

Author: None (vabridgers)


Changes

This change avoids crashes in the stream checker when bifurcating the analysis 
state produces a non-null return value for opening a stream and does not 
produces a null return value because of constraints found during an analysis 
path.

A snippet of the crash stack seen is shown here.

...
 #6 __restore_rt sigaction.c:0:0
 #7 clang::ento::ProgramState::getStateManager() const
 clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h:148:13
 #8 llvm::IntrusiveRefCntPtr
 clang::ento::ProgramState::set<(anonymous 
namespace)::StreamMap>(clang::ento::ProgramStateTrait<(
 anonymous 
namespace)::StreamMap>::key_type,clang::ento::ProgramStateTrait<(anonymous
 namespace)::StreamMap>::value_type) const
 clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h:864:10
 #9 (anonymous namespace)::StreamChecker::evalFopen((anonymous 
namespace)::FnDescription const*,
clang::ento::CallEvent const&, clang::ento::CheckerContext&) const
 clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:951:13
...

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


2 Files Affected:

- (modified) clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp (+12-8) 
- (added) clang/test/Analysis/stream-no-crash.c (+25) 


``diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index 53770532609d5..c34c6b9fc6c0d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -946,14 +946,18 @@ void StreamChecker::evalFopen(const FnDescription *Desc, 
const CallEvent &Call,
   std::tie(StateNotNull, StateNull) =
   C.getConstraintManager().assumeDual(State, RetVal);
 
-  StateNotNull =
-  StateNotNull->set(RetSym, StreamState::getOpened(Desc));
-  StateNull =
-  StateNull->set(RetSym, StreamState::getOpenFailed(Desc));
-
-  C.addTransition(StateNotNull,
-  constructLeakNoteTag(C, RetSym, "Stream opened here"));
-  C.addTransition(StateNull);
+  if (StateNotNull)
+StateNotNull =
+StateNotNull->set(RetSym, StreamState::getOpened(Desc));
+  if (StateNull)
+StateNull =
+StateNull->set(RetSym, StreamState::getOpenFailed(Desc));
+
+  if (StateNotNull)
+C.addTransition(StateNotNull,
+constructLeakNoteTag(C, RetSym, "Stream opened here"));
+  if (StateNull)
+C.addTransition(StateNull);
 }
 
 void StreamChecker::preFreopen(const FnDescription *Desc, const CallEvent 
&Call,
diff --git a/clang/test/Analysis/stream-no-crash.c 
b/clang/test/Analysis/stream-no-crash.c
new file mode 100644
index 0..7a4922c8a35c2
--- /dev/null
+++ b/clang/test/Analysis/stream-no-crash.c
@@ -0,0 +1,25 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Stream -verify %s
+
+// This test is isolate since it uses line markers to repro the problem.
+// The test is expected to find the issues noted below without crashing.
+
+# 1 "" 1
+# 1 "" 1
+# 1 "" 1
+# 1 "" 1 3
+typedef FILE;
+extern *stdout;
+char a;
+*fopen();
+# 0 "" 2
+# 7 "" 2
+# 7 "" 2
+# 7 "" 2
+void b() {
+  fopen(&a, "");
+  int c = stdout && c;
+  b();
+}
+// expected-warning@-3{{Assigned value is garbage or undefined}}
+// expected-warning@-4{{Opened stream never closed. Potential resource leak}}
+

``




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] check deduction consistency when partial ordering function templates (PR #100692)

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

https://github.com/mizvekov edited 
https://github.com/llvm/llvm-project/pull/100692
___
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-27 Thread Matheus Izvekov via cfe-commits


@@ -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);

mizvekov wrote:

Looking at this again, leaving this line would break this test case:

```C++
template void g(const char (*)[([]{ return N; })()]) {}
template void g(const char (*)[([]{ return N; })()]) {}
void use_g() { g<6>(&"hello"); }
```

On the partial ordering case, N stays dependent, so we hit here.
This function assumes that, in certain evaluation modes, this expression has to 
contain an error.
But I don't see how that assumption holds true from the surrounding code.

CC @hokein since he implemented this originally, and was the last one to touch 
this code.

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


[clang] Revert "Reland [clang][ASTImport] Add support for import of empty records" (PR #100903)

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

https://github.com/Michael137 created 
https://github.com/llvm/llvm-project/pull/100903

This reverts commit 88e5206f2c96a34e23a4d63f0a38afb2db044f0a. The original 
change went in a while ago (last year) in https://reviews.llvm.org/D145057. The 
specific reason I'm proposing a revert is that this is now causing exactly the 
issue that @balazske predicted in https://reviews.llvm.org/D145057#4164717:
> Problematic case is if the attribute has pointer to a Decl or Type that is 
> imported here in a state when the field is already created but not 
> initialized. Another problem is that attributes are added a second time in 
> Import(Decl *)

This now came up in the testing of LLDB support for 
https://github.com/llvm/llvm-project/issues/93069. There, `__compressed_pair`s 
are now replaced with fields that have an `alignof(...)`  and 
`[[no_unique_address]]` attribute. In the specific case, we're importing the ` 
size_type& __sz() _NOEXCEPT { return __size_; }` method of `std::list`. During 
this process, we create a new `__size_` `FieldDecl` (but don't initialize it 
yet). Then we go down the `ImportAttrs` codepath added in D145057. This imports 
the `alignof` expression which then references the uninitialized `__size_` and 
we trigger an assertion.

Important to note, this codepath was added specifically to support 
`[[no_unique_address]]` in LLDB, and was supposed to land with 
https://reviews.llvm.org/D143347. But the LLDB side of that never landed, and 
the way we plan to support `[[no_unique_address]]` doesn't require things like 
the `markEmpty` method added here. So really, this is a dead codepath, which as 
pointed out in the original review isn't fully sound.

>From dcff39aa994f925caac55105e395df642c3b8d34 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Sat, 27 Jul 2024 23:03:59 +0100
Subject: [PATCH] Revert "Reland [clang][ASTImport] Add support for import of
 empty records"

This reverts commit 88e5206f2c96a34e23a4d63f0a38afb2db044f0a.
---
 clang/include/clang/AST/ASTImporter.h   |  1 -
 clang/include/clang/AST/DeclCXX.h   |  4 
 clang/lib/AST/ASTImporter.cpp   | 30 -
 clang/unittests/AST/ASTImporterTest.cpp | 23 ---
 4 files changed, 9 insertions(+), 49 deletions(-)

diff --git a/clang/include/clang/AST/ASTImporter.h 
b/clang/include/clang/AST/ASTImporter.h
index 4ffd913846575..f851decd0965c 100644
--- a/clang/include/clang/AST/ASTImporter.h
+++ b/clang/include/clang/AST/ASTImporter.h
@@ -258,7 +258,6 @@ class TypeSourceInfo;
 FoundDeclsTy findDeclsInToCtx(DeclContext *DC, DeclarationName Name);
 
 void AddToLookupTable(Decl *ToD);
-llvm::Error ImportAttrs(Decl *ToD, Decl *FromD);
 
   protected:
 /// Can be overwritten by subclasses to implement their own import logic.
diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index fb52ac804849d..3a110454f29ed 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1188,10 +1188,6 @@ class CXXRecordDecl : public RecordDecl {
   ///
   /// \note This does NOT include a check for union-ness.
   bool isEmpty() const { return data().Empty; }
-  /// Marks this record as empty. This is used by DWARFASTParserClang
-  /// when parsing records with empty fields having [[no_unique_address]]
-  /// attribute
-  void markEmpty() { data().Empty = true; }
 
   void setInitMethod(bool Val) { data().HasInitMethod = Val; }
   bool hasInitMethod() const { return data().HasInitMethod; }
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 08ef09d353afc..da1981d8dd05f 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -4179,12 +4179,6 @@ ExpectedDecl ASTNodeImporter::VisitFieldDecl(FieldDecl 
*D) {
   D->getInClassInitStyle()))
 return ToField;
 
-  // We need [[no_unqiue_address]] attributes to be added to FieldDecl, before
-  // we add fields in CXXRecordDecl::addedMember, otherwise record will be
-  // marked as having non-zero size.
-  Err = Importer.ImportAttrs(ToField, D);
-  if (Err)
-return std::move(Err);
   ToField->setAccess(D->getAccess());
   ToField->setLexicalDeclContext(LexicalDC);
   ToField->setImplicit(D->isImplicit());
@@ -9399,19 +9393,6 @@ TranslationUnitDecl *ASTImporter::GetFromTU(Decl *ToD) {
   return FromDPos->second->getTranslationUnitDecl();
 }
 
-Error ASTImporter::ImportAttrs(Decl *ToD, Decl *FromD) {
-  if (!FromD->hasAttrs() || ToD->hasAttrs())
-return Error::success();
-  for (const Attr *FromAttr : FromD->getAttrs()) {
-auto ToAttrOrErr = Import(FromAttr);
-if (ToAttrOrErr)
-  ToD->addAttr(*ToAttrOrErr);
-else
-  return ToAttrOrErr.takeError();
-  }
-  return Error::success();
-}
-
 Expected ASTImporter::Import(Decl *FromD) {
   if (!FromD)
 return nullptr;
@@ -9545,8 +9526,15 @@ Expected ASTImporter::Import(Decl *FromD) {
   }
   // Make sure that ImportImpl registered the imp

[clang] Revert "Reland [clang][ASTImport] Add support for import of empty records" (PR #100903)

2024-07-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Michael Buch (Michael137)


Changes

This reverts commit 88e5206f2c96a34e23a4d63f0a38afb2db044f0a. The original 
change went in a while ago (last year) in https://reviews.llvm.org/D145057. The 
specific reason I'm proposing a revert is that this is now causing exactly the 
issue that @balazske predicted in https://reviews.llvm.org/D145057#4164717:
> Problematic case is if the attribute has pointer to a Decl or Type that is 
imported here in a state when the field is already created but not initialized. 
Another problem is that attributes are added a second time in Import(Decl *)

This now came up in the testing of LLDB support for 
https://github.com/llvm/llvm-project/issues/93069. There, `__compressed_pair`s 
are now replaced with fields that have an `alignof(...)`  and 
`[[no_unique_address]]` attribute. In the specific case, we're importing the ` 
size_type& __sz() _NOEXCEPT { return __size_; }` method of `std::list`. 
During this process, we create a new `__size_` `FieldDecl` (but don't 
initialize it yet). Then we go down the `ImportAttrs` codepath added in 
D145057. This imports the `alignof` expression which then references the 
uninitialized `__size_` and we trigger an assertion.

Important to note, this codepath was added specifically to support 
`[[no_unique_address]]` in LLDB, and was supposed to land with 
https://reviews.llvm.org/D143347. But the LLDB side of that never landed, and 
the way we plan to support `[[no_unique_address]]` doesn't require things like 
the `markEmpty` method added here. So really, this is a dead codepath, which as 
pointed out in the original review isn't fully sound.

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


4 Files Affected:

- (modified) clang/include/clang/AST/ASTImporter.h (-1) 
- (modified) clang/include/clang/AST/DeclCXX.h (-4) 
- (modified) clang/lib/AST/ASTImporter.cpp (+9-21) 
- (modified) clang/unittests/AST/ASTImporterTest.cpp (-23) 


``diff
diff --git a/clang/include/clang/AST/ASTImporter.h 
b/clang/include/clang/AST/ASTImporter.h
index 4ffd913846575..f851decd0965c 100644
--- a/clang/include/clang/AST/ASTImporter.h
+++ b/clang/include/clang/AST/ASTImporter.h
@@ -258,7 +258,6 @@ class TypeSourceInfo;
 FoundDeclsTy findDeclsInToCtx(DeclContext *DC, DeclarationName Name);
 
 void AddToLookupTable(Decl *ToD);
-llvm::Error ImportAttrs(Decl *ToD, Decl *FromD);
 
   protected:
 /// Can be overwritten by subclasses to implement their own import logic.
diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index fb52ac804849d..3a110454f29ed 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1188,10 +1188,6 @@ class CXXRecordDecl : public RecordDecl {
   ///
   /// \note This does NOT include a check for union-ness.
   bool isEmpty() const { return data().Empty; }
-  /// Marks this record as empty. This is used by DWARFASTParserClang
-  /// when parsing records with empty fields having [[no_unique_address]]
-  /// attribute
-  void markEmpty() { data().Empty = true; }
 
   void setInitMethod(bool Val) { data().HasInitMethod = Val; }
   bool hasInitMethod() const { return data().HasInitMethod; }
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 08ef09d353afc..da1981d8dd05f 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -4179,12 +4179,6 @@ ExpectedDecl ASTNodeImporter::VisitFieldDecl(FieldDecl 
*D) {
   D->getInClassInitStyle()))
 return ToField;
 
-  // We need [[no_unqiue_address]] attributes to be added to FieldDecl, before
-  // we add fields in CXXRecordDecl::addedMember, otherwise record will be
-  // marked as having non-zero size.
-  Err = Importer.ImportAttrs(ToField, D);
-  if (Err)
-return std::move(Err);
   ToField->setAccess(D->getAccess());
   ToField->setLexicalDeclContext(LexicalDC);
   ToField->setImplicit(D->isImplicit());
@@ -9399,19 +9393,6 @@ TranslationUnitDecl *ASTImporter::GetFromTU(Decl *ToD) {
   return FromDPos->second->getTranslationUnitDecl();
 }
 
-Error ASTImporter::ImportAttrs(Decl *ToD, Decl *FromD) {
-  if (!FromD->hasAttrs() || ToD->hasAttrs())
-return Error::success();
-  for (const Attr *FromAttr : FromD->getAttrs()) {
-auto ToAttrOrErr = Import(FromAttr);
-if (ToAttrOrErr)
-  ToD->addAttr(*ToAttrOrErr);
-else
-  return ToAttrOrErr.takeError();
-  }
-  return Error::success();
-}
-
 Expected ASTImporter::Import(Decl *FromD) {
   if (!FromD)
 return nullptr;
@@ -9545,8 +9526,15 @@ Expected ASTImporter::Import(Decl *FromD) {
   }
   // Make sure that ImportImpl registered the imported decl.
   assert(ImportedDecls.count(FromD) != 0 && "Missing call to MapImported?");
-  if (auto Error = ImportAttrs(ToD, FromD))
-return std::move(Error);
+
+  if (FromD->hasAttrs())
+for (const Attr *FromAttr : FromD->getAttrs()) {
+  

[clang] Revert "Reland [clang][ASTImport] Add support for import of empty records" (PR #100903)

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

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


[clang] Revert "Reland [clang][ASTImport] Add support for import of empty records" (PR #100903)

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

https://github.com/Michael137 edited 
https://github.com/llvm/llvm-project/pull/100903
___
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-27 Thread Max Coplan 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]];

vegerot wrote:

Sorry, I'm new to contributing to LLVM.  This was my thought process:

This PR has two stacked commits.  The first commit is the same commit that is 
in #100821.  This is needed so that the CI for the second commit (which is this 
PR) passes.

Once the first PR lands, I'll update this PR to just have a single commit.

Does that make sense?  If I unstack this PR now, the CI will fail.

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] [libcxx] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

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


https://github.com/vegerot edited 
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] [libcxx] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-07-27 Thread Max Coplan 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]];

vegerot wrote:

edit: just read your other comment 
https://github.com/llvm/llvm-project/pull/100821#issuecomment-2254201186

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

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] [libcxx] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

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


https://github.com/vegerot converted_to_draft 
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-repl] [codegen] Reduce the state in TBAA. NFC for static compilation. (PR #98138)

2024-07-27 Thread Jeaye Wilkerson via cfe-commits

jeaye wrote:

Thanks, Vassil! I'm following up to confirm that this does fix the hard crash I 
was seeing. Really hoping we can get this merged.

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


[clang] [CMake][Fuchsia] Include libunwind and libc++abi in baremetal build (PR #100908)

2024-07-27 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek created 
https://github.com/llvm/llvm-project/pull/100908

These are needed for baremetal targets as well.

>From 5177b4ac9ce9d1b45e80e0613e1cb3363e73bd39 Mon Sep 17 00:00:00 2001
From: Petr Hosek 
Date: Sat, 27 Jul 2024 17:10:01 -0700
Subject: [PATCH] [CMake][Fuchsia] Include libunwind and libc++abi in baremetal
 build

These are needed for baremetal targets as well.
---
 clang/cmake/caches/Fuchsia-stage2.cmake | 42 -
 1 file changed, 34 insertions(+), 8 deletions(-)

diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 8e0835cb3158f..237b103ef8847 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -312,6 +312,7 @@ foreach(target 
armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m.main-unknown-eabi)
   set(BUILTINS_${target}_CMAKE_${lang}_local_flags 
"${BUILTINS_${target}_CMAKE_${lang}_local_flags} -mfloat-abi=hard 
-march=armv8m.main+fp+dsp -mcpu=cortex-m33" CACHE STRING "")
 endif()
 set(BUILTINS_${target}_CMAKE_${lang}_FLAGS 
"${BUILTINS_${target}_CMAKE_${lang}_local_flags}" CACHE STRING "")
+set(BUILTINS_${target}_CMAKE_${lang}_FLAGS_MINSIZEREL "-Oz -DNDEBUG" CACHE 
STRING "")
   endforeach()
   foreach(type SHARED;MODULE;EXE)
 set(BUILTINS_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
@@ -328,6 +329,7 @@ foreach(target 
armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m.main-unknown-eabi)
 # TODO: The preprocessor defines workaround various issues in libc and 
libc++ integration.
 # These should be addressed and removed over time.
 set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS "--target=${target} -mthumb 
-Wno-atomic-alignment \"-Dvfprintf(stream, format, vlist)=vprintf(format, 
vlist)\" \"-Dfprintf(stream, format, ...)=printf(format)\" \"-Dtimeval=struct 
timeval{int tv_sec; int tv_usec;}\" \"-Dgettimeofday(tv, tz)\" 
-D_LIBCPP_PRINT=1" CACHE STRING "")
+set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS_MINSIZEREL "-Oz -DNDEBUG" CACHE 
STRING "")
   endforeach()
   foreach(type SHARED;MODULE;EXE)
 set(RUNTIMES_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
@@ -335,11 +337,23 @@ foreach(target 
armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m.main-unknown-eabi)
   set(RUNTIMES_${target}_LLVM_LIBC_FULL_BUILD ON CACHE BOOL "")
   set(RUNTIMES_${target}_LIBC_ENABLE_USE_BY_CLANG ON CACHE BOOL "")
   set(RUNTIMES_${target}_LIBC_USE_NEW_HEADER_GEN OFF CACHE BOOL "")
-  set(RUNTIMES_${target}_LIBCXX_ABI_VERSION 2 CACHE STRING "")
-  set(RUNTIMES_${target}_LIBCXX_CXX_ABI none CACHE STRING "")
+  set(RUNTIMES_${target}_LIBUNWIND_IS_BAREMETAL ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBUNWIND_ENABLE_ASSERTIONS OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBUNWIND_ENABLE_THREADS OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBUNWIND_ENABLE_STATIC ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBUNWIND_REMEMBER_HEAP_ALLOC ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXXABI_BAREMETAL ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXXABI_ENABLE_ASSERTIONS OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXXABI_ENABLE_THREADS OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXX_ABI_UNSTABLE ON CACHE BOOL "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
-  set(RUNTIMES_${target}_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "")
   set(RUNTIMES_${target}_LIBCXX_LIBC "llvm-libc" CACHE STRING "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "")
@@ -353,7 +367,7 @@ foreach(target 
armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m.main-unknown-eabi)
   set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
   set(RUNTIMES_${target}_LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "")
-  set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc;libcxx" CACHE STRING "")
+  set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES 
"libc;libunwind;libcxxabi;libcxx" CACHE STRING "")
 endforeach()
 
 foreach(target riscv32-unknown-elf)
@@ -387,11 +401,23 @@ foreach(target riscv32-unknown-elf)
   set(RUNTIMES_${target}_LLVM_LIBC_FULL_BUILD ON CACHE BOOL "")
   set(RUNTIMES_${target}_LIBC_ENABLE_USE_BY_CLANG ON CACHE BOOL "")
   set(RUNTIMES_${target}_LIBC_USE_NEW_HEADER_GEN OFF CACHE BOOL "")
-  set(RUNTIMES_${target}_LIBCXX_ABI_VERSION 2 CACHE STRING "")
-  set(RUNTIMES_${target

[clang] [CMake][Fuchsia] Include libunwind and libc++abi in baremetal build (PR #100908)

2024-07-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Petr Hosek (petrhosek)


Changes

These are needed for baremetal targets as well.

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


1 Files Affected:

- (modified) clang/cmake/caches/Fuchsia-stage2.cmake (+34-8) 


``diff
diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 8e0835cb3158f..237b103ef8847 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -312,6 +312,7 @@ foreach(target 
armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m.main-unknown-eabi)
   set(BUILTINS_${target}_CMAKE_${lang}_local_flags 
"${BUILTINS_${target}_CMAKE_${lang}_local_flags} -mfloat-abi=hard 
-march=armv8m.main+fp+dsp -mcpu=cortex-m33" CACHE STRING "")
 endif()
 set(BUILTINS_${target}_CMAKE_${lang}_FLAGS 
"${BUILTINS_${target}_CMAKE_${lang}_local_flags}" CACHE STRING "")
+set(BUILTINS_${target}_CMAKE_${lang}_FLAGS_MINSIZEREL "-Oz -DNDEBUG" CACHE 
STRING "")
   endforeach()
   foreach(type SHARED;MODULE;EXE)
 set(BUILTINS_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
@@ -328,6 +329,7 @@ foreach(target 
armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m.main-unknown-eabi)
 # TODO: The preprocessor defines workaround various issues in libc and 
libc++ integration.
 # These should be addressed and removed over time.
 set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS "--target=${target} -mthumb 
-Wno-atomic-alignment \"-Dvfprintf(stream, format, vlist)=vprintf(format, 
vlist)\" \"-Dfprintf(stream, format, ...)=printf(format)\" \"-Dtimeval=struct 
timeval{int tv_sec; int tv_usec;}\" \"-Dgettimeofday(tv, tz)\" 
-D_LIBCPP_PRINT=1" CACHE STRING "")
+set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS_MINSIZEREL "-Oz -DNDEBUG" CACHE 
STRING "")
   endforeach()
   foreach(type SHARED;MODULE;EXE)
 set(RUNTIMES_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
@@ -335,11 +337,23 @@ foreach(target 
armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m.main-unknown-eabi)
   set(RUNTIMES_${target}_LLVM_LIBC_FULL_BUILD ON CACHE BOOL "")
   set(RUNTIMES_${target}_LIBC_ENABLE_USE_BY_CLANG ON CACHE BOOL "")
   set(RUNTIMES_${target}_LIBC_USE_NEW_HEADER_GEN OFF CACHE BOOL "")
-  set(RUNTIMES_${target}_LIBCXX_ABI_VERSION 2 CACHE STRING "")
-  set(RUNTIMES_${target}_LIBCXX_CXX_ABI none CACHE STRING "")
+  set(RUNTIMES_${target}_LIBUNWIND_IS_BAREMETAL ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBUNWIND_ENABLE_ASSERTIONS OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBUNWIND_ENABLE_THREADS OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBUNWIND_ENABLE_STATIC ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBUNWIND_REMEMBER_HEAP_ALLOC ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXXABI_BAREMETAL ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXXABI_ENABLE_ASSERTIONS OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXXABI_ENABLE_THREADS OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBCXX_ABI_UNSTABLE ON CACHE BOOL "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
-  set(RUNTIMES_${target}_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "")
   set(RUNTIMES_${target}_LIBCXX_LIBC "llvm-libc" CACHE STRING "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "")
@@ -353,7 +367,7 @@ foreach(target 
armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m.main-unknown-eabi)
   set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
   set(RUNTIMES_${target}_LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
   set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "")
-  set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc;libcxx" CACHE STRING "")
+  set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES 
"libc;libunwind;libcxxabi;libcxx" CACHE STRING "")
 endforeach()
 
 foreach(target riscv32-unknown-elf)
@@ -387,11 +401,23 @@ foreach(target riscv32-unknown-elf)
   set(RUNTIMES_${target}_LLVM_LIBC_FULL_BUILD ON CACHE BOOL "")
   set(RUNTIMES_${target}_LIBC_ENABLE_USE_BY_CLANG ON CACHE BOOL "")
   set(RUNTIMES_${target}_LIBC_USE_NEW_HEADER_GEN OFF CACHE BOOL "")
-  set(RUNTIMES_${target}_LIBCXX_ABI_VERSION 2 CACHE STRING "")
-  set(RUNTIMES_${target}_LIBCXX_CXX_ABI none CACHE STRING "")
+  set(RUNTIMES_${target}_LIBUNWIND_IS_BAREMETAL ON CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBUNWIND_ENABLE_ASSERTIONS OFF CACHE BOOL "")
+  set(RUNTIMES_${target}_LIBUNWIND_ENABL

[clang] [libcxx] Reapply "[Clang] Implement resolution for CWG1835 (#92957, #98547)" (PR #100425)

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


@@ -767,6 +757,7 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S, 
NestedNameSpecInfo &IdInfo,
   else
 Diag(IdInfo.IdentifierLoc, diag::err_undeclared_var_use)
 << IdInfo.Identifier;
+#endif

mizvekov wrote:

You should probably remove these before merging :)

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


[clang] [libcxx] Reapply "[Clang] Implement resolution for CWG1835 (#92957, #98547)" (PR #100425)

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


@@ -698,13 +685,15 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S, 
NestedNameSpecInfo &IdInfo,
   if (ErrorRecoveryLookup)
 return true;
 
+#if 0
   // If we didn't find anything during our lookup, try again with
   // ordinary name lookup, which can help us produce better error
   // messages.
   if (Found.empty()) {
 Found.clear(LookupOrdinaryName);
 LookupName(Found, S);
   }
+#endif

mizvekov wrote:

Ditto

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


[clang] [clang-repl] [codegen] Reduce the state in TBAA. NFC for static compilation. (PR #98138)

2024-07-27 Thread Vassil Vassilev via cfe-commits

vgvassilev wrote:

Hi @AaronBallman, could we move that forward?

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