[clang] 0140ba0 - [clang] Enable FPContract with optnone (#91061)

2024-05-06 Thread via cfe-commits

Author: Serge Pavlov
Date: 2024-05-06T14:30:54+07:00
New Revision: 0140ba031c9b6a4028b36adb292fb37eb62f3dc0

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

LOG: [clang] Enable FPContract with optnone (#91061)

Previously treatment of the attribute `optnone` was modified in
https://github.com/llvm/llvm-project/pull/85605 ([clang] Set correct
FPOptions if attribute 'optnone' presents). As a side effect FPContract
was disabled for optnone. It created unneeded divergence with the
behavior of -O0, which enables this optimization.

In the discussion
https://github.com/llvm/llvm-project/pull/85605#issuecomment-2089350379
it was pointed out that FP contraction should be enabled even if all
optimizations are turned off, otherwise results of calculations would be
different. This change enables FPContract at optnone.

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.h
clang/test/AST/ast-dump-fpfeatures.cpp
clang/test/AST/ast-dump-fpfeatures.m
clang/test/AST/ast-dump-late-parsing.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index e2a2aa71b880b3..75e88afbd97050 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -968,10 +968,7 @@ class FPOptionsOverride {
   setAllowFPContractAcrossStatement();
   }
 
-  void setDisallowOptimizations() {
-setFPPreciseEnabled(true);
-setDisallowFPContract();
-  }
+  void setDisallowOptimizations() { setFPPreciseEnabled(true); }
 
   storage_type getAsOpaqueInt() const {
 return (static_cast(Options.getAsOpaqueInt())

diff  --git a/clang/test/AST/ast-dump-fpfeatures.cpp 
b/clang/test/AST/ast-dump-fpfeatures.cpp
index 2c66a73812f5b3..cd00650db55cc9 100644
--- a/clang/test/AST/ast-dump-fpfeatures.cpp
+++ b/clang/test/AST/ast-dump-fpfeatures.cpp
@@ -198,7 +198,7 @@ float func_19(float x, float y) {
 // CHECK-LABEL: FunctionDecl {{.*}} func_19 'float (float, float)'
 // CHECK: CompoundStmt {{.*}} MathErrno=1
 // CHECK:   ReturnStmt
-// CHECK: BinaryOperator {{.*}} 'float' '+' 
ConstRoundingMode=downward MathErrno=1
+// CHECK: BinaryOperator {{.*}} 'float' '+' FPContractMode=1 
ConstRoundingMode=downward MathErrno=1
 
 __attribute__((optnone))
 float func_20(float x, float y) try {
@@ -210,7 +210,7 @@ float func_20(float x, float y) try {
 // CHECK-LABEL: FunctionDecl {{.*}} func_20 'float (float, float)'
 // CHECK: CompoundStmt {{.*}} ConstRoundingMode=downward MathErrno=1
 // CHECK:   ReturnStmt
-// CHECK: BinaryOperator {{.*}} 'float' '+' 
ConstRoundingMode=downward MathErrno=1
+// CHECK: BinaryOperator {{.*}} 'float' '+' FPContractMode=1 
ConstRoundingMode=downward MathErrno=1
 
 struct C21 {
   C21(float x, float y);
@@ -221,15 +221,15 @@ struct C21 {
 };
 
 // CHECK-LABEL: CXXMethodDecl {{.*}} a_method 'float (float, float)'
-// CHECK: CompoundStmt {{.*}} ConstRoundingMode=downward MathErrno=1
+// CHECK: CompoundStmt {{.*}} FPContractMode=1 
ConstRoundingMode=downward MathErrno=1
 // CHECK:   ReturnStmt
-// CHECK: BinaryOperator {{.*}} 'float' '*' 
ConstRoundingMode=downward MathErrno=1
+// CHECK: BinaryOperator {{.*}} 'float' '*' FPContractMode=1 
ConstRoundingMode=downward MathErrno=1
 
 __attribute__((optnone)) C21::C21(float x, float y) : member(x + y) {}
 
 // CHECK-LABEL: CXXConstructorDecl {{.*}} C21 'void (float, float)'
 // CHECK: CXXCtorInitializer {{.*}} 'member' 'float'
-// CHECK:   BinaryOperator {{.*}} 'float' '+' 
ConstRoundingMode=downward MathErrno=1
+// CHECK:   BinaryOperator {{.*}} 'float' '+' FPContractMode=1 
ConstRoundingMode=downward MathErrno=1
 
 template 
 __attribute__((optnone)) T func_22(T x, T y) {
@@ -238,13 +238,13 @@ __attribute__((optnone)) T func_22(T x, T y) {
 
 // CHECK-LABEL: FunctionTemplateDecl {{.*}} func_22
 // CHECK: FunctionDecl {{.*}} func_22 'T (T, T)'
-// CHECK:   CompoundStmt {{.*}} ConstRoundingMode=downward MathErrno=1
+// CHECK:   CompoundStmt {{.*}} FPContractMode=1 
ConstRoundingMode=downward MathErrno=1
 // CHECK: ReturnStmt
-// CHECK:   BinaryOperator {{.*}} '+' ConstRoundingMode=downward 
MathErrno=1
+// CHECK:   BinaryOperator {{.*}} '+' FPContractMode=1 
ConstRoundingMode=downward MathErrno=1
 // CHECK: FunctionDecl {{.*}} func_22 'float (float, float)'
-// CHECK:   CompoundStmt {{.*}} ConstRoundingMode=downward MathErrno=1
+// CHECK:   CompoundStmt {{.*}} FPContractMode=1 
ConstRoundingMode=downward MathErrno=1
 // CHECK: ReturnStmt
-// CHECK:   BinaryOperator {{.*}} 'float' '+' 
Const

[clang] [clang] Enable FPContract with optnone (PR #91061)

2024-05-06 Thread Serge Pavlov via cfe-commits

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


[clang] [Clang] Implement P3034R1 Module Declarations Shouldn’t be Macros (PR #90574)

2024-05-06 Thread via cfe-commits

cor3ntin wrote:

> Thanks! I'd like to move the implementation from Parser to Preprocessor. I 
> think It would make more sense to do these checks during lexing.

I'm not sure that would make a lot of sense (unless we were doing exactly how 
the specification does it, by injecting a token for a fully parsed module... 
but that does seem necessary).

Either way, the parsing of semi conlon/attributes should stay in the parser.

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


[clang] [llvm] [openmp] [OpenMP] Depobj optimisation (PR #91145)

2024-05-06 Thread PEREIRA Romain via cfe-commits

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


[clang] [clang] Use constant rounding mode for floating literals (PR #90877)

2024-05-06 Thread Serge Pavlov via cfe-commits

https://github.com/spavloff updated 
https://github.com/llvm/llvm-project/pull/90877

>From 5d906b537636ca0d8706a8a888dd78edfbec684f Mon Sep 17 00:00:00 2001
From: Serge Pavlov 
Date: Thu, 2 May 2024 22:28:05 +0700
Subject: [PATCH 01/10] [clang] Use constant rounding mode for floating
 literals

Conversion of floating-point literal to binary representation must be
made using constant rounding mode, which can be changed using pragma
FENV_ROUND. For example, the literal "0.1F" should be representes by
either 0.09994 or 0.10001 depending on the rounding direction.
---
 clang/include/clang/Lex/LiteralSupport.h | 10 --
 clang/lib/Lex/LiteralSupport.cpp |  6 +++---
 clang/lib/Sema/SemaExpr.cpp  |  3 ++-
 clang/test/AST/const-fpfeatures.c|  6 ++
 4 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/clang/include/clang/Lex/LiteralSupport.h 
b/clang/include/clang/Lex/LiteralSupport.h
index 2ed42d1c5f9aae..705021fcfa5b11 100644
--- a/clang/include/clang/Lex/LiteralSupport.h
+++ b/clang/include/clang/Lex/LiteralSupport.h
@@ -118,12 +118,10 @@ class NumericLiteralParser {
   /// bits of the result and return true.  Otherwise, return false.
   bool GetIntegerValue(llvm::APInt &Val);
 
-  /// GetFloatValue - Convert this numeric literal to a floating value, using
-  /// the specified APFloat fltSemantics (specifying float, double, etc).
-  /// The optional bool isExact (passed-by-reference) has its value
-  /// set to true if the returned APFloat can represent the number in the
-  /// literal exactly, and false otherwise.
-  llvm::APFloat::opStatus GetFloatValue(llvm::APFloat &Result);
+  /// Convert this numeric literal to a floating value, using the specified
+  /// APFloat fltSemantics (specifying float, double, etc) and rounding mode.
+  llvm::APFloat::opStatus GetFloatValue(llvm::APFloat &Result,
+llvm::RoundingMode RM);
 
   /// GetFixedPointValue - Convert this numeric literal value into a
   /// scaled integer that represents this value. Returns true if an overflow
diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp
index 9c0cbea5052cb2..3df0391bdda772 100644
--- a/clang/lib/Lex/LiteralSupport.cpp
+++ b/clang/lib/Lex/LiteralSupport.cpp
@@ -1520,7 +1520,8 @@ bool NumericLiteralParser::GetIntegerValue(llvm::APInt 
&Val) {
 }
 
 llvm::APFloat::opStatus
-NumericLiteralParser::GetFloatValue(llvm::APFloat &Result) {
+NumericLiteralParser::GetFloatValue(llvm::APFloat &Result,
+llvm::RoundingMode RM) {
   using llvm::APFloat;
 
   unsigned n = std::min(SuffixBegin - ThisTokBegin, ThisTokEnd - ThisTokBegin);
@@ -1534,8 +1535,7 @@ NumericLiteralParser::GetFloatValue(llvm::APFloat 
&Result) {
 Str = Buffer;
   }
 
-  auto StatusOrErr =
-  Result.convertFromString(Str, APFloat::rmNearestTiesToEven);
+  auto StatusOrErr = Result.convertFromString(Str, RM);
   assert(StatusOrErr && "Invalid floating point representation");
   return !errorToBool(StatusOrErr.takeError()) ? *StatusOrErr
: APFloat::opInvalidOp;
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 0cca02c338954a..db96c8692f2516 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -3858,7 +3858,8 @@ static Expr *BuildFloatingLiteral(Sema &S, 
NumericLiteralParser &Literal,
   using llvm::APFloat;
   APFloat Val(Format);
 
-  APFloat::opStatus result = Literal.GetFloatValue(Val);
+  APFloat::opStatus result =
+  Literal.GetFloatValue(Val, S.CurFPFeatures.getRoundingMode());
 
   // Overflow is always an error, but underflow is only an error if
   // we underflowed to zero (APFloat reports denormals as underflow).
diff --git a/clang/test/AST/const-fpfeatures.c 
b/clang/test/AST/const-fpfeatures.c
index 6600ea27405d9c..247245c776fed1 100644
--- a/clang/test/AST/const-fpfeatures.c
+++ b/clang/test/AST/const-fpfeatures.c
@@ -19,6 +19,9 @@ float FI1u = 0xU;
 float _Complex C1u = C0;
 // CHECK: @C1u = {{.*}} { float, float } { float 0x3FF02000, float 
0x3FF02000 }
 
+float FLu = 0.1F;
+// CHECK: @FLu = {{.*}} float 0x3FB98000
+
 
 #pragma STDC FENV_ROUND FE_DOWNWARD
 
@@ -35,3 +38,6 @@ float FI1d = 0xU;
 
 float _Complex C1d = C0;
 // CHECK: @C1d = {{.*}} { float, float } { float 1.00e+00, float 
1.00e+00 }
+
+float FLd = 0.1F;
+// CHECK: @FLd = {{.*}} float 0x3FB9A000

>From a6fad25517b283c4b282324595d1e84f99717e16 Mon Sep 17 00:00:00 2001
From: Serge Pavlov 
Date: Fri, 3 May 2024 13:45:36 +0700
Subject: [PATCH 02/10] Fix typo

---
 clang/test/AST/const-fpfeatures.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/AST/const-fpfeatures.c 
b/clang/test/AST/const-fpfeatures.c
index 247245c776fed1..276d46b70c21d9 100644
--- a/clang/test/AST/const-fpfeatures.c
+++ b/clang/test/AST/const-fpfeatures.c
@@ -20,7 +20,7 @@

[clang] reland 90438 (PR #91172)

2024-05-06 Thread via cfe-commits

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

- **Reapply "[clang][dataflow] Don't propagate result objects in unevaluated 
contexts (#90438)"**
- **fixup! Reapply "[clang][dataflow] Don't propagate result objects in 
unevaluated contexts (#90438)"**


>From af6de532e14c6b3bf89f238533dea197fbc8114a Mon Sep 17 00:00:00 2001
From: Martin Braenne 
Date: Mon, 6 May 2024 06:46:33 +
Subject: [PATCH 1/2] Reapply "[clang][dataflow] Don't propagate result objects
 in unevaluated contexts (#90438)"

This reverts commit 2252c5c42b95dd12dda0c7fb1b2811f943b21949.
---
 .../FlowSensitive/DataflowEnvironment.cpp | 11 
 .../Analysis/FlowSensitive/TransferTest.cpp   | 52 +++
 2 files changed, 63 insertions(+)

diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index d79e734402892a..cb6c8b2ef1072b 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -350,6 +350,17 @@ class ResultObjectVisitor : public 
RecursiveASTVisitor {
 return RecursiveASTVisitor::TraverseDecl(D);
   }
 
+  // Don't traverse expressions in unevaluated contexts, as we don't model
+  // fields that are only used in these.
+  // Note: The operand of the `noexcept` operator is an unevaluated operand, 
but
+  // nevertheless it appears in the Clang CFG, so we don't exclude it here.
+  bool TraverseDecltypeTypeLoc(DecltypeTypeLoc) { return true; }
+  bool TraverseTypeOfExprTypeLoc(TypeOfExprTypeLoc) { return true; }
+  bool TraverseCXXTypeidExpr(CXXTypeidExpr *) { return true; }
+  bool TraverseUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *) {
+return true;
+  }
+
   bool TraverseBindingDecl(BindingDecl *BD) {
 // `RecursiveASTVisitor` doesn't traverse holding variables for
 // `BindingDecl`s by itself, so we need to tell it to.
diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 0b441faa6c76da..91bd496226caf2 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3400,6 +3400,58 @@ TEST(TransferTest, 
ResultObjectLocationDontVisitNestedRecordDecl) {
  ASTContext &ASTCtx) {});
 }
 
+TEST(TransferTest, ResultObjectLocationDontVisitUnevaluatedContexts) {
+  // This is a crash repro.
+  // We used to crash because when propagating result objects, we would visit
+  // unevaluated contexts, but we don't model fields used only in these.
+
+  auto testFunction = [](llvm::StringRef Code, llvm::StringRef TargetFun) {
+runDataflow(
+Code,
+[](const llvm::StringMap> &Results,
+   ASTContext &ASTCtx) {},
+LangStandard::lang_gnucxx17,
+/* ApplyBuiltinTransfer= */ true, TargetFun);
+  };
+
+  std::string Code = R"cc(
+// Definitions needed for `typeid`.
+namespace std {
+  class type_info {};
+  class bad_typeid {};
+}  // namespace std
+
+struct S1 {};
+struct S2 { S1 s1; };
+
+// We test each type of unevaluated context from a different target
+// function. Some types of unevaluated contexts may actually cause the
+// field `s1` to be modeled, and we don't want this to "pollute" the tests
+// for the other unevaluated contexts.
+void decltypeTarget() {
+decltype(S2{}) Dummy;
+}
+void typeofTarget() {
+typeof(S2{}) Dummy;
+}
+void typeidTarget() {
+typeid(S2{});
+}
+void sizeofTarget() {
+sizeof(S2{});
+}
+void noexceptTarget() {
+noexcept(S2{});
+}
+  )cc";
+
+  testFunction(Code, "decltypeTarget");
+  testFunction(Code, "typeofTarget");
+  testFunction(Code, "typeidTarget");
+  testFunction(Code, "sizeofTarget");
+  testFunction(Code, "noexceptTarget");
+}
+
 TEST(TransferTest, StaticCast) {
   std::string Code = R"(
 void target(int Foo) {

>From 77222057b948a668aebda9cbd0b6fd41e01a21a2 Mon Sep 17 00:00:00 2001
From: Martin Braenne 
Date: Mon, 6 May 2024 08:11:11 +
Subject: [PATCH 2/2] fixup! Reapply "[clang][dataflow] Don't propagate result
 objects in unevaluated contexts (#90438)"

---
 clang/unittests/Analysis/FlowSensitive/TransferTest.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 91bd496226caf2..6743e778a2ffeb 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3435,7 +3435,9 @@ TEST(TransferTest, 
ResultObjectLocationDontVisitUnevaluatedContexts) {
 typeof(S2{}) Dummy;
 }
 void typeidTarget() {
+#if __has_feature(cxx_rtti)
 typeid(S2{});
+#endif
 }
 void sizeofTarget() {
 sizeof(S2{});

__

[clang] reland 90438 (PR #91172)

2024-05-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (martinboehme)


Changes

- **Reapply "[clang][dataflow] Don't propagate result objects in unevaluated 
contexts (#90438)"**
- **fixup! Reapply "[clang][dataflow] Don't propagate result objects in 
unevaluated contexts (#90438)"**


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


2 Files Affected:

- (modified) clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp (+11) 
- (modified) clang/unittests/Analysis/FlowSensitive/TransferTest.cpp (+54) 


``diff
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index d79e734402892a..cb6c8b2ef1072b 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -350,6 +350,17 @@ class ResultObjectVisitor : public 
RecursiveASTVisitor {
 return RecursiveASTVisitor::TraverseDecl(D);
   }
 
+  // Don't traverse expressions in unevaluated contexts, as we don't model
+  // fields that are only used in these.
+  // Note: The operand of the `noexcept` operator is an unevaluated operand, 
but
+  // nevertheless it appears in the Clang CFG, so we don't exclude it here.
+  bool TraverseDecltypeTypeLoc(DecltypeTypeLoc) { return true; }
+  bool TraverseTypeOfExprTypeLoc(TypeOfExprTypeLoc) { return true; }
+  bool TraverseCXXTypeidExpr(CXXTypeidExpr *) { return true; }
+  bool TraverseUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *) {
+return true;
+  }
+
   bool TraverseBindingDecl(BindingDecl *BD) {
 // `RecursiveASTVisitor` doesn't traverse holding variables for
 // `BindingDecl`s by itself, so we need to tell it to.
diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 0b441faa6c76da..6743e778a2ffeb 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3400,6 +3400,60 @@ TEST(TransferTest, 
ResultObjectLocationDontVisitNestedRecordDecl) {
  ASTContext &ASTCtx) {});
 }
 
+TEST(TransferTest, ResultObjectLocationDontVisitUnevaluatedContexts) {
+  // This is a crash repro.
+  // We used to crash because when propagating result objects, we would visit
+  // unevaluated contexts, but we don't model fields used only in these.
+
+  auto testFunction = [](llvm::StringRef Code, llvm::StringRef TargetFun) {
+runDataflow(
+Code,
+[](const llvm::StringMap> &Results,
+   ASTContext &ASTCtx) {},
+LangStandard::lang_gnucxx17,
+/* ApplyBuiltinTransfer= */ true, TargetFun);
+  };
+
+  std::string Code = R"cc(
+// Definitions needed for `typeid`.
+namespace std {
+  class type_info {};
+  class bad_typeid {};
+}  // namespace std
+
+struct S1 {};
+struct S2 { S1 s1; };
+
+// We test each type of unevaluated context from a different target
+// function. Some types of unevaluated contexts may actually cause the
+// field `s1` to be modeled, and we don't want this to "pollute" the tests
+// for the other unevaluated contexts.
+void decltypeTarget() {
+decltype(S2{}) Dummy;
+}
+void typeofTarget() {
+typeof(S2{}) Dummy;
+}
+void typeidTarget() {
+#if __has_feature(cxx_rtti)
+typeid(S2{});
+#endif
+}
+void sizeofTarget() {
+sizeof(S2{});
+}
+void noexceptTarget() {
+noexcept(S2{});
+}
+  )cc";
+
+  testFunction(Code, "decltypeTarget");
+  testFunction(Code, "typeofTarget");
+  testFunction(Code, "typeidTarget");
+  testFunction(Code, "sizeofTarget");
+  testFunction(Code, "noexceptTarget");
+}
+
 TEST(TransferTest, StaticCast) {
   std::string Code = R"(
 void target(int Foo) {

``




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


[clang] [clang][dataflow] Don't propagate result objects in unevaluated contexts (reland #90438) (PR #91172)

2024-05-06 Thread via cfe-commits

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


[clang] [clang][dataflow] Don't propagate result objects in unevaluated contexts (reland #90438) (PR #91172)

2024-05-06 Thread via cfe-commits

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


[clang] [clang] Use constant rounding mode for floating literals (PR #90877)

2024-05-06 Thread Serge Pavlov via cfe-commits


@@ -79,3 +79,16 @@ float V7 = []() -> float {
   0x0.01p0F);
 }();
 // CHECK: @V7 = {{.*}} float 1.00e+00
+
+template struct L {
+  constexpr L() : value(V) {}
+  float value;
+};
+
+#pragma STDC FENV_ROUND FE_DOWNWARD

spavloff wrote:

Explicit instantiation also should use the rounding mode at the point of 
definition. It is possible that the template is instantiated in two translation 
units and rounding mode is different at the points of instantiation.

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


[clang] [llvm] [RISCV] Teach .option arch to support experimental extensions. (PR #89727)

2024-05-06 Thread via cfe-commits

dyung wrote:

@yetingk, the two tests you added are failing on a couple of build bots:
- https://lab.llvm.org/buildbot/#/builders/164/builds/51995
- https://lab.llvm.org/buildbot/#/builders/258/builds/17867
- https://lab.llvm.org/buildbot/#/builders/91/builds/25943
- https://lab.llvm.org/buildbot/#/builders/280/builds/3159
- https://lab.llvm.org/buildbot/#/builders/283/builds/1636
- https://lab.llvm.org/buildbot/#/builders/139/builds/64910
- https://lab.llvm.org/buildbot/#/builders/259/builds/3993
- https://lab.llvm.org/buildbot/#/builders/285/builds/1756

Can you take a look and revert if you need time to investigate?

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


[clang] [clang][dataflow] Don't propagate result objects in unevaluated contexts (reland #90438) (PR #91172)

2024-05-06 Thread via cfe-commits

martinboehme wrote:

CI failure (DataFlowSanitizer-x86_64 :: release_shadow_space.c) looks unrelated.

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


[clang] 9a521e2 - [clang][Interp] Fix primitive lambda capture defaults

2024-05-06 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-05-06T10:37:30+02:00
New Revision: 9a521e274d0ad4a4a461952d23809320e080ffb4

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

LOG: [clang][Interp] Fix primitive lambda capture defaults

We need to use InitField here, not SetField.

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/test/AST/Interp/lambda.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index b9318fbd9ae9e6..630fdb60c35182 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -2025,7 +2025,7 @@ bool ByteCodeExprGen::VisitLambdaExpr(const 
LambdaExpr *E) {
   if (!this->visit(Init))
 return false;
 
-  if (!this->emitSetField(*T, F.Offset, E))
+  if (!this->emitInitField(*T, F.Offset, E))
 return false;
 } else {
   if (!this->emitDupPtr(E))

diff  --git a/clang/test/AST/Interp/lambda.cpp 
b/clang/test/AST/Interp/lambda.cpp
index d056bb304eeb30..77e035ce254703 100644
--- a/clang/test/AST/Interp/lambda.cpp
+++ b/clang/test/AST/Interp/lambda.cpp
@@ -248,3 +248,19 @@ namespace ns2_capture_this_byval {
   constexpr auto L = S{5}.f(S{10});
   static_assert(L(S{100}) == 115, "");
 } // end test_captures_1::ns2_capture_this_byval
+
+namespace CaptureDefaults {
+  struct S {
+int x;
+  };
+
+  constexpr auto f = [x = S{10}]() {
+  return x.x;
+  };
+  static_assert(f() == 10, "");
+
+  constexpr auto f2 = [x = 3]() {
+  return x;
+  };
+  static_assert(f2() == 3, "");
+}



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


[clang] [compiler-rt] [XRay] Add support for instrumentation of DSOs on x86_64 (PR #90959)

2024-05-06 Thread Sebastian Kreutzer via cfe-commits

https://github.com/sebastiankreutzer updated 
https://github.com/llvm/llvm-project/pull/90959

>From 1f0484b73ad0bb9b40e3cd86d8abad4af14e32dc Mon Sep 17 00:00:00 2001
From: Sebastian Kreutzer 
Date: Thu, 26 Oct 2023 15:13:05 +0200
Subject: [PATCH 1/4] [XRay] Add DSO support for XRay instrumentation on X86_64

---
 clang/include/clang/Driver/Options.td |   4 +
 clang/include/clang/Driver/XRayArgs.h |   4 +
 clang/lib/Driver/ToolChains/CommonArgs.cpp|  12 +-
 clang/lib/Driver/XRayArgs.cpp |   7 +
 .../cmake/Modules/AllSupportedArchDefs.cmake  |   1 +
 compiler-rt/cmake/config-ix.cmake |   4 +
 compiler-rt/include/xray/xray_interface.h |  23 ++
 compiler-rt/lib/xray/CMakeLists.txt   |  73 -
 compiler-rt/lib/xray/xray_dso_init.cpp|  62 +
 compiler-rt/lib/xray/xray_init.cpp| 158 +--
 compiler-rt/lib/xray/xray_interface.cpp   | 261 ++
 .../lib/xray/xray_interface_internal.h|  83 +-
 compiler-rt/lib/xray/xray_trampoline_x86_64.S |  24 +-
 compiler-rt/lib/xray/xray_x86_64.cpp  |  23 +-
 .../xray/TestCases/Posix/basic-mode-dso.cpp   |  47 
 .../TestCases/Posix/clang-enable-shared.cpp   |  14 +
 .../test/xray/TestCases/Posix/dlopen.cpp  | 110 
 .../TestCases/Posix/patch-premain-dso.cpp |  45 +++
 .../Posix/patching-unpatching-dso.cpp |  75 +
 19 files changed, 912 insertions(+), 118 deletions(-)
 create mode 100644 compiler-rt/lib/xray/xray_dso_init.cpp
 create mode 100644 compiler-rt/test/xray/TestCases/Posix/basic-mode-dso.cpp
 create mode 100644 
compiler-rt/test/xray/TestCases/Posix/clang-enable-shared.cpp
 create mode 100644 compiler-rt/test/xray/TestCases/Posix/dlopen.cpp
 create mode 100644 compiler-rt/test/xray/TestCases/Posix/patch-premain-dso.cpp
 create mode 100644 
compiler-rt/test/xray/TestCases/Posix/patching-unpatching-dso.cpp

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 953f6fc649e621..3e3be5475c0c4d 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2850,6 +2850,10 @@ def fxray_selected_function_group :
   HelpText<"When using -fxray-function-groups, select which group of functions 
to instrument. Valid range is 0 to fxray-function-groups - 1">,
   MarshallingInfoInt, "0">;
 
+def fxray_enable_shared : Flag<["-"], "fxray-enable-shared">, Group,  
Visibility<[ClangOption, CC1Option]>,
+  HelpText<"Enable shared library instrumentation.">;
+def fno_xray_enable_shared : Flag<["-"], "fno-xray-enable-shared">, 
Group,
+  Visibility<[ClangOption, CC1Option]>;
 
 defm fine_grained_bitfield_accesses : BoolOption<"f", 
"fine-grained-bitfield-accesses",
   CodeGenOpts<"FineGrainedBitfieldAccesses">, DefaultFalse,
diff --git a/clang/include/clang/Driver/XRayArgs.h 
b/clang/include/clang/Driver/XRayArgs.h
index bdd3d979547eed..90a21e69586033 100644
--- a/clang/include/clang/Driver/XRayArgs.h
+++ b/clang/include/clang/Driver/XRayArgs.h
@@ -27,6 +27,7 @@ class XRayArgs {
   XRayInstrSet InstrumentationBundle;
   llvm::opt::Arg *XRayInstrument = nullptr;
   bool XRayRT = true;
+  bool XRayEnableShared = false;
 
 public:
   /// Parses the XRay arguments from an argument list.
@@ -35,6 +36,9 @@ class XRayArgs {
llvm::opt::ArgStringList &CmdArgs, types::ID InputType) const;
 
   bool needsXRayRt() const { return XRayInstrument && XRayRT; }
+  bool needsXRayDSORt() const {
+return XRayInstrument && XRayRT && XRayEnableShared;
+  }
   llvm::ArrayRef modeList() const { return Modes; }
   XRayInstrSet instrumentationBundle() const { return InstrumentationBundle; }
 };
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 6796b43a155020..399bf795ce394e 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1520,10 +1520,14 @@ bool tools::addSanitizerRuntimes(const ToolChain &TC, 
const ArgList &Args,
 }
 
 bool tools::addXRayRuntime(const ToolChain&TC, const ArgList &Args, 
ArgStringList &CmdArgs) {
-  if (Args.hasArg(options::OPT_shared))
-return false;
-
-  if (TC.getXRayArgs().needsXRayRt()) {
+  if (Args.hasArg(options::OPT_shared)) {
+if (TC.getXRayArgs().needsXRayDSORt()) {
+  CmdArgs.push_back("-whole-archive");
+  CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray-dso"));
+  CmdArgs.push_back("-no-whole-archive");
+  return true;
+}
+  } else if (TC.getXRayArgs().needsXRayRt()) {
 CmdArgs.push_back("--whole-archive");
 CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray"));
 for (const auto &Mode : TC.getXRayArgs().modeList())
diff --git a/clang/lib/Driver/XRayArgs.cpp b/clang/lib/Driver/XRayArgs.cpp
index 8c5134e2501358..7809cd7ef7c759 100644
--- a/clang/lib/Driver/XRayArgs.cpp
+++ b/clang/lib/Driver/XRayArgs.cpp
@@ -63,6 +63,10 @@ XRayArgs::XRayArgs(const ToolChain &TC, c

[clang] [clang-tools-extra] [compiler-rt] [flang] [lldb] [llvm] [mlir] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-05-06 Thread via cfe-commits


@@ -1,3 +1,10 @@
+# Checkout as native, commit as LF except in specific circumstances
+* text=auto
+*.bat text eol=crlf
+*.rc text eol=crlf
+*.sln text eol=crlf

ldrumm wrote:

I think it makes sense to put the well-known-extension attributes in the root. 
I don't envision a `.sln` file ever *not* having crlf endings, so I considered 
it a global convenience

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


[clang] [clang-format] Handle Java switch expressions (PR #91112)

2024-05-06 Thread Emilia Kond via cfe-commits

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

Also works well for pattern matching
```java
switch (obj) {
  case String s when !s.isEmpty() -> 0;
  default -> 1;
}
```
and upcoming destructuring
```java
switch (n) {
  case IntExpr(int i)  -> i;
  case NegExpr(Expr n) -> -1 * eval(n);
  case AddExpr(Expr lhs, Expr rhs) -> eval(lhs) + eval(rhs);
  case MulExpr(Expr lhs, Expr rhs) -> eval(lhs) * eval(rhs);
  default  -> throw new IllegalStateException();
};
```

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


[clang] 69d740e - [clang][Interp] Fix creating functions with explicit instance parameters

2024-05-06 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-05-06T11:38:06+02:00
New Revision: 69d740e5d64257524914aabd6dfead7565185d4f

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

LOG: [clang][Interp] Fix creating functions with explicit instance parameters

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeEmitter.cpp
clang/test/AST/Interp/cxx23.cpp
clang/test/SemaCXX/cxx2b-deducing-this-constexpr.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeEmitter.cpp 
b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
index d912c101449d80..918cd66c9a9767 100644
--- a/clang/lib/AST/Interp/ByteCodeEmitter.cpp
+++ b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
@@ -82,11 +82,13 @@ Function *ByteCodeEmitter::compileFunc(const FunctionDecl 
*FuncDecl) {
   // InterpStack when calling the function.
   bool HasThisPointer = false;
   if (const auto *MD = dyn_cast(FuncDecl)) {
-if (MD->isImplicitObjectMemberFunction() && !IsLambdaStaticInvoker) {
-  HasThisPointer = true;
-  ParamTypes.push_back(PT_Ptr);
-  ParamOffsets.push_back(ParamOffset);
-  ParamOffset += align(primSize(PT_Ptr));
+if (!IsLambdaStaticInvoker) {
+  HasThisPointer = MD->isInstance();
+  if (MD->isImplicitObjectMemberFunction()) {
+ParamTypes.push_back(PT_Ptr);
+ParamOffsets.push_back(ParamOffset);
+ParamOffset += align(primSize(PT_Ptr));
+  }
 }
 
 // Set up lambda capture to closure record field mapping.

diff  --git a/clang/test/AST/Interp/cxx23.cpp b/clang/test/AST/Interp/cxx23.cpp
index d1ec93e99803e5..55807f0e0f115a 100644
--- a/clang/test/AST/Interp/cxx23.cpp
+++ b/clang/test/AST/Interp/cxx23.cpp
@@ -170,3 +170,10 @@ namespace LabelGoto {
   static_assert(foo() == 1, ""); // all-error {{not an integral constant 
expression}} \
  // all-note {{in call to}}
 }
+
+namespace ExplicitLambdaThis {
+  constexpr auto f = [x = 3](this Self self) { // all20-error 
{{explicit object parameters are incompatible with C++ standards before C++2b}}
+  return x;
+  };
+  static_assert(f());
+}

diff  --git a/clang/test/SemaCXX/cxx2b-deducing-this-constexpr.cpp 
b/clang/test/SemaCXX/cxx2b-deducing-this-constexpr.cpp
index 9dbea17dd2cae3..191fb013e0316f 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this-constexpr.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this-constexpr.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++2b %s -verify
+// RUN: %clang_cc1 -fsyntax-only -std=c++2b %s -verify 
-fexperimental-new-constant-interpreter
 // expected-no-diagnostics
 
 template 



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


[clang] [clang][PowerPC] Add flag to enable compatibility with GNU for complex arguments (PR #77732)

2024-05-06 Thread Kishan Parmar via cfe-commits


@@ -0,0 +1,286 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
+
+// RUN: %clang_cc1 -triple powerpc-unknown-linux-gnu -fcomplex-ppc-gnu-abi \
+// RUN:   -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-GNU-DEF
+// RUN: %clang_cc1 -msoft-float  -mfloat-abi soft -triple 
powerpc-unknown-linux-gnu -fcomplex-ppc-gnu-abi \
+// RUN:   -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-GNU-SOFT-FLOAT
+
+// CHECK-GNU-DEF-LABEL: define dso_local [8 x i32] @_cldouble
+// CHECK-GNU-DEF-SAME: (float noundef [[F:%.*]], [8 x i32] noundef 
[[X_COERCE:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-GNU-DEF-NEXT:  entry:
+// CHECK-GNU-DEF-NEXT:[[RETVAL:%.*]] = alloca { ppc_fp128, ppc_fp128 }, 
align 16
+// CHECK-GNU-DEF-NEXT:[[X:%.*]] = alloca { ppc_fp128, ppc_fp128 }, align 16
+// CHECK-GNU-DEF-NEXT:[[F_ADDR:%.*]] = alloca float, align 4
+// CHECK-GNU-DEF-NEXT:store [8 x i32] [[X_COERCE]], ptr [[X]], align 16
+// CHECK-GNU-DEF-NEXT:store float [[F]], ptr [[F_ADDR]], align 4
+// CHECK-GNU-DEF-NEXT:[[X_REALP:%.*]] = getelementptr inbounds { 
ppc_fp128, ppc_fp128 }, ptr [[X]], i32 0, i32 0
+// CHECK-GNU-DEF-NEXT:[[X_REAL:%.*]] = load ppc_fp128, ptr [[X_REALP]], 
align 16
+// CHECK-GNU-DEF-NEXT:[[X_IMAGP:%.*]] = getelementptr inbounds { 
ppc_fp128, ppc_fp128 }, ptr [[X]], i32 0, i32 1
+// CHECK-GNU-DEF-NEXT:[[X_IMAG:%.*]] = load ppc_fp128, ptr [[X_IMAGP]], 
align 16
+// CHECK-GNU-DEF-NEXT:[[RETVAL_REALP:%.*]] = getelementptr inbounds { 
ppc_fp128, ppc_fp128 }, ptr [[RETVAL]], i32 0, i32 0
+// CHECK-GNU-DEF-NEXT:[[RETVAL_IMAGP:%.*]] = getelementptr inbounds { 
ppc_fp128, ppc_fp128 }, ptr [[RETVAL]], i32 0, i32 1
+// CHECK-GNU-DEF-NEXT:store ppc_fp128 [[X_REAL]], ptr [[RETVAL_REALP]], 
align 16
+// CHECK-GNU-DEF-NEXT:store ppc_fp128 [[X_IMAG]], ptr [[RETVAL_IMAGP]], 
align 16
+// CHECK-GNU-DEF-NEXT:[[TMP0:%.*]] = load [8 x i32], ptr [[RETVAL]], align 
16
+// CHECK-GNU-DEF-NEXT:ret [8 x i32] [[TMP0]]
+//
+// CHECK-GNU-SOFT-FLOAT-LABEL: define dso_local [8 x i32] @_cldouble
+// CHECK-GNU-SOFT-FLOAT-SAME: (float noundef [[F:%.*]], ptr noundef byval({ 
ppc_fp128, ppc_fp128 }) align 16 [[X:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-GNU-SOFT-FLOAT-NEXT:  entry:
+// CHECK-GNU-SOFT-FLOAT-NEXT:[[RETVAL:%.*]] = alloca { ppc_fp128, 
ppc_fp128 }, align 16
+// CHECK-GNU-SOFT-FLOAT-NEXT:[[F_ADDR:%.*]] = alloca float, align 4
+// CHECK-GNU-SOFT-FLOAT-NEXT:store float [[F]], ptr [[F_ADDR]], align 4
+// CHECK-GNU-SOFT-FLOAT-NEXT:[[X_REALP:%.*]] = getelementptr inbounds { 
ppc_fp128, ppc_fp128 }, ptr [[X]], i32 0, i32 0
+// CHECK-GNU-SOFT-FLOAT-NEXT:[[X_REAL:%.*]] = load ppc_fp128, ptr 
[[X_REALP]], align 16
+// CHECK-GNU-SOFT-FLOAT-NEXT:[[X_IMAGP:%.*]] = getelementptr inbounds { 
ppc_fp128, ppc_fp128 }, ptr [[X]], i32 0, i32 1
+// CHECK-GNU-SOFT-FLOAT-NEXT:[[X_IMAG:%.*]] = load ppc_fp128, ptr 
[[X_IMAGP]], align 16
+// CHECK-GNU-SOFT-FLOAT-NEXT:[[RETVAL_REALP:%.*]] = getelementptr inbounds 
{ ppc_fp128, ppc_fp128 }, ptr [[RETVAL]], i32 0, i32 0
+// CHECK-GNU-SOFT-FLOAT-NEXT:[[RETVAL_IMAGP:%.*]] = getelementptr inbounds 
{ ppc_fp128, ppc_fp128 }, ptr [[RETVAL]], i32 0, i32 1
+// CHECK-GNU-SOFT-FLOAT-NEXT:store ppc_fp128 [[X_REAL]], ptr 
[[RETVAL_REALP]], align 16
+// CHECK-GNU-SOFT-FLOAT-NEXT:store ppc_fp128 [[X_IMAG]], ptr 
[[RETVAL_IMAGP]], align 16
+// CHECK-GNU-SOFT-FLOAT-NEXT:[[TMP0:%.*]] = load [8 x i32], ptr 
[[RETVAL]], align 16
+// CHECK-GNU-SOFT-FLOAT-NEXT:ret [8 x i32] [[TMP0]]
+//
+_Complex long double _cldouble(float f, _Complex long double x) {
+  return x;
+}
+
+// CHECK-GNU-DEF-LABEL: define dso_local [4 x i32] @testComplexDouble
+// CHECK-GNU-DEF-SAME: (float noundef [[W:%.*]], [1 x i64] noundef 
[[X_COERCE:%.*]], [4 x i32] noundef [[Z_COERCE:%.*]]) #[[ATTR0]] {
+// CHECK-GNU-DEF-NEXT:  entry:
+// CHECK-GNU-DEF-NEXT:[[RETVAL:%.*]] = alloca { double, double }, align 8
+// CHECK-GNU-DEF-NEXT:[[X:%.*]] = alloca { float, float }, align 4
+// CHECK-GNU-DEF-NEXT:[[Z:%.*]] = alloca { double, double }, align 8
+// CHECK-GNU-DEF-NEXT:[[W_ADDR:%.*]] = alloca float, align 4
+// CHECK-GNU-DEF-NEXT:store [1 x i64] [[X_COERCE]], ptr [[X]], align 4
+// CHECK-GNU-DEF-NEXT:store [4 x i32] [[Z_COERCE]], ptr [[Z]], align 8
+// CHECK-GNU-DEF-NEXT:store float [[W]], ptr [[W_ADDR]], align 4
+// CHECK-GNU-DEF-NEXT:[[Z_REALP:%.*]] = getelementptr inbounds { double, 
double }, ptr [[Z]], i32 0, i32 0
+// CHECK-GNU-DEF-NEXT:[[Z_REAL:%.*]] = load double, ptr [[Z_REALP]], align 
8
+// CHECK-GNU-DEF-NEXT:[[Z_IMAGP:%.*]] = getelementptr inbounds { double, 
double }, ptr [[Z]], i32 0, i32 1
+// CHECK-GNU-DEF-NEXT:[[Z_IMAG:%.*]] = load double, ptr [[Z_IMAGP]], align 
8
+// CHECK-GNU-DEF-NEXT:[[RETVAL_REALP:%.*]] = getelementptr inbounds { 
double, double }, ptr [[RETVAL]], i32 0, i32 0
+// CHECK-GNU-DEF-NEXT:[[RETVAL_IMAGP:%.*]] = 

[clang] [clang][PowerPC] Add flag to enable compatibility with GNU for complex arguments (PR #77732)

2024-05-06 Thread Kishan Parmar via cfe-commits

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


[clang] [clang][PowerPC] Add flag to enable compatibility with GNU for complex arguments (PR #77732)

2024-05-06 Thread Kishan Parmar via cfe-commits


@@ -0,0 +1,286 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
+
+// RUN: %clang_cc1 -triple powerpc-unknown-linux-gnu -fcomplex-ppc-gnu-abi \
+// RUN:   -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-GNU-DEF
+// RUN: %clang_cc1 -msoft-float  -mfloat-abi soft -triple 
powerpc-unknown-linux-gnu -fcomplex-ppc-gnu-abi \
+// RUN:   -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-GNU-SOFT-FLOAT
+
+// CHECK-GNU-DEF-LABEL: define dso_local [8 x i32] @_cldouble
+// CHECK-GNU-DEF-SAME: (float noundef [[F:%.*]], [8 x i32] noundef 
[[X_COERCE:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-GNU-DEF-NEXT:  entry:
+// CHECK-GNU-DEF-NEXT:[[RETVAL:%.*]] = alloca { ppc_fp128, ppc_fp128 }, 
align 16
+// CHECK-GNU-DEF-NEXT:[[X:%.*]] = alloca { ppc_fp128, ppc_fp128 }, align 16
+// CHECK-GNU-DEF-NEXT:[[F_ADDR:%.*]] = alloca float, align 4
+// CHECK-GNU-DEF-NEXT:store [8 x i32] [[X_COERCE]], ptr [[X]], align 16
+// CHECK-GNU-DEF-NEXT:store float [[F]], ptr [[F_ADDR]], align 4
+// CHECK-GNU-DEF-NEXT:[[X_REALP:%.*]] = getelementptr inbounds { 
ppc_fp128, ppc_fp128 }, ptr [[X]], i32 0, i32 0
+// CHECK-GNU-DEF-NEXT:[[X_REAL:%.*]] = load ppc_fp128, ptr [[X_REALP]], 
align 16
+// CHECK-GNU-DEF-NEXT:[[X_IMAGP:%.*]] = getelementptr inbounds { 
ppc_fp128, ppc_fp128 }, ptr [[X]], i32 0, i32 1
+// CHECK-GNU-DEF-NEXT:[[X_IMAG:%.*]] = load ppc_fp128, ptr [[X_IMAGP]], 
align 16
+// CHECK-GNU-DEF-NEXT:[[RETVAL_REALP:%.*]] = getelementptr inbounds { 
ppc_fp128, ppc_fp128 }, ptr [[RETVAL]], i32 0, i32 0
+// CHECK-GNU-DEF-NEXT:[[RETVAL_IMAGP:%.*]] = getelementptr inbounds { 
ppc_fp128, ppc_fp128 }, ptr [[RETVAL]], i32 0, i32 1
+// CHECK-GNU-DEF-NEXT:store ppc_fp128 [[X_REAL]], ptr [[RETVAL_REALP]], 
align 16
+// CHECK-GNU-DEF-NEXT:store ppc_fp128 [[X_IMAG]], ptr [[RETVAL_IMAGP]], 
align 16
+// CHECK-GNU-DEF-NEXT:[[TMP0:%.*]] = load [8 x i32], ptr [[RETVAL]], align 
16
+// CHECK-GNU-DEF-NEXT:ret [8 x i32] [[TMP0]]
+//
+// CHECK-GNU-SOFT-FLOAT-LABEL: define dso_local [8 x i32] @_cldouble
+// CHECK-GNU-SOFT-FLOAT-SAME: (float noundef [[F:%.*]], ptr noundef byval({ 
ppc_fp128, ppc_fp128 }) align 16 [[X:%.*]]) #[[ATTR0:[0-9]+]] {

Long5hot wrote:

Below assembly's generated with -fcomplex-ppc-gnu-abi -O1 --target=ppc32 -S  
-msoft-float

"use-soft-float"="true" get's passed in IR in attributes

```
_Complex double testComplexDouble(float w, _Complex float x, _Complex double z)
{
  return z;
}

testComplexDouble:  # @testComplexDouble
.Lfunc_begin2:
.cfi_startproc
# %bb.0:
mr  6, 10
mr  5, 9
mr  4, 8
mr  3, 7
blr
.Lfunc_end2:
.size   testComplexDouble, .Lfunc_end2-.Lfunc_begin2
.cfi_endproc
# -- End function
```

```
_Complex double checkComplexDoubleOnStack(float x1, _Complex float cf, float 
x2, _Complex double cd)
{
  return testComplexDouble(x2, cf, cd);
}

.globl  checkComplexDoubleOnStack   # -- Begin function 
checkComplexDoubleOnStack
.p2align2
.type   checkComplexDoubleOnStack,@function
checkComplexDoubleOnStack:  # @checkComplexDoubleOnStack
.Lfunc_begin3:
.cfi_startproc
# %bb.0:
lwz 3, 0(8)
lwz 4, 4(8)
lwz 5, 8(8)
lwz 6, 12(8)
blr
```

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


[clang] [Clang][Sema] Explicit template arguments are not substituted into the exception specification of a function (PR #90760)

2024-05-06 Thread Krystian Stasiowski via cfe-commits

sdkrystian wrote:

Ping @erichkeane 

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


[clang] [NFC] Use `const&` avoiding copies (PR #90334)

2024-05-06 Thread Danny Mösch via cfe-commits

https://github.com/SimplyDanny updated 
https://github.com/llvm/llvm-project/pull/90334

From bf9a6bb1e899b756d2d9e795f689947f2f5d6a00 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Danny=20M=C3=B6sch?= 
Date: Sat, 27 Apr 2024 11:38:20 +0200
Subject: [PATCH] [NFC] Use const& avoiding copies

---
 clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp 
b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
index d58f5bb0919906..f8dced5dbafb60 100644
--- a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
+++ b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
@@ -295,7 +295,7 @@ class InterfaceStubFunctionsConsumer : public ASTConsumer {
   OS << "Symbols:\n";
   for (const auto &E : Symbols) {
 const MangledSymbol &Symbol = E.second;
-for (auto Name : Symbol.Names) {
+for (const auto &Name : Symbol.Names) {
   OS << "  - { Name: \""
  << (Symbol.ParentName.empty() || Instance.getLangOpts().CPlusPlus
  ? ""

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


[clang] [clang][dataflow] Strengthen pointer comparison. (PR #75170)

2024-05-06 Thread via cfe-commits

https://github.com/martinboehme updated 
https://github.com/llvm/llvm-project/pull/75170

>From 0ec84267ca5c76ff733c4a5907df9226260a4a76 Mon Sep 17 00:00:00 2001
From: Martin Braenne 
Date: Mon, 6 May 2024 10:06:29 +
Subject: [PATCH] [clang][dataflow] Strengthen pointer comparison.

-  Instead of comparing the identity of the `PointerValue`s, compare the
   underlying `StorageLocation`s.

-  If the `StorageLocation`s are the same, return a definite "true" as the
   result of the comparison. Before, if the `PointerValue`s were different, we
   would return an atom, even if the storage locations themselves were the same.

-  If the `StorageLocation`s are different, return an atom (as before). Pointers
   that have different storage locations may still alias, so we can't return a
   definite "false" in this case.

The application-level gains from this are relatively modest. For the Crubit
nullability check running on an internal codebase, this change reduces the
number of functions on which the SAT solver times out from 223 to 221; the
number of "pointer expression not modeled" errors reduces from 3815 to 3778.

Still, it seems that the gain in precision is generally worthwhile.

@Xazax-hun inspired me to think about this with his
[comments](https://github.com/llvm/llvm-project/pull/73860#pullrequestreview-1761484615)
on a different PR.
---
 clang/lib/Analysis/FlowSensitive/Transfer.cpp |  8 ++
 .../Analysis/FlowSensitive/TransferTest.cpp   | 88 +++
 2 files changed, 96 insertions(+)

diff --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp 
b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
index fd224aeb79b151..0ff0ca74ffd033 100644
--- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -68,6 +68,14 @@ static BoolValue &evaluateBooleanEquality(const Expr &LHS, 
const Expr &RHS,
 if (auto *RHSBool = dyn_cast_or_null(RHSValue))
   return Env.makeIff(*LHSBool, *RHSBool);
 
+  if (auto *LHSPtr = dyn_cast_or_null(LHSValue))
+if (auto *RHSPtr = dyn_cast_or_null(RHSValue))
+  // If the storage locations are the same, the pointers definitely compare
+  // the same. If the storage locations are different, they may still 
alias,
+  // so we fall through to the case below that returns an atom.
+  if (&LHSPtr->getPointeeLoc() == &RHSPtr->getPointeeLoc())
+return Env.getBoolLiteralValue(true);
+
   return Env.makeAtomicBoolValue();
 }
 
diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 301bec32c0cf1d..555f3f2024f8b8 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -4586,6 +4586,94 @@ TEST(TransferTest, BooleanInequality) {
   });
 }
 
+TEST(TransferTest, PointerEquality) {
+  std::string Code = R"cc(
+void target() {
+  int i = 0;
+  int i_other = 0;
+  int *p1 = &i;
+  int *p2 = &i;
+  int *p_other = &i_other;
+  int *null = nullptr;
+
+  bool p1_eq_p1 = (p1 == p1);
+  bool p1_eq_p2 = (p1 == p2);
+  bool p1_eq_p_other = (p1 == p_other);
+
+  bool p1_eq_null = (p1 == null);
+  bool p1_eq_nullptr = (p1 == nullptr);
+  bool null_eq_nullptr = (null == nullptr);
+  bool nullptr_eq_nullptr = (nullptr == nullptr);
+
+  // We won't duplicate all of the tests above with `!=`, as we know that
+  // the implementation simply negates the result of the `==` comparison.
+  // Instaed, just spot-check one case.
+  bool p1_ne_p1 = (p1 != p1);
+
+  (void)0; // [[p]]
+}
+  )cc";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+// Check the we have indeed set things up so that `p1` and `p2` have
+// different pointer values.
+EXPECT_NE(&getValueForDecl(ASTCtx, Env, "p1"),
+  &getValueForDecl(ASTCtx, Env, "p2"));
+
+EXPECT_EQ(&getValueForDecl(ASTCtx, Env, "p1_eq_p1"),
+  &Env.getBoolLiteralValue(true));
+EXPECT_EQ(&getValueForDecl(ASTCtx, Env, "p1_eq_p2"),
+  &Env.getBoolLiteralValue(true));
+EXPECT_TRUE(isa(
+getValueForDecl(ASTCtx, Env, "p1_eq_p_other")));
+
+EXPECT_TRUE(isa(
+getValueForDecl(ASTCtx, Env, "p1_eq_null")));
+EXPECT_TRUE(isa(
+getValueForDecl(ASTCtx, Env, "p1_eq_nullptr")));
+EXPECT_EQ(&getValueForDecl(ASTCtx, Env, "null_eq_nullptr"),
+  &Env.getBoolLiteralValue(true));
+EXPECT_EQ(
+&getValueForDecl(ASTCtx, Env, "nullptr_eq_nullptr"),
+&Env.getBoolLiteralValue(true));
+
+EXPECT_EQ(&getValueForDecl(ASTCtx, Env, "p1_ne_p1"),
+  &Env.getBoolLiteralValue(false));
+  });
+}
+
+TEST(TransferTest, PointerEqualityUnio

[clang] [clang][dataflow] Strengthen pointer comparison. (PR #75170)

2024-05-06 Thread via cfe-commits

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


[clang] [clang][dataflow] Strengthen pointer comparison. (PR #75170)

2024-05-06 Thread via cfe-commits

martinboehme wrote:

> I'll change the PR accordingly and will let you know once it's ready for 
> another look.

Sorry, this completely fell off my radar. I've finally revisited this now, and 
the PR is ready for review again. PTAL.

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


[clang] 6217abc - Add requires clause to risc-v clang driver tests

2024-05-06 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2024-05-06T12:33:48+02:00
New Revision: 6217abce86b55778cf39f7db7f591a16b9fd4d28

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

LOG: Add requires clause to risc-v clang driver tests

Followup to #89727

Added: 


Modified: 
clang/test/Driver/riscv-option-arch.c
clang/test/Driver/riscv-option-arch.s

Removed: 




diff  --git a/clang/test/Driver/riscv-option-arch.c 
b/clang/test/Driver/riscv-option-arch.c
index e583e9fd62b08c..9f0e037cd12e01 100644
--- a/clang/test/Driver/riscv-option-arch.c
+++ b/clang/test/Driver/riscv-option-arch.c
@@ -1,3 +1,4 @@
+// REQUIRES: riscv-registered-target
 // RUN: %clang --target=riscv64 -menable-experimental-extensions -c -o 
/dev/null %s
 // RUN: ! %clang --target=riscv64 -c -o /dev/null %s 2>&1 | FileCheck 
-check-prefixes=CHECK-ERR %s
 

diff  --git a/clang/test/Driver/riscv-option-arch.s 
b/clang/test/Driver/riscv-option-arch.s
index 8ce84dd8ffe79d..c4ca4aa459ce2e 100644
--- a/clang/test/Driver/riscv-option-arch.s
+++ b/clang/test/Driver/riscv-option-arch.s
@@ -1,3 +1,4 @@
+# REQUIRES: riscv-registered-target
 # RUN: %clang --target=riscv64 -menable-experimental-extensions -c -o 
/dev/null %s
 # RUN: ! %clang --target=riscv64 -c -o /dev/null %s 2>&1 | FileCheck 
-check-prefixes=CHECK-ERR %s
 



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


[clang] [llvm] [RISCV] Teach .option arch to support experimental extensions. (PR #89727)

2024-05-06 Thread via cfe-commits

zmodem wrote:

6217abc should fix the test failures.

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


[clang] [Clang][Sema] Explicit template arguments are not substituted into the exception specification of a function (PR #90760)

2024-05-06 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian updated 
https://github.com/llvm/llvm-project/pull/90760

>From a30530b4de31fab70911cb7b51e7a7e274fd2a38 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Wed, 1 May 2024 10:54:12 -0400
Subject: [PATCH 1/3] [Clang][Sema] Explicit template arguments are not
 substituted into the exception specification of a function

---
 clang/lib/Sema/SemaTemplateDeduction.cpp | 17 -
 clang/test/CXX/temp/temp.deduct/p7.cpp   | 14 ++
 2 files changed, 14 insertions(+), 17 deletions(-)
 create mode 100644 clang/test/CXX/temp/temp.deduct/p7.cpp

diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 9f9e4422827173..026ce6db1c8eb9 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3509,23 +3509,6 @@ TemplateDeductionResult 
Sema::SubstituteExplicitTemplateArguments(
   if (FunctionType) {
 auto EPI = Proto->getExtProtoInfo();
 EPI.ExtParameterInfos = ExtParamInfos.getPointerOrNull(ParamTypes.size());
-
-// In C++1z onwards, exception specifications are part of the function 
type,
-// so substitution into the type must also substitute into the exception
-// specification.
-SmallVector ExceptionStorage;
-if (getLangOpts().CPlusPlus17 &&
-SubstExceptionSpec(
-Function->getLocation(), EPI.ExceptionSpec, ExceptionStorage,
-getTemplateInstantiationArgs(
-FunctionTemplate, nullptr, /*Final=*/true,
-/*Innermost=*/SugaredExplicitArgumentList->asArray(),
-/*RelativeToPrimary=*/false,
-/*Pattern=*/nullptr,
-/*ForConstraintInstantiation=*/false,
-/*SkipForSpecialization=*/true)))
-  return TemplateDeductionResult::SubstitutionFailure;
-
 *FunctionType = BuildFunctionType(ResultType, ParamTypes,
   Function->getLocation(),
   Function->getDeclName(),
diff --git a/clang/test/CXX/temp/temp.deduct/p7.cpp 
b/clang/test/CXX/temp/temp.deduct/p7.cpp
new file mode 100644
index 00..cf6d17fc51ac95
--- /dev/null
+++ b/clang/test/CXX/temp/temp.deduct/p7.cpp
@@ -0,0 +1,14 @@
+// RUN:  %clang_cc1 -verify %s
+
+struct A {
+  static constexpr bool x = true;
+};
+
+template
+void f(T, U) noexcept(T::x);
+
+template
+void f(T, U*) noexcept(T::y); // expected-error {{no member named 'y' in 'A'}}
+
+template<>
+void f(A, int*); // expected-note {{in instantiation of exception 
specification}}

>From 9172000c589d7235e0e93d22b10017d25b3df1fd Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Wed, 1 May 2024 14:14:28 -0400
Subject: [PATCH 2/3] [FOLD]

---
 clang/lib/Sema/SemaInit.cpp   | 24 ++-
 clang/lib/Sema/SemaTemplateDeduction.cpp  | 11 ++---
 clang/test/CXX/drs/dr13xx.cpp | 13 --
 .../SemaCXX/cxx1z-noexcept-function-type.cpp  |  4 ++--
 clang/test/SemaTemplate/temp_arg_type.cpp | 10 
 5 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 7d9eaf6720461d..c8049ae581f843 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -6576,12 +6576,12 @@ void InitializationSequence::InitializeFrom(Sema &S,
 
 AddPassByIndirectCopyRestoreStep(DestType, ShouldCopy);
   } else if (ICS.isBad()) {
-DeclAccessPair dap;
-if (isLibstdcxxPointerReturnFalseHack(S, Entity, Initializer)) {
+if (isLibstdcxxPointerReturnFalseHack(S, Entity, Initializer))
   AddZeroInitializationStep(Entity.getType());
-} else if (Initializer->getType() == Context.OverloadTy &&
-   !S.ResolveAddressOfOverloadedFunction(Initializer, DestType,
- false, dap))
+else if (DeclAccessPair Found;
+ Initializer->getType() == Context.OverloadTy &&
+ !S.ResolveAddressOfOverloadedFunction(Initializer, DestType,
+   /*Complain=*/false, Found))
   SetFailed(InitializationSequence::FK_AddressOfOverloadFailed);
 else if (Initializer->getType()->isFunctionType() &&
  isExprAnUnaddressableFunction(S, Initializer))
@@ -9641,6 +9641,8 @@ bool InitializationSequence::Diagnose(Sema &S,
   if (!Failed())
 return false;
 
+  QualType DestType = Entity.getType();
+
   // When we want to diagnose only one element of a braced-init-list,
   // we need to factor it out.
   Expr *OnlyArg;
@@ -9650,11 +9652,21 @@ bool InitializationSequence::Diagnose(Sema &S,
   OnlyArg = List->getInit(0);
 else
   OnlyArg = Args[0];
+
+if (OnlyArg->getType() == S.Context.OverloadTy) {
+  DeclAccessPair Found;
+  if (FunctionDecl *FD = S.ResolveAddressOfOverloadedFunction(
+  OnlyArg, DestType.getNonReferenceType(), /*Complain=*/false,
+  

[clang-tools-extra] [NFC][clang-tidy]increase stability for bugprone-return-const-ref-from-parameter (PR #91160)

2024-05-06 Thread Julian Schmidt via cfe-commits

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

Is there something specific you hit (test-case)? Either way, it's good to check

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


[clang] [Clang][Sema] Improve support for explicit specializations of constrained member functions & member function templates (PR #88963)

2024-05-06 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian updated 
https://github.com/llvm/llvm-project/pull/88963

>From bcffb80bba2a6f9ce9eddad61b99a3e59a58f8a0 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Tue, 16 Apr 2024 13:36:11 -0400
Subject: [PATCH 1/5] [Clang][Sema] Improve support for explicit
 specializations of constrained member functions & member function templates

---
 clang/lib/Sema/SemaConcept.cpp|  2 +-
 clang/lib/Sema/SemaOverload.cpp   | 11 ++-
 clang/lib/Sema/SemaTemplate.cpp   | 44 +--
 clang/lib/Sema/SemaTemplateInstantiate.cpp|  4 +
 .../CXX/temp/temp.spec/temp.expl.spec/p8.cpp  | 74 +++
 5 files changed, 124 insertions(+), 11 deletions(-)
 create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p8.cpp

diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index e00c972602829e..7bfec4e11f7aab 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -811,7 +811,7 @@ static const Expr 
*SubstituteConstraintExpressionWithoutSatisfaction(
   // this may happen while we're comparing two templates' constraint
   // equivalence.
   LocalInstantiationScope ScopeForParameters(S);
-  if (auto *FD = llvm::dyn_cast(DeclInfo.getDecl()))
+  if (auto *FD = DeclInfo.getDecl()->getAsFunction())
 for (auto *PVD : FD->parameters())
   ScopeForParameters.InstantiatedLocal(PVD, PVD);
 
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index a416df2e97c439..5c70588bd28b84 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -1303,6 +1303,8 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, 
FunctionDecl *New,
   if (New->isMSVCRTEntryPoint())
 return false;
 
+  NamedDecl *OldDecl = Old;
+  NamedDecl *NewDecl = New;
   FunctionTemplateDecl *OldTemplate = Old->getDescribedFunctionTemplate();
   FunctionTemplateDecl *NewTemplate = New->getDescribedFunctionTemplate();
 
@@ -1347,6 +1349,8 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, 
FunctionDecl *New,
   // references to non-instantiated entities during constraint substitution.
   // GH78101.
   if (NewTemplate) {
+OldDecl = OldTemplate;
+NewDecl = NewTemplate;
 // C++ [temp.over.link]p4:
 //   The signature of a function template consists of its function
 //   signature, its return type and its template parameter list. The names
@@ -1506,13 +1510,14 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, 
FunctionDecl *New,
 }
   }
 
-  if (!UseOverrideRules) {
+  if (!UseOverrideRules &&
+  New->getTemplateSpecializationKind() != TSK_ExplicitSpecialization) {
 Expr *NewRC = New->getTrailingRequiresClause(),
  *OldRC = Old->getTrailingRequiresClause();
 if ((NewRC != nullptr) != (OldRC != nullptr))
   return true;
-
-if (NewRC && !SemaRef.AreConstraintExpressionsEqual(Old, OldRC, New, 
NewRC))
+if (NewRC &&
+!SemaRef.AreConstraintExpressionsEqual(OldDecl, OldRC, NewDecl, NewRC))
   return true;
   }
 
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index e647ac267ab395..eeadc47e99069c 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -10354,6 +10354,25 @@ bool Sema::CheckFunctionTemplateSpecialization(
   return false;
 }
 
+static bool IsMoreConstrainedFunction(Sema &S, FunctionDecl *FD1,
+  FunctionDecl *FD2) {
+  if (FunctionDecl *MF = FD1->getInstantiatedFromMemberFunction())
+FD1 = MF;
+  if (FunctionDecl *MF = FD2->getInstantiatedFromMemberFunction())
+FD2 = MF;
+  llvm::SmallVector AC1, AC2;
+  FD1->getAssociatedConstraints(AC1);
+  FD2->getAssociatedConstraints(AC2);
+  bool AtLeastAsConstrained1, AtLeastAsConstrained2;
+  if (S.IsAtLeastAsConstrained(FD1, AC1, FD2, AC2, AtLeastAsConstrained1))
+return false;
+  if (S.IsAtLeastAsConstrained(FD2, AC2, FD1, AC1, AtLeastAsConstrained2))
+return false;
+  if (AtLeastAsConstrained1 == AtLeastAsConstrained2)
+return false;
+  return AtLeastAsConstrained1;
+}
+
 /// Perform semantic analysis for the given non-template member
 /// specialization.
 ///
@@ -10388,15 +10407,26 @@ Sema::CheckMemberSpecialization(NamedDecl *Member, 
LookupResult &Previous) {
 QualType Adjusted = Function->getType();
 if (!hasExplicitCallingConv(Adjusted))
   Adjusted = adjustCCAndNoReturn(Adjusted, Method->getType());
+if (!Context.hasSameType(Adjusted, Method->getType()))
+  continue;
+if (Method->getTrailingRequiresClause()) {
+  ConstraintSatisfaction Satisfaction;
+  if (CheckFunctionConstraints(Method, Satisfaction,
+   /*UsageLoc=*/Member->getLocation(),
+   /*ForOverloadResolution=*/true) ||
+  !Satisfaction.IsSatisfied)
+continue;
+  if (Instantiation &&
+  !I

[clang] [compiler-rt] [XRay] Add support for instrumentation of DSOs on x86_64 (PR #90959)

2024-05-06 Thread Sebastian Kreutzer via cfe-commits

https://github.com/sebastiankreutzer updated 
https://github.com/llvm/llvm-project/pull/90959

>From 1f0484b73ad0bb9b40e3cd86d8abad4af14e32dc Mon Sep 17 00:00:00 2001
From: Sebastian Kreutzer 
Date: Thu, 26 Oct 2023 15:13:05 +0200
Subject: [PATCH 1/5] [XRay] Add DSO support for XRay instrumentation on X86_64

---
 clang/include/clang/Driver/Options.td |   4 +
 clang/include/clang/Driver/XRayArgs.h |   4 +
 clang/lib/Driver/ToolChains/CommonArgs.cpp|  12 +-
 clang/lib/Driver/XRayArgs.cpp |   7 +
 .../cmake/Modules/AllSupportedArchDefs.cmake  |   1 +
 compiler-rt/cmake/config-ix.cmake |   4 +
 compiler-rt/include/xray/xray_interface.h |  23 ++
 compiler-rt/lib/xray/CMakeLists.txt   |  73 -
 compiler-rt/lib/xray/xray_dso_init.cpp|  62 +
 compiler-rt/lib/xray/xray_init.cpp| 158 +--
 compiler-rt/lib/xray/xray_interface.cpp   | 261 ++
 .../lib/xray/xray_interface_internal.h|  83 +-
 compiler-rt/lib/xray/xray_trampoline_x86_64.S |  24 +-
 compiler-rt/lib/xray/xray_x86_64.cpp  |  23 +-
 .../xray/TestCases/Posix/basic-mode-dso.cpp   |  47 
 .../TestCases/Posix/clang-enable-shared.cpp   |  14 +
 .../test/xray/TestCases/Posix/dlopen.cpp  | 110 
 .../TestCases/Posix/patch-premain-dso.cpp |  45 +++
 .../Posix/patching-unpatching-dso.cpp |  75 +
 19 files changed, 912 insertions(+), 118 deletions(-)
 create mode 100644 compiler-rt/lib/xray/xray_dso_init.cpp
 create mode 100644 compiler-rt/test/xray/TestCases/Posix/basic-mode-dso.cpp
 create mode 100644 
compiler-rt/test/xray/TestCases/Posix/clang-enable-shared.cpp
 create mode 100644 compiler-rt/test/xray/TestCases/Posix/dlopen.cpp
 create mode 100644 compiler-rt/test/xray/TestCases/Posix/patch-premain-dso.cpp
 create mode 100644 
compiler-rt/test/xray/TestCases/Posix/patching-unpatching-dso.cpp

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 953f6fc649e621..3e3be5475c0c4d 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2850,6 +2850,10 @@ def fxray_selected_function_group :
   HelpText<"When using -fxray-function-groups, select which group of functions 
to instrument. Valid range is 0 to fxray-function-groups - 1">,
   MarshallingInfoInt, "0">;
 
+def fxray_enable_shared : Flag<["-"], "fxray-enable-shared">, Group,  
Visibility<[ClangOption, CC1Option]>,
+  HelpText<"Enable shared library instrumentation.">;
+def fno_xray_enable_shared : Flag<["-"], "fno-xray-enable-shared">, 
Group,
+  Visibility<[ClangOption, CC1Option]>;
 
 defm fine_grained_bitfield_accesses : BoolOption<"f", 
"fine-grained-bitfield-accesses",
   CodeGenOpts<"FineGrainedBitfieldAccesses">, DefaultFalse,
diff --git a/clang/include/clang/Driver/XRayArgs.h 
b/clang/include/clang/Driver/XRayArgs.h
index bdd3d979547eed..90a21e69586033 100644
--- a/clang/include/clang/Driver/XRayArgs.h
+++ b/clang/include/clang/Driver/XRayArgs.h
@@ -27,6 +27,7 @@ class XRayArgs {
   XRayInstrSet InstrumentationBundle;
   llvm::opt::Arg *XRayInstrument = nullptr;
   bool XRayRT = true;
+  bool XRayEnableShared = false;
 
 public:
   /// Parses the XRay arguments from an argument list.
@@ -35,6 +36,9 @@ class XRayArgs {
llvm::opt::ArgStringList &CmdArgs, types::ID InputType) const;
 
   bool needsXRayRt() const { return XRayInstrument && XRayRT; }
+  bool needsXRayDSORt() const {
+return XRayInstrument && XRayRT && XRayEnableShared;
+  }
   llvm::ArrayRef modeList() const { return Modes; }
   XRayInstrSet instrumentationBundle() const { return InstrumentationBundle; }
 };
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 6796b43a155020..399bf795ce394e 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1520,10 +1520,14 @@ bool tools::addSanitizerRuntimes(const ToolChain &TC, 
const ArgList &Args,
 }
 
 bool tools::addXRayRuntime(const ToolChain&TC, const ArgList &Args, 
ArgStringList &CmdArgs) {
-  if (Args.hasArg(options::OPT_shared))
-return false;
-
-  if (TC.getXRayArgs().needsXRayRt()) {
+  if (Args.hasArg(options::OPT_shared)) {
+if (TC.getXRayArgs().needsXRayDSORt()) {
+  CmdArgs.push_back("-whole-archive");
+  CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray-dso"));
+  CmdArgs.push_back("-no-whole-archive");
+  return true;
+}
+  } else if (TC.getXRayArgs().needsXRayRt()) {
 CmdArgs.push_back("--whole-archive");
 CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray"));
 for (const auto &Mode : TC.getXRayArgs().modeList())
diff --git a/clang/lib/Driver/XRayArgs.cpp b/clang/lib/Driver/XRayArgs.cpp
index 8c5134e2501358..7809cd7ef7c759 100644
--- a/clang/lib/Driver/XRayArgs.cpp
+++ b/clang/lib/Driver/XRayArgs.cpp
@@ -63,6 +63,10 @@ XRayArgs::XRayArgs(const ToolChain &TC, c

[clang] [llvm] [SPIRV] Add tan intrinsic part 3 (PR #90278)

2024-05-06 Thread Nathan Gauër via cfe-commits

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


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


[clang-tools-extra] [clangd] Support callHierarchy/outgoingCalls (PR #91191)

2024-05-06 Thread Christian Kandeler via cfe-commits

https://github.com/ckandeler created 
https://github.com/llvm/llvm-project/pull/91191

None

>From d7cfeb6599fd507eed8935e452efd782fc3f0481 Mon Sep 17 00:00:00 2001
From: Christian Kandeler 
Date: Tue, 30 Apr 2024 18:20:05 +0200
Subject: [PATCH] [clangd] Support callHierarchy/outgoingCalls

---
 clang-tools-extra/clangd/ClangdLSPServer.cpp  |   7 +
 clang-tools-extra/clangd/ClangdLSPServer.h|   3 +
 clang-tools-extra/clangd/ClangdServer.cpp |  13 +
 clang-tools-extra/clangd/ClangdServer.h   |   4 +
 clang-tools-extra/clangd/XRefs.cpp|  71 ++
 clang-tools-extra/clangd/XRefs.h  |   3 +
 .../clangd/unittests/CallHierarchyTests.cpp   | 226 +++---
 7 files changed, 293 insertions(+), 34 deletions(-)

diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 7fd599d4e1a0b0..5820a644088e3e 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -1368,6 +1368,12 @@ void ClangdLSPServer::onCallHierarchyIncomingCalls(
   Server->incomingCalls(Params.item, std::move(Reply));
 }
 
+void ClangdLSPServer::onCallHierarchyOutgoingCalls(
+const CallHierarchyOutgoingCallsParams &Params,
+Callback> Reply) {
+  Server->outgoingCalls(Params.item, std::move(Reply));
+}
+
 void ClangdLSPServer::onClangdInlayHints(const InlayHintsParams &Params,
  Callback Reply) {
   // Our extension has a different representation on the wire than the 
standard.
@@ -1688,6 +1694,7 @@ void ClangdLSPServer::bindMethods(LSPBinder &Bind,
   Bind.method("typeHierarchy/subtypes", this, &ClangdLSPServer::onSubTypes);
   Bind.method("textDocument/prepareCallHierarchy", this, 
&ClangdLSPServer::onPrepareCallHierarchy);
   Bind.method("callHierarchy/incomingCalls", this, 
&ClangdLSPServer::onCallHierarchyIncomingCalls);
+  Bind.method("callHierarchy/outgoingCalls", this, 
&ClangdLSPServer::onCallHierarchyOutgoingCalls);
   Bind.method("textDocument/selectionRange", this, 
&ClangdLSPServer::onSelectionRange);
   Bind.method("textDocument/documentLink", this, 
&ClangdLSPServer::onDocumentLink);
   Bind.method("textDocument/semanticTokens/full", this, 
&ClangdLSPServer::onSemanticTokens);
diff --git a/clang-tools-extra/clangd/ClangdLSPServer.h 
b/clang-tools-extra/clangd/ClangdLSPServer.h
index 8bcb29522509b7..4981027372cb57 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.h
+++ b/clang-tools-extra/clangd/ClangdLSPServer.h
@@ -153,6 +153,9 @@ class ClangdLSPServer : private ClangdServer::Callbacks,
   void onCallHierarchyIncomingCalls(
   const CallHierarchyIncomingCallsParams &,
   Callback>);
+  void onCallHierarchyOutgoingCalls(
+  const CallHierarchyOutgoingCallsParams &,
+  Callback>);
   void onClangdInlayHints(const InlayHintsParams &,
   Callback);
   void onInlayHint(const InlayHintsParams &, Callback>);
diff --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 1c4c2a79b5c051..19d01dfbd873e2 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -898,6 +898,19 @@ void ClangdServer::incomingCalls(
  });
 }
 
+void ClangdServer::outgoingCalls(
+const CallHierarchyItem &Item,
+Callback> CB) {
+  auto Action = [Item,
+ CB = std::move(CB)](Expected InpAST) mutable {
+if (!InpAST)
+  return CB(InpAST.takeError());
+CB(clangd::outgoingCalls(InpAST->AST, Item));
+  };
+  WorkScheduler->runWithAST("Outgoing Calls", Item.uri.file(),
+std::move(Action));
+}
+
 void ClangdServer::inlayHints(PathRef File, std::optional RestrictRange,
   Callback> CB) {
   auto Action = [RestrictRange(std::move(RestrictRange)),
diff --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index 1661028be88b4e..4caef917c1ec16 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -288,6 +288,10 @@ class ClangdServer {
   void incomingCalls(const CallHierarchyItem &Item,
  Callback>);
 
+  /// Resolve outgoing calls for a given call hierarchy item.
+  void outgoingCalls(const CallHierarchyItem &Item,
+ Callback>);
+
   /// Resolve inlay hints for a given document.
   void inlayHints(PathRef File, std::optional RestrictRange,
   Callback>);
diff --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index cd909266489a85..b9bf944a7bba98 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -42,6 +42,7 @@
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/AST/Type.h"
+#include "clang/Analysis/CallGraph.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/

[clang-tools-extra] [clangd] Support callHierarchy/outgoingCalls (PR #91191)

2024-05-06 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-tools-extra

@llvm/pr-subscribers-clangd

Author: Christian Kandeler (ckandeler)


Changes



---

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


7 Files Affected:

- (modified) clang-tools-extra/clangd/ClangdLSPServer.cpp (+7) 
- (modified) clang-tools-extra/clangd/ClangdLSPServer.h (+3) 
- (modified) clang-tools-extra/clangd/ClangdServer.cpp (+13) 
- (modified) clang-tools-extra/clangd/ClangdServer.h (+4) 
- (modified) clang-tools-extra/clangd/XRefs.cpp (+71) 
- (modified) clang-tools-extra/clangd/XRefs.h (+3) 
- (modified) clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp 
(+192-34) 


``diff
diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 7fd599d4e1a0b0..5820a644088e3e 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -1368,6 +1368,12 @@ void ClangdLSPServer::onCallHierarchyIncomingCalls(
   Server->incomingCalls(Params.item, std::move(Reply));
 }
 
+void ClangdLSPServer::onCallHierarchyOutgoingCalls(
+const CallHierarchyOutgoingCallsParams &Params,
+Callback> Reply) {
+  Server->outgoingCalls(Params.item, std::move(Reply));
+}
+
 void ClangdLSPServer::onClangdInlayHints(const InlayHintsParams &Params,
  Callback Reply) {
   // Our extension has a different representation on the wire than the 
standard.
@@ -1688,6 +1694,7 @@ void ClangdLSPServer::bindMethods(LSPBinder &Bind,
   Bind.method("typeHierarchy/subtypes", this, &ClangdLSPServer::onSubTypes);
   Bind.method("textDocument/prepareCallHierarchy", this, 
&ClangdLSPServer::onPrepareCallHierarchy);
   Bind.method("callHierarchy/incomingCalls", this, 
&ClangdLSPServer::onCallHierarchyIncomingCalls);
+  Bind.method("callHierarchy/outgoingCalls", this, 
&ClangdLSPServer::onCallHierarchyOutgoingCalls);
   Bind.method("textDocument/selectionRange", this, 
&ClangdLSPServer::onSelectionRange);
   Bind.method("textDocument/documentLink", this, 
&ClangdLSPServer::onDocumentLink);
   Bind.method("textDocument/semanticTokens/full", this, 
&ClangdLSPServer::onSemanticTokens);
diff --git a/clang-tools-extra/clangd/ClangdLSPServer.h 
b/clang-tools-extra/clangd/ClangdLSPServer.h
index 8bcb29522509b7..4981027372cb57 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.h
+++ b/clang-tools-extra/clangd/ClangdLSPServer.h
@@ -153,6 +153,9 @@ class ClangdLSPServer : private ClangdServer::Callbacks,
   void onCallHierarchyIncomingCalls(
   const CallHierarchyIncomingCallsParams &,
   Callback>);
+  void onCallHierarchyOutgoingCalls(
+  const CallHierarchyOutgoingCallsParams &,
+  Callback>);
   void onClangdInlayHints(const InlayHintsParams &,
   Callback);
   void onInlayHint(const InlayHintsParams &, Callback>);
diff --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 1c4c2a79b5c051..19d01dfbd873e2 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -898,6 +898,19 @@ void ClangdServer::incomingCalls(
  });
 }
 
+void ClangdServer::outgoingCalls(
+const CallHierarchyItem &Item,
+Callback> CB) {
+  auto Action = [Item,
+ CB = std::move(CB)](Expected InpAST) mutable {
+if (!InpAST)
+  return CB(InpAST.takeError());
+CB(clangd::outgoingCalls(InpAST->AST, Item));
+  };
+  WorkScheduler->runWithAST("Outgoing Calls", Item.uri.file(),
+std::move(Action));
+}
+
 void ClangdServer::inlayHints(PathRef File, std::optional RestrictRange,
   Callback> CB) {
   auto Action = [RestrictRange(std::move(RestrictRange)),
diff --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index 1661028be88b4e..4caef917c1ec16 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -288,6 +288,10 @@ class ClangdServer {
   void incomingCalls(const CallHierarchyItem &Item,
  Callback>);
 
+  /// Resolve outgoing calls for a given call hierarchy item.
+  void outgoingCalls(const CallHierarchyItem &Item,
+ Callback>);
+
   /// Resolve inlay hints for a given document.
   void inlayHints(PathRef File, std::optional RestrictRange,
   Callback>);
diff --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index cd909266489a85..b9bf944a7bba98 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -42,6 +42,7 @@
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/AST/Type.h"
+#include "clang/Analysis/CallGraph.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceLocation.h"
@@

[clang] 6e31a49 - [driver] Do not warn about unused plugin flags. (#88948)

2024-05-06 Thread via cfe-commits

Author: Michael Kruse
Date: 2024-05-06T14:04:12+02:00
New Revision: 6e31a49931b8b057868a64e89838e3c9b40f9198

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

LOG: [driver] Do not warn about unused plugin flags. (#88948)

Plugins are not loaded without the -cc1 phase. Do not report them when
running on an assembly file or when linking. Many build tools add these
options to all driver invocations, including LLVM's build system.

Fixes #88173

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/plugin-driver-args.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 938d5358eeda6b..c9f7c4e5f718b4 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3663,14 +3663,14 @@ defm rwpi : BoolFOption<"rwpi",
   "Generate read-write position independent code (ARM only)">,
   NegFlag>;
 def fplugin_EQ : Joined<["-"], "fplugin=">, Group,
-  Flags<[NoXarchOption]>, MetaVarName<"">,
+  Flags<[NoXarchOption, NoArgumentUnused]>, MetaVarName<"">,
   HelpText<"Load the named plugin (dynamic shared object)">;
 def fplugin_arg : Joined<["-"], "fplugin-arg-">,
-  MetaVarName<"-">,
+  MetaVarName<"-">, Flags<[NoArgumentUnused]>,
   HelpText<"Pass  to plugin ">;
 def fpass_plugin_EQ : Joined<["-"], "fpass-plugin=">,
   Group, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
-  MetaVarName<"">,
+  MetaVarName<"">, Flags<[NoArgumentUnused]>,
   HelpText<"Load pass plugin from a dynamic shared object file (only with new 
pass manager).">,
   MarshallingInfoStringVector>;
 defm tocdata : BoolOption<"m","tocdata",

diff  --git a/clang/test/Driver/plugin-driver-args.cpp 
b/clang/test/Driver/plugin-driver-args.cpp
index d6475b4b3d733a..6f0e6e2ba75251 100644
--- a/clang/test/Driver/plugin-driver-args.cpp
+++ b/clang/test/Driver/plugin-driver-args.cpp
@@ -20,3 +20,8 @@
 
 // RUN: %clang -fplugin=%llvmshlibdir/CallSuperAttr%pluginext 
-fplugin-arg-testname- -fsyntax-only %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-NO-PLUGIN-ARG2
 // CHECK-NO-PLUGIN-ARG2: missing plugin argument for plugin testname in 
-fplugin-arg-testname-
+
+// Plugins are only relevant for the -cc1 phase. No warning should be raised
+// when only using the assembler. See GH #88173.
+// RUN: %clang -c -fpass-plugin=bar.so -fplugin=bar.so -fplugin-arg-bar-option 
-Werror -x assembler %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PLUGIN-ASM
+// CHECK-PLUGIN-ASM-NOT: argument unused during compilation



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


[clang] [driver] Do not warn about unused plugin flags. (PR #88948)

2024-05-06 Thread Michael Kruse via cfe-commits

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


[clang] [compiler-rt] [XRay] Add support for instrumentation of DSOs on x86_64 (PR #90959)

2024-05-06 Thread Sebastian Kreutzer via cfe-commits

https://github.com/sebastiankreutzer updated 
https://github.com/llvm/llvm-project/pull/90959

>From 1f0484b73ad0bb9b40e3cd86d8abad4af14e32dc Mon Sep 17 00:00:00 2001
From: Sebastian Kreutzer 
Date: Thu, 26 Oct 2023 15:13:05 +0200
Subject: [PATCH 1/6] [XRay] Add DSO support for XRay instrumentation on X86_64

---
 clang/include/clang/Driver/Options.td |   4 +
 clang/include/clang/Driver/XRayArgs.h |   4 +
 clang/lib/Driver/ToolChains/CommonArgs.cpp|  12 +-
 clang/lib/Driver/XRayArgs.cpp |   7 +
 .../cmake/Modules/AllSupportedArchDefs.cmake  |   1 +
 compiler-rt/cmake/config-ix.cmake |   4 +
 compiler-rt/include/xray/xray_interface.h |  23 ++
 compiler-rt/lib/xray/CMakeLists.txt   |  73 -
 compiler-rt/lib/xray/xray_dso_init.cpp|  62 +
 compiler-rt/lib/xray/xray_init.cpp| 158 +--
 compiler-rt/lib/xray/xray_interface.cpp   | 261 ++
 .../lib/xray/xray_interface_internal.h|  83 +-
 compiler-rt/lib/xray/xray_trampoline_x86_64.S |  24 +-
 compiler-rt/lib/xray/xray_x86_64.cpp  |  23 +-
 .../xray/TestCases/Posix/basic-mode-dso.cpp   |  47 
 .../TestCases/Posix/clang-enable-shared.cpp   |  14 +
 .../test/xray/TestCases/Posix/dlopen.cpp  | 110 
 .../TestCases/Posix/patch-premain-dso.cpp |  45 +++
 .../Posix/patching-unpatching-dso.cpp |  75 +
 19 files changed, 912 insertions(+), 118 deletions(-)
 create mode 100644 compiler-rt/lib/xray/xray_dso_init.cpp
 create mode 100644 compiler-rt/test/xray/TestCases/Posix/basic-mode-dso.cpp
 create mode 100644 
compiler-rt/test/xray/TestCases/Posix/clang-enable-shared.cpp
 create mode 100644 compiler-rt/test/xray/TestCases/Posix/dlopen.cpp
 create mode 100644 compiler-rt/test/xray/TestCases/Posix/patch-premain-dso.cpp
 create mode 100644 
compiler-rt/test/xray/TestCases/Posix/patching-unpatching-dso.cpp

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 953f6fc649e621..3e3be5475c0c4d 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2850,6 +2850,10 @@ def fxray_selected_function_group :
   HelpText<"When using -fxray-function-groups, select which group of functions 
to instrument. Valid range is 0 to fxray-function-groups - 1">,
   MarshallingInfoInt, "0">;
 
+def fxray_enable_shared : Flag<["-"], "fxray-enable-shared">, Group,  
Visibility<[ClangOption, CC1Option]>,
+  HelpText<"Enable shared library instrumentation.">;
+def fno_xray_enable_shared : Flag<["-"], "fno-xray-enable-shared">, 
Group,
+  Visibility<[ClangOption, CC1Option]>;
 
 defm fine_grained_bitfield_accesses : BoolOption<"f", 
"fine-grained-bitfield-accesses",
   CodeGenOpts<"FineGrainedBitfieldAccesses">, DefaultFalse,
diff --git a/clang/include/clang/Driver/XRayArgs.h 
b/clang/include/clang/Driver/XRayArgs.h
index bdd3d979547eed..90a21e69586033 100644
--- a/clang/include/clang/Driver/XRayArgs.h
+++ b/clang/include/clang/Driver/XRayArgs.h
@@ -27,6 +27,7 @@ class XRayArgs {
   XRayInstrSet InstrumentationBundle;
   llvm::opt::Arg *XRayInstrument = nullptr;
   bool XRayRT = true;
+  bool XRayEnableShared = false;
 
 public:
   /// Parses the XRay arguments from an argument list.
@@ -35,6 +36,9 @@ class XRayArgs {
llvm::opt::ArgStringList &CmdArgs, types::ID InputType) const;
 
   bool needsXRayRt() const { return XRayInstrument && XRayRT; }
+  bool needsXRayDSORt() const {
+return XRayInstrument && XRayRT && XRayEnableShared;
+  }
   llvm::ArrayRef modeList() const { return Modes; }
   XRayInstrSet instrumentationBundle() const { return InstrumentationBundle; }
 };
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 6796b43a155020..399bf795ce394e 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1520,10 +1520,14 @@ bool tools::addSanitizerRuntimes(const ToolChain &TC, 
const ArgList &Args,
 }
 
 bool tools::addXRayRuntime(const ToolChain&TC, const ArgList &Args, 
ArgStringList &CmdArgs) {
-  if (Args.hasArg(options::OPT_shared))
-return false;
-
-  if (TC.getXRayArgs().needsXRayRt()) {
+  if (Args.hasArg(options::OPT_shared)) {
+if (TC.getXRayArgs().needsXRayDSORt()) {
+  CmdArgs.push_back("-whole-archive");
+  CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray-dso"));
+  CmdArgs.push_back("-no-whole-archive");
+  return true;
+}
+  } else if (TC.getXRayArgs().needsXRayRt()) {
 CmdArgs.push_back("--whole-archive");
 CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray"));
 for (const auto &Mode : TC.getXRayArgs().modeList())
diff --git a/clang/lib/Driver/XRayArgs.cpp b/clang/lib/Driver/XRayArgs.cpp
index 8c5134e2501358..7809cd7ef7c759 100644
--- a/clang/lib/Driver/XRayArgs.cpp
+++ b/clang/lib/Driver/XRayArgs.cpp
@@ -63,6 +63,10 @@ XRayArgs::XRayArgs(const ToolChain &TC, c

[clang] [llvm] [openmp] [OpenMP] Depobj optimisation (PR #91145)

2024-05-06 Thread PEREIRA Romain via cfe-commits

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


[clang] [clang][dataflow] Don't propagate result objects in unevaluated contexts (reland #90438) (PR #91172)

2024-05-06 Thread Yitzhak Mandelbaum via cfe-commits

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


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


[clang] [clang-tools-extra] [Clang] Unify interface for accessing template arguments as written for class/variable template specializations (PR #81642)

2024-05-06 Thread Krystian Stasiowski via cfe-commits

sdkrystian wrote:

Ping @AaronBallman 


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


[clang] [clang][dataflow] Don't propagate result objects in unevaluated contexts (reland #90438) (PR #91172)

2024-05-06 Thread via cfe-commits

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


[clang] 4d839d8 - [clang][dataflow] Don't propagate result objects in unevaluated contexts (reland #90438) (#91172)

2024-05-06 Thread via cfe-commits

Author: martinboehme
Date: 2024-05-06T14:21:15+02:00
New Revision: 4d839d8f18e41bd97e1c5e82d53ad5687c07e586

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

LOG: [clang][dataflow] Don't propagate result objects in unevaluated contexts 
(reland #90438) (#91172)

This relands #90348 with a fix for a [buildbot
failure](https://lab.llvm.org/buildbot/#/builders/216/builds/38446)
caused by the test being run with `-fno-rtti`.

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index d79e734402892a..cb6c8b2ef1072b 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -350,6 +350,17 @@ class ResultObjectVisitor : public 
RecursiveASTVisitor {
 return RecursiveASTVisitor::TraverseDecl(D);
   }
 
+  // Don't traverse expressions in unevaluated contexts, as we don't model
+  // fields that are only used in these.
+  // Note: The operand of the `noexcept` operator is an unevaluated operand, 
but
+  // nevertheless it appears in the Clang CFG, so we don't exclude it here.
+  bool TraverseDecltypeTypeLoc(DecltypeTypeLoc) { return true; }
+  bool TraverseTypeOfExprTypeLoc(TypeOfExprTypeLoc) { return true; }
+  bool TraverseCXXTypeidExpr(CXXTypeidExpr *) { return true; }
+  bool TraverseUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *) {
+return true;
+  }
+
   bool TraverseBindingDecl(BindingDecl *BD) {
 // `RecursiveASTVisitor` doesn't traverse holding variables for
 // `BindingDecl`s by itself, so we need to tell it to.

diff  --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 0b441faa6c76da..6743e778a2ffeb 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3400,6 +3400,60 @@ TEST(TransferTest, 
ResultObjectLocationDontVisitNestedRecordDecl) {
  ASTContext &ASTCtx) {});
 }
 
+TEST(TransferTest, ResultObjectLocationDontVisitUnevaluatedContexts) {
+  // This is a crash repro.
+  // We used to crash because when propagating result objects, we would visit
+  // unevaluated contexts, but we don't model fields used only in these.
+
+  auto testFunction = [](llvm::StringRef Code, llvm::StringRef TargetFun) {
+runDataflow(
+Code,
+[](const llvm::StringMap> &Results,
+   ASTContext &ASTCtx) {},
+LangStandard::lang_gnucxx17,
+/* ApplyBuiltinTransfer= */ true, TargetFun);
+  };
+
+  std::string Code = R"cc(
+// Definitions needed for `typeid`.
+namespace std {
+  class type_info {};
+  class bad_typeid {};
+}  // namespace std
+
+struct S1 {};
+struct S2 { S1 s1; };
+
+// We test each type of unevaluated context from a 
diff erent target
+// function. Some types of unevaluated contexts may actually cause the
+// field `s1` to be modeled, and we don't want this to "pollute" the tests
+// for the other unevaluated contexts.
+void decltypeTarget() {
+decltype(S2{}) Dummy;
+}
+void typeofTarget() {
+typeof(S2{}) Dummy;
+}
+void typeidTarget() {
+#if __has_feature(cxx_rtti)
+typeid(S2{});
+#endif
+}
+void sizeofTarget() {
+sizeof(S2{});
+}
+void noexceptTarget() {
+noexcept(S2{});
+}
+  )cc";
+
+  testFunction(Code, "decltypeTarget");
+  testFunction(Code, "typeofTarget");
+  testFunction(Code, "typeidTarget");
+  testFunction(Code, "sizeofTarget");
+  testFunction(Code, "noexceptTarget");
+}
+
 TEST(TransferTest, StaticCast) {
   std::string Code = R"(
 void target(int Foo) {



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


[clang] [clang][dataflow] Strengthen pointer comparison. (PR #75170)

2024-05-06 Thread Yitzhak Mandelbaum via cfe-commits

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


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


[clang] [clang][PowerPC] Add flag to enable compatibility with GNU for complex arguments (PR #77732)

2024-05-06 Thread Kishan Parmar via cfe-commits

https://github.com/Long5hot updated 
https://github.com/llvm/llvm-project/pull/77732

>From cc5fe4a6aa4762040077ab39edb6677f42638673 Mon Sep 17 00:00:00 2001
From: Kishan Parmar 
Date: Sun, 28 Apr 2024 14:18:42 +0530
Subject: [PATCH 1/2] [clang][PowerPC] Add flag to enable compatibility with
 GNU for complex arguments

Fixes : https://github.com/llvm/llvm-project/issues/56023

https://godbolt.org/z/1bsW1sKMs

newFlag : -fcomplex-ppc-gnu-abi

GNU uses GPRs for complex parameters and return values storing for 
PowerPC-32bit,
which can be enabled which above flag.
Intent of this patch is to make clang compatible with GNU libraries of complex.

Following up with this patch : https://reviews.llvm.org/D146942
---
 clang/include/clang/Basic/CodeGenOptions.def  |   2 +
 clang/include/clang/Basic/CodeGenOptions.h|   6 +
 clang/include/clang/Driver/Options.td |   4 +
 clang/lib/CodeGen/Targets/PPC.cpp |  87 +++-
 clang/lib/Driver/ToolChains/Clang.cpp |   9 +
 clang/lib/Frontend/CompilerInvocation.cpp |   8 +
 .../CodeGen/PowerPC/ppc32-complex-gnu-abi.c   | 394 ++
 .../ppc32-complex-soft-float-gnu-abi.c| 286 +
 .../test/Driver/ppc32-fcomplex-ppc-gnu-abi.c  |  15 +
 9 files changed, 805 insertions(+), 6 deletions(-)
 create mode 100644 clang/test/CodeGen/PowerPC/ppc32-complex-gnu-abi.c
 create mode 100644 
clang/test/CodeGen/PowerPC/ppc32-complex-soft-float-gnu-abi.c
 create mode 100644 clang/test/Driver/ppc32-fcomplex-ppc-gnu-abi.c

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 340b08dd7e2a33..f4845e9e424c67 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -225,6 +225,8 @@ CODEGENOPT(MCDCCoverage , 1, 0) ///< Enable MC/DC code 
coverage criteria.
 
   /// If -fpcc-struct-return or -freg-struct-return is specified.
 ENUM_CODEGENOPT(StructReturnConvention, StructReturnConventionKind, 2, 
SRCK_Default)
+  /// If -fcomplex-ppc-gnu-abi is specified on ppc32.
+ENUM_CODEGENOPT(ComplexInRegABI, ComplexArgumentConventionKind, 2, 
CMPLX_OnStack)
 
 CODEGENOPT(RelaxAll  , 1, 0) ///< Relax all machine code instructions.
 CODEGENOPT(RelaxedAliasing   , 1, 0) ///< Set when -fno-strict-aliasing is 
enabled.
diff --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index 9469a424045bb0..1c9424f65623dd 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -78,6 +78,12 @@ class CodeGenOptions : public CodeGenOptionsBase {
 SRCK_InRegs// Small structs in registers (-freg-struct-return).
   };
 
+  enum ComplexArgumentConventionKind {
+CMPLX_OnStack,
+CMPLX_InGPR, // If -fcomplex-ppc-gnu-abi is specified on ppc32
+CMPLX_InFPR
+  };
+
   enum ProfileInstrKind {
 ProfileNone,   // Profile instrumentation is turned off.
 ProfileClangInstr, // Clang instrumentation to generate execution counts
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 086aedefc11878..e35ac8ea36d727 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2601,6 +2601,10 @@ def ffp_contract : Joined<["-"], "ffp-contract=">, 
Group,
   HelpText<"Form fused FP ops (e.g. FMAs)">,
   Values<"fast,on,off,fast-honor-pragmas">;
 
+def fcomplex_ppc_gnu_abi : Flag<["-"], "fcomplex-ppc-gnu-abi">, 
Group, Visibility<[ClangOption, CC1Option]>,
+  DocBrief<"Follow the GNU ABI, pass Complex values in GPRs instead of the 
stack for PowerPC-32">,
+  HelpText<"Pass Complex values in GPR instead of stack for PowerPC-32">;
+
 defm strict_float_cast_overflow : BoolFOption<"strict-float-cast-overflow",
   CodeGenOpts<"StrictFloatCastOverflow">, DefaultTrue,
   NegFlaghttps://reviews.llvm.org/D146942 and the related LLVM pull
+  // request: #77732
+
+  if (TypeSize == 64) {
+ElemTy = llvm::Type::getInt64Ty(getVMContext());
+RegsNeeded = 1;
+  } else {
+ElemTy = llvm::Type::getInt32Ty(getVMContext());
+RegsNeeded = TypeSize >> 5;
+  }
+  return ABIArgInfo::getDirect(llvm::ArrayType::get(ElemTy, RegsNeeded));
+}
+
+ABIArgInfo PPC32_SVR4_ABIInfo::classifyArgumentType(QualType Ty,
+int &ArgGPRsLeft) const {
+  Ty = useFirstFieldIfTransparentUnion(Ty);
+  bool IsComplex = Ty->isAnyComplexType();
+
+  if ((getCodeGenOpts().getComplexInRegABI() != CodeGenOptions::CMPLX_InGPR) ||
+  !ArgGPRsLeft || (!IsComplex && Ty->isFloatingType() && !IsSoftFloatABI))
+return DefaultABIInfo::classifyArgumentType(Ty);
+
+  assert(ArgGPRsLeft >= 0 && "Arg GPR must be large or equal than zero");
+  ASTContext &Context = getContext();
+  uint64_t TypeSize = Context.getTypeSize(Ty);
+
+  // For complex type or any other primitive types.
+  if (IsComplex || !isAggregateTypeForABI(Ty)) {
+// If gr is even set gr = gr

[clang] d751e40 - [NFC] Use `const&` avoiding copies (#90334)

2024-05-06 Thread via cfe-commits

Author: Danny Mösch
Date: 2024-05-06T14:32:29+02:00
New Revision: d751e407def4e1540ae0af12a179ce4f2a8f676c

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

LOG: [NFC] Use `const&` avoiding copies (#90334)

Fixes #90285.

Added: 


Modified: 
clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp

Removed: 




diff  --git a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp 
b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
index d58f5bb0919906..f8dced5dbafb60 100644
--- a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
+++ b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
@@ -295,7 +295,7 @@ class InterfaceStubFunctionsConsumer : public ASTConsumer {
   OS << "Symbols:\n";
   for (const auto &E : Symbols) {
 const MangledSymbol &Symbol = E.second;
-for (auto Name : Symbol.Names) {
+for (const auto &Name : Symbol.Names) {
   OS << "  - { Name: \""
  << (Symbol.ParentName.empty() || Instance.getLangOpts().CPlusPlus
  ? ""



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


[clang] [NFC] Use `const&` avoiding copies (PR #90334)

2024-05-06 Thread Danny Mösch via cfe-commits

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


[clang] [Clang][Sema] Improve support for explicit specializations of constrained member functions & member function templates (PR #88963)

2024-05-06 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian updated 
https://github.com/llvm/llvm-project/pull/88963

>From bcffb80bba2a6f9ce9eddad61b99a3e59a58f8a0 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Tue, 16 Apr 2024 13:36:11 -0400
Subject: [PATCH 1/6] [Clang][Sema] Improve support for explicit
 specializations of constrained member functions & member function templates

---
 clang/lib/Sema/SemaConcept.cpp|  2 +-
 clang/lib/Sema/SemaOverload.cpp   | 11 ++-
 clang/lib/Sema/SemaTemplate.cpp   | 44 +--
 clang/lib/Sema/SemaTemplateInstantiate.cpp|  4 +
 .../CXX/temp/temp.spec/temp.expl.spec/p8.cpp  | 74 +++
 5 files changed, 124 insertions(+), 11 deletions(-)
 create mode 100644 clang/test/CXX/temp/temp.spec/temp.expl.spec/p8.cpp

diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index e00c972602829e..7bfec4e11f7aab 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -811,7 +811,7 @@ static const Expr 
*SubstituteConstraintExpressionWithoutSatisfaction(
   // this may happen while we're comparing two templates' constraint
   // equivalence.
   LocalInstantiationScope ScopeForParameters(S);
-  if (auto *FD = llvm::dyn_cast(DeclInfo.getDecl()))
+  if (auto *FD = DeclInfo.getDecl()->getAsFunction())
 for (auto *PVD : FD->parameters())
   ScopeForParameters.InstantiatedLocal(PVD, PVD);
 
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index a416df2e97c439..5c70588bd28b84 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -1303,6 +1303,8 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, 
FunctionDecl *New,
   if (New->isMSVCRTEntryPoint())
 return false;
 
+  NamedDecl *OldDecl = Old;
+  NamedDecl *NewDecl = New;
   FunctionTemplateDecl *OldTemplate = Old->getDescribedFunctionTemplate();
   FunctionTemplateDecl *NewTemplate = New->getDescribedFunctionTemplate();
 
@@ -1347,6 +1349,8 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, 
FunctionDecl *New,
   // references to non-instantiated entities during constraint substitution.
   // GH78101.
   if (NewTemplate) {
+OldDecl = OldTemplate;
+NewDecl = NewTemplate;
 // C++ [temp.over.link]p4:
 //   The signature of a function template consists of its function
 //   signature, its return type and its template parameter list. The names
@@ -1506,13 +1510,14 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, 
FunctionDecl *New,
 }
   }
 
-  if (!UseOverrideRules) {
+  if (!UseOverrideRules &&
+  New->getTemplateSpecializationKind() != TSK_ExplicitSpecialization) {
 Expr *NewRC = New->getTrailingRequiresClause(),
  *OldRC = Old->getTrailingRequiresClause();
 if ((NewRC != nullptr) != (OldRC != nullptr))
   return true;
-
-if (NewRC && !SemaRef.AreConstraintExpressionsEqual(Old, OldRC, New, 
NewRC))
+if (NewRC &&
+!SemaRef.AreConstraintExpressionsEqual(OldDecl, OldRC, NewDecl, NewRC))
   return true;
   }
 
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index e647ac267ab395..eeadc47e99069c 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -10354,6 +10354,25 @@ bool Sema::CheckFunctionTemplateSpecialization(
   return false;
 }
 
+static bool IsMoreConstrainedFunction(Sema &S, FunctionDecl *FD1,
+  FunctionDecl *FD2) {
+  if (FunctionDecl *MF = FD1->getInstantiatedFromMemberFunction())
+FD1 = MF;
+  if (FunctionDecl *MF = FD2->getInstantiatedFromMemberFunction())
+FD2 = MF;
+  llvm::SmallVector AC1, AC2;
+  FD1->getAssociatedConstraints(AC1);
+  FD2->getAssociatedConstraints(AC2);
+  bool AtLeastAsConstrained1, AtLeastAsConstrained2;
+  if (S.IsAtLeastAsConstrained(FD1, AC1, FD2, AC2, AtLeastAsConstrained1))
+return false;
+  if (S.IsAtLeastAsConstrained(FD2, AC2, FD1, AC1, AtLeastAsConstrained2))
+return false;
+  if (AtLeastAsConstrained1 == AtLeastAsConstrained2)
+return false;
+  return AtLeastAsConstrained1;
+}
+
 /// Perform semantic analysis for the given non-template member
 /// specialization.
 ///
@@ -10388,15 +10407,26 @@ Sema::CheckMemberSpecialization(NamedDecl *Member, 
LookupResult &Previous) {
 QualType Adjusted = Function->getType();
 if (!hasExplicitCallingConv(Adjusted))
   Adjusted = adjustCCAndNoReturn(Adjusted, Method->getType());
+if (!Context.hasSameType(Adjusted, Method->getType()))
+  continue;
+if (Method->getTrailingRequiresClause()) {
+  ConstraintSatisfaction Satisfaction;
+  if (CheckFunctionConstraints(Method, Satisfaction,
+   /*UsageLoc=*/Member->getLocation(),
+   /*ForOverloadResolution=*/true) ||
+  !Satisfaction.IsSatisfied)
+continue;
+  if (Instantiation &&
+  !I

[clang] [NFC][Driver] Clean up RenderFloatingPointOptions() (PR #91017)

2024-05-06 Thread Zahira Ammarguellat via cfe-commits

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

LGTM. Thanks.

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


[clang] [NFC][Driver] Clean up RenderFloatingPointOptions() (PR #91017)

2024-05-06 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [NFC][Driver] Clean up RenderFloatingPointOptions() (PR #91017)

2024-05-06 Thread Zahira Ammarguellat via cfe-commits


@@ -2885,6 +2883,7 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
   Range = RangeVal;
   break;
 }
+

zahiraam wrote:

nit. no need for this line.

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


[clang] [NFC][Driver] Clean up RenderFloatingPointOptions() (PR #91017)

2024-05-06 Thread Zahira Ammarguellat via cfe-commits


@@ -3152,6 +3125,12 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
   }
   break;
 }
+// The StrictFPModel local variable is needed to report warnings
+// in the wat we intend. If -ffp-model=strict has been used, we

zahiraam wrote:

in the "way" we intend?

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


[clang] [Clang] Implement __reference_converts_from_temporary (PR #91199)

2024-05-06 Thread via cfe-commits

https://github.com/cor3ntin created 
https://github.com/llvm/llvm-project/pull/91199

This completes the required language support for P2255R2.

>From dbc1c6296e943a3b9eff921e762cca641734dd3d Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Mon, 6 May 2024 14:55:54 +0200
Subject: [PATCH] [Clang] Implement __reference_converts_from_temporary

This completes the required language support for P2255R2.
---
 clang/docs/LanguageExtensions.rst|   5 +-
 clang/docs/ReleaseNotes.rst  |   3 +
 clang/include/clang/Basic/TokenKinds.def |   1 +
 clang/lib/Lex/PPMacroExpansion.cpp   |   2 -
 clang/lib/Parse/ParseDeclCXX.cpp |   5 +-
 clang/lib/Parse/ParseExpr.cpp|   1 -
 clang/lib/Sema/SemaExprCXX.cpp   | 157 +--
 clang/test/SemaCXX/type-traits.cpp   |  68 ++
 clang/www/cxx_status.html|  10 +-
 9 files changed, 170 insertions(+), 82 deletions(-)

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index c2e90f4e7d587a..97c6d69cee1116 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1661,8 +1661,11 @@ The following type trait primitives are supported by 
Clang. Those traits marked
   ``T`` from ``U`` is ill-formed.
   Deprecated, use ``__reference_constructs_from_temporary``.
 * ``__reference_constructs_from_temporary(T, U)`` (C++)
-  Returns true if a reference ``T`` can be constructed from a temporary of type
+  Returns true if a reference ``T`` can be direct-initialized from a temporary 
of type
   a non-cv-qualified ``U``.
+* ``__reference_converts_from_temporary(T, U)`` (C++)
+Returns true if a reference ``T`` can be copy-initialized from a temporary 
of type
+a non-cv-qualified ``U``.
 * ``__underlying_type`` (C++, GNU, Microsoft)
 
 In addition, the following expression traits are supported:
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2c5308fbcb319a..4e9b23d9a6a80f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -142,6 +142,9 @@ C++23 Feature Support
 
 - Implemented `P2448R2: Relaxing some constexpr restrictions 
`_.
 
+- Added a ``__reference_converts_from_temporary`` builtin, completing the 
necessary compiler support for
+  `P2255R2: Type trait to determine if a reference binds to a temporary 
`_.
+
 C++2c Feature Support
 ^
 
diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index a27fbed358a60c..56c4b17f769d70 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -537,6 +537,7 @@ TYPE_TRAIT_1(__is_referenceable, IsReferenceable, KEYCXX)
 TYPE_TRAIT_1(__can_pass_in_regs, CanPassInRegs, KEYCXX)
 TYPE_TRAIT_2(__reference_binds_to_temporary, ReferenceBindsToTemporary, KEYCXX)
 TYPE_TRAIT_2(__reference_constructs_from_temporary, 
ReferenceConstructsFromTemporary, KEYCXX)
+TYPE_TRAIT_2(__reference_converts_from_temporary, 
ReferenceConvertsFromTemporary, KEYCXX)
 
 // Embarcadero Expression Traits
 EXPRESSION_TRAIT(__is_lvalue_expr, IsLValueExpr, KEYCXX)
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp 
b/clang/lib/Lex/PPMacroExpansion.cpp
index a5f22f01682d25..a478e0badb0c7c 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -1714,8 +1714,6 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
   return llvm::StringSwitch(II->getName())
   .Case("__array_rank", true)
   .Case("__array_extent", true)
-  .Case("__reference_binds_to_temporary", true)
-  .Case("__reference_constructs_from_temporary", true)
 #define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) .Case("__" #Trait, true)
 #include "clang/Basic/TransformTypeTraits.def"
   .Default(false);
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 8e0e8682482933..96c9708c3711b7 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -1779,9 +1779,8 @@ void Parser::ParseClassSpecifier(tok::TokenKind 
TagTokKind,
   tok::kw___is_union,
   tok::kw___is_unsigned,
   tok::kw___is_void,
-  tok::kw___is_volatile,
-  tok::kw___reference_binds_to_temporary,
-  tok::kw___reference_constructs_from_temporary))
+  tok::kw___is_volatile
+  ))
 // GNU libstdc++ 4.2 and libc++ use certain intrinsic names as the
 // name of struct templates, but some are keywords in GCC >= 4.3
 // and Clang. Therefore, when we see the token sequence "struct
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 7d6febb04a82c4..41e25bebde06cc 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1166,7 +1166,6 @@ ExprResult Parser::ParseCastExpression(CastParseKind 
ParseKind,
   REVERTIBL

[clang] [Clang] Implement __reference_converts_from_temporary (PR #91199)

2024-05-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: cor3ntin (cor3ntin)


Changes

This completes the required language support for P2255R2.

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


9 Files Affected:

- (modified) clang/docs/LanguageExtensions.rst (+4-1) 
- (modified) clang/docs/ReleaseNotes.rst (+3) 
- (modified) clang/include/clang/Basic/TokenKinds.def (+1) 
- (modified) clang/lib/Lex/PPMacroExpansion.cpp (-2) 
- (modified) clang/lib/Parse/ParseDeclCXX.cpp (+2-3) 
- (modified) clang/lib/Parse/ParseExpr.cpp (-1) 
- (modified) clang/lib/Sema/SemaExprCXX.cpp (+91-66) 
- (modified) clang/test/SemaCXX/type-traits.cpp (+68) 
- (modified) clang/www/cxx_status.html (+1-9) 


``diff
diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index c2e90f4e7d587a..97c6d69cee1116 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1661,8 +1661,11 @@ The following type trait primitives are supported by 
Clang. Those traits marked
   ``T`` from ``U`` is ill-formed.
   Deprecated, use ``__reference_constructs_from_temporary``.
 * ``__reference_constructs_from_temporary(T, U)`` (C++)
-  Returns true if a reference ``T`` can be constructed from a temporary of type
+  Returns true if a reference ``T`` can be direct-initialized from a temporary 
of type
   a non-cv-qualified ``U``.
+* ``__reference_converts_from_temporary(T, U)`` (C++)
+Returns true if a reference ``T`` can be copy-initialized from a temporary 
of type
+a non-cv-qualified ``U``.
 * ``__underlying_type`` (C++, GNU, Microsoft)
 
 In addition, the following expression traits are supported:
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2c5308fbcb319a..4e9b23d9a6a80f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -142,6 +142,9 @@ C++23 Feature Support
 
 - Implemented `P2448R2: Relaxing some constexpr restrictions 
`_.
 
+- Added a ``__reference_converts_from_temporary`` builtin, completing the 
necessary compiler support for
+  `P2255R2: Type trait to determine if a reference binds to a temporary 
`_.
+
 C++2c Feature Support
 ^
 
diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index a27fbed358a60c..56c4b17f769d70 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -537,6 +537,7 @@ TYPE_TRAIT_1(__is_referenceable, IsReferenceable, KEYCXX)
 TYPE_TRAIT_1(__can_pass_in_regs, CanPassInRegs, KEYCXX)
 TYPE_TRAIT_2(__reference_binds_to_temporary, ReferenceBindsToTemporary, KEYCXX)
 TYPE_TRAIT_2(__reference_constructs_from_temporary, 
ReferenceConstructsFromTemporary, KEYCXX)
+TYPE_TRAIT_2(__reference_converts_from_temporary, 
ReferenceConvertsFromTemporary, KEYCXX)
 
 // Embarcadero Expression Traits
 EXPRESSION_TRAIT(__is_lvalue_expr, IsLValueExpr, KEYCXX)
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp 
b/clang/lib/Lex/PPMacroExpansion.cpp
index a5f22f01682d25..a478e0badb0c7c 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -1714,8 +1714,6 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
   return llvm::StringSwitch(II->getName())
   .Case("__array_rank", true)
   .Case("__array_extent", true)
-  .Case("__reference_binds_to_temporary", true)
-  .Case("__reference_constructs_from_temporary", true)
 #define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) .Case("__" #Trait, true)
 #include "clang/Basic/TransformTypeTraits.def"
   .Default(false);
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 8e0e8682482933..96c9708c3711b7 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -1779,9 +1779,8 @@ void Parser::ParseClassSpecifier(tok::TokenKind 
TagTokKind,
   tok::kw___is_union,
   tok::kw___is_unsigned,
   tok::kw___is_void,
-  tok::kw___is_volatile,
-  tok::kw___reference_binds_to_temporary,
-  tok::kw___reference_constructs_from_temporary))
+  tok::kw___is_volatile
+  ))
 // GNU libstdc++ 4.2 and libc++ use certain intrinsic names as the
 // name of struct templates, but some are keywords in GCC >= 4.3
 // and Clang. Therefore, when we see the token sequence "struct
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 7d6febb04a82c4..41e25bebde06cc 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1166,7 +1166,6 @@ ExprResult Parser::ParseCastExpression(CastParseKind 
ParseKind,
   REVERTIBLE_TYPE_TRAIT(__is_void);
   REVERTIBLE_TYPE_TRAIT(__is_volatile);
   REVERTIBLE_TYPE_TRAIT(__reference_binds_to_temporary);
-  REVERTIBLE_TYPE_TRAIT(__reference_constructs_from_temporary);
 #define 

[clang] [Clang] Implement __reference_converts_from_temporary (PR #91199)

2024-05-06 Thread via cfe-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 3a3bdd8fb63ffb49741a9c32b3a5a789ce4c3b91 
dbc1c6296e943a3b9eff921e762cca641734dd3d -- clang/lib/Lex/PPMacroExpansion.cpp 
clang/lib/Parse/ParseDeclCXX.cpp clang/lib/Parse/ParseExpr.cpp 
clang/lib/Sema/SemaExprCXX.cpp clang/test/SemaCXX/type-traits.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 96c9708c37..60fc51cfb7 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -1722,65 +1722,32 @@ void Parser::ParseClassSpecifier(tok::TokenKind 
TagTokKind,
   Tok.isOneOf(
 #define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) tok::kw___##Trait,
 #include "clang/Basic/TransformTypeTraits.def"
-  tok::kw___is_abstract,
-  tok::kw___is_aggregate,
-  tok::kw___is_arithmetic,
-  tok::kw___is_array,
-  tok::kw___is_assignable,
-  tok::kw___is_base_of,
-  tok::kw___is_bounded_array,
-  tok::kw___is_class,
-  tok::kw___is_complete_type,
-  tok::kw___is_compound,
-  tok::kw___is_const,
-  tok::kw___is_constructible,
-  tok::kw___is_convertible,
-  tok::kw___is_convertible_to,
-  tok::kw___is_destructible,
-  tok::kw___is_empty,
-  tok::kw___is_enum,
-  tok::kw___is_floating_point,
-  tok::kw___is_final,
-  tok::kw___is_function,
-  tok::kw___is_fundamental,
-  tok::kw___is_integral,
-  tok::kw___is_interface_class,
-  tok::kw___is_literal,
-  tok::kw___is_lvalue_expr,
-  tok::kw___is_lvalue_reference,
-  tok::kw___is_member_function_pointer,
-  tok::kw___is_member_object_pointer,
-  tok::kw___is_member_pointer,
-  tok::kw___is_nothrow_assignable,
-  tok::kw___is_nothrow_constructible,
-  tok::kw___is_nothrow_convertible,
-  tok::kw___is_nothrow_destructible,
-  tok::kw___is_nullptr,
-  tok::kw___is_object,
-  tok::kw___is_pod,
-  tok::kw___is_pointer,
-  tok::kw___is_polymorphic,
-  tok::kw___is_reference,
-  tok::kw___is_referenceable,
-  tok::kw___is_rvalue_expr,
-  tok::kw___is_rvalue_reference,
-  tok::kw___is_same,
-  tok::kw___is_scalar,
-  tok::kw___is_scoped_enum,
-  tok::kw___is_sealed,
-  tok::kw___is_signed,
-  tok::kw___is_standard_layout,
-  tok::kw___is_trivial,
+  tok::kw___is_abstract, tok::kw___is_aggregate,
+  tok::kw___is_arithmetic, tok::kw___is_array, tok::kw___is_assignable,
+  tok::kw___is_base_of, tok::kw___is_bounded_array, tok::kw___is_class,
+  tok::kw___is_complete_type, tok::kw___is_compound, 
tok::kw___is_const,
+  tok::kw___is_constructible, tok::kw___is_convertible,
+  tok::kw___is_convertible_to, tok::kw___is_destructible,
+  tok::kw___is_empty, tok::kw___is_enum, tok::kw___is_floating_point,
+  tok::kw___is_final, tok::kw___is_function, tok::kw___is_fundamental,
+  tok::kw___is_integral, tok::kw___is_interface_class,
+  tok::kw___is_literal, tok::kw___is_lvalue_expr,
+  tok::kw___is_lvalue_reference, tok::kw___is_member_function_pointer,
+  tok::kw___is_member_object_pointer, tok::kw___is_member_pointer,
+  tok::kw___is_nothrow_assignable, tok::kw___is_nothrow_constructible,
+  tok::kw___is_nothrow_convertible, tok::kw___is_nothrow_destructible,
+  tok::kw___is_nullptr, tok::kw___is_object, tok::kw___is_pod,
+  tok::kw___is_pointer, tok::kw___is_polymorphic,
+  tok::kw___is_reference, tok::kw___is_referenceable,
+  tok::kw___is_rvalue_expr, tok::kw___is_rvalue_reference,
+  tok::kw___is_same, tok::kw___is_scalar, tok::kw___is_scoped_enum,
+  tok::kw___is_sealed, tok::kw___is_signed,
+  tok::kw___is_standard_layout, tok::kw___is_trivial,
   tok::kw___is_trivially_equality_comparable,
   tok::kw___is_trivially_assignable,
-  tok::kw___is_trivially_constructible,
-  tok::kw___is_trivially_copyable,
-  tok::kw___is_unbounded_array,
-  tok::kw___is_union,
-  tok::kw___is_unsigned,
-  tok::kw___is_void,
-  tok::kw___is_volatile
-  ))
+  tok::kw___is_trivially_constructible, 
tok::kw___is_trivially_copyable,
+  tok::kw___is_unbounded_array, tok::kw___is_union,
+  tok::kw___is_unsigned, tok::kw___is_void, tok::kw___is_volatile))
 // GNU libstdc++ 4.2 and libc++ use certain intrinsic names as the
 // name of struct templates, but some are keywords in GCC >= 4.3
 // and Clang. Therefore, whe

[clang] [Clang][Sema] Earlier type checking for builtin unary operators (PR #90500)

2024-05-06 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian updated 
https://github.com/llvm/llvm-project/pull/90500

>From 68ae8a9321b96da8cde1a1813d5e2b0c352649b7 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Thu, 25 Apr 2024 08:17:21 -0400
Subject: [PATCH 1/4] [Clang][Sema] Earlier type checking for builtin unary
 operators

---
 clang/include/clang/AST/Type.h|  5 -
 clang/lib/Sema/SemaExpr.cpp   | 22 +++
 clang/test/AST/ast-dump-expr-json.cpp |  4 ++--
 clang/test/AST/ast-dump-expr.cpp  |  2 +-
 clang/test/AST/ast-dump-lambda.cpp|  2 +-
 clang/test/CXX/over/over.built/ast.cpp|  8 ---
 clang/test/Frontend/noderef_templates.cpp |  4 ++--
 clang/test/SemaCXX/cxx2b-deducing-this.cpp|  6 ++---
 .../test/SemaTemplate/class-template-spec.cpp | 12 +-
 9 files changed, 36 insertions(+), 29 deletions(-)

diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index e6643469e0b334..da3834f19ca044 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -8044,7 +8044,10 @@ inline bool Type::isUndeducedType() const {
 /// Determines whether this is a type for which one can define
 /// an overloaded operator.
 inline bool Type::isOverloadableType() const {
-  return isDependentType() || isRecordType() || isEnumeralType();
+  if (!CanonicalType->isDependentType())
+return isRecordType() || isEnumeralType();
+  return !isArrayType() && !isFunctionType() && !isAnyPointerType() &&
+ !isMemberPointerType();
 }
 
 /// Determines whether this type is written as a typedef-name.
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index b1322f30fa6b6a..ad670165242187 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -671,12 +671,12 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) {
 
   // We don't want to throw lvalue-to-rvalue casts on top of
   // expressions of certain types in C++.
-  if (getLangOpts().CPlusPlus &&
-  (E->getType() == Context.OverloadTy ||
-   // FIXME: This is a hack! We want the lvalue-to-rvalue conversion 
applied
-   // to pointer types even if the pointee type is dependent.
-   (T->isDependentType() && !T->isPointerType()) || T->isRecordType()))
-return E;
+  if (getLangOpts().CPlusPlus) {
+if (T == Context.OverloadTy || T->isRecordType() ||
+(T->isDependentType() && !T->isAnyPointerType() &&
+ !T->isMemberPointerType()))
+  return E;
+  }
 
   // The C standard is actually really unclear on this point, and
   // DR106 tells us what the result should be but not why.  It's
@@ -7,7 +7,7 @@ static bool checkArithmeticIncompletePointerType(Sema 
&S, SourceLocation Loc,
   if (const AtomicType *ResAtomicType = ResType->getAs())
 ResType = ResAtomicType->getValueType();
 
-  assert(ResType->isAnyPointerType() && !ResType->isDependentType());
+  assert(ResType->isAnyPointerType());
   QualType PointeeTy = ResType->getPointeeType();
   return S.RequireCompleteSizedType(
   Loc, PointeeTy,
@@ -14288,7 +14288,9 @@ static QualType CheckIncrementDecrementOperand(Sema &S, 
Expr *Op,
ExprObjectKind &OK,
SourceLocation OpLoc,
bool IsInc, bool IsPrefix) {
-  if (Op->isTypeDependent())
+  if (Op->isTypeDependent() &&
+  (Op->hasPlaceholderType() ||
+   Op->getType()->isSpecificBuiltinType(BuiltinType::Dependent)))
 return S.Context.DependentTy;
 
   QualType ResType = Op->getType();
@@ -14742,7 +14744,9 @@ static void RecordModifiableNonNullParam(Sema &S, const 
Expr *Exp) {
 static QualType CheckIndirectionOperand(Sema &S, Expr *Op, ExprValueKind &VK,
 SourceLocation OpLoc,
 bool IsAfterAmp = false) {
-  if (Op->isTypeDependent())
+  if (Op->isTypeDependent() &&
+  (Op->hasPlaceholderType() ||
+   Op->getType()->isSpecificBuiltinType(BuiltinType::Dependent)))
 return S.Context.DependentTy;
 
   ExprResult ConvResult = S.UsualUnaryConversions(Op);
diff --git a/clang/test/AST/ast-dump-expr-json.cpp 
b/clang/test/AST/ast-dump-expr-json.cpp
index 0fb07b0b434cc3..4b7365e554cb7c 100644
--- a/clang/test/AST/ast-dump-expr-json.cpp
+++ b/clang/test/AST/ast-dump-expr-json.cpp
@@ -4261,9 +4261,9 @@ void TestNonADLCall3() {
 // CHECK-NEXT: }
 // CHECK-NEXT:},
 // CHECK-NEXT:"type": {
-// CHECK-NEXT: "qualType": ""
+// CHECK-NEXT: "qualType": "V"
 // CHECK-NEXT:},
-// CHECK-NEXT:"valueCategory": "prvalue",
+// CHECK-NEXT:"valueCategory": "lvalue",
 // CHECK-NEXT:"isPostfix": false,
 // CHECK-NEXT:"opcode": "*",
 // CHECK-NEXT: 

[clang-tools-extra] [clangd] Support callHierarchy/outgoingCalls (PR #91191)

2024-05-06 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

I remembered @HighCommander4 had filed a similar PR at 
https://github.com/llvm/llvm-project/pull/77556. Is this one separate, or are 
they actually the same (i.e. both are salvaged from 
https://reviews.llvm.org/D93829)?

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


[clang] [llvm] [Driver] Add option to select compiler-rt arch suffix (PR #89775)

2024-05-06 Thread Paul T Robinson via cfe-commits

pogo59 wrote:

My understanding is that this change never had a proper Discourse RFC, which 
means it was quite possible for vendors not to have noticed it. Certainly I (on 
behalf of Sony) was not aware, and I make some effort to keep an eye on things. 
There is no good reason to suppose Visual Studio will adopt the change if they 
are unaware of it.

I understand that @tru has adopted the new style downstream for their internal 
use. The argument I am hearing here is that you are _requiring_ all downstream 
Windows users to do the same, because otherwise their builds will start failing 
(as our internal builds have done). But, despite that requirement, it appears 
that the Windows _default_ is to build with the old style. This is at best an 
inconsistency, and at worst really broken. I can see a few ways to fix it.

1. Windows does not adopt the new style. The build default remains as it is, 
and there is a Windows exception to match the AIX exception as seen in this 
patch. If someone wants to change to the new style for their own downstream 
use, as @tru has, they need to deal with it themselves.
2. Windows _fully_ adopts the new style. The build default changes, there is no 
Windows exception. I have not run the experiment, but if this had been done, 
probably I never would have noticed.
3. Windows stays as it is. The build defaults to old style, but for those who 
choose to adopt the new style, we add a driver option so the compiler knows 
something is different.


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


[clang-tools-extra] [clangd] Support callHierarchy/outgoingCalls (PR #91191)

2024-05-06 Thread Christian Kandeler via cfe-commits

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


[clang-tools-extra] [clangd] Support callHierarchy/outgoingCalls (PR #91191)

2024-05-06 Thread Christian Kandeler via cfe-commits

ckandeler wrote:

> I remembered @HighCommander4 had filed a similar PR at #77556. Is this one 
> separate, or are they actually the same (i.e. both are salvaged from 
> https://reviews.llvm.org/D93829)?

I didn't know about that one. Seems nothing gets reviewed anymore these days.

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


[clang] [CIR] Build out AST consumer patterns to reach the entry point into CIRGen (PR #91007)

2024-05-06 Thread Erich Keane via cfe-commits


@@ -0,0 +1,61 @@
+//=== CIRGenAction.h - CIR Code Generation Frontend Action -*- C++ 
-*--===//
+//
+// 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
+//
+//===--===//
+
+#ifndef LLVM_CLANG_CIR_CIRGENACTION_H
+#define LLVM_CLANG_CIR_CIRGENACTION_H
+
+#include "clang/Frontend/FrontendAction.h"
+
+#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/OwningOpRef.h"
+
+namespace mlir {
+class MLIRContext;
+class ModuleOp;
+} // namespace mlir
+
+namespace cir {
+class CIRGenConsumer;
+
+class CIRGenAction : public clang::ASTFrontendAction {
+public:
+  enum class OutputType {
+EmitCIR,

erichkeane wrote:

Got it, thanks!

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


[clang] [CIR] Build out AST consumer patterns to reach the entry point into CIRGen (PR #91007)

2024-05-06 Thread Erich Keane via cfe-commits


@@ -42,6 +47,14 @@ CreateFrontendBaseAction(CompilerInstance &CI) {
   StringRef Action("unknown");
   (void)Action;
 
+  auto UseCIR = CI.getFrontendOpts().UseClangIRPipeline;

erichkeane wrote:

Thats a question I think for @AaronBallman .  This DOES live in the 'clang' 
directory, so I would think this should all follow the Clang coding standards, 
but I can see the justification for using the MLIR standard, same as the 
capitalization (@lanza ).  

There WAS some discussion elsewhere, but I cant find the thread, so I dont know 
what was agreed upon.

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


[clang] [CIR] Build out AST consumer patterns to reach the entry point into CIRGen (PR #91007)

2024-05-06 Thread Erich Keane via cfe-commits


@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s

erichkeane wrote:

> We don't have any IR to test just yet. @lanza you could use `FileCheck` with 
> `--allow-empty` here for now. You could also rename this test `emit-cir.c` 
> since the purpose for now is to not crash (as it would before this PR).

Both of those are OK enough ideas to me.  So at this point, we're just emitting 
a blank-file, right?   Perhaps   `--allow-empty` plus a `// CHECK-NOT: *` or 
something.

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


[clang] [llvm] [Driver] Add option to select compiler-rt arch suffix (PR #89775)

2024-05-06 Thread Tobias Hieta via cfe-commits

tru wrote:

Yeah I think this should be brought up as an RFC in discourse. I would like to 
see that we move away from two different layouts and just adopt one (my 
preference is the new layout, but honestly - I don't feel that strongly about 
it).

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


[clang] [llvm] [openmp] [OpenMP] Depobj optimisation (PR #91145)

2024-05-06 Thread PEREIRA Romain via cfe-commits

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


[clang] [llvm] [openmp] [OpenMP] Depobj optimisation (PR #91145)

2024-05-06 Thread PEREIRA Romain via cfe-commits

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


[clang] [llvm] [openmp] [OpenMP] Depobj optimisation (PR #91145)

2024-05-06 Thread PEREIRA Romain via cfe-commits

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


[clang-tools-extra] [clangd] Support callHierarchy/outgoingCalls (PR #91191)

2024-05-06 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

> Seems nothing gets reviewed anymore these days.

Yeah, and unfortunately folks who are qualified/versed in clangd indices don't 
have enough bandwidths recently, nor does the author @HighCommander4.

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


[libcxx] [libcxxabi] [libunwind] [llvm] [libc++][WIP] Move the libc++ test format to Lit (PR #90803)

2024-05-06 Thread Louis Dionne via cfe-commits

https://github.com/ldionne updated 
https://github.com/llvm/llvm-project/pull/90803

>From ecab1e5689f9f7ea6f87d9cc8c51910b733f6859 Mon Sep 17 00:00:00 2001
From: Louis Dionne 
Date: Wed, 1 May 2024 18:10:07 -0600
Subject: [PATCH] [libc++][WIP] Move the libc++ test format to Lit

This allows the generally-useful parts of the test format to be
shipped alongside Lit, which would make it usable for third-party
developers as well. This came up at C++Now in the context of the
Beman project where we'd like to set up a non-LLVM project that can
use the same testing framework as libc++.

With the test format moved to Lit, the format would be available
after installing Lit with pip, which is really convenient.
---
 libcxx/test/configs/cmake-bridge.cfg.in   |   2 +-
 libcxx/utils/libcxx/test/dsl.py   |   6 +-
 libcxx/utils/libcxx/test/format.py| 419 +++---
 libcxxabi/test/configs/cmake-bridge.cfg.in|   2 +-
 libunwind/test/configs/cmake-bridge.cfg.in|   2 +-
 llvm/utils/lit/lit/formats/__init__.py|   1 +
 .../lit/lit/formats/standardlibrarytest.py| 355 +++
 7 files changed, 421 insertions(+), 366 deletions(-)
 create mode 100644 llvm/utils/lit/lit/formats/standardlibrarytest.py

diff --git a/libcxx/test/configs/cmake-bridge.cfg.in 
b/libcxx/test/configs/cmake-bridge.cfg.in
index 84b3270a8940ac..b220e5ebcafb17 100644
--- a/libcxx/test/configs/cmake-bridge.cfg.in
+++ b/libcxx/test/configs/cmake-bridge.cfg.in
@@ -18,7 +18,7 @@ import libcxx.test.format
 # Basic configuration of the test suite
 config.name = os.path.basename('@LIBCXX_TEST_CONFIG@')
 config.test_source_root = os.path.join('@LIBCXX_SOURCE_DIR@', 'test')
-config.test_format = libcxx.test.format.CxxStandardLibraryTest()
+config.test_format = libcxx.test.format.LibcxxTest()
 config.recursiveExpansionLimit = 10
 config.test_exec_root = os.path.join('@CMAKE_BINARY_DIR@', 'test')
 
diff --git a/libcxx/utils/libcxx/test/dsl.py b/libcxx/utils/libcxx/test/dsl.py
index 387862ae6f496d..6177dc9dccd327 100644
--- a/libcxx/utils/libcxx/test/dsl.py
+++ b/libcxx/utils/libcxx/test/dsl.py
@@ -99,7 +99,7 @@ def _executeWithFakeConfig(test, commands):
 order="smart",
 params={},
 )
-return libcxx.test.format._executeScriptInternal(test, litConfig, commands)
+return lit.formats.standardlibrarytest._executeScriptInternal(test, 
litConfig, commands)
 
 
 def _makeConfigTest(config):
@@ -121,12 +121,12 @@ def _makeConfigTest(config):
 
 class TestWrapper(lit.Test.Test):
 def __enter__(self):
-testDir, _ = libcxx.test.format._getTempPaths(self)
+testDir, _ = lit.formats.standardlibrarytest._getTempPaths(self)
 os.makedirs(testDir)
 return self
 
 def __exit__(self, *args):
-testDir, _ = libcxx.test.format._getTempPaths(self)
+testDir, _ = lit.formats.standardlibrarytest._getTempPaths(self)
 shutil.rmtree(testDir)
 os.remove(tmp.name)
 
diff --git a/libcxx/utils/libcxx/test/format.py 
b/libcxx/utils/libcxx/test/format.py
index 7e5281c0b74064..a670f57f67965d 100644
--- a/libcxx/utils/libcxx/test/format.py
+++ b/libcxx/utils/libcxx/test/format.py
@@ -7,50 +7,8 @@
 # 
===--===##
 
 import lit
-import libcxx.test.config as config
 import lit.formats
 import os
-import re
-
-
-def _getTempPaths(test):
-"""
-Return the values to use for the %T and %t substitutions, respectively.
-
-The difference between this and Lit's default behavior is that we guarantee
-that %T is a path unique to the test being run.
-"""
-tmpDir, _ = lit.TestRunner.getTempPaths(test)
-_, testName = os.path.split(test.getExecPath())
-tmpDir = os.path.join(tmpDir, testName + ".dir")
-tmpBase = os.path.join(tmpDir, "t")
-return tmpDir, tmpBase
-
-
-def _checkBaseSubstitutions(substitutions):
-substitutions = [s for (s, _) in substitutions]
-for s in ["%{cxx}", "%{compile_flags}", "%{link_flags}", "%{flags}", 
"%{exec}"]:
-assert s in substitutions, "Required substitution {} was not 
provided".format(s)
-
-def _executeScriptInternal(test, litConfig, commands):
-"""
-Returns (stdout, stderr, exitCode, timeoutInfo, parsedCommands)
-
-TODO: This really should be easier to access from Lit itself
-"""
-parsedCommands = parseScript(test, preamble=commands)
-
-_, tmpBase = _getTempPaths(test)
-execDir = os.path.dirname(test.getExecPath())
-try:
-res = lit.TestRunner.executeScriptInternal(
-test, litConfig, tmpBase, parsedCommands, execDir, debug=False
-)
-except lit.TestRunner.ScriptFatal as e:
-res = ("", str(e), 127, None)
-(out, err, exitCode, timeoutInfo) = res
-
-return (out, err, exitCode, timeoutInfo, parsedCommands)
 
 
 def _validateModuleDependencies(modules):
@@ -61,334 +19,75 @@ def _validateModuleDep

[clang] [clang][deps] Only bypass scanning VFS for the module cache (PR #88800)

2024-05-06 Thread Alexandre Ganea via cfe-commits

aganea wrote:

Ping @jansvoboda11! Are you able to get back to this soon? LG generally, just 
missing a test case above. Thanks!

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


[clang] [Clang] Implement __reference_converts_from_temporary (PR #91199)

2024-05-06 Thread Erich Keane via cfe-commits

https://github.com/erichkeane commented:

Seems reasonable to me.  Curious about 1 change though.

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


[clang] [Clang] Implement __reference_converts_from_temporary (PR #91199)

2024-05-06 Thread Erich Keane via cfe-commits

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


[clang] [Clang] Implement __reference_converts_from_temporary (PR #91199)

2024-05-06 Thread Erich Keane via cfe-commits


@@ -1779,9 +1779,8 @@ void Parser::ParseClassSpecifier(tok::TokenKind 
TagTokKind,
   tok::kw___is_union,
   tok::kw___is_unsigned,
   tok::kw___is_void,
-  tok::kw___is_volatile,
-  tok::kw___reference_binds_to_temporary,
-  tok::kw___reference_constructs_from_temporary))
+  tok::kw___is_volatile

erichkeane wrote:

Curious why the change here?  It seems the fallback is still valuable here?

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


[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-05-06 Thread Daniel M. Katz via cfe-commits

katzdm wrote:

👋 Friendly ping - No worries if more time is needed to consider the impact of 
this one, but wanted to check if any more changes are needed at this time.

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


[clang] [Clang] Implement __reference_converts_from_temporary (PR #91199)

2024-05-06 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

@cjdb said he had discarded the implementation of this intrinsic in 
https://reviews.llvm.org/D135341 because he thought this was not as trivial as 
the `construct` version. Given that we have lost all the Phab histories, I 
think it'd be better to invite @cjdb to take a look at this? And I'm also 
curious what the previous implementation was :)

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


[clang] [Clang][Comments] Add argument parsing for @throw @throws @exception (PR #84726)

2024-05-06 Thread via cfe-commits

cor3ntin wrote:

Before I do an in-depth review i think supporting arguments to `@throw` etc 
makes a lot of sense.
However, I don't think we want to have a `type-id` parser in the  comment 
parser. The grammar is complicated, and the approach seems brittle and hard to 
maintain.

Given use cases, I think it's sufficient to consider anything before a space as 
part of a type.
You can try to support things like `foo` just by balancing `<>`,  
but I really don't think we want to parse arbitrary types (including function 
types, arrays, lambdas, etc) as types that you can throw.

If people want to throw "unsigned int" exceptions, well... it won't work. I 
think it's a reasonable tradeoff.
99% of exceptions are going to be class types.

In the long term, if we really want to support arbitrary constructs there, I 
think it would take a more robust approach such as the one that was [proposed 
here (and subsequently abandoned) 
](https://discourse.llvm.org/t/rfc-a-c-pseudo-parser-for-tooling/59217 
)

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


[clang] cc1: Report an error for multiple actions unless separated by -main-file-name (PR #91140)

2024-05-06 Thread Erich Keane via cfe-commits

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


[clang] cc1: Report an error for multiple actions unless separated by -main-file-name (PR #91140)

2024-05-06 Thread Erich Keane via cfe-commits

https://github.com/erichkeane commented:

CI seems to have noticed what I feared :)  This is going to hit a good amount 
of our internal tests, there is no way our copy-paste cargo-cult didn't come up 
with this before.

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


[clang] cc1: Report an error for multiple actions unless separated by -main-file-name (PR #91140)

2024-05-06 Thread Erich Keane via cfe-commits


@@ -134,6 +134,8 @@ def err_fe_no_pch_in_dir : Error<
 "no suitable precompiled header file found in directory '%0'">;
 def err_fe_action_not_available : Error<
 "action %0 not compiled in">;
+def err_fe_invalid_multiple_actions : Error<
+"action %0 is specified, another action is not allowed: %1">;

erichkeane wrote:

```suggestion
"'%1' action ignored; '%0' action specified previously">;
```

Maybe something like this?  I dont think the original fits very well?  Also the 
single ticks around the actions is, IMO, better for readability.

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


[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-05-06 Thread Erich Keane via cfe-commits

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

This seems reasonable to me, I think @cor3ntin should also approve before 
committing though.

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


[clang] [llvm] [Driver] Add option to select compiler-rt arch suffix (PR #89775)

2024-05-06 Thread Paul T Robinson via cfe-commits

pogo59 wrote:

To answer @MaskRay 's question directly, with respect to PlayStation (not 
Windows, which is the major problem):

We have exactly one target, so neither the arch suffix nor a target-specific 
directory are useful. (Arguably we have two targets, but as we deliver entirely 
separate SDKs for PS4 and PS5, that's really irrelevant.) I've raised an 
internal ticket so the relevant people will become aware of what's going on.

I'm making a fuss about Windows because internally we do self-hosted builds, so 
we are essentially vending a Windows-target toolchain to ourselves. And that's 
the one that is failing.

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


[clang] [Clang][Sema] Explicit template arguments are not substituted into the exception specification of a function (PR #90760)

2024-05-06 Thread Erich Keane via cfe-commits

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

LGTM.  I want @Endilll to confirm the DR test looks right though.

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


[clang] [clang][NFC] Remove class layout scissor (PR #89055)

2024-05-06 Thread Nathan Sidwell via cfe-commits

https://github.com/urnathan updated 
https://github.com/llvm/llvm-project/pull/89055

>From db5e6456f26ea9b859d3ff24161d7494d58bb7e1 Mon Sep 17 00:00:00 2001
From: Nathan Sidwell 
Date: Mon, 1 Apr 2024 16:15:12 -0400
Subject: [PATCH 1/3] [clang] Remove class layout scissor

---
 clang/lib/CodeGen/CGRecordLayoutBuilder.cpp | 22 ++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp 
b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
index 868b1ab98e048a..cc51cc3476c438 100644
--- a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
+++ b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
@@ -75,7 +75,7 @@ struct CGRecordLowering {
   // sentinel member type that ensures correct rounding.
   struct MemberInfo {
 CharUnits Offset;
-enum InfoKind { VFPtr, VBPtr, Field, Base, VBase, Scissor } Kind;
+enum InfoKind { VFPtr, VBPtr, Field, Base, VBase } Kind;
 llvm::Type *Data;
 union {
   const FieldDecl *FD;
@@ -197,7 +197,7 @@ struct CGRecordLowering {
  const CXXRecordDecl *Query) const;
   void calculateZeroInit();
   CharUnits calculateTailClippingOffset(bool isNonVirtualBaseType) const;
-  void checkBitfieldClipping() const;
+  void checkBitfieldClipping(bool isNonVirtualBaseType) const;
   /// Determines if we need a packed llvm struct.
   void determinePacked(bool NVBaseType);
   /// Inserts padding everywhere it's needed.
@@ -299,8 +299,8 @@ void CGRecordLowering::lower(bool NVBaseType) {
   accumulateVBases();
   }
   llvm::stable_sort(Members);
+  checkBitfieldClipping(NVBaseType);
   Members.push_back(StorageInfo(Size, getIntNType(8)));
-  checkBitfieldClipping();
   determinePacked(NVBaseType);
   insertPadding();
   Members.pop_back();
@@ -894,8 +894,6 @@ CGRecordLowering::calculateTailClippingOffset(bool 
isNonVirtualBaseType) const {
 }
 
 void CGRecordLowering::accumulateVBases() {
-  Members.push_back(MemberInfo(calculateTailClippingOffset(false),
-   MemberInfo::Scissor, nullptr, RD));
   for (const auto &Base : RD->vbases()) {
 const CXXRecordDecl *BaseDecl = Base.getType()->getAsCXXRecordDecl();
 if (BaseDecl->isEmpty())
@@ -950,18 +948,20 @@ void CGRecordLowering::calculateZeroInit() {
 }
 
 // Verify accumulateBitfields computed the correct storage representations.
-void CGRecordLowering::checkBitfieldClipping() const {
+void CGRecordLowering::checkBitfieldClipping(
+bool isNonVirtualBaseType LLVM_ATTRIBUTE_UNUSED) const {
 #ifndef NDEBUG
+  auto ScissorOffset = calculateTailClippingOffset(isNonVirtualBaseType);
   auto Tail = CharUnits::Zero();
   for (const auto &M : Members) {
-// Only members with data and the scissor can cut into tail padding.
-if (!M.Data && M.Kind != MemberInfo::Scissor)
+// Only members with data could possibly overlap.
+if (!M.Data)
   continue;
 
 assert(M.Offset >= Tail && "Bitfield access unit is not clipped");
-Tail = M.Offset;
-if (M.Data)
-  Tail += getSize(M.Data);
+Tail = M.Offset + getSize(M.Data);
+assert((Tail <= ScissorOffset || M.Offset >= ScissorOffset) &&
+   "Bitfield straddles scissor offset");
   }
 #endif
 }

>From 36705e5bcdcda6983ed5a163ae8ea3e9911ad275 Mon Sep 17 00:00:00 2001
From: Nathan Sidwell 
Date: Wed, 17 Apr 2024 17:15:57 -0400
Subject: [PATCH 2/3] Fix param spelling

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

diff --git a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp 
b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
index cc51cc3476c438..38167903cda508 100644
--- a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
+++ b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
@@ -949,9 +949,9 @@ void CGRecordLowering::calculateZeroInit() {
 
 // Verify accumulateBitfields computed the correct storage representations.
 void CGRecordLowering::checkBitfieldClipping(
-bool isNonVirtualBaseType LLVM_ATTRIBUTE_UNUSED) const {
+bool IsNonVirtualBaseType LLVM_ATTRIBUTE_UNUSED) const {
 #ifndef NDEBUG
-  auto ScissorOffset = calculateTailClippingOffset(isNonVirtualBaseType);
+  auto ScissorOffset = calculateTailClippingOffset(IsNonVirtualBaseType);
   auto Tail = CharUnits::Zero();
   for (const auto &M : Members) {
 // Only members with data could possibly overlap.

>From 2d2dcdecb0328b8d397bb14072e5750ddf20a39a Mon Sep 17 00:00:00 2001
From: Nathan Sidwell 
Date: Mon, 6 May 2024 10:28:06 -0400
Subject: [PATCH 3/3] lose attribute

---
 clang/lib/CodeGen/CGRecordLayoutBuilder.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp 
b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
index 38167903cda508..5169be204c14d0 100644
--- a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
+++ b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
@@ -948,8 +948,7 @@ void CGRecordLowering::calculateZeroInit() {
 }
 
 // Verify accumulateBitfields computed the correct

[clang] [Clang][Comments] Support for parsing headers in Doxygen \par commands (PR #91100)

2024-05-06 Thread Aaron Ballman via cfe-commits


@@ -149,6 +149,63 @@ class TextTokenRetokenizer {
 addToken();
   }
 
+  /// Check if this line starts with @par or \par
+  bool startsWithParCommand() {
+unsigned Offset = 1;
+
+/// Skip all whitespace characters at the beginning.
+/// This needs to backtrack because Pos has already advanced past the
+/// actual \par or @par command by the time this function is called.
+while (isWhitespace(*(Pos.BufferPtr - Offset)))
+  Offset++;
+
+/// Check if next four characters are \par or @par
+llvm::StringRef LineStart(Pos.BufferPtr - 5, 4);
+return LineStart.starts_with("\\par") || LineStart.starts_with("@par");
+  }
+
+  /// Extract a par command argument-header.
+  bool lexParHeading(Token &Tok) {
+if (isEnd())
+  return false;
+
+Position SavedPos = Pos;
+
+consumeWhitespace();
+SmallString<32> WordText;
+const char *WordBegin = Pos.BufferPtr;
+SourceLocation Loc = getSourceLocation();
+
+if (!startsWithParCommand())
+  return false;
+
+// Read until the end of this token, which is effectively the end of the
+// line This gets us the content of the par header, if there is one.
+while (!isEnd()) {
+  WordText.push_back(peek());
+  if (Pos.BufferPtr + 1 == Pos.BufferEnd) {
+consumeChar();
+break;
+  } else {
+consumeChar();
+  }

AaronBallman wrote:

```suggestion
  }
  consumeChar();
```
No need for an `else` because we'd have broken out of the loop if we entered 
the `if`.

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


[clang] [Clang][Comments] Support for parsing headers in Doxygen \par commands (PR #91100)

2024-05-06 Thread Aaron Ballman via cfe-commits


@@ -149,6 +149,63 @@ class TextTokenRetokenizer {
 addToken();
   }
 
+  /// Check if this line starts with @par or \par
+  bool startsWithParCommand() {
+unsigned Offset = 1;
+
+/// Skip all whitespace characters at the beginning.
+/// This needs to backtrack because Pos has already advanced past the
+/// actual \par or @par command by the time this function is called.
+while (isWhitespace(*(Pos.BufferPtr - Offset)))
+  Offset++;

AaronBallman wrote:

You can use `StringRef::ltrim()` to handle this instead of doing it manually.

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


[clang] [Clang][Comments] Support for parsing headers in Doxygen \par commands (PR #91100)

2024-05-06 Thread Aaron Ballman via cfe-commits


@@ -304,6 +361,23 @@ Parser::parseCommandArgs(TextTokenRetokenizer 
&Retokenizer, unsigned NumArgs) {
   return llvm::ArrayRef(Args, ParsedArgs);
 }
 
+ArrayRef
+Parser::parseParCommandArgs(TextTokenRetokenizer &Retokenizer,
+unsigned NumArgs) {

AaronBallman wrote:

Can we assert that `NumArgs > 0`?

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


[clang] [Clang][Comments] Support for parsing headers in Doxygen \par commands (PR #91100)

2024-05-06 Thread Aaron Ballman via cfe-commits


@@ -149,6 +149,63 @@ class TextTokenRetokenizer {
 addToken();
   }
 
+  /// Check if this line starts with @par or \par
+  bool startsWithParCommand() {
+unsigned Offset = 1;
+
+/// Skip all whitespace characters at the beginning.
+/// This needs to backtrack because Pos has already advanced past the
+/// actual \par or @par command by the time this function is called.
+while (isWhitespace(*(Pos.BufferPtr - Offset)))
+  Offset++;
+
+/// Check if next four characters are \par or @par
+llvm::StringRef LineStart(Pos.BufferPtr - 5, 4);
+return LineStart.starts_with("\\par") || LineStart.starts_with("@par");
+  }
+
+  /// Extract a par command argument-header.
+  bool lexParHeading(Token &Tok) {
+if (isEnd())
+  return false;
+
+Position SavedPos = Pos;
+
+consumeWhitespace();
+SmallString<32> WordText;
+const char *WordBegin = Pos.BufferPtr;
+SourceLocation Loc = getSourceLocation();
+
+if (!startsWithParCommand())
+  return false;
+
+// Read until the end of this token, which is effectively the end of the
+// line This gets us the content of the par header, if there is one.
+while (!isEnd()) {
+  WordText.push_back(peek());
+  if (Pos.BufferPtr + 1 == Pos.BufferEnd) {
+consumeChar();
+break;
+  } else {
+consumeChar();
+  }
+}
+
+const unsigned Length = WordText.size();

AaronBallman wrote:

```suggestion
unsigned Length = WordText.size();
```
(We don't really use top-level `const`.)

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


[clang] [Clang] Implement __reference_converts_from_temporary (PR #91199)

2024-05-06 Thread via cfe-commits


@@ -1779,9 +1779,8 @@ void Parser::ParseClassSpecifier(tok::TokenKind 
TagTokKind,
   tok::kw___is_union,
   tok::kw___is_unsigned,
   tok::kw___is_void,
-  tok::kw___is_volatile,
-  tok::kw___reference_binds_to_temporary,
-  tok::kw___reference_constructs_from_temporary))
+  tok::kw___is_volatile

cor3ntin wrote:

As they are new names, they were never structs. So there is no need for 
compatibility for old standard libraries.

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


[clang] [Clang] Implement __reference_converts_from_temporary (PR #91199)

2024-05-06 Thread Erich Keane via cfe-commits


@@ -1779,9 +1779,8 @@ void Parser::ParseClassSpecifier(tok::TokenKind 
TagTokKind,
   tok::kw___is_union,
   tok::kw___is_unsigned,
   tok::kw___is_void,
-  tok::kw___is_volatile,
-  tok::kw___reference_binds_to_temporary,
-  tok::kw___reference_constructs_from_temporary))
+  tok::kw___is_volatile

erichkeane wrote:

Ah, so was here unintentionally/without good reason?  I guess that makes sense. 
 SGTM.

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


[clang] Don't wrap immediate invocations in ConstantExprs within constexpr initializers (PR #89565)

2024-05-06 Thread via cfe-commits

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

LGTM too

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


[clang] [clang-format] Add option to remove leading blank lines (PR #91221)

2024-05-06 Thread via cfe-commits

https://github.com/sstwcw created 
https://github.com/llvm/llvm-project/pull/91221

None

>From 72e15ffb87eff94d51af69c0f804084ab7abe474 Mon Sep 17 00:00:00 2001
From: sstwcw 
Date: Mon, 6 May 2024 14:34:08 +
Subject: [PATCH] [clang-format] Add option to remove leading blank lines

---
 clang/docs/ClangFormatStyleOptions.rst  | 5 +
 clang/include/clang/Format/Format.h | 5 +
 clang/lib/Format/ContinuationIndenter.cpp   | 3 +++
 clang/lib/Format/Format.cpp | 2 ++
 clang/lib/Format/UnwrappedLineFormatter.cpp | 4 +++-
 clang/unittests/Format/ConfigParseTest.cpp  | 1 +
 clang/unittests/Format/FormatTest.cpp   | 7 +++
 7 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index ce9035a2770eec..c81de131f050c1 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -4406,6 +4406,11 @@ the configuration (without a prefix: ``Auto``).
 **KeepEmptyLinesAtEOF** (``Boolean``) :versionbadge:`clang-format 17` :ref:`¶ 
`
   Keep empty lines (up to ``MaxEmptyLinesToKeep``) at end of file.
 
+.. _KeepEmptyLinesAtStart:
+
+**KeepEmptyLinesAtStart** (``Boolean``) :versionbadge:`clang-format 19` 
:ref:`¶ `
+  Keep empty lines (up to ``MaxEmptyLinesToKeep``) at start of file.
+
 .. _KeepEmptyLinesAtTheStartOfBlocks:
 
 **KeepEmptyLinesAtTheStartOfBlocks** (``Boolean``) :versionbadge:`clang-format 
3.7` :ref:`¶ `
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 8ebdc86b98329c..9a7837b1bac2d2 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -3061,6 +3061,10 @@ struct FormatStyle {
   /// \version 17
   bool KeepEmptyLinesAtEOF;
 
+  /// Keep empty lines (up to ``MaxEmptyLinesToKeep``) at start of file.
+  /// \version 19
+  bool KeepEmptyLinesAtStart;
+
   /// If true, the empty line at the start of blocks is kept.
   /// \code
   ///true:  false:
@@ -4994,6 +4998,7 @@ struct FormatStyle {
JavaScriptQuotes == R.JavaScriptQuotes &&
JavaScriptWrapImports == R.JavaScriptWrapImports &&
KeepEmptyLinesAtEOF == R.KeepEmptyLinesAtEOF &&
+   KeepEmptyLinesAtStart == R.KeepEmptyLinesAtStart &&
KeepEmptyLinesAtTheStartOfBlocks ==
R.KeepEmptyLinesAtTheStartOfBlocks &&
Language == R.Language &&
diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index ad0e2c3c620c32..33dca7b08f998d 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -208,6 +208,9 @@ RawStringFormatStyleManager::RawStringFormatStyleManager(
   LanguageStyle = PredefinedStyle;
 }
 LanguageStyle->ColumnLimit = CodeStyle.ColumnLimit;
+// This way the first line of the string does not have to follow the code
+// before the string.
+LanguageStyle->KeepEmptyLinesAtStart = true;
 for (StringRef Delimiter : RawStringFormat.Delimiters)
   DelimiterStyle.insert({Delimiter, *LanguageStyle});
 for (StringRef EnclosingFunction : RawStringFormat.EnclosingFunctions)
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index c8d8ec3afbd990..31ffbf46cdd085 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1003,6 +1003,7 @@ template <> struct MappingTraits {
 IO.mapOptional("KeepEmptyLinesAtTheStartOfBlocks",
Style.KeepEmptyLinesAtTheStartOfBlocks);
 IO.mapOptional("KeepEmptyLinesAtEOF", Style.KeepEmptyLinesAtEOF);
+IO.mapOptional("KeepEmptyLinesAtStart", Style.KeepEmptyLinesAtStart);
 IO.mapOptional("LambdaBodyIndentation", Style.LambdaBodyIndentation);
 IO.mapOptional("LineEnding", Style.LineEnding);
 IO.mapOptional("MacroBlockBegin", Style.MacroBlockBegin);
@@ -1513,6 +1514,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.JavaScriptQuotes = FormatStyle::JSQS_Leave;
   LLVMStyle.JavaScriptWrapImports = true;
   LLVMStyle.KeepEmptyLinesAtEOF = false;
+  LLVMStyle.KeepEmptyLinesAtStart = true;
   LLVMStyle.KeepEmptyLinesAtTheStartOfBlocks = true;
   LLVMStyle.LambdaBodyIndentation = FormatStyle::LBI_Signature;
   LLVMStyle.Language = Language;
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 4ae54e56331bdc..b8485ae2b91975 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1473,8 +1473,10 @@ static auto computeNewlines(const AnnotatedLine &Line,
 Newlines = std::min(Newlines, 1u);
   if (Newlines == 0 && !RootToken.IsFirst)
 Newlines = 1;
-  if (RootToken.IsFirst && !RootToken.HasUnescapedNewline)
+  if (RootToken.IsFirst &&
+  (!Style.KeepEmptyLinesAtStart || !RootToken.HasUnescapedNewline)) {
 Newlines = 0;
+  }
 
   

[clang] [clang-format] Add option to remove leading blank lines (PR #91221)

2024-05-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (sstwcw)


Changes



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


7 Files Affected:

- (modified) clang/docs/ClangFormatStyleOptions.rst (+5) 
- (modified) clang/include/clang/Format/Format.h (+5) 
- (modified) clang/lib/Format/ContinuationIndenter.cpp (+3) 
- (modified) clang/lib/Format/Format.cpp (+2) 
- (modified) clang/lib/Format/UnwrappedLineFormatter.cpp (+3-1) 
- (modified) clang/unittests/Format/ConfigParseTest.cpp (+1) 
- (modified) clang/unittests/Format/FormatTest.cpp (+7) 


``diff
diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index ce9035a2770eec..c81de131f050c1 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -4406,6 +4406,11 @@ the configuration (without a prefix: ``Auto``).
 **KeepEmptyLinesAtEOF** (``Boolean``) :versionbadge:`clang-format 17` :ref:`¶ 
`
   Keep empty lines (up to ``MaxEmptyLinesToKeep``) at end of file.
 
+.. _KeepEmptyLinesAtStart:
+
+**KeepEmptyLinesAtStart** (``Boolean``) :versionbadge:`clang-format 19` 
:ref:`¶ `
+  Keep empty lines (up to ``MaxEmptyLinesToKeep``) at start of file.
+
 .. _KeepEmptyLinesAtTheStartOfBlocks:
 
 **KeepEmptyLinesAtTheStartOfBlocks** (``Boolean``) :versionbadge:`clang-format 
3.7` :ref:`¶ `
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 8ebdc86b98329c..9a7837b1bac2d2 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -3061,6 +3061,10 @@ struct FormatStyle {
   /// \version 17
   bool KeepEmptyLinesAtEOF;
 
+  /// Keep empty lines (up to ``MaxEmptyLinesToKeep``) at start of file.
+  /// \version 19
+  bool KeepEmptyLinesAtStart;
+
   /// If true, the empty line at the start of blocks is kept.
   /// \code
   ///true:  false:
@@ -4994,6 +4998,7 @@ struct FormatStyle {
JavaScriptQuotes == R.JavaScriptQuotes &&
JavaScriptWrapImports == R.JavaScriptWrapImports &&
KeepEmptyLinesAtEOF == R.KeepEmptyLinesAtEOF &&
+   KeepEmptyLinesAtStart == R.KeepEmptyLinesAtStart &&
KeepEmptyLinesAtTheStartOfBlocks ==
R.KeepEmptyLinesAtTheStartOfBlocks &&
Language == R.Language &&
diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index ad0e2c3c620c32..33dca7b08f998d 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -208,6 +208,9 @@ RawStringFormatStyleManager::RawStringFormatStyleManager(
   LanguageStyle = PredefinedStyle;
 }
 LanguageStyle->ColumnLimit = CodeStyle.ColumnLimit;
+// This way the first line of the string does not have to follow the code
+// before the string.
+LanguageStyle->KeepEmptyLinesAtStart = true;
 for (StringRef Delimiter : RawStringFormat.Delimiters)
   DelimiterStyle.insert({Delimiter, *LanguageStyle});
 for (StringRef EnclosingFunction : RawStringFormat.EnclosingFunctions)
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index c8d8ec3afbd990..31ffbf46cdd085 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1003,6 +1003,7 @@ template <> struct MappingTraits {
 IO.mapOptional("KeepEmptyLinesAtTheStartOfBlocks",
Style.KeepEmptyLinesAtTheStartOfBlocks);
 IO.mapOptional("KeepEmptyLinesAtEOF", Style.KeepEmptyLinesAtEOF);
+IO.mapOptional("KeepEmptyLinesAtStart", Style.KeepEmptyLinesAtStart);
 IO.mapOptional("LambdaBodyIndentation", Style.LambdaBodyIndentation);
 IO.mapOptional("LineEnding", Style.LineEnding);
 IO.mapOptional("MacroBlockBegin", Style.MacroBlockBegin);
@@ -1513,6 +1514,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.JavaScriptQuotes = FormatStyle::JSQS_Leave;
   LLVMStyle.JavaScriptWrapImports = true;
   LLVMStyle.KeepEmptyLinesAtEOF = false;
+  LLVMStyle.KeepEmptyLinesAtStart = true;
   LLVMStyle.KeepEmptyLinesAtTheStartOfBlocks = true;
   LLVMStyle.LambdaBodyIndentation = FormatStyle::LBI_Signature;
   LLVMStyle.Language = Language;
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 4ae54e56331bdc..b8485ae2b91975 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1473,8 +1473,10 @@ static auto computeNewlines(const AnnotatedLine &Line,
 Newlines = std::min(Newlines, 1u);
   if (Newlines == 0 && !RootToken.IsFirst)
 Newlines = 1;
-  if (RootToken.IsFirst && !RootToken.HasUnescapedNewline)
+  if (RootToken.IsFirst &&
+  (!Style.KeepEmptyLinesAtStart || !RootToken.HasUnescapedNewline)) {
 Newlines = 0;
+  }
 
   // Remove empty lines after "{".
   if (!Style.KeepEmptyLinesAtTheStartOfBlocks && PreviousLine &&
diff --git a/clang/unittest

[clang] [clang-format] Add option to remove leading blank lines (PR #91221)

2024-05-06 Thread via cfe-commits

sstwcw wrote:

Should I make dropping leading blank lines the default?

There are some tests verifying that files that start with newlines should still 
start with newlines after being formatted.  However, they seem to be there to 
prevent the newlines from moving to wrong places.

There is 303baf53b1 "skip empty lines and comments in the top of the code when 
inserting new headers".

```C++
  std::string Code = "\nint x;";
  std::string Expected = "\n#include \"fix.h\"\n"
 "#include \"a.h\"\n"
 "#include \"b.h\"\n"
 "#include \"c.h\"\n"
 "#include \n"
 "#include \n"
 "int x;";
  tooling::Replacements Replaces = toReplacements(
  {createInsertion("#include \"a.h\""), createInsertion("#include \"c.h\""),
   createInsertion("#include \"b.h\""),
   createInsertion("#include "), createInsertion("#include "),
   createInsertion("#include \"fix.h\"")});
  EXPECT_EQ(Expected, formatAndApply(Code, Replaces));
```

There is also a test for preserving the byte order mark.

```C++
  verifyFormat("\xef\xbb\xbf\n#include ");
```

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


[clang] [llvm] [RISCV] Teach .option arch to support experimental extensions. (PR #89727)

2024-05-06 Thread Paul T Robinson via cfe-commits

pogo59 wrote:

Driver tests are supposed to verify Driver behavior. That is, use `-###` and 
make sure the correct option is being passed down to the compiler. They should 
not be compiling anything.

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


[clang] [Clang][Sema] Explicit template arguments are not substituted into the exception specification of a function (PR #90760)

2024-05-06 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll commented:

DR tests changes LGTM

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


[clang] [llvm] [DirectX][DXIL] Set DXIL Version in DXIL target triple based on shader model version (PR #90809)

2024-05-06 Thread S. Bharadwaj Yadavalli via cfe-commits

https://github.com/bharadwajy updated 
https://github.com/llvm/llvm-project/pull/90809

>From 1b6bb5bf115c9f72adde27b6d77d957edbc49321 Mon Sep 17 00:00:00 2001
From: Bharadwaj Yadavalli 
Date: Wed, 1 May 2024 14:42:42 -0400
Subject: [PATCH 1/2] Set DXIL Version in DXIL target triple based on shader
 model version a) specified as compilation target profile or b) specified as
 target triple string

Update relevant HLSL tests that check for target triple.
Update one MIR test to reflect use of normalized target triple.
---
 clang/lib/Basic/Targets.cpp   |  2 +-
 clang/lib/Driver/ToolChains/HLSL.cpp  | 44 +-
 clang/lib/Frontend/CompilerInvocation.cpp |  7 +--
 clang/test/CodeGenHLSL/basic-target.c |  2 +-
 clang/test/Driver/dxc_dxv_path.hlsl   |  6 +--
 .../enable_16bit_types_validation.hlsl|  4 +-
 clang/unittests/Driver/DXCModeTest.cpp| 22 -
 llvm/include/llvm/TargetParser/Triple.h   |  1 +
 llvm/lib/CodeGen/CommandFlags.cpp |  2 +-
 llvm/lib/IR/Verifier.cpp  |  4 +-
 llvm/lib/TargetParser/Triple.cpp  | 45 +++
 .../mir/infer-triple-unknown-target.mir   |  2 +-
 llvm/tools/opt/optdriver.cpp  |  2 +-
 13 files changed, 116 insertions(+), 27 deletions(-)

diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index e3283510c6aac7..dc1792b3471e6c 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -760,7 +760,7 @@ using namespace clang::targets;
 TargetInfo *
 TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags,
  const std::shared_ptr &Opts) {
-  llvm::Triple Triple(Opts->Triple);
+  llvm::Triple Triple(llvm::Triple::normalize(Opts->Triple));
 
   // Construct the target
   std::unique_ptr Target = AllocateTarget(Triple, *Opts);
diff --git a/clang/lib/Driver/ToolChains/HLSL.cpp 
b/clang/lib/Driver/ToolChains/HLSL.cpp
index 1169b5d8c92dd6..c4c92613f44723 100644
--- a/clang/lib/Driver/ToolChains/HLSL.cpp
+++ b/clang/lib/Driver/ToolChains/HLSL.cpp
@@ -98,9 +98,49 @@ std::optional tryParseProfile(StringRef 
Profile) {
   else if (llvm::getAsUnsignedInteger(Parts[2], 0, Minor))
 return std::nullopt;
 
-  // dxil-unknown-shadermodel-hull
+  // Determine DXIL version using the minor version number of Shader
+  // Model version specified in target profile. Prior to decoupling DXIL 
version
+  // numbering from that of Shader Model DXIL version 1.Y corresponds to SM 
6.Y.
+  // E.g., dxilv1.Y-unknown-shadermodelX.Y-hull
   llvm::Triple T;
-  T.setArch(Triple::ArchType::dxil);
+  Triple::SubArchType SubArch = llvm::Triple::NoSubArch;
+  switch (Minor) {
+  case 0:
+SubArch = llvm::Triple::DXILSubArch_v1_0;
+break;
+  case 1:
+SubArch = llvm::Triple::DXILSubArch_v1_1;
+break;
+  case 2:
+SubArch = llvm::Triple::DXILSubArch_v1_2;
+break;
+  case 3:
+SubArch = llvm::Triple::DXILSubArch_v1_3;
+break;
+  case 4:
+SubArch = llvm::Triple::DXILSubArch_v1_4;
+break;
+  case 5:
+SubArch = llvm::Triple::DXILSubArch_v1_5;
+break;
+  case 6:
+SubArch = llvm::Triple::DXILSubArch_v1_6;
+break;
+  case 7:
+SubArch = llvm::Triple::DXILSubArch_v1_7;
+break;
+  case 8:
+SubArch = llvm::Triple::DXILSubArch_v1_8;
+break;
+  case OfflineLibMinor:
+// Always consider minor version x as the latest supported DXIL version
+SubArch = llvm::Triple::LatestDXILSubArch;
+break;
+  default:
+// No DXIL Version corresponding to specified Shader Model version found
+return std::nullopt;
+  }
+  T.setArch(Triple::ArchType::dxil, SubArch);
   T.setOSName(Triple::getOSTypeName(Triple::OSType::ShaderModel).str() +
   VersionTuple(Major, Minor).getAsString());
   T.setEnvironment(Kind);
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 8312abc3603953..a2600174e02296 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -587,7 +587,8 @@ static bool FixupInvocation(CompilerInvocation &Invocation,
   LangOpts.SpeculativeLoadHardening = CodeGenOpts.SpeculativeLoadHardening;
   LangOpts.CurrentModule = LangOpts.ModuleName;
 
-  llvm::Triple T(TargetOpts.Triple);
+  llvm::Triple T(llvm::Triple::normalize(TargetOpts.Triple));
+
   llvm::Triple::ArchType Arch = T.getArch();
 
   CodeGenOpts.CodeModel = TargetOpts.CodeModel;
@@ -4675,7 +4676,7 @@ bool CompilerInvocation::CreateFromArgsImpl(
   // FIXME: We shouldn't have to pass the DashX option around here
   InputKind DashX = Res.getFrontendOpts().DashX;
   ParseTargetArgs(Res.getTargetOpts(), Args, Diags);
-  llvm::Triple T(Res.getTargetOpts().Triple);
+  llvm::Triple T(llvm::Triple::normalize(Res.getTargetOpts().Triple));
   ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), Args, Diags,
 Res.getFileSystemOpts().WorkingDir);
   ParseAPINotesArgs

[clang] [clang][dataflow] Strengthen pointer comparison. (PR #75170)

2024-05-06 Thread Gábor Horváth via cfe-commits

https://github.com/Xazax-hun approved this pull request.


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


[clang] [llvm] [DirectX][DXIL] Set DXIL Version in DXIL target triple based on shader model version (PR #90809)

2024-05-06 Thread S. Bharadwaj Yadavalli via cfe-commits


@@ -1200,6 +1224,27 @@ std::string Triple::normalize(StringRef Str) {
 }
   }
 
+  // Normalize DXIL triple if it does not include DXIL version number.
+  // Determine DXIL version number using the minor version number of Shader
+  // Model version specified in target triple, if any. Prior to decoupling DXIL
+  // version numbering from that of Shader Model DXIL version 1.Y corresponds 
to
+  // SM 6.Y. E.g., dxilv1.Y-unknown-shadermodelX.Y-hull
+  if (Components[0] == "dxil") {
+std::string DXILVerStr{"dxilv1."};
+if (Components.size() > 2) {
+  // OS component specified
+  if (Components[2].starts_with("shadermodel6.")) {
+Components[0] = DXILVerStr.append(
+Components[2].drop_front(strlen("shadermodel6.")));
+  } else if (Components[2].starts_with("shadermodel")) {
+// If shader model specified is other than 6.x, set DXIL Version to 1.0
+Components[0] = DXILVerStr.append("0");
+  }
+}

bharadwajy wrote:

The function `normalize` does not parse for `SubArch`. So, `SubArch` is not 
available  for checking.

An input DXIL triple string `Str` with or without version (e.g., 
`dxil-pc-shadermodel6.3` or `dxilv1.3-pc-shadermodel6.3` will set `Arch` to 
`Triple::dxil`. Implicit deduction and insertion of DXIL version should be done 
only is `Component[0] == "dxil"` and not otherwise. Hence the string 
equivalence check for "dxil" and not for `Arch == Triple::dxil`.

However, made code changes to leverage Arch and OS values already parsed as 
suggested. A couple of additional sanity checks are also added.


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


[clang] [llvm] [DirectX][DXIL] Set DXIL Version in DXIL target triple based on shader model version (PR #90809)

2024-05-06 Thread S. Bharadwaj Yadavalli via cfe-commits


@@ -1200,6 +1224,27 @@ std::string Triple::normalize(StringRef Str) {
 }
   }
 
+  // Normalize DXIL triple if it does not include DXIL version number.
+  // Determine DXIL version number using the minor version number of Shader
+  // Model version specified in target triple, if any. Prior to decoupling DXIL
+  // version numbering from that of Shader Model DXIL version 1.Y corresponds 
to
+  // SM 6.Y. E.g., dxilv1.Y-unknown-shadermodelX.Y-hull
+  if (Components[0] == "dxil") {
+std::string DXILVerStr{"dxilv1."};
+if (Components.size() > 2) {
+  // OS component specified
+  if (Components[2].starts_with("shadermodel6.")) {
+Components[0] = DXILVerStr.append(
+Components[2].drop_front(strlen("shadermodel6.")));
+  } else if (Components[2].starts_with("shadermodel")) {
+// If shader model specified is other than 6.x, set DXIL Version to 1.0
+Components[0] = DXILVerStr.append("0");
+  }
+}
+// DXIL version is not set for a non-specified OS string or one that does
+// not starts with shadermodel.
+  }
+

bharadwajy wrote:

> We should add unit tests to test the normalization.

Additional unit tests added.

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


[clang] [llvm] [DirectX][DXIL] Set DXIL Version in DXIL target triple based on shader model version (PR #90809)

2024-05-06 Thread S. Bharadwaj Yadavalli via cfe-commits

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


[clang] [clang][dataflow] Strengthen pointer comparison. (PR #75170)

2024-05-06 Thread Gábor Horváth via cfe-commits

Xazax-hun wrote:

> In summary, if the storage locations for two pointers are the same, we can 
> return a true literal for the comparison, but if the storage locations are 
> different, we need to return an atom.

I am wondering, if it would make sense to "fix up" the state when we discover 
aliasing? I.e., "merging" the two storage locations. Consider:

```
void f(MyBoolPair* a, MyBoolPair *b) {
  if (a == b && a->first && !b->second)
  {
// Here, we should know: a->first == b->first == true and a->second == 
b->second == false
  } 
}
```

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


  1   2   3   4   >