[clang] bce8b3c - [clang][Interp] Implement C++ Range-for loops

2023-03-02 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-03-02T08:59:07+01:00
New Revision: bce8b3c1830434c10b8a30380db522d7c6a8658d

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

LOG: [clang][Interp] Implement C++ Range-for loops

Differential Revision: https://reviews.llvm.org/D140803

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeStmtGen.cpp
clang/lib/AST/Interp/ByteCodeStmtGen.h
clang/test/AST/Interp/loops.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp 
b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
index ff2727cc4d35..80a81c67df40 100644
--- a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -172,6 +172,8 @@ bool ByteCodeStmtGen::visitStmt(const Stmt *S) {
 return visitDoStmt(cast(S));
   case Stmt::ForStmtClass:
 return visitForStmt(cast(S));
+  case Stmt::CXXForRangeStmtClass:
+return visitCXXForRangeStmt(cast(S));
   case Stmt::BreakStmtClass:
 return visitBreakStmt(cast(S));
   case Stmt::ContinueStmtClass:
@@ -369,6 +371,56 @@ bool ByteCodeStmtGen::visitForStmt(const ForStmt 
*S) {
   return true;
 }
 
+template 
+bool ByteCodeStmtGen::visitCXXForRangeStmt(const CXXForRangeStmt *S) {
+  const Stmt *Init = S->getInit();
+  const Expr *Cond = S->getCond();
+  const Expr *Inc = S->getInc();
+  const Stmt *Body = S->getBody();
+  const Stmt *BeginStmt = S->getBeginStmt();
+  const Stmt *RangeStmt = S->getRangeStmt();
+  const Stmt *EndStmt = S->getEndStmt();
+  const VarDecl *LoopVar = S->getLoopVariable();
+
+  LabelTy EndLabel = this->getLabel();
+  LabelTy CondLabel = this->getLabel();
+  LabelTy IncLabel = this->getLabel();
+  ExprScope ES(this);
+  LoopScope LS(this, EndLabel, IncLabel);
+
+  // Emit declarations needed in the loop.
+  if (Init && !this->visitStmt(Init))
+return false;
+  if (!this->visitStmt(RangeStmt))
+return false;
+  if (!this->visitStmt(BeginStmt))
+return false;
+  if (!this->visitStmt(EndStmt))
+return false;
+
+  // Now the condition as well as the loop variable assignment.
+  this->emitLabel(CondLabel);
+  if (!this->visitBool(Cond))
+return false;
+  if (!this->jumpFalse(EndLabel))
+return false;
+
+  if (!this->visitVarDecl(LoopVar))
+return false;
+
+  // Body.
+  if (!this->visitStmt(Body))
+return false;
+  this->emitLabel(IncLabel);
+  if (!this->discard(Inc))
+return false;
+  if (!this->jump(CondLabel))
+return false;
+
+  this->emitLabel(EndLabel);
+  return true;
+}
+
 template 
 bool ByteCodeStmtGen::visitBreakStmt(const BreakStmt *S) {
   if (!BreakLabel)

diff  --git a/clang/lib/AST/Interp/ByteCodeStmtGen.h 
b/clang/lib/AST/Interp/ByteCodeStmtGen.h
index 7a30f7b69470..6b3644ad1346 100644
--- a/clang/lib/AST/Interp/ByteCodeStmtGen.h
+++ b/clang/lib/AST/Interp/ByteCodeStmtGen.h
@@ -60,6 +60,7 @@ class ByteCodeStmtGen final : public ByteCodeExprGen 
{
   bool visitWhileStmt(const WhileStmt *S);
   bool visitDoStmt(const DoStmt *S);
   bool visitForStmt(const ForStmt *S);
+  bool visitCXXForRangeStmt(const CXXForRangeStmt *S);
   bool visitBreakStmt(const BreakStmt *S);
   bool visitContinueStmt(const ContinueStmt *S);
   bool visitSwitchStmt(const SwitchStmt *S);

diff  --git a/clang/test/AST/Interp/loops.cpp b/clang/test/AST/Interp/loops.cpp
index d0386e3ac759..2e235123af76 100644
--- a/clang/test/AST/Interp/loops.cpp
+++ b/clang/test/AST/Interp/loops.cpp
@@ -3,10 +3,6 @@
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++20 
-verify=expected-cpp20 %s
 // RUN: %clang_cc1 -std=c++20 -verify=ref %s
 
-// ref-no-diagnostics
-// expected-no-diagnostics
-// expected-cpp20-no-diagnostics
-
 namespace WhileLoop {
   constexpr int f() {
 int i = 0;
@@ -274,3 +270,57 @@ namespace ForLoop {
 #endif
 
 };
+
+namespace RangeForLoop {
+  constexpr int localArray() {
+int a[] = {1,2,3,4};
+int s = 0;
+for(int i : a) {
+  s += i;
+}
+return s;
+  }
+  static_assert(localArray() == 10, "");
+
+  constexpr int localArray2() {
+int a[] = {1,2,3,4};
+int s = 0;
+for(const int &i : a) {
+  s += i;
+}
+return s;
+  }
+  static_assert(localArray2() == 10, "");
+
+  constexpr int nested() {
+int s = 0;
+for (const int i : (int[]){1,2,3,4}) {
+  int a[] = {i, i};
+  for(int m : a) {
+s += m;
+  }
+}
+return s;
+  }
+  static_assert(nested() == 20, "");
+
+  constexpr int withBreak() {
+int s = 0;
+for (const int &i: (bool[]){false, true}) {
+  if (i)
+break;
+  s++;
+}
+return s;
+  }
+  static_assert(withBreak() == 1, "");
+
+  constexpr void NoBody() {
+for (const int &i: (bool[]){false, true}); // expected-warning {{empty 
body}} \
+   // expected-note {{semicol

[PATCH] D140803: [clang][Interp] Implement C++ Range-for loops

2023-03-02 Thread Timm Bäder via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbce8b3c18304: [clang][Interp] Implement C++ Range-for loops 
(authored by tbaeder).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140803/new/

https://reviews.llvm.org/D140803

Files:
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/lib/AST/Interp/ByteCodeStmtGen.h
  clang/test/AST/Interp/loops.cpp

Index: clang/test/AST/Interp/loops.cpp
===
--- clang/test/AST/Interp/loops.cpp
+++ clang/test/AST/Interp/loops.cpp
@@ -3,10 +3,6 @@
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++20 -verify=expected-cpp20 %s
 // RUN: %clang_cc1 -std=c++20 -verify=ref %s
 
-// ref-no-diagnostics
-// expected-no-diagnostics
-// expected-cpp20-no-diagnostics
-
 namespace WhileLoop {
   constexpr int f() {
 int i = 0;
@@ -274,3 +270,57 @@
 #endif
 
 };
+
+namespace RangeForLoop {
+  constexpr int localArray() {
+int a[] = {1,2,3,4};
+int s = 0;
+for(int i : a) {
+  s += i;
+}
+return s;
+  }
+  static_assert(localArray() == 10, "");
+
+  constexpr int localArray2() {
+int a[] = {1,2,3,4};
+int s = 0;
+for(const int &i : a) {
+  s += i;
+}
+return s;
+  }
+  static_assert(localArray2() == 10, "");
+
+  constexpr int nested() {
+int s = 0;
+for (const int i : (int[]){1,2,3,4}) {
+  int a[] = {i, i};
+  for(int m : a) {
+s += m;
+  }
+}
+return s;
+  }
+  static_assert(nested() == 20, "");
+
+  constexpr int withBreak() {
+int s = 0;
+for (const int &i: (bool[]){false, true}) {
+  if (i)
+break;
+  s++;
+}
+return s;
+  }
+  static_assert(withBreak() == 1, "");
+
+  constexpr void NoBody() {
+for (const int &i: (bool[]){false, true}); // expected-warning {{empty body}} \
+   // expected-note {{semicolon on a separate line}} \
+   // expected-cpp20-warning {{empty body}} \
+   // expected-cpp20-note {{semicolon on a separate line}} \
+   // ref-warning {{empty body}} \
+   // ref-note {{semicolon on a separate line}}
+  }
+}
Index: clang/lib/AST/Interp/ByteCodeStmtGen.h
===
--- clang/lib/AST/Interp/ByteCodeStmtGen.h
+++ clang/lib/AST/Interp/ByteCodeStmtGen.h
@@ -60,6 +60,7 @@
   bool visitWhileStmt(const WhileStmt *S);
   bool visitDoStmt(const DoStmt *S);
   bool visitForStmt(const ForStmt *S);
+  bool visitCXXForRangeStmt(const CXXForRangeStmt *S);
   bool visitBreakStmt(const BreakStmt *S);
   bool visitContinueStmt(const ContinueStmt *S);
   bool visitSwitchStmt(const SwitchStmt *S);
Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -172,6 +172,8 @@
 return visitDoStmt(cast(S));
   case Stmt::ForStmtClass:
 return visitForStmt(cast(S));
+  case Stmt::CXXForRangeStmtClass:
+return visitCXXForRangeStmt(cast(S));
   case Stmt::BreakStmtClass:
 return visitBreakStmt(cast(S));
   case Stmt::ContinueStmtClass:
@@ -369,6 +371,56 @@
   return true;
 }
 
+template 
+bool ByteCodeStmtGen::visitCXXForRangeStmt(const CXXForRangeStmt *S) {
+  const Stmt *Init = S->getInit();
+  const Expr *Cond = S->getCond();
+  const Expr *Inc = S->getInc();
+  const Stmt *Body = S->getBody();
+  const Stmt *BeginStmt = S->getBeginStmt();
+  const Stmt *RangeStmt = S->getRangeStmt();
+  const Stmt *EndStmt = S->getEndStmt();
+  const VarDecl *LoopVar = S->getLoopVariable();
+
+  LabelTy EndLabel = this->getLabel();
+  LabelTy CondLabel = this->getLabel();
+  LabelTy IncLabel = this->getLabel();
+  ExprScope ES(this);
+  LoopScope LS(this, EndLabel, IncLabel);
+
+  // Emit declarations needed in the loop.
+  if (Init && !this->visitStmt(Init))
+return false;
+  if (!this->visitStmt(RangeStmt))
+return false;
+  if (!this->visitStmt(BeginStmt))
+return false;
+  if (!this->visitStmt(EndStmt))
+return false;
+
+  // Now the condition as well as the loop variable assignment.
+  this->emitLabel(CondLabel);
+  if (!this->visitBool(Cond))
+return false;
+  if (!this->jumpFalse(EndLabel))
+return false;
+
+  if (!this->visitVarDecl(LoopVar))
+return false;
+
+  // Body.
+  if (!this->visitStmt(Body))
+return false;
+  this->emitLabel(IncLabel);
+  if (!this->discard(Inc))
+return false;
+  if (!this->jump(CondLabel))
+return false;
+
+  this->emitLabel(EndLabel);
+  return true;
+}
+
 template 
 bool ByteCodeStmtGen::visitBreakStmt(const BreakStmt *S) {
   if (!BreakLabel)

[clang] 569222e - [clang][Interp] Only check constructors for global variables

2023-03-02 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-03-02T09:13:47+01:00
New Revision: 569222e172e5d28d66e9607325475b107cee20cb

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

LOG: [clang][Interp] Only check constructors for global variables

Local variables may be partially initialized.

Differential Revision: https://reviews.llvm.org/D140723

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.h
clang/lib/AST/Interp/Interp.cpp
clang/lib/AST/Interp/Interp.h
clang/lib/AST/Interp/Opcodes.td
clang/test/AST/Interp/cxx20.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.h 
b/clang/lib/AST/Interp/ByteCodeExprGen.h
index 7b804b4cad3d..231f39ff8bd6 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -162,6 +162,9 @@ class ByteCodeExprGen : public 
ConstStmtVisitor, bool>,
 if (!visitInitializer(Init))
   return false;
 
+if (Init->getType()->isRecordType() && !this->emitCheckGlobalCtor(Init))
+  return false;
+
 return this->emitPopPtr(Init);
   }
 

diff  --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp
index 329cc0ff949d..554e9a8e2d20 100644
--- a/clang/lib/AST/Interp/Interp.cpp
+++ b/clang/lib/AST/Interp/Interp.cpp
@@ -431,6 +431,15 @@ static bool CheckFieldsInitialized(InterpState &S, CodePtr 
OpPC,
   Result = false;
 }
   }
+
+  // Check Fields in all bases
+  for (const Record::Base &B : R->bases()) {
+Pointer P = Pointer(BasePtr.block(), B.Offset);
+Result &= CheckFieldsInitialized(S, OpPC, P, B.R);
+  }
+
+  // TODO: Virtual bases
+
   return Result;
 }
 

diff  --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h
index 99c1bd58acd2..fbf74b54e330 100644
--- a/clang/lib/AST/Interp/Interp.h
+++ b/clang/lib/AST/Interp/Interp.h
@@ -1455,6 +1455,11 @@ inline bool ExpandPtr(InterpState &S, CodePtr OpPC) {
   return true;
 }
 
+inline bool CheckGlobalCtor(InterpState &S, CodePtr &PC) {
+  const Pointer &Obj = S.Stk.peek();
+  return CheckCtorCall(S, PC, Obj);
+}
+
 inline bool Call(InterpState &S, CodePtr &PC, const Function *Func) {
   auto NewFrame = std::make_unique(S, Func, PC);
   Pointer ThisPtr;
@@ -1480,11 +1485,6 @@ inline bool Call(InterpState &S, CodePtr &PC, const 
Function *Func) {
   if (Interpret(S, CallResult)) {
 NewFrame.release(); // Frame was delete'd already.
 assert(S.Current == FrameBefore);
-
-// For constructors, check that all fields have been initialized.
-if (Func->isConstructor() && !CheckCtorCall(S, PC, ThisPtr))
-  return false;
-
 return true;
   }
 

diff  --git a/clang/lib/AST/Interp/Opcodes.td b/clang/lib/AST/Interp/Opcodes.td
index d1ad7adc1edc..1e325055c417 100644
--- a/clang/lib/AST/Interp/Opcodes.td
+++ b/clang/lib/AST/Interp/Opcodes.td
@@ -328,6 +328,8 @@ def GetLocal : AccessOpcode { let HasCustomEval = 1; }
 // [] -> [Pointer]
 def SetLocal : AccessOpcode { let HasCustomEval = 1; }
 
+def CheckGlobalCtor : Opcode {}
+
 // [] -> [Value]
 def GetGlobal : AccessOpcode;
 // [Value] -> []

diff  --git a/clang/test/AST/Interp/cxx20.cpp b/clang/test/AST/Interp/cxx20.cpp
index 44c97dd1afcd..cc37722730fc 100644
--- a/clang/test/AST/Interp/cxx20.cpp
+++ b/clang/test/AST/Interp/cxx20.cpp
@@ -85,10 +85,11 @@ static_assert(initializedLocal2() == 20); // expected-error 
{{not an integral co
   // ref-note {{in call to}}
 
 
-struct Int { int a; }; // expected-note {{subobject declared here}}
+struct Int { int a; };
 constexpr int initializedLocal3() {
-  Int i; // expected-note {{subobject of type 'int' is not initialized}}
-  return i.a; // ref-note {{read of uninitialized object is not allowed in a 
constant expression}}
+  Int i;
+  return i.a; // ref-note {{read of uninitialized object is not allowed in a 
constant expression}} \
+  // expected-note {{read of object outside its lifetime}}
 }
 static_assert(initializedLocal3() == 20); // expected-error {{not an integral 
constant expression}} \
   // expected-note {{in call to}} \
@@ -157,21 +158,19 @@ namespace UninitializedFields {
 
   class Derived : public Base {
   public:
-constexpr Derived() : Base() {} // expected-note {{subobject of type 'int' 
is not initialized}}
-  };
+constexpr Derived() : Base() {}   };
 
-constexpr Derived D; // expected-error {{must be initialized by a constant 
expression}} \\
- // expected-note {{in call to 'Derived()'}} \
- // ref-error {{must be initialized by a constant 
expression}} \
- // ref-note {{subobject of type 'int' is not initialized}}
+  constexpr Derived D; // expected-error {{must be initialized by a constant 
expression}} \

[PATCH] D140723: [clang][Interp] Only check constructors for global variables

2023-03-02 Thread Timm Bäder via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG569222e172e5: [clang][Interp] Only check constructors for 
global variables (authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D140723?vs=485480&id=501770#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140723/new/

https://reviews.llvm.org/D140723

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/Interp.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/Opcodes.td
  clang/test/AST/Interp/cxx20.cpp

Index: clang/test/AST/Interp/cxx20.cpp
===
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -85,10 +85,11 @@
   // ref-note {{in call to}}
 
 
-struct Int { int a; }; // expected-note {{subobject declared here}}
+struct Int { int a; };
 constexpr int initializedLocal3() {
-  Int i; // expected-note {{subobject of type 'int' is not initialized}}
-  return i.a; // ref-note {{read of uninitialized object is not allowed in a constant expression}}
+  Int i;
+  return i.a; // ref-note {{read of uninitialized object is not allowed in a constant expression}} \
+  // expected-note {{read of object outside its lifetime}}
 }
 static_assert(initializedLocal3() == 20); // expected-error {{not an integral constant expression}} \
   // expected-note {{in call to}} \
@@ -157,21 +158,19 @@
 
   class Derived : public Base {
   public:
-constexpr Derived() : Base() {} // expected-note {{subobject of type 'int' is not initialized}}
-  };
+constexpr Derived() : Base() {}   };
 
-constexpr Derived D; // expected-error {{must be initialized by a constant expression}} \\
- // expected-note {{in call to 'Derived()'}} \
- // ref-error {{must be initialized by a constant expression}} \
- // ref-note {{subobject of type 'int' is not initialized}}
+  constexpr Derived D; // expected-error {{must be initialized by a constant expression}} \
+   // expected-note {{subobject of type 'int' is not initialized}} \
+   // ref-error {{must be initialized by a constant expression}} \
+   // ref-note {{subobject of type 'int' is not initialized}}
 
   class C2 {
   public:
 A a;
-constexpr C2() {} // expected-note {{subobject of type 'int' is not initialized}}
-  };
+constexpr C2() {}   };
   constexpr C2 c2; // expected-error {{must be initialized by a constant expression}} \
-   // expected-note {{in call to 'C2()'}} \
+   // expected-note {{subobject of type 'int' is not initialized}} \
// ref-error {{must be initialized by a constant expression}} \
// ref-note {{subobject of type 'int' is not initialized}}
 
Index: clang/lib/AST/Interp/Opcodes.td
===
--- clang/lib/AST/Interp/Opcodes.td
+++ clang/lib/AST/Interp/Opcodes.td
@@ -328,6 +328,8 @@
 // [] -> [Pointer]
 def SetLocal : AccessOpcode { let HasCustomEval = 1; }
 
+def CheckGlobalCtor : Opcode {}
+
 // [] -> [Value]
 def GetGlobal : AccessOpcode;
 // [Value] -> []
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -1455,6 +1455,11 @@
   return true;
 }
 
+inline bool CheckGlobalCtor(InterpState &S, CodePtr &PC) {
+  const Pointer &Obj = S.Stk.peek();
+  return CheckCtorCall(S, PC, Obj);
+}
+
 inline bool Call(InterpState &S, CodePtr &PC, const Function *Func) {
   auto NewFrame = std::make_unique(S, Func, PC);
   Pointer ThisPtr;
@@ -1480,11 +1485,6 @@
   if (Interpret(S, CallResult)) {
 NewFrame.release(); // Frame was delete'd already.
 assert(S.Current == FrameBefore);
-
-// For constructors, check that all fields have been initialized.
-if (Func->isConstructor() && !CheckCtorCall(S, PC, ThisPtr))
-  return false;
-
 return true;
   }
 
Index: clang/lib/AST/Interp/Interp.cpp
===
--- clang/lib/AST/Interp/Interp.cpp
+++ clang/lib/AST/Interp/Interp.cpp
@@ -431,6 +431,15 @@
   Result = false;
 }
   }
+
+  // Check Fields in all bases
+  for (const Record::Base &B : R->bases()) {
+Pointer P = Pointer(BasePtr.block(), B.Offset);
+Result &= CheckFieldsInitialized(S, OpPC, P, B.R);
+  }
+
+  // TODO: Virtual bases
+
   return Result;
 }
 
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -162,6 +162,9 @@
 if (!visitIniti

[PATCH] D143418: [libclang] Add API to override preamble storage path

2023-03-02 Thread Igor Kushnir via Phabricator via cfe-commits
vedgy added inline comments.



Comment at: clang/include/clang-c/Index.h:329
+ * CXIndexOptions Opts = { sizeof(CXIndexOptions),
+ * clang_getDefaultGlobalOptions() };
+ * \endcode

aaron.ballman wrote:
> vedgy wrote:
> > When I almost finished the requested changes, I remembered that the return 
> > value of `clang_getDefaultGlobalOptions()` depends on environment 
> > variables, and thus `0` is not necessarily the default. Adjusted the 
> > changes and updated this revision.
> > 
> > Does the extra requirement to non-zero initialize this second member sway 
> > your opinion on the usefulness of the helper function `inline 
> > CXIndexOptions clang_getDefaultIndexOptions()`? Note that there may be same 
> > (environment) or other important reasons why future new options couldn't be 
> > zeroes by default.
> Thinking out loud a bit... (potentially bad idea incoming)
> 
> What if we dropped `clang_getDefaultGlobalOptions()` and instead made a 
> change to `CXGlobalOptFlags`:
> ```
> typedef enum {
>   /**
>* Used to indicate that the default CXIndex options are used. By default, 
> no
>* global options will be used. However, environment variables may change 
> which
>* global options are in effect at runtime.
>*/
>   CXGlobalOpt_Default = 0x0,
> 
>   /**
>* Used to indicate that threads that libclang creates for indexing
>* purposes should use background priority.
>*
>* Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
>* #clang_parseTranslationUnit, #clang_saveTranslationUnit.
>*/
>   CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
> 
>   /**
>* Used to indicate that threads that libclang creates for editing
>* purposes should use background priority.
>*
>* Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
>* #clang_annotateTokens
>*/
>   CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
> 
>   /**
>* Used to indicate that all threads that libclang creates should use
>* background priority.
>*/
>   CXGlobalOpt_ThreadBackgroundPriorityForAll =
>   CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
>   CXGlobalOpt_ThreadBackgroundPriorityForEditing,
> 
>   /**
>* Used to indicate that no global options should be used, even
>* in the presence of environment variables.
>*/
>   CXGlobalOpt_None = 0x
> } CXGlobalOptFlags;
> ```
> so that when the user passes `0` they get the previous behavior.
> 
> `clang_CXIndex_setGlobalOptions()` would remain deprecated. 
> `clang_CXIndex_getGlobalOptions()` would be interesting though -- would it 
> return `CXGlobalOpt_None` or `CXGlobalOpt_Default` in the event the index was 
> created without any global options? Hmmm.
> 
> Err, actually, I suppose this won't work too well because then code silently 
> changes behavior if it does 
> `clang_CXIndex_setGlobalOptions(CXGlobalOpt_None);` because that would change 
> from "do what the environment says" to "ignore the environment". But I have 
> to wonder whether anyone actually *does* that or not... my intuition is that 
> folks would not call `clang_CXIndex_setGlobalOptions()` at all unless they 
> were setting an option to a non-none value. We could rename 
> `CXGlobalOpt_None` to `CXGlobalOpt_Nothing` (or something along those lines) 
> to force a compilation error, but that's a bit of a nuclear option for what's 
> supposed to be a stable API.
> 
> So I'm on the fence, I guess. I'd still prefer for zero to give sensible 
> defaults and I don't think there's enough use of the global options + 
> environment variables to matter. But I also don't like silently breaking 
> code, so my idea above may be a nonstarter.
> 
> I suppose another possible idea is: deprecate the notion of global options 
> enum and setter/getter entirely, add two new fields to `CXIndexOptions`:
> ```
> typedef enum {
>   CXChoice_Default = 0,
>   CXChoice_Enabled = 1,
>   CXChoice_Disabled = 2
> } CXChoice;
> 
> ...
> unsigned ThreadPriorityBackgroundForIndexing;
> unsigned ThreadPriorityBackgroundForEditing;
> ...
> ```
> so that `0` gives the correct default behavior based on environment variable. 
> There would be no global setter or getter for this information (and we'd 
> eventually remove `clang_CXIndex_[gs]etGlobalOptions()`).
> I suppose this won't work too well because then code silently changes 
> behavior if it does `clang_CXIndex_setGlobalOptions(CXGlobalOpt_None);` 
> because that would change from "do what the environment says" to "ignore the 
> environment".
No, the current consequence of such a call already is to ignore the 
environment. What would change is the consequence of calling 
`clang_CXIndex_setGlobalOptions(0);` - from "ignore the environment" to "do 
what the environment says".

> But I have to wonder whether anyone actually *does* that or not... my 
> intuition is that folks would not call `clang_CXIndex_setGlobalOptions()` at 
> all un

[PATCH] D144454: Add builtin for llvm set rounding

2023-03-02 Thread xiongji90 via Phabricator via cfe-commits
xiongji90 added a comment.

In D144454#4163688 , @rjmccall wrote:

> I see.  If we're going to take the target-independent values specified by 
> `FLT_ROUNDS`, then the original builtin name is more appropriate.  Of course, 
> this has the disadvantage of not allowing target-specific values that might 
> exist beyond those specified in the standard; are we pretty certain that's 
> not a problem in practice?
>
> Working on x86, ARM, and AArch64 is great, but I'm a little worried about 
> adding another builtin that works only on major targets and probably crashes 
> on others.  I suppose we've got some number of those already, though.

Hi, @rjmccall @sepavloff 
Which name do you prefer for this builtin? __builtin_flt_rounds_set or 
__builtin_set_flt_rounds?
Does LLVM have mechanism to restrict builtin to work only on specific targets? 
If not, can we check add target check code to guard just like: 
https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGBuiltin.cpp#LL4685C8-L4685C8
And although the builtin should work automatically for arm and aarch64, I 
didn't have environment to verify, can I enable it only for x86 currently?
Thanks very much.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144454/new/

https://reviews.llvm.org/D144454

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


[PATCH] D140805: [clang][Interp] Add ArrayElemPtr{,Pop} opcode

2023-03-02 Thread Timm Bäder via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6b5afda61c4a: [clang][Interp] Add ArrayElemPtr{,Pop} opcode 
(authored by tbaeder).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140805/new/

https://reviews.llvm.org/D140805

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/Opcodes.td

Index: clang/lib/AST/Interp/Opcodes.td
===
--- clang/lib/AST/Interp/Opcodes.td
+++ clang/lib/AST/Interp/Opcodes.td
@@ -306,6 +306,9 @@
 def NarrowPtr : Opcode;
 // [Pointer] -> [Pointer]
 def ExpandPtr : Opcode;
+// [Pointer, Offset] -> [Pointer]
+def ArrayElemPtr : AluOpcode;
+def ArrayElemPtrPop : AluOpcode;
 
 //===--===//
 // Direct field accessors
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -1455,6 +1455,36 @@
   return true;
 }
 
+// 1) Pops an integral value from the stack
+// 2) Peeks a pointer
+// 3) Pushes a new pointer that's a narrowed array
+//   element of the peeked pointer with the value
+//   from 1) added as offset.
+//
+// This leaves the original pointer on the stack and pushes a new one
+// with the offset applied and narrowed.
+template ::T>
+inline bool ArrayElemPtr(InterpState &S, CodePtr OpPC) {
+  const T &Offset = S.Stk.pop();
+  const Pointer &Ptr = S.Stk.peek();
+
+  if (!OffsetHelper(S, OpPC, Offset, Ptr))
+return false;
+
+  return NarrowPtr(S, OpPC);
+}
+
+template ::T>
+inline bool ArrayElemPtrPop(InterpState &S, CodePtr OpPC) {
+  const T &Offset = S.Stk.pop();
+  const Pointer &Ptr = S.Stk.pop();
+
+  if (!OffsetHelper(S, OpPC, Offset, Ptr))
+return false;
+
+  return NarrowPtr(S, OpPC);
+}
+
 inline bool CheckGlobalCtor(InterpState &S, CodePtr &PC) {
   const Pointer &Obj = S.Stk.peek();
   return CheckCtorCall(S, PC, Obj);
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -413,7 +413,7 @@
   const Expr *Index = E->getIdx();
   PrimType IndexT = classifyPrim(Index->getType());
 
-  // Take pointer of LHS, add offset from RHS, narrow result.
+  // Take pointer of LHS, add offset from RHS.
   // What's left on the stack after this is a pointer.
   if (!this->visit(Base))
 return false;
@@ -421,10 +421,7 @@
   if (!this->visit(Index))
 return false;
 
-  if (!this->emitAddOffset(IndexT, E))
-return false;
-
-  if (!this->emitNarrowPtr(E))
+  if (!this->emitArrayElemPtrPop(IndexT, E))
 return false;
 
   if (DiscardResult)
@@ -1214,16 +1211,11 @@
   return false;
   } else {
 // Advance the pointer currently on the stack to the given
-// dimension and narrow().
-if (!this->emitDupPtr(Init))
-  return false;
+// dimension.
 if (!this->emitConstUint32(ElementIndex, Init))
   return false;
-if (!this->emitAddOffsetUint32(Init))
+if (!this->emitArrayElemPtrUint32(Init))
   return false;
-if (!this->emitNarrowPtr(Init))
-  return false;
-
 if (!visitInitializer(Init))
   return false;
 if (!this->emitPopPtr(Init))
@@ -1249,31 +1241,22 @@
 for (size_t I = 0; I != Size; ++I) {
   ArrayIndexScope IndexScope(this, I);
 
-  if (!this->emitDupPtr(SubExpr)) // LHS
-return false;
-
   if (ElemT) {
 if (!this->visit(SubExpr))
   return false;
 if (!this->emitInitElem(*ElemT, I, Initializer))
   return false;
   } else {
-// Narrow to our array element and recurse into visitInitializer()
+// Get to our array element and recurse into visitInitializer()
 if (!this->emitConstUint64(I, SubExpr))
   return false;
-
-if (!this->emitAddOffsetUint64(SubExpr))
-  return false;
-
-if (!this->emitNarrowPtr(SubExpr))
+if (!this->emitArrayElemPtrUint64(SubExpr))
   return false;
-
 if (!visitInitializer(SubExpr))
   return false;
+if (!this->emitPopPtr(Initializer))
+  return false;
   }
-
-  if (!this->emitPopPtr(Initializer))
-return false;
 }
 return true;
   } else if (const auto *IVIE = dyn_cast(Initializer)) {
@@ -1309,13 +1292,9 @@
 // FIXME(perf): We're calling the constructor once per array element here,
 //   in the old intepreter we had a special-case for trivial constructors.
 for (size_t I = 0; I != NumElems; ++I) {
-  if (!this->emitDupPtr(Initializer))
-return false;
   if (!this->emitConstUint64(I, Initializer))
 retu

[clang] 6b5afda - [clang][Interp] Add ArrayElemPtr{,Pop} opcode

2023-03-02 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-03-02T09:45:18+01:00
New Revision: 6b5afda61c4ad6890e62cb8572a13a538316d31c

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

LOG: [clang][Interp] Add ArrayElemPtr{,Pop} opcode

We usually access array elements in the same pattern, which uses
narrow(). Add an extra opcode for this. This saves us quite some
instructions and makes the bytecode easier to read.

Differential Revision: https://reviews.llvm.org/D140805

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/Interp.h
clang/lib/AST/Interp/Opcodes.td

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 7b8253c6e193..1f5c4f6e1cd1 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -413,7 +413,7 @@ bool ByteCodeExprGen::VisitArraySubscriptExpr(
   const Expr *Index = E->getIdx();
   PrimType IndexT = classifyPrim(Index->getType());
 
-  // Take pointer of LHS, add offset from RHS, narrow result.
+  // Take pointer of LHS, add offset from RHS.
   // What's left on the stack after this is a pointer.
   if (!this->visit(Base))
 return false;
@@ -421,10 +421,7 @@ bool ByteCodeExprGen::VisitArraySubscriptExpr(
   if (!this->visit(Index))
 return false;
 
-  if (!this->emitAddOffset(IndexT, E))
-return false;
-
-  if (!this->emitNarrowPtr(E))
+  if (!this->emitArrayElemPtrPop(IndexT, E))
 return false;
 
   if (DiscardResult)
@@ -1214,16 +1211,11 @@ bool 
ByteCodeExprGen::visitArrayInitializer(const Expr *Initializer) {
   return false;
   } else {
 // Advance the pointer currently on the stack to the given
-// dimension and narrow().
-if (!this->emitDupPtr(Init))
-  return false;
+// dimension.
 if (!this->emitConstUint32(ElementIndex, Init))
   return false;
-if (!this->emitAddOffsetUint32(Init))
+if (!this->emitArrayElemPtrUint32(Init))
   return false;
-if (!this->emitNarrowPtr(Init))
-  return false;
-
 if (!visitInitializer(Init))
   return false;
 if (!this->emitPopPtr(Init))
@@ -1249,31 +1241,22 @@ bool 
ByteCodeExprGen::visitArrayInitializer(const Expr *Initializer) {
 for (size_t I = 0; I != Size; ++I) {
   ArrayIndexScope IndexScope(this, I);
 
-  if (!this->emitDupPtr(SubExpr)) // LHS
-return false;
-
   if (ElemT) {
 if (!this->visit(SubExpr))
   return false;
 if (!this->emitInitElem(*ElemT, I, Initializer))
   return false;
   } else {
-// Narrow to our array element and recurse into visitInitializer()
+// Get to our array element and recurse into visitInitializer()
 if (!this->emitConstUint64(I, SubExpr))
   return false;
-
-if (!this->emitAddOffsetUint64(SubExpr))
-  return false;
-
-if (!this->emitNarrowPtr(SubExpr))
+if (!this->emitArrayElemPtrUint64(SubExpr))
   return false;
-
 if (!visitInitializer(SubExpr))
   return false;
+if (!this->emitPopPtr(Initializer))
+  return false;
   }
-
-  if (!this->emitPopPtr(Initializer))
-return false;
 }
 return true;
   } else if (const auto *IVIE = dyn_cast(Initializer)) {
@@ -1309,13 +1292,9 @@ bool 
ByteCodeExprGen::visitArrayInitializer(const Expr *Initializer) {
 // FIXME(perf): We're calling the constructor once per array element here,
 //   in the old intepreter we had a special-case for trivial constructors.
 for (size_t I = 0; I != NumElems; ++I) {
-  if (!this->emitDupPtr(Initializer))
-return false;
   if (!this->emitConstUint64(I, Initializer))
 return false;
-  if (!this->emitAddOffsetUint64(Initializer))
-return false;
-  if (!this->emitNarrowPtr(Initializer))
+  if (!this->emitArrayElemPtrUint64(Initializer))
 return false;
 
   // Constructor arguments.

diff  --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h
index fbf74b54e330..98561f0a9ce0 100644
--- a/clang/lib/AST/Interp/Interp.h
+++ b/clang/lib/AST/Interp/Interp.h
@@ -1455,6 +1455,36 @@ inline bool ExpandPtr(InterpState &S, CodePtr OpPC) {
   return true;
 }
 
+// 1) Pops an integral value from the stack
+// 2) Peeks a pointer
+// 3) Pushes a new pointer that's a narrowed array
+//   element of the peeked pointer with the value
+//   from 1) added as offset.
+//
+// This leaves the original pointer on the stack and pushes a new one
+// with the offset applied and narrowed.
+template ::T>
+inline bool ArrayElemPtr(InterpState &S, CodePtr OpPC) {
+  const T &Offset = S.Stk.pop();
+  const Pointer &Ptr =

[clang] f7ca013 - [llvm-c] Remove bindings for creating legacy passes

2023-03-02 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2023-03-02T09:53:50+01:00
New Revision: f7ca01333214f934c580c162afdee933e7430b6c

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

LOG: [llvm-c] Remove bindings for creating legacy passes

Legacy passes are only supported for codegen, and I don't believe
it's possible to write backends using the C API, so we should drop
all of those. Reduces the number of places that need to be modified
when removing legacy passes.

Differential Revision: https://reviews.llvm.org/D144970

Added: 


Modified: 
clang/docs/tools/clang-formatted-files.txt
llvm/docs/ReleaseNotes.rst
llvm/lib/Transforms/IPO/IPO.cpp
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/lib/Transforms/Scalar/Scalar.cpp
llvm/lib/Transforms/Utils/Utils.cpp
llvm/lib/Transforms/Vectorize/Vectorize.cpp
llvm/tools/llvm-c-test/include-all.c

Removed: 
llvm/include/llvm-c/Transforms/IPO.h
llvm/include/llvm-c/Transforms/InstCombine.h
llvm/include/llvm-c/Transforms/Scalar.h
llvm/include/llvm-c/Transforms/Utils.h
llvm/include/llvm-c/Transforms/Vectorize.h



diff  --git a/clang/docs/tools/clang-formatted-files.txt 
b/clang/docs/tools/clang-formatted-files.txt
index 45970232d0c0f..31d1dd7f365a2 100644
--- a/clang/docs/tools/clang-formatted-files.txt
+++ b/clang/docs/tools/clang-formatted-files.txt
@@ -5713,8 +5713,6 @@ llvm/include/llvm-c/OrcEE.h
 llvm/include/llvm-c/Remarks.h
 llvm/include/llvm-c/Types.h
 llvm/include/llvm-c/Transforms/PassBuilder.h
-llvm/include/llvm-c/Transforms/Scalar.h
-llvm/include/llvm-c/Transforms/Vectorize.h
 llvm/lib/Analysis/CodeMetrics.cpp
 llvm/lib/Analysis/CycleAnalysis.cpp
 llvm/lib/Analysis/DDGPrinter.cpp

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index ef7dacd82bf07..aed1df36b4901 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -145,6 +145,8 @@ Changes to the C API
 
 * ``LLVMContextSetOpaquePointers``, a temporary API to pin to legacy typed
   pointer, has been removed.
+* Functions for adding legacy passes like ``LLVMAddInstructionCombiningPass``
+  have been removed.
 
 Changes to the FastISel infrastructure
 --

diff  --git a/llvm/include/llvm-c/Transforms/IPO.h 
b/llvm/include/llvm-c/Transforms/IPO.h
deleted file mode 100644
index c558aa37f1c3d..0
--- a/llvm/include/llvm-c/Transforms/IPO.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*===-- IPO.h - Interprocedural Transformations C Interface -*- 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
*|
-|*
*|
-|*===--===*|
-|*
*|
-|* This header declares the C interface to libLLVMIPO.a, which implements 
*|
-|* various interprocedural transformations of the LLVM IR.
*|
-|*
*|
-\*===--===*/
-
-#ifndef LLVM_C_TRANSFORMS_IPO_H
-#define LLVM_C_TRANSFORMS_IPO_H
-
-#include "llvm-c/ExternC.h"
-#include "llvm-c/Types.h"
-
-LLVM_C_EXTERN_C_BEGIN
-
-/**
- * @defgroup LLVMCTransformsIPO Interprocedural transformations
- * @ingroup LLVMCTransforms
- *
- * @{
- */
-
-/** See llvm::createDeadArgEliminationPass function. */
-void LLVMAddDeadArgEliminationPass(LLVMPassManagerRef PM);
-
-/** See llvm::createFunctionAttrsPass function. */
-void LLVMAddFunctionAttrsPass(LLVMPassManagerRef PM);
-
-/** See llvm::createAlwaysInlinerPass function. */
-void LLVMAddAlwaysInlinerPass(LLVMPassManagerRef PM);
-
-/**
- * @}
- */
-
-LLVM_C_EXTERN_C_END
-
-#endif

diff  --git a/llvm/include/llvm-c/Transforms/InstCombine.h 
b/llvm/include/llvm-c/Transforms/InstCombine.h
deleted file mode 100644
index ebe17d667061e..0
--- a/llvm/include/llvm-c/Transforms/InstCombine.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*===-- Scalar.h - Scalar Transformation Library C Interface *- C++ 
-*-===*\
-|*
*|
-|* Part of the LLVM Project, under the Apache License v2.0 with LLVM  
*|
-|* Exceptions.
*|
-|* See https://llvm.o

[PATCH] D144970: [llvm-c] Remove bindings for creating legacy passes

2023-03-02 Thread Nikita Popov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf7ca01333214: [llvm-c] Remove bindings for creating legacy 
passes (authored by nikic).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144970/new/

https://reviews.llvm.org/D144970

Files:
  clang/docs/tools/clang-formatted-files.txt
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm-c/Transforms/IPO.h
  llvm/include/llvm-c/Transforms/InstCombine.h
  llvm/include/llvm-c/Transforms/Scalar.h
  llvm/include/llvm-c/Transforms/Utils.h
  llvm/include/llvm-c/Transforms/Vectorize.h
  llvm/lib/Transforms/IPO/IPO.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/lib/Transforms/Scalar/Scalar.cpp
  llvm/lib/Transforms/Utils/Utils.cpp
  llvm/lib/Transforms/Vectorize/Vectorize.cpp
  llvm/tools/llvm-c-test/include-all.c

Index: llvm/tools/llvm-c-test/include-all.c
===
--- llvm/tools/llvm-c-test/include-all.c
+++ llvm/tools/llvm-c-test/include-all.c
@@ -35,11 +35,7 @@
 #include "llvm-c/Support.h"
 #include "llvm-c/Target.h"
 #include "llvm-c/TargetMachine.h"
-#include "llvm-c/Transforms/InstCombine.h"
-#include "llvm-c/Transforms/IPO.h"
+#include "llvm-c/Transforms/PassBuilder.h"
 #include "llvm-c/Transforms/PassManagerBuilder.h"
-#include "llvm-c/Transforms/Scalar.h"
-#include "llvm-c/Transforms/Utils.h"
-#include "llvm-c/Transforms/Vectorize.h"
 #include "llvm-c/Types.h"
 #include "llvm-c/lto.h"
Index: llvm/lib/Transforms/Vectorize/Vectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/Vectorize.cpp
+++ llvm/lib/Transforms/Vectorize/Vectorize.cpp
@@ -14,7 +14,6 @@
 
 #include "llvm/Transforms/Vectorize.h"
 #include "llvm-c/Initialization.h"
-#include "llvm-c/Transforms/Vectorize.h"
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/PassRegistry.h"
@@ -31,11 +30,3 @@
 void LLVMInitializeVectorization(LLVMPassRegistryRef R) {
   initializeVectorization(*unwrap(R));
 }
-
-void LLVMAddLoopVectorizePass(LLVMPassManagerRef PM) {
-  unwrap(PM)->add(createLoopVectorizePass());
-}
-
-void LLVMAddSLPVectorizePass(LLVMPassManagerRef PM) {
-  unwrap(PM)->add(createSLPVectorizerPass());
-}
Index: llvm/lib/Transforms/Utils/Utils.cpp
===
--- llvm/lib/Transforms/Utils/Utils.cpp
+++ llvm/lib/Transforms/Utils/Utils.cpp
@@ -13,7 +13,6 @@
 
 #include "llvm/Transforms/Utils.h"
 #include "llvm-c/Initialization.h"
-#include "llvm-c/Transforms/Utils.h"
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/Pass.h"
@@ -50,15 +49,3 @@
 void LLVMInitializeTransformUtils(LLVMPassRegistryRef R) {
   initializeTransformUtils(*unwrap(R));
 }
-
-void LLVMAddLowerSwitchPass(LLVMPassManagerRef PM) {
-  unwrap(PM)->add(createLowerSwitchPass());
-}
-
-void LLVMAddPromoteMemoryToRegisterPass(LLVMPassManagerRef PM) {
-  unwrap(PM)->add(createPromoteMemoryToRegisterPass());
-}
-
-void LLVMAddAddDiscriminatorsPass(LLVMPassManagerRef PM) {
-  unwrap(PM)->add(createAddDiscriminatorsPass());
-}
Index: llvm/lib/Transforms/Scalar/Scalar.cpp
===
--- llvm/lib/Transforms/Scalar/Scalar.cpp
+++ llvm/lib/Transforms/Scalar/Scalar.cpp
@@ -14,7 +14,6 @@
 
 #include "llvm/Transforms/Scalar.h"
 #include "llvm-c/Initialization.h"
-#include "llvm-c/Transforms/Scalar.h"
 #include "llvm/Analysis/BasicAliasAnalysis.h"
 #include "llvm/Analysis/ScopedNoAliasAA.h"
 #include "llvm/Analysis/TypeBasedAliasAnalysis.h"
@@ -97,163 +96,6 @@
   initializeLoopSimplifyCFGLegacyPassPass(Registry);
 }
 
-void LLVMAddLoopSimplifyCFGPass(LLVMPassManagerRef PM) {
-  unwrap(PM)->add(createLoopSimplifyCFGPass());
-}
-
 void LLVMInitializeScalarOpts(LLVMPassRegistryRef R) {
   initializeScalarOpts(*unwrap(R));
 }
-
-void LLVMAddAggressiveDCEPass(LLVMPassManagerRef PM) {
-  unwrap(PM)->add(createAggressiveDCEPass());
-}
-
-void LLVMAddDCEPass(LLVMPassManagerRef PM) {
-  unwrap(PM)->add(createDeadCodeEliminationPass());
-}
-
-void LLVMAddBitTrackingDCEPass(LLVMPassManagerRef PM) {
-  unwrap(PM)->add(createBitTrackingDCEPass());
-}
-
-void LLVMAddAlignmentFromAssumptionsPass(LLVMPassManagerRef PM) {
-  unwrap(PM)->add(createAlignmentFromAssumptionsPass());
-}
-
-void LLVMAddCFGSimplificationPass(LLVMPassManagerRef PM) {
-  unwrap(PM)->add(createCFGSimplificationPass());
-}
-
-void LLVMAddDeadStoreEliminationPass(LLVMPassManagerRef PM) {
-  unwrap(PM)->add(createDeadStoreEliminationPass());
-}
-
-void LLVMAddScalarizerPass(LLVMPassManagerRef PM) {
-  unwrap(PM)->add(createScalarizerPass());
-}
-
-void LLVMAddGVNPass(LLVMPassManagerRef PM) {
-  unwrap(PM)->add(createGVNPass());
-}
-
-void LLVMAddNewGV

[PATCH] D145146: [Driver][NFC] Remove some redundant code in Driver.cpp.

2023-03-02 Thread WangLian via Phabricator via cfe-commits
Jimerlife created this revision.
Jimerlife added reviewers: phosek, kazu, abrachet.
Jimerlife added a project: LLVM.
Herald added a project: All.
Jimerlife requested review of this revision.
Herald added subscribers: cfe-commits, jacquesguan, MaskRay.
Herald added a project: clang.

`options::OPT_target` has been done in `Driver::BuildCompilation`, so I think 
this part of code is redundant.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145146

Files:
  clang/lib/Driver/Driver.cpp


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -527,10 +527,6 @@
 StringRef TargetTriple,
 const ArgList &Args,
 StringRef DarwinArchName = "") {
-  // FIXME: Already done in Compilation *Driver::BuildCompilation
-  if (const Arg *A = Args.getLastArg(options::OPT_target))
-TargetTriple = A->getValue();
-
   llvm::Triple Target(llvm::Triple::normalize(TargetTriple));
 
   // GNU/Hurd's triples should have been -hurd-gnu*, but were historically made


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -527,10 +527,6 @@
 StringRef TargetTriple,
 const ArgList &Args,
 StringRef DarwinArchName = "") {
-  // FIXME: Already done in Compilation *Driver::BuildCompilation
-  if (const Arg *A = Args.getLastArg(options::OPT_target))
-TargetTriple = A->getValue();
-
   llvm::Triple Target(llvm::Triple::normalize(TargetTriple));
 
   // GNU/Hurd's triples should have been -hurd-gnu*, but were historically made
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138713: Fix assertion failure "PathDiagnosticSpotPiece's must have a valid location." in ReturnPtrRange checker on builtin functions

2023-03-02 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

I think we should backport this to `release/16.x`.
Here is the ticket for it: https://github.com/llvm/llvm-project/issues/61115


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138713/new/

https://reviews.llvm.org/D138713

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


[PATCH] D144963: [UTC] Include return type/attributes under --version 2

2023-03-02 Thread Nikita Popov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa26d3031cf89: [UTC] Include return type/attributes under 
--version 2 (authored by nikic).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144963/new/

https://reviews.llvm.org/D144963

Files:
  
clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.v2.expected
  clang/test/utils/update_cc_test_checks/mangled_names.test
  llvm/utils/UpdateTestChecks/asm.py
  llvm/utils/UpdateTestChecks/common.py
  llvm/utils/UpdateTestChecks/isel.py
  llvm/utils/update_cc_test_checks.py
  llvm/utils/update_test_checks.py

Index: llvm/utils/update_test_checks.py
===
--- llvm/utils/update_test_checks.py
+++ llvm/utils/update_test_checks.py
@@ -177,6 +177,7 @@
   func,
   False,
   args.function_signature,
+  args.version,
   global_vars_seen_dict,
   is_filtered=builder.is_filtered(
 else:
@@ -203,6 +204,7 @@
   func_name,
   args.preserve_names,
   args.function_signature,
+  args.version,
   global_vars_seen_dict,
   is_filtered=builder.is_filtered()))
   is_in_function_start = False
Index: llvm/utils/update_cc_test_checks.py
===
--- llvm/utils/update_cc_test_checks.py
+++ llvm/utils/update_cc_test_checks.py
@@ -350,6 +350,7 @@
   prefixes,
   func_dict, func, False,
   ti.args.function_signature,
+  ti.args.version,
   global_vars_seen_dict,
   is_filtered=builder.is_filtered())
 else:
@@ -417,6 +418,7 @@
   mangled,
   False,
   args.function_signature,
+  args.version,
   global_vars_seen_dict,
   is_filtered=builder.is_filtered()))
   if line.rstrip('\n') == '//':
Index: llvm/utils/UpdateTestChecks/isel.py
===
--- llvm/utils/UpdateTestChecks/isel.py
+++ llvm/utils/UpdateTestChecks/isel.py
@@ -51,7 +51,7 @@
 def add_checks(output_lines, comment_marker, prefix_list, func_dict, func_name,
global_vars_seen_dict, is_filtered):
   # Label format is based on iSel string.
-  check_label_format = '{} %s-LABEL: %s%s%s'.format(comment_marker)
+  check_label_format = '{} %s-LABEL: %s%s%s%s'.format(comment_marker)
   return common.add_checks(output_lines, comment_marker, prefix_list, func_dict,
-   func_name, check_label_format, True, False,
+   func_name, check_label_format, True, False, 1,
global_vars_seen_dict, is_filtered=is_filtered)
Index: llvm/utils/UpdateTestChecks/common.py
===
--- llvm/utils/UpdateTestChecks/common.py
+++ llvm/utils/UpdateTestChecks/common.py
@@ -22,6 +22,7 @@
 Version changelog:
 
 1: Initial version, used by tests that don't specify --version explicitly.
+2: --function-signature now also checks return type/attributes.
 """
 DEFAULT_VERSION = 1
 
@@ -346,7 +347,7 @@
 UNUSED_NOTE = 'NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:'
 
 OPT_FUNCTION_RE = re.compile(
-r'^(\s*;\s*Function\sAttrs:\s(?P[\w\s():,]+?))?\s*define\s+(?:internal\s+)?[^@]*@(?P[\w.$-]+?)\s*'
+r'^(\s*;\s*Function\sAttrs:\s(?P[\w\s():,]+?))?\s*define\s+(?P[^@]*)@(?P[\w.$-]+?)\s*'
 r'(?P\((\)|(.*?[\w.-]+?)\))[^{]*\{)\n(?P.*?)^\}$',
 flags=(re.M | re.S))
 
@@ -459,13 +460,14 @@
 
 # Build up a dictionary of all the function bodies.
 class function_body(object):
-  def __init__(self, string, extra, args_and_sig, attrs, func_name_separator):
+  def __init__(self, string, extra, funcdef_attrs_and_ret, args_and_sig, attrs, func_name_separator):
 self.scrub = string
 self.extrascrub = extra
+self.funcdef_attrs_and_ret = funcdef_attrs_and_ret
 self.args_and_sig = args_and_sig
 self.attrs = attrs
 self.func_name_separator = func_name_separator
-  def is_same_except_arg_names(self, extrascrub, args_and_sig, attrs, is_backend):
+  def is_same_except_arg_names(self, extrascrub, funcdef_attrs_and_ret, args_and_sig, attrs, is_backend):
 arg_names = set()
 def drop_arg_names(match):
   arg_names.add(match.group(variable_group_in_ir_value_match))
@@ -478,6 +480,8 @@
   if match.g

[clang] a26d303 - [UTC] Include return type/attributes under --version 2

2023-03-02 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2023-03-02T09:59:22+01:00
New Revision: a26d3031cf89954d030e494d47ca6653d531dc82

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

LOG: [UTC] Include return type/attributes under --version 2

If --function-signature is used with --version 2, then also include
the return type/attributes in the check lines. This is the
implementation of D133943 rebased on the --version mechanism from
D142473.

This doesn't bump the default version yet, because I'd like to do
that together with D140212 (which enables --function-signature by
default), as these changes seem closely related. For now this
functionality can be accessed by explicitly passing --version 2
to UTC.

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

Differential Revision: https://reviews.llvm.org/D144963

Added: 

clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.v2.expected

Modified: 
clang/test/utils/update_cc_test_checks/mangled_names.test
llvm/utils/UpdateTestChecks/asm.py
llvm/utils/UpdateTestChecks/common.py
llvm/utils/UpdateTestChecks/isel.py
llvm/utils/update_cc_test_checks.py
llvm/utils/update_test_checks.py

Removed: 




diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.v2.expected
 
b/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.v2.expected
new file mode 100644
index 0..c70179fc21777
--- /dev/null
+++ 
b/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.v2.expected
@@ -0,0 +1,43 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --version 2
+// Example input for update_cc_test_checks
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
+
+// CHECK-LABEL: define dso_local i64 @test
+// CHECK-SAME: (i64 noundef [[A:%.*]], i32 noundef [[B:%.*]]) 
#[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i64 [[A]], ptr [[A_ADDR]], align 8
+// CHECK-NEXT:store i32 [[B]], ptr [[B_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load i64, ptr [[A_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[B_ADDR]], align 4
+// CHECK-NEXT:[[CONV:%.*]] = sext i32 [[TMP1]] to i64
+// CHECK-NEXT:[[ADD:%.*]] = add nsw i64 [[TMP0]], [[CONV]]
+// CHECK-NEXT:ret i64 [[ADD]]
+//
+long test(long a, int b) {
+  return a + b;
+}
+
+// A function with a mangled name
+// CHECK-LABEL: define dso_local i64 @_Z4testlii
+// CHECK-SAME: (i64 noundef [[A:%.*]], i32 noundef [[B:%.*]], i32 noundef 
[[C:%.*]]) #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[C_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i64 [[A]], ptr [[A_ADDR]], align 8
+// CHECK-NEXT:store i32 [[B]], ptr [[B_ADDR]], align 4
+// CHECK-NEXT:store i32 [[C]], ptr [[C_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load i64, ptr [[A_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[B_ADDR]], align 4
+// CHECK-NEXT:[[CONV:%.*]] = sext i32 [[TMP1]] to i64
+// CHECK-NEXT:[[ADD:%.*]] = add nsw i64 [[TMP0]], [[CONV]]
+// CHECK-NEXT:[[TMP2:%.*]] = load i32, ptr [[C_ADDR]], align 4
+// CHECK-NEXT:[[CONV1:%.*]] = sext i32 [[TMP2]] to i64
+// CHECK-NEXT:[[ADD2:%.*]] = add nsw i64 [[ADD]], [[CONV1]]
+// CHECK-NEXT:ret i64 [[ADD2]]
+//
+__attribute__((overloadable)) long test(long a, int b, int c) {
+  return a + b + c;
+}

diff  --git a/clang/test/utils/update_cc_test_checks/mangled_names.test 
b/clang/test/utils/update_cc_test_checks/mangled_names.test
index bc88c9b5a382f..40f8a5d78b521 100644
--- a/clang/test/utils/update_cc_test_checks/mangled_names.test
+++ b/clang/test/utils/update_cc_test_checks/mangled_names.test
@@ -16,3 +16,6 @@
 # RUN: grep -v UTC_ARGS %t.c > %t-no-args.c
 # RUN: %update_cc_test_checks %t-no-args.c
 # RUN: 
diff  -u %t-no-args.c %S/Inputs/mangled_names.c.expected
+## Also try --version 2
+# RUN: %update_cc_test_checks %t.c --function-signature --version 2
+# RUN: 
diff  -u %t.c %S/Inputs/mangled_names.c.funcsig.v2.expected

diff  --git a/llvm/utils/UpdateTestChecks/asm.py 
b/llvm/utils/UpdateTestChecks/asm.py
index e24197f3b63bb..697d3ee17d96f 100644
--- a/llvm/utils/UpdateTestChecks/asm.py
+++ b/llvm/utils/UpdateTestChecks/asm.py
@@ -534,7 +534,7 @@ def get_run_handler(triple):
 def add_checks(output_lines, comment_marker, prefix_list, func_dict,
func_name, global_vars_seen_dict, is_filtered):
   # Label format is based on ASM string.
-  check_label_format = '

[clang] 93d7002 - [Clang] Implement Change scope of lambda trailing-return-type

2023-03-02 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2023-03-02T10:04:16+01:00
New Revision: 93d7002dc4644b0a6f15a998dff0d55c72012e87

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

LOG: [Clang] Implement Change scope of lambda trailing-return-type

This implements P2036R3 and P2579R0.
That is, explicit, int, and implicit capture become visible
at the start of the parameter head.

Reviewed By: aaron.ballman, rupprecht, shafik

Differential Revision: https://reviews.llvm.org/D124351

Added: 
clang/test/SemaCXX/lambda-capture-type-deduction.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/DeclCXX.h
clang/include/clang/Sema/Scope.h
clang/include/clang/Sema/ScopeInfo.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Sema/Scope.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaCXXScopeSpec.cpp
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/TreeTransform.h
clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp
clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
clang/test/SemaCXX/lambda-expressions.cpp
clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ce37020aa86fb..7dc80a43e5eb4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -82,6 +82,11 @@ C++20 Feature Support
 C++2b Feature Support
 ^
 
+- Implemented `P2036R3: Change scope of lambda trailing-return-type 
`_
+  and `P2579R0 Mitigation strategies for P2036 `_.
+  These proposals modify how variables captured in lambdas can appear in 
trailing return type
+  expressions and how their types are deduced therein, in all C++ language 
versions.
+
 Resolutions to C++ Defect Reports
 ^
 

diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 11276c77490ce..ff8f8a1bb12d6 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1092,6 +1092,11 @@ class CXXRecordDecl : public RecordDecl {
 
   unsigned capture_size() const { return getLambdaData().NumCaptures; }
 
+  const LambdaCapture *getCapture(unsigned I) const {
+assert(isLambda() && I < capture_size() && "invalid index for capture");
+return captures_begin() + I;
+  }
+
   using conversion_iterator = UnresolvedSetIterator;
 
   conversion_iterator conversion_begin() const {
@@ -1826,6 +1831,20 @@ class CXXRecordDecl : public RecordDecl {
 return getLambdaData().MethodTyInfo;
   }
 
+  void setLambdaTypeInfo(TypeSourceInfo *TS) {
+assert(DefinitionData && DefinitionData->IsLambda &&
+   "setting lambda property of non-lambda class");
+auto &DL = static_cast(*DefinitionData);
+DL.MethodTyInfo = TS;
+  }
+
+  void setLambdaIsGeneric(bool IsGeneric) {
+assert(DefinitionData && DefinitionData->IsLambda &&
+   "setting lambda property of non-lambda class");
+auto &DL = static_cast(*DefinitionData);
+DL.IsGenericLambda = IsGeneric;
+  }
+
   // Determine whether this type is an Interface Like type for
   // __interface inheritance purposes.
   bool isInterfaceLike() const;

diff  --git a/clang/include/clang/Sema/Scope.h 
b/clang/include/clang/Sema/Scope.h
index be5cdb62045b1..9e81706cd2aa1 100644
--- a/clang/include/clang/Sema/Scope.h
+++ b/clang/include/clang/Sema/Scope.h
@@ -145,6 +145,11 @@ class Scope {
 /// This is a scope of some OpenMP directive with
 /// order clause which specifies concurrent
 OpenMPOrderClauseScope = 0x400,
+/// This is the scope for a lambda, after the lambda introducer.
+/// Lambdas need two FunctionPrototypeScope scopes (because there is a
+/// template scope in between), the outer scope does not increase the
+/// depth of recursion.
+LambdaScope = 0x800,
   };
 
 private:

diff  --git a/clang/include/clang/Sema/ScopeInfo.h 
b/clang/include/clang/Sema/ScopeInfo.h
index 65fa18fbb2903..5888dee0a883d 100644
--- a/clang/include/clang/Sema/ScopeInfo.h
+++ b/clang/include/clang/Sema/ScopeInfo.h
@@ -838,6 +838,11 @@ class LambdaScopeInfo final :
   /// The lambda's compiler-generated \c operator().
   CXXMethodDecl *CallOperator = nullptr;
 
+  /// Indicate that we parsed the parameter list
+  /// at which point the mutability of the lambda
+  /// is known.
+  bool AfterParameterList = true;
+
   /// Source range covering the lambda introducer [...].
   SourceRange IntroducerRange;
 
@@ -849,8 +854,9 @@ class LambdaScopeInfo final :

[PATCH] D124351: [Clang] Implement Change scope of lambda trailing-return-type

2023-03-02 Thread Corentin Jabot via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG93d7002dc464: [Clang] Implement Change scope of lambda 
trailing-return-type (authored by cor3ntin).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124351/new/

https://reviews.llvm.org/D124351

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Scope.h
  clang/include/clang/Sema/ScopeInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/Scope.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCXXScopeSpec.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
  clang/test/SemaCXX/lambda-capture-type-deduction.cpp
  clang/test/SemaCXX/lambda-expressions.cpp
  clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1373,7 +1373,7 @@
 
   Change scope of lambda trailing-return-type
   https://wg21.link/P2036R3";>P2036R3
-  No
+  Clang 17
 
 
   https://wg21.link/P2579R0";>P2579R0
Index: clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
===
--- clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
+++ clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
@@ -95,7 +95,7 @@
 #ifdef AVOID
   auto l4 = [var = param] (int param) { ; }; // no warning
 #else
-  auto l4 = [var = param] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+  auto l4 = [var = param](int param) { ; }; // expected-warning 2{{declaration shadows a local variable}}
 #endif
 
   // Make sure that inner lambdas work as well.
Index: clang/test/SemaCXX/lambda-expressions.cpp
===
--- clang/test/SemaCXX/lambda-expressions.cpp
+++ clang/test/SemaCXX/lambda-expressions.cpp
@@ -665,3 +665,27 @@
 // expected-note@-2 2 {{default capture by}}
 }
 };
+
+namespace GH60518 {
+// Lambdas should not try to capture
+// function parameters that are used in enable_if
+struct StringLiteral {
+template 
+StringLiteral(const char (&array)[N])
+__attribute__((enable_if(__builtin_strlen(array) == 2,
+  "invalid string literal")));
+};
+
+namespace cpp_attribute {
+struct StringLiteral {
+template 
+StringLiteral(const char (&array)[N]) [[clang::annotate_type("test", array)]];
+};
+}
+
+void Func1() {
+  [[maybe_unused]] auto y = [&](decltype(StringLiteral("xx"))) {};
+  [[maybe_unused]] auto z = [&](decltype(cpp_attribute::StringLiteral("xx"))) {};
+}
+
+}
Index: clang/test/SemaCXX/lambda-capture-type-deduction.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/lambda-capture-type-deduction.cpp
@@ -0,0 +1,243 @@
+// RUN: %clang_cc1 -std=c++2b -verify -fsyntax-only %s
+
+template 
+constexpr bool is_same = false;
+
+template 
+constexpr bool is_same = true;
+
+void f() {
+
+  int y;
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  auto ref = [&x = y](
+ decltype([&](decltype(x)) { return 0; }) y) {
+return x;
+  };
+}
+
+void test_noexcept() {
+
+  int y;
+
+  static_assert(noexcept([x = 1] noexcept(is_same) {}()));
+  static_assert(noexcept([x = 1] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([y] noexcept(is_same) {}()));
+  static_assert(noexcept([y] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([=] noexcept(is_same) {}()));
+  static_assert(noexcept([=] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([&] noexcept(is_same) {}()));
+  static_assert(noexcept([&] mutable noexcept(is_same) {}()));
+}
+
+void test_requires() {
+
+  int x;
+
+  [x = 1]() requires is_same {}
+  ();
+  [x = 1]() mutable requires is_same {}
+  ();
+  [x]() requires is_same {}
+  ();
+  [x]() mutable requires is_same {}
+  ();
+  [=]() requires is_same {}
+  ();
+  [=]() mutable requires is_same {}
+  ();
+  [&]() requires is_same {}
+  ();
+  [&]() mutable requires is_same {}
+  ();
+  [&x]() requires is_same {}
+  ();
+  [&x]() mutable requires is_same {}
+  ();
+
+  [x = 1]() requires is_same {} ();
+  [x = 1]() mutable requires is_same {} ();
+}
+
+void err() {
+  int 

[clang] 90d921f - [clang][Interp] Handle record initialization via CastExpr

2023-03-02 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-03-02T10:08:41+01:00
New Revision: 90d921fa1f71ff219cb42682d123a4c3922af71e

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

LOG: [clang][Interp] Handle record initialization via CastExpr

Differential Revision: https://reviews.llvm.org/D140808

Added: 


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

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 1f5c4f6e1cd1..1740c5dd939e 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1410,6 +1410,8 @@ bool 
ByteCodeExprGen::visitRecordInitializer(const Expr *Initializer) {
 return this->VisitCallExpr(CE);
   } else if (const auto *DIE = dyn_cast(Initializer)) {
 return this->visitInitializer(DIE->getExpr());
+  } else if (const auto *CE = dyn_cast(Initializer)) {
+return this->visitInitializer(CE->getSubExpr());
   }
 
   return false;

diff  --git a/clang/test/AST/Interp/records.cpp 
b/clang/test/AST/Interp/records.cpp
index fcf4b578d7d3..c0bfdeb090eb 100644
--- a/clang/test/AST/Interp/records.cpp
+++ b/clang/test/AST/Interp/records.cpp
@@ -88,6 +88,10 @@ constexpr Ints2 ints22; // expected-error {{without a 
user-provided default cons
 // expected-error {{must be initialized by a constant 
expression}} \
 // ref-error {{without a user-provided default 
constructor}}
 
+constexpr Ints2 I2 = Ints2{12, 25};
+static_assert(I2.a == 12, "");
+static_assert(I2.b == 25, "");
+
 class C {
   public:
 int a;



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


[PATCH] D140808: [clang][Interp] Handle record initialization via CastExpr

2023-03-02 Thread Timm Bäder via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG90d921fa1f71: [clang][Interp] Handle record initialization 
via CastExpr (authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D140808?vs=485781&id=501788#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140808/new/

https://reviews.llvm.org/D140808

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/test/AST/Interp/records.cpp


Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -88,6 +88,10 @@
 // expected-error {{must be initialized by a constant 
expression}} \
 // ref-error {{without a user-provided default 
constructor}}
 
+constexpr Ints2 I2 = Ints2{12, 25};
+static_assert(I2.a == 12, "");
+static_assert(I2.b == 25, "");
+
 class C {
   public:
 int a;
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1410,6 +1410,8 @@
 return this->VisitCallExpr(CE);
   } else if (const auto *DIE = dyn_cast(Initializer)) {
 return this->visitInitializer(DIE->getExpr());
+  } else if (const auto *CE = dyn_cast(Initializer)) {
+return this->visitInitializer(CE->getSubExpr());
   }
 
   return false;


Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -88,6 +88,10 @@
 // expected-error {{must be initialized by a constant expression}} \
 // ref-error {{without a user-provided default constructor}}
 
+constexpr Ints2 I2 = Ints2{12, 25};
+static_assert(I2.a == 12, "");
+static_assert(I2.b == 25, "");
+
 class C {
   public:
 int a;
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1410,6 +1410,8 @@
 return this->VisitCallExpr(CE);
   } else if (const auto *DIE = dyn_cast(Initializer)) {
 return this->visitInitializer(DIE->getExpr());
+  } else if (const auto *CE = dyn_cast(Initializer)) {
+return this->visitInitializer(CE->getSubExpr());
   }
 
   return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 94dd476 - [Coverage] Fix an issue: a statement after calling 'assert()' function is wrongly

2023-03-02 Thread Ying Yi via cfe-commits

Author: Ying Yi
Date: 2023-03-02T09:14:44Z
New Revision: 94dd4766a61bb18b263415e17e745dc2fa609162

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

LOG: [Coverage] Fix an issue: a statement after calling 'assert()' function is 
wrongly
marked as 'not executed'.

In the current coverage mapping implementation, we terminate the current region
and start a zero region when we hit a nonreturn function. However, for logical 
OR,
the second operand is not executed if the first operand evaluates to true. If 
the
nonreturn function is called in the right side of logical OR and the left side 
of
logical OR is TRUE, we should not start a zero `GapRegionCounter`. This will 
also
apply to `VisitAbstractConditionalOperator`.

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

Reviewed By: zequanwu

Differential Revision: https://reviews.llvm.org/D144371

Added: 


Modified: 
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/test/CoverageMapping/terminate-statements.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 56ff36438098..68e6457419ab 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1466,6 +1466,7 @@ struct CounterCoverageMappingBuilder
 Counter TrueCount = getRegionCounter(E);
 
 propagateCounts(ParentCount, E->getCond());
+Counter OutCount;
 
 if (!isa(E)) {
   // The 'then' count applies to the area immediately after the condition.
@@ -1475,12 +1476,18 @@ struct CounterCoverageMappingBuilder
 fillGapAreaWithCount(Gap->getBegin(), Gap->getEnd(), TrueCount);
 
   extendRegion(E->getTrueExpr());
-  propagateCounts(TrueCount, E->getTrueExpr());
+  OutCount = propagateCounts(TrueCount, E->getTrueExpr());
 }
 
 extendRegion(E->getFalseExpr());
-propagateCounts(subtractCounters(ParentCount, TrueCount),
-E->getFalseExpr());
+OutCount = addCounters(
+OutCount, propagateCounts(subtractCounters(ParentCount, TrueCount),
+  E->getFalseExpr()));
+
+if (OutCount != ParentCount) {
+  pushRegion(OutCount);
+  GapRegionCounter = OutCount;
+}
 
 // Create Branch Region around condition.
 createBranchRegion(E->getCond(), TrueCount,
@@ -1514,9 +1521,19 @@ struct CounterCoverageMappingBuilder
subtractCounters(RHSExecCnt, RHSTrueCnt));
   }
 
+  // Determine whether the right side of OR operation need to be visited.
+  bool shouldVisitRHS(const Expr *LHS) {
+bool LHSIsTrue = false;
+bool LHSIsConst = false;
+if (!LHS->isValueDependent())
+  LHSIsConst = LHS->EvaluateAsBooleanCondition(
+  LHSIsTrue, CVM.getCodeGenModule().getContext());
+return !LHSIsConst || (LHSIsConst && !LHSIsTrue);
+  }
+
   void VisitBinLOr(const BinaryOperator *E) {
 extendRegion(E->getLHS());
-propagateCounts(getRegion().getCounter(), E->getLHS());
+Counter OutCount = propagateCounts(getRegion().getCounter(), E->getLHS());
 handleFileExit(getEnd(E->getLHS()));
 
 // Counter tracks the right hand side of a logical or operator.
@@ -1529,6 +1546,10 @@ struct CounterCoverageMappingBuilder
 // Extract the RHS's "False" Instance Counter.
 Counter RHSFalseCnt = getRegionCounter(E->getRHS());
 
+if (!shouldVisitRHS(E->getLHS())) {
+  GapRegionCounter = OutCount;
+}
+
 // Extract the Parent Region Counter.
 Counter ParentCnt = getRegion().getCounter();
 

diff  --git a/clang/test/CoverageMapping/terminate-statements.cpp 
b/clang/test/CoverageMapping/terminate-statements.cpp
index fa309b8efea2..0067185fee8e 100644
--- a/clang/test/CoverageMapping/terminate-statements.cpp
+++ b/clang/test/CoverageMapping/terminate-statements.cpp
@@ -320,6 +320,32 @@ void include() {
   included_func();
 }
 
+// CHECK-LABEL: _Z7ornoretv:
+void abort() __attribute__((noreturn));
+
+int ornoret(void) {
+  ( true || (abort(), 0) );  // CHECK: Gap,File 0, [[@LINE]]:28 -> 
[[@LINE+1]]:3 = #0
+  ( false || (abort(), 0) ); // CHECK: Gap,File 0, [[@LINE]]:29 -> 
[[@LINE+1]]:3 = 0
+  return 0;
+}
+
+// CHECK-LABEL: _Z17abstractcondnoretv:
+int abstractcondnoret(void) {
+  ( true ? void (0) : abort() );  // CHECK: Gap,File 0, [[@LINE]]:33 -> 
[[@LINE+1]]:3 = #1
+  ( false ? void (0) : abort() ); // CHECK: Gap,File 0, [[@LINE]]:34 -> 
[[@LINE+1]]:3 = #2
+  ( true ? abort() : void (0) );  // CHECK: Gap,File 0, [[@LINE]]:33 -> 
[[@LINE+1]]:3 = (#2 - #3)
+  ( false ? abort() : void (0) ); // CHECK: Gap,File 0, [[@LINE]]:34 -> 
[[@LINE+1]]:3 = ((#2 - #3) - #4)
+  return 0;
+}
+
+// CHECK-LABEL: _Z13elsecondnoretv:
+int elsecondnoret(void) {
+  if (true) {} else {
+true ? void (0) : abort();
+  } // C

[PATCH] D144371: [LLVM-COV] Fix an issue: a statement after calling 'assert()' function is wrongly marked as 'not executed'

2023-03-02 Thread Ying Yi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
MaggieYi marked an inline comment as done.
Closed by commit rG94dd4766a61b: [Coverage] Fix an issue: a statement after 
calling 'assert()' function is… (authored by MaggieYi).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144371/new/

https://reviews.llvm.org/D144371

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/terminate-statements.cpp

Index: clang/test/CoverageMapping/terminate-statements.cpp
===
--- clang/test/CoverageMapping/terminate-statements.cpp
+++ clang/test/CoverageMapping/terminate-statements.cpp
@@ -320,6 +320,32 @@
   included_func();
 }
 
+// CHECK-LABEL: _Z7ornoretv:
+void abort() __attribute__((noreturn));
+
+int ornoret(void) {
+  ( true || (abort(), 0) );  // CHECK: Gap,File 0, [[@LINE]]:28 -> [[@LINE+1]]:3 = #0
+  ( false || (abort(), 0) ); // CHECK: Gap,File 0, [[@LINE]]:29 -> [[@LINE+1]]:3 = 0
+  return 0;
+}
+
+// CHECK-LABEL: _Z17abstractcondnoretv:
+int abstractcondnoret(void) {
+  ( true ? void (0) : abort() );  // CHECK: Gap,File 0, [[@LINE]]:33 -> [[@LINE+1]]:3 = #1
+  ( false ? void (0) : abort() ); // CHECK: Gap,File 0, [[@LINE]]:34 -> [[@LINE+1]]:3 = #2
+  ( true ? abort() : void (0) );  // CHECK: Gap,File 0, [[@LINE]]:33 -> [[@LINE+1]]:3 = (#2 - #3)
+  ( false ? abort() : void (0) ); // CHECK: Gap,File 0, [[@LINE]]:34 -> [[@LINE+1]]:3 = ((#2 - #3) - #4)
+  return 0;
+}
+
+// CHECK-LABEL: _Z13elsecondnoretv:
+int elsecondnoret(void) {
+  if (true) {} else {
+true ? void (0) : abort();
+  } // CHECK: Gap,File 0, [[@LINE]]:4 -> [[@LINE+1]]:3 = (#1 + #2)
+  return 0;
+}
+
 int main() {
   foo(0);
   foo(1);
@@ -339,5 +365,8 @@
   while_loop();
   gotos();
   include();
+  ornoret();
+  abstractcondnoret();
+  elsecondnoret();
   return 0;
 }
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1466,6 +1466,7 @@
 Counter TrueCount = getRegionCounter(E);
 
 propagateCounts(ParentCount, E->getCond());
+Counter OutCount;
 
 if (!isa(E)) {
   // The 'then' count applies to the area immediately after the condition.
@@ -1475,12 +1476,18 @@
 fillGapAreaWithCount(Gap->getBegin(), Gap->getEnd(), TrueCount);
 
   extendRegion(E->getTrueExpr());
-  propagateCounts(TrueCount, E->getTrueExpr());
+  OutCount = propagateCounts(TrueCount, E->getTrueExpr());
 }
 
 extendRegion(E->getFalseExpr());
-propagateCounts(subtractCounters(ParentCount, TrueCount),
-E->getFalseExpr());
+OutCount = addCounters(
+OutCount, propagateCounts(subtractCounters(ParentCount, TrueCount),
+  E->getFalseExpr()));
+
+if (OutCount != ParentCount) {
+  pushRegion(OutCount);
+  GapRegionCounter = OutCount;
+}
 
 // Create Branch Region around condition.
 createBranchRegion(E->getCond(), TrueCount,
@@ -1514,9 +1521,19 @@
subtractCounters(RHSExecCnt, RHSTrueCnt));
   }
 
+  // Determine whether the right side of OR operation need to be visited.
+  bool shouldVisitRHS(const Expr *LHS) {
+bool LHSIsTrue = false;
+bool LHSIsConst = false;
+if (!LHS->isValueDependent())
+  LHSIsConst = LHS->EvaluateAsBooleanCondition(
+  LHSIsTrue, CVM.getCodeGenModule().getContext());
+return !LHSIsConst || (LHSIsConst && !LHSIsTrue);
+  }
+
   void VisitBinLOr(const BinaryOperator *E) {
 extendRegion(E->getLHS());
-propagateCounts(getRegion().getCounter(), E->getLHS());
+Counter OutCount = propagateCounts(getRegion().getCounter(), E->getLHS());
 handleFileExit(getEnd(E->getLHS()));
 
 // Counter tracks the right hand side of a logical or operator.
@@ -1529,6 +1546,10 @@
 // Extract the RHS's "False" Instance Counter.
 Counter RHSFalseCnt = getRegionCounter(E->getRHS());
 
+if (!shouldVisitRHS(E->getLHS())) {
+  GapRegionCounter = OutCount;
+}
+
 // Extract the Parent Region Counter.
 Counter ParentCnt = getRegion().getCounter();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145047: Fix broken link on Clang documentation page

2023-03-02 Thread Breno Rodrigues Guimaraes via Phabricator via cfe-commits
brenoguim accepted this revision.
brenoguim added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145047/new/

https://reviews.llvm.org/D145047

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


[PATCH] D144976: [clangd] Add provider info on symbol hover.

2023-03-02 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Thanks, left a few comments on the implementation.




Comment at: clang-tools-extra/clangd/Hover.cpp:1091
 
+// FIXME(bakalova): Remove after merging https://reviews.llvm.org/D143496
+std::vector

I'm not sure how we can do it. https://reviews.llvm.org/D143496 doesn't expose 
`collectMacroReferences` function, so we still duplicate this hacky 
implementations in two places, which is probably fine at the moment.

I think this will be fixed when we unify them with clangd's 
`CollectMainFileMacros`.



Comment at: clang-tools-extra/clangd/Hover.cpp:1093
+std::vector
+collectMacroReferences(ParsedAST &AST) {
+  const auto &SM = AST.getSourceManager();

On a second thought, I think we might not really need it. We handle the macro 
vs non-macro cases separately, and we only care about the symbol reference 
under the cursor.
so we can simply the implementation:

1) For macro case, we already have the located macro and Tok in the call site 
(on line1231), we can just construct a single 
`include_cleaner::SymbolReference` from them, and pass a single-element 
`Macros` and empty `ASTRoots` to the `walkUsed` API.

2) For non-macro case, we can just pass an empty macro references to `walkUsed` 
as we already know the symbol under the hover is not a macro. 



Comment at: clang-tools-extra/clangd/Hover.cpp:1123
+if (!Ref.RefLocation.isFileID() ||
+!SM.isWrittenInMainFile(SM.getSpellingLoc(Ref.RefLocation)))
+  // Ignore locations within macro expansions or not in the main file

no need to do the isWrittenInMainFile check in the callback, the walkUsed 
implementation already does it.



Comment at: clang-tools-extra/clangd/Hover.cpp:1128
+if (Ref.RT != include_cleaner::RefType::Explicit)
+  // Ignore non-explicit references (e.g. variable names).
+  return;

I don't get it, why variable names are non-explicit references?



Comment at: clang-tools-extra/clangd/Hover.cpp:1140
+// Check that the user is hovering over the current symbol reference.
+if (CurLoc < Ref.RefLocation || CurLoc > RefEndLocation) {
+  return;

We're using the location as a heuristic to join the symbol (Decl) from two 
difference sources (clangd's hover impl, and include-cleaner lib impl)

This heuristics works most of time, but it will fail in the case where the 
symbol under the hover is a `UsingDecl`

```
// absl_string_view.h
namespace absl {
using std::string_view;
}

// main.cpp
#includle "absl_string_view.h"
absl::str^ing_view abc; // hover on string_view
```

- clangd's hover uses the underlying decl (std::string_view), see the 
`pickDeclToUse` function for details;
- include-cleaner lib reports the using decl (asbl::string_view);

As a result, we will show the #include of the using decl for the underlying 
decl in the hover card.

To solve the issue, I think we need to check the equality of Decl from hover 
and Decl from `SymbolReference` (comparing both `getCanonicalDecl` should be 
enough).




Comment at: clang-tools-extra/clangd/Hover.cpp:1153
+SM.getFileEntryForID(SM.getMainFileID()) ==
+Provider.physical()) {
+  // Do not report main file as provider.

We probably don't need to handle this main-file case specially, in practice, 
main-file is hardly included in the MainFileIncludes, so the following logic 
will filter the main-file as well.



Comment at: clang-tools-extra/clangd/Hover.cpp:1163
+case include_cleaner::Header::Physical:
+  if (Provider.physical()->tryGetRealPathName() == Inc.Resolved)
+DirectlyIncludedProviders.push_back(WrittenRef.str());

checking the spelled string can cause subtle behavior & bugs. A robust way is 
to use the `include_cleaner::Includes.match API` to determine a header is used 
or not (this is similar to what you did in https://reviews.llvm.org/D143496, we 
need to expose the transformation function `convertIncludes`)



Comment at: clang-tools-extra/clangd/Hover.cpp:1172
+  if (Provider.verbatim() == Inc.Written)
+DirectlyIncludedProviders.push_back(WrittenRef.str());
+}

nit: I'd suggest adding a `break` even though it is the last case. 



Comment at: clang-tools-extra/clangd/Hover.cpp:1181
+HI.ProviderInfo = std::optional>{
+std::move(DirectlyIncludedProviders)};
+  });

I wonder whether we need to deduplicate the `DirectlyIncludedProviders`, 
reading the code, it might be possible that we add duplicated headers, but in 
practice, we should only have a single Ref reported, so the deduplication is 
probably not needed. 



Comment at: clang-tools-extra

[PATCH] D145148: [Clang][CodeGen] Fix this argument type for certain destructors

2023-03-02 Thread Jacob Young via Phabricator via cfe-commits
jacobly created this revision.
jacobly added reviewers: efriedma, aaron.ballman.
Herald added a project: All.
jacobly requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

With the Microsoft ABI, some destructors need to offset a parameter to
get the derived this pointer, in which case the type of that parameter
should not be a pointer to the derived type.

Fixes #60465


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145148

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/test/CodeGenCXX/constructor-destructor-return-this.cpp
  clang/test/CodeGenCXX/cxx2a-destroying-delete.cpp
  clang/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
  clang/test/CodeGenCXX/microsoft-abi-structors.cpp
  clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp

Index: clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
===
--- clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
@@ -53,6 +53,7 @@
 B::~B() {
   // CHECK-LABEL: define dso_local x86_thiscallcc void @"??1B@@UAE@XZ"
   // Store initial this:
+  // CHECK:   %[[THIS:.*]] = alloca %struct.B*
   // CHECK:   %[[THIS_ADDR:.*]] = alloca %struct.B*
   // CHECK:   store %struct.B* %{{.*}}, %struct.B** %[[THIS_ADDR]], align 4
   // Reload and adjust the this parameter:
@@ -90,8 +91,7 @@
   // CHECK2: %[[THIS:.*]] = load %struct.B*, %struct.B** {{.*}}
   // CHECK2: %[[THIS_i8:.*]] = bitcast %struct.B* %[[THIS]] to i8*
   // CHECK2: %[[B_i8:.*]] = getelementptr i8, i8* %[[THIS_i8]], i32 8
-  // CHECK2: %[[B:.*]] = bitcast i8* %[[B_i8]] to %struct.B*
-  // CHECK2: call x86_thiscallcc void @"??1B@@UAE@XZ"(%struct.B* {{[^,]*}} %[[B]])
+  // CHECK2: call x86_thiscallcc void @"??1B@@UAE@XZ"(i8*{{[^,]*}} %[[B_i8]])
   // CHECK2: %[[THIS_i8:.*]] = bitcast %struct.B* %[[THIS]] to i8*
   // CHECK2: %[[VBASE_i8:.*]] = getelementptr inbounds i8, i8* %[[THIS_i8]], i32 8
   // CHECK2: %[[VBASE:.*]] = bitcast i8* %[[VBASE_i8]] to %struct.VBase*
@@ -99,6 +99,7 @@
   // CHECK2: ret
 
   // CHECK2-LABEL: define linkonce_odr dso_local x86_thiscallcc noundef i8* @"??_GB@@UAEPAXI@Z"
+  // CHECK2:   store %struct.B* %{{.*}}, %struct.B** %[[THIS:.*]], align 4
   // CHECK2:   store %struct.B* %{{.*}}, %struct.B** %[[THIS_ADDR:.*]], align 4
   // CHECK2:   %[[THIS:.*]] = load %struct.B*, %struct.B** %[[THIS_ADDR]]
   // CHECK2:   %[[THIS_PARAM_i8:.*]] = bitcast %struct.B* %[[THIS]] to i8*
@@ -195,8 +196,7 @@
 // CHECK: %[[VBENTRY:.*]] = getelementptr inbounds i32, i32* %[[VBTABLE]], i32 1
 // CHECK: %[[VBOFFSET32:.*]] = load i32, i32* %[[VBENTRY]]
 // CHECK: %[[VBOFFSET:.*]] = add nsw i32 0, %[[VBOFFSET32]]
-// CHECK: %[[VBASE_i8:.*]] = getelementptr inbounds i8, i8* %[[OBJ_i8]], i32 %[[VBOFFSET]]
-// CHECK: %[[VBASE:.*]] = bitcast i8* %[[VBASE_i8]] to %struct.B*
+// CHECK: %[[VBASE:.*]] = getelementptr inbounds i8, i8* %[[OBJ_i8]], i32 %[[VBOFFSET]]
 //
 // CHECK: %[[OBJ_i8:.*]] = bitcast %struct.B* %[[OBJ]] to i8*
 // CHECK: %[[VBPTR:.*]] = getelementptr inbounds i8, i8* %[[OBJ_i8]], i32 0
@@ -206,12 +206,12 @@
 // CHECK: %[[VBOFFSET32:.*]] = load i32, i32* %[[VBENTRY]]
 // CHECK: %[[VBOFFSET:.*]] = add nsw i32 0, %[[VBOFFSET32]]
 // CHECK: %[[VBASE_i8:.*]] = getelementptr inbounds i8, i8* %[[OBJ_i8]], i32 %[[VBOFFSET]]
-// CHECK: %[[VFPTR:.*]] = bitcast i8* %[[VBASE_i8]] to i8* (%struct.B*, i32)***
-// CHECK: %[[VFTABLE:.*]] = load i8* (%struct.B*, i32)**, i8* (%struct.B*, i32)*** %[[VFPTR]]
-// CHECK: %[[VFUN:.*]] = getelementptr inbounds i8* (%struct.B*, i32)*, i8* (%struct.B*, i32)** %[[VFTABLE]], i64 0
-// CHECK: %[[VFUN_VALUE:.*]] = load i8* (%struct.B*, i32)*, i8* (%struct.B*, i32)** %[[VFUN]]
+// CHECK: %[[VFPTR:.*]] = bitcast i8* %[[VBASE_i8]] to i8* (i8*, i32)***
+// CHECK: %[[VFTABLE:.*]] = load i8* (i8*, i32)**, i8* (i8*, i32)*** %[[VFPTR]]
+// CHECK: %[[VFUN:.*]] = getelementptr inbounds i8* (i8*, i32)*, i8* (i8*, i32)** %[[VFTABLE]], i64 0
+// CHECK: %[[VFUN_VALUE:.*]] = load i8* (i8*, i32)*, i8* (i8*, i32)** %[[VFUN]]
 //
-// CHECK: call x86_thiscallcc noundef i8* %[[VFUN_VALUE]](%struct.B* {{[^,]*}} %[[VBASE]], i32 noundef 1)
+// CHECK: call x86_thiscallcc noundef i8* %[[VFUN_VALUE]](i8* {{[^,]*}} %[[VBASE]], i32 noundef 1)
 // CHECK: ret void
 }
 
@@ -295,8 +295,9 @@
 } d;
 
 D::~D() {
-  // CHECK-LABEL: define dso_local x86_thiscallcc void @"??1D@diamond@@UAE@XZ"(%"struct.diamond::D"*{{.*}})
+  // CHECK-LABEL: define dso_local x86_thiscallcc void @"??1D@diamond@@UAE@XZ"(i8*{{.*}})
   // Store initial this:
+  // CHECK: %[[THIS:.*]] = alloca %"struct.diamond::D"*
   // CHECK: %[[THIS_ADDR:.*]] = alloca %"struct.diamond::D"*
   // CHECK: store %"struct.diamond::D"* %{{.*}}, %"struct.diamond::D"** %[[THIS_ADDR]], align 4
   //
@@ -310,16 +3

[PATCH] D143233: [Clang][CodeGen] Fix this argument type for certain destructors

2023-03-02 Thread Jacob Young via Phabricator via cfe-commits
jacobly added a comment.

In D143233#4161909 , @aaron.ballman 
wrote:

> In D143233#4160206 , @efriedma 
> wrote:
>
>> Maybe worth cherry-picking to 16 branch?  I think someone will need to 
>> rebase onto the branch for that, though; there was merge conflict on the 
>> microsoft-abi-eh-cleanups.cpp change.
>
> I wouldn't be opposed to picking this onto 16 given that it's fixing an ABI 
> issue, if someone wants to do the work to cherry-pick it.

https://reviews.llvm.org/D145148


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143233/new/

https://reviews.llvm.org/D143233

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


[PATCH] D145148: [Clang][CodeGen] Fix this argument type for certain destructors

2023-03-02 Thread Jacob Young via Phabricator via cfe-commits
jacobly added a comment.

cherry-picked to release/16.x


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145148/new/

https://reviews.llvm.org/D145148

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


[PATCH] D145148: [Clang][CodeGen] Fix this argument type for certain destructors

2023-03-02 Thread Jacob Young via Phabricator via cfe-commits
jacobly updated this revision to Diff 501811.
jacobly added a comment.

Fix discrepency with original patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145148/new/

https://reviews.llvm.org/D145148

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/test/CodeGenCXX/constructor-destructor-return-this.cpp
  clang/test/CodeGenCXX/cxx2a-destroying-delete.cpp
  clang/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
  clang/test/CodeGenCXX/microsoft-abi-structors.cpp
  clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp

Index: clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
===
--- clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
@@ -53,6 +53,7 @@
 B::~B() {
   // CHECK-LABEL: define dso_local x86_thiscallcc void @"??1B@@UAE@XZ"
   // Store initial this:
+  // CHECK:   %[[THIS:.*]] = alloca %struct.B*
   // CHECK:   %[[THIS_ADDR:.*]] = alloca %struct.B*
   // CHECK:   store %struct.B* %{{.*}}, %struct.B** %[[THIS_ADDR]], align 4
   // Reload and adjust the this parameter:
@@ -90,8 +91,7 @@
   // CHECK2: %[[THIS:.*]] = load %struct.B*, %struct.B** {{.*}}
   // CHECK2: %[[THIS_i8:.*]] = bitcast %struct.B* %[[THIS]] to i8*
   // CHECK2: %[[B_i8:.*]] = getelementptr i8, i8* %[[THIS_i8]], i32 8
-  // CHECK2: %[[B:.*]] = bitcast i8* %[[B_i8]] to %struct.B*
-  // CHECK2: call x86_thiscallcc void @"??1B@@UAE@XZ"(%struct.B* {{[^,]*}} %[[B]])
+  // CHECK2: call x86_thiscallcc void @"??1B@@UAE@XZ"(i8*{{[^,]*}} %[[B_i8]])
   // CHECK2: %[[THIS_i8:.*]] = bitcast %struct.B* %[[THIS]] to i8*
   // CHECK2: %[[VBASE_i8:.*]] = getelementptr inbounds i8, i8* %[[THIS_i8]], i32 8
   // CHECK2: %[[VBASE:.*]] = bitcast i8* %[[VBASE_i8]] to %struct.VBase*
@@ -99,6 +99,7 @@
   // CHECK2: ret
 
   // CHECK2-LABEL: define linkonce_odr dso_local x86_thiscallcc noundef i8* @"??_GB@@UAEPAXI@Z"
+  // CHECK2:   store %struct.B* %{{.*}}, %struct.B** %[[THIS:.*]], align 4
   // CHECK2:   store %struct.B* %{{.*}}, %struct.B** %[[THIS_ADDR:.*]], align 4
   // CHECK2:   %[[THIS:.*]] = load %struct.B*, %struct.B** %[[THIS_ADDR]]
   // CHECK2:   %[[THIS_PARAM_i8:.*]] = bitcast %struct.B* %[[THIS]] to i8*
@@ -195,8 +196,7 @@
 // CHECK: %[[VBENTRY:.*]] = getelementptr inbounds i32, i32* %[[VBTABLE]], i32 1
 // CHECK: %[[VBOFFSET32:.*]] = load i32, i32* %[[VBENTRY]]
 // CHECK: %[[VBOFFSET:.*]] = add nsw i32 0, %[[VBOFFSET32]]
-// CHECK: %[[VBASE_i8:.*]] = getelementptr inbounds i8, i8* %[[OBJ_i8]], i32 %[[VBOFFSET]]
-// CHECK: %[[VBASE:.*]] = bitcast i8* %[[VBASE_i8]] to %struct.B*
+// CHECK: %[[VBASE:.*]] = getelementptr inbounds i8, i8* %[[OBJ_i8]], i32 %[[VBOFFSET]]
 //
 // CHECK: %[[OBJ_i8:.*]] = bitcast %struct.B* %[[OBJ]] to i8*
 // CHECK: %[[VBPTR:.*]] = getelementptr inbounds i8, i8* %[[OBJ_i8]], i32 0
@@ -206,12 +206,12 @@
 // CHECK: %[[VBOFFSET32:.*]] = load i32, i32* %[[VBENTRY]]
 // CHECK: %[[VBOFFSET:.*]] = add nsw i32 0, %[[VBOFFSET32]]
 // CHECK: %[[VBASE_i8:.*]] = getelementptr inbounds i8, i8* %[[OBJ_i8]], i32 %[[VBOFFSET]]
-// CHECK: %[[VFPTR:.*]] = bitcast i8* %[[VBASE_i8]] to i8* (%struct.B*, i32)***
-// CHECK: %[[VFTABLE:.*]] = load i8* (%struct.B*, i32)**, i8* (%struct.B*, i32)*** %[[VFPTR]]
-// CHECK: %[[VFUN:.*]] = getelementptr inbounds i8* (%struct.B*, i32)*, i8* (%struct.B*, i32)** %[[VFTABLE]], i64 0
-// CHECK: %[[VFUN_VALUE:.*]] = load i8* (%struct.B*, i32)*, i8* (%struct.B*, i32)** %[[VFUN]]
+// CHECK: %[[VFPTR:.*]] = bitcast i8* %[[VBASE_i8]] to i8* (i8*, i32)***
+// CHECK: %[[VFTABLE:.*]] = load i8* (i8*, i32)**, i8* (i8*, i32)*** %[[VFPTR]]
+// CHECK: %[[VFUN:.*]] = getelementptr inbounds i8* (i8*, i32)*, i8* (i8*, i32)** %[[VFTABLE]], i64 0
+// CHECK: %[[VFUN_VALUE:.*]] = load i8* (i8*, i32)*, i8* (i8*, i32)** %[[VFUN]]
 //
-// CHECK: call x86_thiscallcc noundef i8* %[[VFUN_VALUE]](%struct.B* {{[^,]*}} %[[VBASE]], i32 noundef 1)
+// CHECK: call x86_thiscallcc noundef i8* %[[VFUN_VALUE]](i8* {{[^,]*}} %[[VBASE]], i32 noundef 1)
 // CHECK: ret void
 }
 
@@ -295,8 +295,9 @@
 } d;
 
 D::~D() {
-  // CHECK-LABEL: define dso_local x86_thiscallcc void @"??1D@diamond@@UAE@XZ"(%"struct.diamond::D"*{{.*}})
+  // CHECK-LABEL: define dso_local x86_thiscallcc void @"??1D@diamond@@UAE@XZ"(i8*{{.*}})
   // Store initial this:
+  // CHECK: %[[THIS:.*]] = alloca %"struct.diamond::D"*
   // CHECK: %[[THIS_ADDR:.*]] = alloca %"struct.diamond::D"*
   // CHECK: store %"struct.diamond::D"* %{{.*}}, %"struct.diamond::D"** %[[THIS_ADDR]], align 4
   //
@@ -310,16 +311,13 @@
   // CHECK: %[[C_i8:.*]] = getelementptr inbounds i8, i8* %[[D_i8]], i32 4
   // CHECK: %[[C:.*]] = bitcast i8* %[[C_i8]] to %"struct.diamond::C"*
   // CHECK: %[[C_i8:.*]] = bitcast %"struct.diamond::C"* %[[C]] to i8*
-  // CHECK: %[[ARG_i

[clang] 43e6770 - Revert "[clang][Interp] Implement C++ Range-for loops"

2023-03-02 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-03-02T11:04:09+01:00
New Revision: 43e67707f9ab14deafc57006aad69a263c700450

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

LOG: Revert "[clang][Interp] Implement C++ Range-for loops"

This reverts commit bce8b3c1830434c10b8a30380db522d7c6a8658d.

This commit breaks memory-sanitizer builds:
https://lab.llvm.org/buildbot/#/builders/5/builds/31899

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeStmtGen.cpp
clang/lib/AST/Interp/ByteCodeStmtGen.h
clang/test/AST/Interp/loops.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp 
b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
index 80a81c67df40..ff2727cc4d35 100644
--- a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -172,8 +172,6 @@ bool ByteCodeStmtGen::visitStmt(const Stmt *S) {
 return visitDoStmt(cast(S));
   case Stmt::ForStmtClass:
 return visitForStmt(cast(S));
-  case Stmt::CXXForRangeStmtClass:
-return visitCXXForRangeStmt(cast(S));
   case Stmt::BreakStmtClass:
 return visitBreakStmt(cast(S));
   case Stmt::ContinueStmtClass:
@@ -371,56 +369,6 @@ bool ByteCodeStmtGen::visitForStmt(const ForStmt 
*S) {
   return true;
 }
 
-template 
-bool ByteCodeStmtGen::visitCXXForRangeStmt(const CXXForRangeStmt *S) {
-  const Stmt *Init = S->getInit();
-  const Expr *Cond = S->getCond();
-  const Expr *Inc = S->getInc();
-  const Stmt *Body = S->getBody();
-  const Stmt *BeginStmt = S->getBeginStmt();
-  const Stmt *RangeStmt = S->getRangeStmt();
-  const Stmt *EndStmt = S->getEndStmt();
-  const VarDecl *LoopVar = S->getLoopVariable();
-
-  LabelTy EndLabel = this->getLabel();
-  LabelTy CondLabel = this->getLabel();
-  LabelTy IncLabel = this->getLabel();
-  ExprScope ES(this);
-  LoopScope LS(this, EndLabel, IncLabel);
-
-  // Emit declarations needed in the loop.
-  if (Init && !this->visitStmt(Init))
-return false;
-  if (!this->visitStmt(RangeStmt))
-return false;
-  if (!this->visitStmt(BeginStmt))
-return false;
-  if (!this->visitStmt(EndStmt))
-return false;
-
-  // Now the condition as well as the loop variable assignment.
-  this->emitLabel(CondLabel);
-  if (!this->visitBool(Cond))
-return false;
-  if (!this->jumpFalse(EndLabel))
-return false;
-
-  if (!this->visitVarDecl(LoopVar))
-return false;
-
-  // Body.
-  if (!this->visitStmt(Body))
-return false;
-  this->emitLabel(IncLabel);
-  if (!this->discard(Inc))
-return false;
-  if (!this->jump(CondLabel))
-return false;
-
-  this->emitLabel(EndLabel);
-  return true;
-}
-
 template 
 bool ByteCodeStmtGen::visitBreakStmt(const BreakStmt *S) {
   if (!BreakLabel)

diff  --git a/clang/lib/AST/Interp/ByteCodeStmtGen.h 
b/clang/lib/AST/Interp/ByteCodeStmtGen.h
index 6b3644ad1346..7a30f7b69470 100644
--- a/clang/lib/AST/Interp/ByteCodeStmtGen.h
+++ b/clang/lib/AST/Interp/ByteCodeStmtGen.h
@@ -60,7 +60,6 @@ class ByteCodeStmtGen final : public ByteCodeExprGen 
{
   bool visitWhileStmt(const WhileStmt *S);
   bool visitDoStmt(const DoStmt *S);
   bool visitForStmt(const ForStmt *S);
-  bool visitCXXForRangeStmt(const CXXForRangeStmt *S);
   bool visitBreakStmt(const BreakStmt *S);
   bool visitContinueStmt(const ContinueStmt *S);
   bool visitSwitchStmt(const SwitchStmt *S);

diff  --git a/clang/test/AST/Interp/loops.cpp b/clang/test/AST/Interp/loops.cpp
index 2e235123af76..d0386e3ac759 100644
--- a/clang/test/AST/Interp/loops.cpp
+++ b/clang/test/AST/Interp/loops.cpp
@@ -3,6 +3,10 @@
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++20 
-verify=expected-cpp20 %s
 // RUN: %clang_cc1 -std=c++20 -verify=ref %s
 
+// ref-no-diagnostics
+// expected-no-diagnostics
+// expected-cpp20-no-diagnostics
+
 namespace WhileLoop {
   constexpr int f() {
 int i = 0;
@@ -270,57 +274,3 @@ namespace ForLoop {
 #endif
 
 };
-
-namespace RangeForLoop {
-  constexpr int localArray() {
-int a[] = {1,2,3,4};
-int s = 0;
-for(int i : a) {
-  s += i;
-}
-return s;
-  }
-  static_assert(localArray() == 10, "");
-
-  constexpr int localArray2() {
-int a[] = {1,2,3,4};
-int s = 0;
-for(const int &i : a) {
-  s += i;
-}
-return s;
-  }
-  static_assert(localArray2() == 10, "");
-
-  constexpr int nested() {
-int s = 0;
-for (const int i : (int[]){1,2,3,4}) {
-  int a[] = {i, i};
-  for(int m : a) {
-s += m;
-  }
-}
-return s;
-  }
-  static_assert(nested() == 20, "");
-
-  constexpr int withBreak() {
-int s = 0;
-for (const int &i: (bool[]){false, true}) {
-  if (i)
-break;
-  s++;
-}
-return s;
-  }
-  static_assert(withBreak() == 1, "");
-
-  constexpr void NoBody() {
-for (const int &i: (bool[]){false, true

[PATCH] D145150: clang: Emit nofpclass(nan inf) for -ffinite-math-only

2023-03-02 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: efriedma, nikic, jcranmer-intel, kpn, andrew.w.kaylor, 
cameron.mcinally, sepavloff.
Herald added subscribers: StephenFan, jdoerfert, hiraditya.
Herald added a project: All.
arsenm requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

Set this on any source level floating-point type argument,
return value, call return or outgoing parameter which is lowered
to a valid IR type for the attribute. Currently this isn't
applied to emitted intrinsics since those don't go through
ABI code.


https://reviews.llvm.org/D145150

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/complex-math.c
  clang/test/CodeGen/fp-function-attrs.cpp
  clang/test/CodeGen/fp-options-to-fast-math-flags.c
  clang/test/CodeGen/func-attr.c
  clang/test/CodeGen/matrix-type-operators-fast-math.c
  clang/test/CodeGen/nofpclass.c
  llvm/include/llvm/IR/Attributes.h
  llvm/lib/IR/Attributes.cpp
  llvm/test/Linker/Inputs/nofpclass.ll
  llvm/test/Linker/nofpclass.ll

Index: llvm/test/Linker/nofpclass.ll
===
--- /dev/null
+++ llvm/test/Linker/nofpclass.ll
@@ -0,0 +1,30 @@
+; RUN: llvm-link %s %S/Inputs/nofpclass.ll -S -o - | FileCheck -check-prefix=ORDER1 %s
+; RUN: llvm-link %S/Inputs/nofpclass.ll %s -S -o - | FileCheck -check-prefix=ORDER2 %s
+
+; Make sure nofpclass is dropped if the function was declared as
+; nofpclass, but not defined with nofpclass.
+
+; ORDER1: define float @caller(float %arg) {
+; ORDER1-NEXT: %result = call float @declared_as_nonan(float %arg)
+; ORDER1-NEXT: ret float %result
+
+; ORDER1: define float @declared_as_nonan(float %arg) {
+; ORDER1-NEXT: %add = fadd float %arg, 1.00e+00
+; ORDER1-NEXT: ret float %add
+
+
+; ORDER2: define float @declared_as_nonan(float %arg) {
+; ORDER2-NEXT: %add = fadd float %arg, 1.00e+00
+; ORDER2-NEXT: ret float %add
+
+; ORDER2: define float @caller(float %arg) {
+; ORDER2-NEXT: %result = call float @declared_as_nonan(float %arg)
+; ORDER2-NEXT: ret float %result
+
+
+declare nofpclass(nan) float @declared_as_nonan(float nofpclass(nan))
+
+define float @caller(float %arg) {
+  %result = call float @declared_as_nonan(float %arg)
+  ret float %result
+}
Index: llvm/test/Linker/Inputs/nofpclass.ll
===
--- /dev/null
+++ llvm/test/Linker/Inputs/nofpclass.ll
@@ -0,0 +1,4 @@
+define float @declared_as_nonan(float %arg) {
+  %add = fadd float %arg, 1.0
+  ret float %add
+}
Index: llvm/lib/IR/Attributes.cpp
===
--- llvm/lib/IR/Attributes.cpp
+++ llvm/lib/IR/Attributes.cpp
@@ -266,16 +266,6 @@
   .Default(false);
 }
 
-/// Returns true if this is a type legal for the 'nofpclass' attribute. This
-/// follows the same type rules as FPMathOperator.
-///
-/// TODO: Consider relaxing to any FP type struct fields.
-static bool isNoFPClassCompatibleType(Type *Ty) {
-  while (ArrayType *ArrTy = dyn_cast(Ty))
-Ty = ArrTy->getElementType();
-  return Ty->isFPOrFPVectorTy();
-}
-
 //===--===//
 // Attribute Accessor Methods
 //===--===//
@@ -1896,6 +1886,9 @@
 }
 
 AttrBuilder &AttrBuilder::addNoFPClassAttr(FPClassTest Mask) {
+  if (Mask == fcNone)
+return *this;
+
   return addRawIntAttr(Attribute::NoFPClass, Mask);
 }
 
@@ -1981,6 +1974,16 @@
 // AttributeFuncs Function Defintions
 //===--===//
 
+/// Returns true if this is a type legal for the 'nofpclass' attribute. This
+/// follows the same type rules as FPMathOperator.
+///
+/// TODO: Consider relaxing to any FP type struct fields.
+bool AttributeFuncs::isNoFPClassCompatibleType(Type *Ty) {
+  while (ArrayType *ArrTy = dyn_cast(Ty))
+Ty = ArrTy->getElementType();
+  return Ty->isFPOrFPVectorTy();
+}
+
 /// Which attributes cannot be applied to a type.
 AttributeMask AttributeFuncs::typeIncompatible(Type *Ty,
AttributeSafetyKind ASK) {
Index: llvm/include/llvm/IR/Attributes.h
===
--- llvm/include/llvm/IR/Attributes.h
+++ llvm/include/llvm/IR/Attributes.h
@@ -1265,6 +1265,10 @@
   ASK_ALL = ASK_SAFE_TO_DROP | ASK_UNSAFE_TO_DROP,
 };
 
+/// Returns true if this is a type legal for the 'nofpclass' attribute. This
+/// follows the same type rules as FPMathOperator.
+bool isNoFPClassCompatibleType(Type *Ty);
+
 /// Which attributes cannot be applied to a type. The argument \p ASK indicates,
 /// if only attributes that are known to be safely droppable are contained in
 /// the mask; only attributes that might be unsafe to drop (e.g., ABI-related
Index: clang/test/CodeGen/nofpclass.c
==

[PATCH] D145151: clang: Handle MatrixType in hasFloatingRepresentation

2023-03-02 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added a reviewer: fhahn.
Herald added a subscriber: StephenFan.
Herald added a project: All.
arsenm requested review of this revision.
Herald added a subscriber: wdng.

Allows applying nofpclass to matrix arguments.


https://reviews.llvm.org/D145151

Files:
  clang/lib/AST/Type.cpp
  clang/test/CodeGen/matrix-type-operators-fast-math.c
  clang/test/CodeGen/nofpclass.c

Index: clang/test/CodeGen/nofpclass.c
===
--- clang/test/CodeGen/nofpclass.c
+++ clang/test/CodeGen/nofpclass.c
@@ -1396,40 +1396,40 @@
 }
 
 // CFINITEONLY: Function Attrs: noinline nounwind optnone
-// CFINITEONLY-LABEL: define dso_local <25 x double> @call_matrix
-// CFINITEONLY-SAME: (<25 x double> noundef [[X:%.*]]) #[[ATTR6:[0-9]+]] {
+// CFINITEONLY-LABEL: define dso_local nofpclass(nan inf) <25 x double> @call_matrix
+// CFINITEONLY-SAME: (<25 x double> noundef nofpclass(nan inf) [[X:%.*]]) #[[ATTR6:[0-9]+]] {
 // CFINITEONLY-NEXT:  entry:
 // CFINITEONLY-NEXT:[[X_ADDR:%.*]] = alloca [25 x double], align 8
 // CFINITEONLY-NEXT:store <25 x double> [[X]], ptr [[X_ADDR]], align 8
 // CFINITEONLY-NEXT:[[TMP0:%.*]] = load <25 x double>, ptr [[X_ADDR]], align 8
-// CFINITEONLY-NEXT:[[CALL:%.*]] = call nnan ninf <25 x double> @extern_matrix(<25 x double> noundef [[TMP0]])
+// CFINITEONLY-NEXT:[[CALL:%.*]] = call nnan ninf nofpclass(nan inf) <25 x double> @extern_matrix(<25 x double> noundef nofpclass(nan inf) [[TMP0]])
 // CFINITEONLY-NEXT:ret <25 x double> [[CALL]]
 //
 // CLFINITEONLY: Function Attrs: convergent norecurse nounwind
-// CLFINITEONLY-LABEL: define dso_local <25 x double> @call_matrix
-// CLFINITEONLY-SAME: (<25 x double> noundef [[X:%.*]]) local_unnamed_addr #[[ATTR9:[0-9]+]] {
+// CLFINITEONLY-LABEL: define dso_local nofpclass(nan inf) <25 x double> @call_matrix
+// CLFINITEONLY-SAME: (<25 x double> noundef nofpclass(nan inf) [[X:%.*]]) local_unnamed_addr #[[ATTR9:[0-9]+]] {
 // CLFINITEONLY-NEXT:  entry:
-// CLFINITEONLY-NEXT:[[CALL:%.*]] = tail call nnan ninf <25 x double> @extern_matrix(<25 x double> noundef [[X]]) #[[ATTR10]]
+// CLFINITEONLY-NEXT:[[CALL:%.*]] = tail call nnan ninf nofpclass(nan inf) <25 x double> @extern_matrix(<25 x double> noundef nofpclass(nan inf) [[X]]) #[[ATTR10]]
 // CLFINITEONLY-NEXT:ret <25 x double> [[CALL]]
 //
 // NONANS: Function Attrs: noinline nounwind optnone
-// NONANS-LABEL: define dso_local <25 x double> @call_matrix
-// NONANS-SAME: (<25 x double> noundef [[X:%.*]]) #[[ATTR6:[0-9]+]] {
+// NONANS-LABEL: define dso_local nofpclass(nan) <25 x double> @call_matrix
+// NONANS-SAME: (<25 x double> noundef nofpclass(nan) [[X:%.*]]) #[[ATTR6:[0-9]+]] {
 // NONANS-NEXT:  entry:
 // NONANS-NEXT:[[X_ADDR:%.*]] = alloca [25 x double], align 8
 // NONANS-NEXT:store <25 x double> [[X]], ptr [[X_ADDR]], align 8
 // NONANS-NEXT:[[TMP0:%.*]] = load <25 x double>, ptr [[X_ADDR]], align 8
-// NONANS-NEXT:[[CALL:%.*]] = call nnan <25 x double> @extern_matrix(<25 x double> noundef [[TMP0]])
+// NONANS-NEXT:[[CALL:%.*]] = call nnan nofpclass(nan) <25 x double> @extern_matrix(<25 x double> noundef nofpclass(nan) [[TMP0]])
 // NONANS-NEXT:ret <25 x double> [[CALL]]
 //
 // NOINFS: Function Attrs: noinline nounwind optnone
-// NOINFS-LABEL: define dso_local <25 x double> @call_matrix
-// NOINFS-SAME: (<25 x double> noundef [[X:%.*]]) #[[ATTR6:[0-9]+]] {
+// NOINFS-LABEL: define dso_local nofpclass(inf) <25 x double> @call_matrix
+// NOINFS-SAME: (<25 x double> noundef nofpclass(inf) [[X:%.*]]) #[[ATTR6:[0-9]+]] {
 // NOINFS-NEXT:  entry:
 // NOINFS-NEXT:[[X_ADDR:%.*]] = alloca [25 x double], align 8
 // NOINFS-NEXT:store <25 x double> [[X]], ptr [[X_ADDR]], align 8
 // NOINFS-NEXT:[[TMP0:%.*]] = load <25 x double>, ptr [[X_ADDR]], align 8
-// NOINFS-NEXT:[[CALL:%.*]] = call ninf <25 x double> @extern_matrix(<25 x double> noundef [[TMP0]])
+// NOINFS-NEXT:[[CALL:%.*]] = call ninf nofpclass(inf) <25 x double> @extern_matrix(<25 x double> noundef nofpclass(inf) [[TMP0]])
 // NOINFS-NEXT:ret <25 x double> [[CALL]]
 //
 dx5x5_t call_matrix(dx5x5_t x) {
Index: clang/test/CodeGen/matrix-type-operators-fast-math.c
===
--- clang/test/CodeGen/matrix-type-operators-fast-math.c
+++ clang/test/CodeGen/matrix-type-operators-fast-math.c
@@ -8,7 +8,7 @@
 // Floating point matrix/scalar additions.
 
 void add_matrix_matrix_double(dx5x5_t a, dx5x5_t b, dx5x5_t c) {
-  // CHECK-LABEL: define{{.*}} void @add_matrix_matrix_double(<25 x double> noundef %a, <25 x double> noundef %b, <25 x double> noundef %c)
+  // CHECK-LABEL: define{{.*}} void @add_matrix_matrix_double(<25 x double> noundef nofpclass(nan inf) %a, <25 x double> noundef nofpclass(nan inf) %b, <25 x double> noundef nofpclass(nan inf) %c)
   // CHECK:   [[B:%.*]] = load <25 x double>, ptr {{.*}}, align 8
   // CHECK

[PATCH] D144480: [C++20][ClangTidy] Update the ClangTidy tests to also test in C++20 mode

2023-03-02 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-member-init-cxx98.cpp:2
 // RUN: %check_clang_tidy -std=c++98 %s cppcoreguidelines-pro-type-member-init 
%t -- -- -fno-delayed-template-parsing
-
 struct PositiveFieldBeforeConstructor {

Please revert this unnecessary change.



Comment at: clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h:113
   if (extension == ".cc" || extension == ".cpp" || extension == ".mm") {
-Args.push_back("-std=c++11");
   }

Could you break this out into a separate commit with a description like "change 
ClangTidy unit tests to run in C++20 mode instead of C++11". This is a change, 
not an extension ("also run in C++20").


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144480/new/

https://reviews.llvm.org/D144480

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


[PATCH] D144864: [Flang][Driver][MLIR] Add -fopenmp-is-device to Flang and link to an omp.is_device attribute

2023-03-02 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added inline comments.



Comment at: clang/lib/Driver/ToolChains/Flang.cpp:121-125
+  if (IsOpenMPDevice) {
+// -fopenmp-is-device is passed along to tell the frontend that it is
+// generating code for a device, so that only the relevant declarations are
+// emitted.
+CmdArgs.push_back("-fopenmp-is-device");

Can you add a test for this section?



Comment at: flang/test/Lower/OpenMP/omp-is-device.f90:1
+!RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-is-device %s -o - | FileCheck %s 
--check-prefix=DEVICE
+!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s --check-prefix=HOST

What happens if `-fopenmp-is-device` is used without `-fopnemp`?



Comment at: flang/tools/bbc/bbc.cpp:127
+static llvm::cl::opt
+enableOpenMPDevice("fopenmp-is-device",
+   llvm::cl::desc("enable openmp device compilation"),

This option is not tested


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144864/new/

https://reviews.llvm.org/D144864

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


[PATCH] D143418: [libclang] Add API to override preamble storage path

2023-03-02 Thread Igor Kushnir via Phabricator via cfe-commits
vedgy marked an inline comment as not done.
vedgy added inline comments.



Comment at: clang/include/clang-c/Index.h:329
+ * CXIndexOptions Opts = { sizeof(CXIndexOptions),
+ * clang_getDefaultGlobalOptions() };
+ * \endcode

vedgy wrote:
> aaron.ballman wrote:
> > vedgy wrote:
> > > When I almost finished the requested changes, I remembered that the 
> > > return value of `clang_getDefaultGlobalOptions()` depends on environment 
> > > variables, and thus `0` is not necessarily the default. Adjusted the 
> > > changes and updated this revision.
> > > 
> > > Does the extra requirement to non-zero initialize this second member sway 
> > > your opinion on the usefulness of the helper function `inline 
> > > CXIndexOptions clang_getDefaultIndexOptions()`? Note that there may be 
> > > same (environment) or other important reasons why future new options 
> > > couldn't be zeroes by default.
> > Thinking out loud a bit... (potentially bad idea incoming)
> > 
> > What if we dropped `clang_getDefaultGlobalOptions()` and instead made a 
> > change to `CXGlobalOptFlags`:
> > ```
> > typedef enum {
> >   /**
> >* Used to indicate that the default CXIndex options are used. By 
> > default, no
> >* global options will be used. However, environment variables may change 
> > which
> >* global options are in effect at runtime.
> >*/
> >   CXGlobalOpt_Default = 0x0,
> > 
> >   /**
> >* Used to indicate that threads that libclang creates for indexing
> >* purposes should use background priority.
> >*
> >* Affects #clang_indexSourceFile, #clang_indexTranslationUnit,
> >* #clang_parseTranslationUnit, #clang_saveTranslationUnit.
> >*/
> >   CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1,
> > 
> >   /**
> >* Used to indicate that threads that libclang creates for editing
> >* purposes should use background priority.
> >*
> >* Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt,
> >* #clang_annotateTokens
> >*/
> >   CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2,
> > 
> >   /**
> >* Used to indicate that all threads that libclang creates should use
> >* background priority.
> >*/
> >   CXGlobalOpt_ThreadBackgroundPriorityForAll =
> >   CXGlobalOpt_ThreadBackgroundPriorityForIndexing |
> >   CXGlobalOpt_ThreadBackgroundPriorityForEditing,
> > 
> >   /**
> >* Used to indicate that no global options should be used, even
> >* in the presence of environment variables.
> >*/
> >   CXGlobalOpt_None = 0x
> > } CXGlobalOptFlags;
> > ```
> > so that when the user passes `0` they get the previous behavior.
> > 
> > `clang_CXIndex_setGlobalOptions()` would remain deprecated. 
> > `clang_CXIndex_getGlobalOptions()` would be interesting though -- would it 
> > return `CXGlobalOpt_None` or `CXGlobalOpt_Default` in the event the index 
> > was created without any global options? Hmmm.
> > 
> > Err, actually, I suppose this won't work too well because then code 
> > silently changes behavior if it does 
> > `clang_CXIndex_setGlobalOptions(CXGlobalOpt_None);` because that would 
> > change from "do what the environment says" to "ignore the environment". But 
> > I have to wonder whether anyone actually *does* that or not... my intuition 
> > is that folks would not call `clang_CXIndex_setGlobalOptions()` at all 
> > unless they were setting an option to a non-none value. We could rename 
> > `CXGlobalOpt_None` to `CXGlobalOpt_Nothing` (or something along those 
> > lines) to force a compilation error, but that's a bit of a nuclear option 
> > for what's supposed to be a stable API.
> > 
> > So I'm on the fence, I guess. I'd still prefer for zero to give sensible 
> > defaults and I don't think there's enough use of the global options + 
> > environment variables to matter. But I also don't like silently breaking 
> > code, so my idea above may be a nonstarter.
> > 
> > I suppose another possible idea is: deprecate the notion of global options 
> > enum and setter/getter entirely, add two new fields to `CXIndexOptions`:
> > ```
> > typedef enum {
> >   CXChoice_Default = 0,
> >   CXChoice_Enabled = 1,
> >   CXChoice_Disabled = 2
> > } CXChoice;
> > 
> > ...
> > unsigned ThreadPriorityBackgroundForIndexing;
> > unsigned ThreadPriorityBackgroundForEditing;
> > ...
> > ```
> > so that `0` gives the correct default behavior based on environment 
> > variable. There would be no global setter or getter for this information 
> > (and we'd eventually remove `clang_CXIndex_[gs]etGlobalOptions()`).
> > I suppose this won't work too well because then code silently changes 
> > behavior if it does `clang_CXIndex_setGlobalOptions(CXGlobalOpt_None);` 
> > because that would change from "do what the environment says" to "ignore 
> > the environment".
> No, the current consequence of such a call already is to ignore the 
> environment. What would change is the consequence of calling

[PATCH] D144480: [C++20][ClangTidy] Update the ClangTidy tests to also test in C++20 mode

2023-03-02 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 501822.
usaxena95 marked 2 inline comments as done.
usaxena95 added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144480/new/

https://reviews.llvm.org/D144480

Files:
  clang-tools-extra/test/clang-tidy/checkers/bugprone/dangling-handle.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/easily-swappable-parameters-implicits.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone/signal-handler.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-exception-at-new.cpp
  clang-tools-extra/test/clang-tidy/checkers/cert/throw-exception-type.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc/static-assert.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type-macros.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability/isolate-declaration-cxx17.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/use-anyofallof.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/use-anyofallof.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/use-anyofallof.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/use-anyofallof.cpp
@@ -1,4 +1,5 @@
 // RUN: %check_clang_tidy -std=c++14,c++17 %s readability-use-anyofallof %t -- -- -fexceptions
+// FIXME: Fix the checker to work in C++20 mode.
 
 bool good_any_of() {
   int v[] = {1, 2, 3};
Index: clang-tools-extra/test/clang-tidy/checkers/readability/isolate-declaration-cxx17.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/isolate-declaration-cxx17.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/isolate-declaration-cxx17.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -std=c++17 %s readability-isolate-declaration %t
+// RUN: %check_clang_tidy -std=c++17-or-later %s readability-isolate-declaration %t
 
 template 
 struct pair {
Index: clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -std=c++14 %s readability-const-return-type %t
+// RUN: %check_clang_tidy -std=c++14-or-later %s readability-const-return-type %t
 
 //  p# = positive test
 //  n# = negative test
Index: clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type-macros.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type-macros.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type-macros.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -std=c++14 %s readability-const-return-type %t -- \
+// RUN: %check_clang_tidy -std=c++14-or-later %s readability-const-return-type %t -- \
 // RUN:   -config="{CheckOptions: [{key: readability-const-return-type.IgnoreMacros, value: false}]}"
 
 //  p# = positive test
Index: clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -std=c++17 %s performance-unnecessary-copy-initialization %t
+// RUN: %check_clang_tidy -std=c++17-or-later %s performance-unnecessary-copy-initialization %t
 
 template 
 struct Iterator {
Index: clang-tools-extra/test/clang-tidy/checkers/misc/static-assert.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc/static-assert.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc/static-assert.cpp
@@ -1,5 +1,5 @@
 // RUN: %check_clang_tidy -std=c++11 -check-suffixes=,CXX11 %s misc-static-assert %t
-// RUN: %check_clang_tidy -std=c++17 -check-suffixes=,CXX17 %s misc-static-assert %t
+// RUN: %check_clang_tidy -std=c++17-or-later -check-suffixes=,CXX17 %s misc-static-assert %t
 
 void abort() {}
 #ifdef NDEBUG
Index: clang-tools-extra/test/clang-tidy/checkers/cert/throw-exception-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cert/throw-exception-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cert/throw-exception-type.cpp
@@ -1,

[clang-tools-extra] b4d9ac8 - [C++20][ClangTidy] Update the ClangTidy tests to also test in C++20 mode

2023-03-02 Thread Utkarsh Saxena via cfe-commits

Author: Utkarsh Saxena
Date: 2023-03-02T13:02:51+01:00
New Revision: b4d9ac8b453e20e4223b5935c700698608a6425c

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

LOG: [C++20][ClangTidy] Update the ClangTidy tests to also test in C++20 mode

Differential Revision: https://reviews.llvm.org/D144480

Added: 


Modified: 
clang-tools-extra/test/clang-tidy/checkers/bugprone/dangling-handle.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/easily-swappable-parameters-implicits.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone/signal-handler.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-exception-at-new.cpp
clang-tools-extra/test/clang-tidy/checkers/cert/throw-exception-type.cpp
clang-tools-extra/test/clang-tidy/checkers/misc/static-assert.cpp

clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp

clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type-macros.cpp
clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp

clang-tools-extra/test/clang-tidy/checkers/readability/isolate-declaration-cxx17.cpp
clang-tools-extra/test/clang-tidy/checkers/readability/use-anyofallof.cpp

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/dangling-handle.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/dangling-handle.cpp
index d3caf73b88c14..349875a3c99cd 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/dangling-handle.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/dangling-handle.cpp
@@ -2,7 +2,7 @@
 // RUN:   -config="{CheckOptions: \
 // RUN: [{key: bugprone-dangling-handle.HandleClasses, \
 // RUN:   value: 'std::basic_string_view; ::llvm::StringRef;'}]}"
-// FIXME: Fix the checker to work in C++17 mode.
+// FIXME: Fix the checker to work in C++17 or later mode.
 
 namespace std {
 

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/easily-swappable-parameters-implicits.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/easily-swappable-parameters-implicits.cpp
index ba7aa44a8731a..6c09ab0d89cc3 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/easily-swappable-parameters-implicits.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/easily-swappable-parameters-implicits.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -std=c++17 %s bugprone-easily-swappable-parameters 
%t \
+// RUN: %check_clang_tidy -std=c++17-or-later %s 
bugprone-easily-swappable-parameters %t \
 // RUN:   -config='{CheckOptions: [ \
 // RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 
2}, \
 // RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, 
value: ""}, \

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
index 047da60796298..142c8b114b7c8 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
@@ -4,6 +4,7 @@
 // RUN: {key: bugprone-exception-escape.FunctionsThatShouldNotThrow, 
value: 'enabled1,enabled2,enabled3'} \
 // RUN: ]}" \
 // RUN: -- -fexceptions
+// FIXME: Fix the checker to work in C++17 or later mode.
 
 struct throwing_destructor {
   ~throwing_destructor() {

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/signal-handler.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/signal-handler.cpp
index edb152568abf6..f1dc5ede35f29 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/signal-handler.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/signal-handler.cpp
@@ -1,5 +1,5 @@
 // RUN: %check_clang_tidy -std=c++14 %s bugprone-signal-handler %t -- -- 
-isystem %clang_tidy_headers -isystem %S/Inputs/signal-handler -target 
x86_64-unknown-unknown
-
+// FIXME: Fix the checker to work in C++17 or later mode.
 #include "stdcpp.h"
 #include "stdio.h"
 

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-exception-at-new.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-exception-at-new.cpp
index 6883463b0ae59..297db099f0667 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-exception-at-new.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-exception-at-new.cpp
@@ -1,5 +1,5 @@
 // RUN: %check_clang_tidy -std=c++14 %s bugprone-unhandled-exception-at-new %t 
-- -- -fexceptions
-
+// FIXME: Fix the checker to work in C++17 or l

[PATCH] D144480: [C++20][ClangTidy] Update the ClangTidy tests to also test in C++20 mode

2023-03-02 Thread Utkarsh Saxena via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb4d9ac8b453e: [C++20][ClangTidy] Update the ClangTidy tests 
to also test in C++20 mode (authored by usaxena95).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144480/new/

https://reviews.llvm.org/D144480

Files:
  clang-tools-extra/test/clang-tidy/checkers/bugprone/dangling-handle.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/easily-swappable-parameters-implicits.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone/signal-handler.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-exception-at-new.cpp
  clang-tools-extra/test/clang-tidy/checkers/cert/throw-exception-type.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc/static-assert.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type-macros.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability/isolate-declaration-cxx17.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/use-anyofallof.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/use-anyofallof.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/use-anyofallof.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/use-anyofallof.cpp
@@ -1,4 +1,5 @@
 // RUN: %check_clang_tidy -std=c++14,c++17 %s readability-use-anyofallof %t -- -- -fexceptions
+// FIXME: Fix the checker to work in C++20 mode.
 
 bool good_any_of() {
   int v[] = {1, 2, 3};
Index: clang-tools-extra/test/clang-tidy/checkers/readability/isolate-declaration-cxx17.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/isolate-declaration-cxx17.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/isolate-declaration-cxx17.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -std=c++17 %s readability-isolate-declaration %t
+// RUN: %check_clang_tidy -std=c++17-or-later %s readability-isolate-declaration %t
 
 template 
 struct pair {
Index: clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -std=c++14 %s readability-const-return-type %t
+// RUN: %check_clang_tidy -std=c++14-or-later %s readability-const-return-type %t
 
 //  p# = positive test
 //  n# = negative test
Index: clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type-macros.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type-macros.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type-macros.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -std=c++14 %s readability-const-return-type %t -- \
+// RUN: %check_clang_tidy -std=c++14-or-later %s readability-const-return-type %t -- \
 // RUN:   -config="{CheckOptions: [{key: readability-const-return-type.IgnoreMacros, value: false}]}"
 
 //  p# = positive test
Index: clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -std=c++17 %s performance-unnecessary-copy-initialization %t
+// RUN: %check_clang_tidy -std=c++17-or-later %s performance-unnecessary-copy-initialization %t
 
 template 
 struct Iterator {
Index: clang-tools-extra/test/clang-tidy/checkers/misc/static-assert.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc/static-assert.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc/static-assert.cpp
@@ -1,5 +1,5 @@
 // RUN: %check_clang_tidy -std=c++11 -check-suffixes=,CXX11 %s misc-static-assert %t
-// RUN: %check_clang_tidy -std=c++17 -check-suffixes=,CXX17 %s misc-static-assert %t
+// RUN: %check_clang_tidy -std=c++17-or-later -check-suffixes=,CXX17 %s misc-static-assert %t
 
 void abort() {}
 #ifdef NDEBUG
Index: clang-tools-extra/test/clang-tidy/checkers/cert/throw-exception-type.cpp
===
--- clang-tools-extra/test/clang-tidy/c

[PATCH] D145154: Change ClangTidy unit tests to run in C++20 mode instead of C++11.

2023-03-02 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 created this revision.
usaxena95 added a reviewer: gribozavr2.
Herald added a project: All.
usaxena95 requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145154

Files:
  clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h


Index: clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
@@ -110,7 +110,7 @@
 Args.push_back("-fobjc-arc");
   }
   if (extension == ".cc" || extension == ".cpp" || extension == ".mm") {
-Args.push_back("-std=c++11");
+Args.push_back("-std=c++20");
   }
   Args.push_back("-Iinclude");
   Args.insert(Args.end(), ExtraArgs.begin(), ExtraArgs.end());


Index: clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
@@ -110,7 +110,7 @@
 Args.push_back("-fobjc-arc");
   }
   if (extension == ".cc" || extension == ".cpp" || extension == ".mm") {
-Args.push_back("-std=c++11");
+Args.push_back("-std=c++20");
   }
   Args.push_back("-Iinclude");
   Args.insert(Args.end(), ExtraArgs.begin(), ExtraArgs.end());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144903: [X86] Drop single use check for freeze(undef) in LowerAVXCONCAT_VECTORS

2023-03-02 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

@ManuelJBrito Any luck with getting this committed? Your first attempt was 
reverted but was it just because of the bad Differential Revision tag?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144903/new/

https://reviews.llvm.org/D144903

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


[PATCH] D138539: Use std::nullopt_t instead of NoneType (NFC)

2023-03-02 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.
Herald added a subscriber: thopre.

This patch breaks `llvm::StringSet` equality.
The following code would no longer compile:

  llvm::StringSet LHS;
  llvm::StringSet RHS;
  bool equal = LHS == RHS;

Such code might be used as gtest assertions like `EXPECT_EQ(LHS, RHS)`.
@kazu Do you think we should address this by providing an equality operator for 
the `StringSet`?
I was thinking of adding this:

  bool operator==(const StringSet &RHS) const {
if (Base::size() != RHS.size())
  return false;
  
// For StringSets we only need to check the keys.
for (const auto &KeyValue : *this) {
  if (RHS.find(KeyValue.getKey()) == RHS.end())
return false;
}
return true;
  };

Do you think we should backport this to `release/16.x`, given that this could 
break downstream users and that llvm-16.0.0 is not released yet?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138539/new/

https://reviews.llvm.org/D138539

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


[PATCH] D138539: Use std::nullopt_t instead of NoneType (NFC)

2023-03-02 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Oh, I forgot to mention why this change breaks the equality operator of 
`llvm::StringSet`. It's because the `StringMap::operator==` will try to compare 
the `value` as well, which is of type `std::nullopt_t` and that has no equality 
comparison operator.
Previously, the `enum class NoneType` has a default one.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138539/new/

https://reviews.llvm.org/D138539

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


[clang-tools-extra] 5e6428b - [clangd] Use the normalized file path to do the filtering.

2023-03-02 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2023-03-02T13:36:24+01:00
New Revision: 5e6428b00393d0483f5fede641bbb519632e9585

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

LOG: [clangd] Use the normalized file path to do the filtering.

This is an oversight, where we normalized the path, but we didn't use it
in the filtering.

Added: 


Modified: 
clang-tools-extra/clangd/IncludeCleaner.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/IncludeCleaner.cpp 
b/clang-tools-extra/clangd/IncludeCleaner.cpp
index d9804abd82ee7..7d523d9a63641 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.cpp
+++ b/clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -292,7 +292,7 @@ static bool mayConsiderUnused(const Inclusion &Inc, 
ParsedAST &AST,
 // Convert the path to Unix slashes and try to match against the filter.
 llvm::SmallString<64> Path(Inc.Resolved);
 llvm::sys::path::native(Path, llvm::sys::path::Style::posix);
-if (Filter(Inc.Resolved)) {
+if (Filter(Path)) {
   dlog("{0} header is filtered out by the configuration", FE->getName());
   return false;
 }



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


[PATCH] D138539: Use std::nullopt_t instead of NoneType (NFC)

2023-03-02 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Hm, it would be easier to use `llvm::StringMap` 
instead of `std::nullopt_t`, or some adhoc empty struct.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138539/new/

https://reviews.llvm.org/D138539

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


[clang-tools-extra] c396073 - Change ClangTidy unit tests to run in C++20 mode instead of C++11.

2023-03-02 Thread Utkarsh Saxena via cfe-commits

Author: Utkarsh Saxena
Date: 2023-03-02T14:06:41+01:00
New Revision: c396073a0de6bc156514c34c0ffbdd227178c11b

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

LOG: Change ClangTidy unit tests to run in C++20 mode instead of C++11.

Differential Revision: https://reviews.llvm.org/D145154

Added: 


Modified: 
clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h

Removed: 




diff  --git a/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h 
b/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
index f10b91be2ed2c..078054c5194c5 100644
--- a/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
+++ b/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
@@ -110,7 +110,7 @@ runCheckOnCode(StringRef Code, std::vector 
*Errors = nullptr,
 Args.push_back("-fobjc-arc");
   }
   if (extension == ".cc" || extension == ".cpp" || extension == ".mm") {
-Args.push_back("-std=c++11");
+Args.push_back("-std=c++20");
   }
   Args.push_back("-Iinclude");
   Args.insert(Args.end(), ExtraArgs.begin(), ExtraArgs.end());



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


[PATCH] D145154: Change ClangTidy unit tests to run in C++20 mode instead of C++11.

2023-03-02 Thread Utkarsh Saxena via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc396073a0de6: Change ClangTidy unit tests to run in C++20 
mode instead of C++11. (authored by usaxena95).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145154/new/

https://reviews.llvm.org/D145154

Files:
  clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h


Index: clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
@@ -110,7 +110,7 @@
 Args.push_back("-fobjc-arc");
   }
   if (extension == ".cc" || extension == ".cpp" || extension == ".mm") {
-Args.push_back("-std=c++11");
+Args.push_back("-std=c++20");
   }
   Args.push_back("-Iinclude");
   Args.insert(Args.end(), ExtraArgs.begin(), ExtraArgs.end());


Index: clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
@@ -110,7 +110,7 @@
 Args.push_back("-fobjc-arc");
   }
   if (extension == ".cc" || extension == ".cpp" || extension == ".mm") {
-Args.push_back("-std=c++11");
+Args.push_back("-std=c++20");
   }
   Args.push_back("-Iinclude");
   Args.insert(Args.end(), ExtraArgs.begin(), ExtraArgs.end());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141714: Fix ast print of variables with attributes

2023-03-02 Thread Giuliano Belinassi via Phabricator via cfe-commits
giulianobelinassi updated this revision to Diff 501835.
giulianobelinassi edited the summary of this revision.
giulianobelinassi added a comment.

Update to dump attributes right after the type specification, also
fixing the __declspec case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141714/new/

https://reviews.llvm.org/D141714

Files:
  clang/lib/AST/DeclPrinter.cpp
  clang/test/AST/ast-print-attr-knr.c
  clang/test/AST/ast-print-attr.c
  clang/test/AST/ast-print-pragmas.cpp
  clang/test/Analysis/blocks.mm
  clang/test/Sema/attr-print.c
  clang/test/SemaCXX/attr-print.cpp
  clang/test/SemaCXX/cxx11-attr-print.cpp

Index: clang/test/SemaCXX/cxx11-attr-print.cpp
===
--- clang/test/SemaCXX/cxx11-attr-print.cpp
+++ clang/test/SemaCXX/cxx11-attr-print.cpp
@@ -1,29 +1,28 @@
 // RUN: %clang_cc1 -std=c++11 -ast-print -fms-extensions %s | FileCheck %s
 //
-// CHECK: int x __attribute__((aligned(4)));
-int x __attribute__((aligned(4)));
+// CHECK: int __attribute__((aligned(4))) x;
+int __attribute__((aligned(4))) x;
 
-// FIXME: Print this at a valid location for a __declspec attr.
-// CHECK: int y __declspec(align(4));
-__declspec(align(4)) int y;
+// CHECK: int __declspec(align(4)) y;
+int __declspec(align(4)) y;
 
 // CHECK: int z {{\[}}[gnu::aligned(4)]];
 int z [[gnu::aligned(4)]];
 
-// CHECK: __attribute__((deprecated("warning")));
-int a __attribute__((deprecated("warning")));
+// CHECK: int __attribute__((deprecated("warning"))) a;
+int __attribute__((deprecated("warning"))) a;
 
 // CHECK: int b {{\[}}[gnu::deprecated("warning")]];
 int b [[gnu::deprecated("warning")]];
 
-// CHECK: __declspec(deprecated("warning"))
-__declspec(deprecated("warning")) int c;
+// CHECK: int __declspec(deprecated("warning")) c;
+int __declspec(deprecated("warning")) c;
 
 // CHECK: int d {{\[}}[deprecated("warning")]];
 int d [[deprecated("warning")]];
 
-// CHECK: __attribute__((deprecated("warning", "fixit")));
-int e __attribute__((deprecated("warning", "fixit")));
+// CHECK: int __attribute__((deprecated("warning", "fixit"))) e;
+int __attribute__((deprecated("warning", "fixit"))) e;
 
 // CHECK: int cxx11_alignas alignas(4);
 alignas(4) int cxx11_alignas;
@@ -63,12 +62,12 @@
 // CHECK: __attribute__((format(printf, 2, 3)));
 void f8 (void *, const char *, ...) __attribute__ ((format (printf, 2, 3)));
 
-// CHECK: int m __attribute__((aligned(4
+// CHECK: int m __attribute__((aligned(4)))
 // CHECK: int n alignas(4
 // CHECK: static int f() __attribute__((pure))
 // CHECK: static int g() {{\[}}[gnu::pure]]
 template  struct S {
-  __attribute__((aligned(4))) int m;
+  int __attribute__((aligned(4))) m;
   alignas(4) int n;
   __attribute__((pure)) static int f() {
 return 0;
@@ -78,7 +77,7 @@
   }
 };
 
-// CHECK: int m __attribute__((aligned(4
+// CHECK: int m __attribute__((aligned(4)))
 // CHECK: int n alignas(4
 // CHECK: static int f() __attribute__((pure))
 // CHECK: static int g() {{\[}}[gnu::pure]]
Index: clang/test/SemaCXX/attr-print.cpp
===
--- clang/test/SemaCXX/attr-print.cpp
+++ clang/test/SemaCXX/attr-print.cpp
@@ -1,11 +1,11 @@
 // RUN: %clang_cc1 %s -ast-print -fms-extensions | FileCheck %s
 
-// CHECK: int x __attribute__((aligned(4)));
-int x __attribute__((aligned(4)));
+// CHECK: int __attribute__((aligned(4))) x;
+int __attribute__((aligned(4))) x;
 
 // FIXME: Print this at a valid location for a __declspec attr.
-// CHECK: int y __declspec(align(4));
-__declspec(align(4)) int y;
+// CHECK: int __declspec(align(4)) y;
+int __declspec(align(4)) y;
 
 // CHECK: void foo() __attribute__((const));
 void foo() __attribute__((const));
@@ -20,11 +20,11 @@
 // CHECK: typedef int Small1 __attribute__((mode(byte)));
 typedef int Small1 __attribute__((mode(byte)));
 
-// CHECK: int small __attribute__((mode(byte)));
-int small __attribute__((mode(byte)));
+// CHECK: int __attribute__((mode(byte))) small;
+int __attribute__((mode(byte))) small;
 
-// CHECK: int v __attribute__((visibility("hidden")));
-int v __attribute__((visibility("hidden")));
+// CHECK: int __attribute__((visibility("hidden"))) v;
+int __attribute__((visibility("hidden"))) v;
 
 // CHECK: char *PR24565() __attribute__((malloc))
 char *PR24565() __attribute__((__malloc__));
Index: clang/test/Sema/attr-print.c
===
--- clang/test/Sema/attr-print.c
+++ clang/test/Sema/attr-print.c
@@ -1,14 +1,14 @@
 // RUN: %clang_cc1 %s -ast-print -fms-extensions | FileCheck %s
 
-// CHECK: int x __attribute__((aligned(4)));
-int x __attribute__((aligned(4)));
+// CHECK: int __attribute__((aligned(4))) x;
+int __attribute__((aligned(4))) x;
 
 // FIXME: Print this at a valid location for a __declspec attr.
-// CHECK: int y __declspec(align(4));
-__declspec(align(4)) int y;
+// CHECK: int __declspec(align(4)) y;
+in

[PATCH] D125171: Add a new clang-format option AlwaysBreakBeforeFunctionParameters

2023-03-02 Thread jonathan molinatto via Phabricator via cfe-commits
jrmolin updated this revision to Diff 501836.
jrmolin added a comment.

Updated the version string in the docs and pulled in main.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125171/new/

https://reviews.llvm.org/D125171

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp

Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -4724,6 +4724,18 @@
 return true;
   }
 
+  // If AlwaysBreakBeforeFunctionParameters is true, we want to break before
+  // the next parameter, if there is one.
+  if (Left.is(tok::l_paren) && Style.AlwaysBreakBeforeFunctionParameters &&
+  !Right.is(tok::r_paren)) {
+if (Left.Previous) {
+  const FormatToken &TwoPrevious = *Left.Previous;
+  if (TwoPrevious.is(TT_FunctionDeclarationName)) {
+return true;
+  }
+}
+  }
+
   // If the last token before a '}', ']', or ')' is a comma or a trailing
   // comment, the intention is to insert a line break after it in order to make
   // shuffling around entries easier. Import statements, especially in
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -870,6 +870,8 @@
Style.AlwaysBreakAfterReturnType);
 IO.mapOptional("AlwaysBreakBeforeMultilineStrings",
Style.AlwaysBreakBeforeMultilineStrings);
+IO.mapOptional("AlwaysBreakBeforeFunctionParameters",
+   Style.AlwaysBreakBeforeFunctionParameters);
 IO.mapOptional("AlwaysBreakTemplateDeclarations",
Style.AlwaysBreakTemplateDeclarations);
 IO.mapOptional("AttributeMacros", Style.AttributeMacros);
@@ -1504,6 +1506,7 @@
   FormatStyle::SIS_WithoutElse;
   GoogleStyle.AllowShortLoopsOnASingleLine = true;
   GoogleStyle.AlwaysBreakBeforeMultilineStrings = true;
+  GoogleStyle.AlwaysBreakBeforeFunctionParameters = false;
   GoogleStyle.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_Yes;
   GoogleStyle.DerivePointerAlignment = true;
   GoogleStyle.IncludeStyle.IncludeCategories = {{"^", 2, 0, false},
@@ -1576,6 +1579,7 @@
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
+GoogleStyle.AlwaysBreakBeforeFunctionParameters = false;
 GoogleStyle.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
 GoogleStyle.ColumnLimit = 100;
 GoogleStyle.SpaceAfterCStyleCast = true;
@@ -1587,6 +1591,7 @@
 // TODO: still under discussion whether to switch to SLS_All.
 GoogleStyle.AllowShortLambdasOnASingleLine = FormatStyle::SLS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
+GoogleStyle.AlwaysBreakBeforeFunctionParameters = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
 // taze:, triple slash directives (`/// <...`), tslint:, and @see, which is
 // commonly followed by overlong URLs.
@@ -1612,6 +1617,7 @@
 GoogleStyle.BreakStringLiterals = false;
   } else if (Language == FormatStyle::LK_ObjC) {
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
+GoogleStyle.AlwaysBreakBeforeFunctionParameters = false;
 GoogleStyle.ColumnLimit = 100;
 // "Regroup" doesn't work well for ObjC yet (main header heuristic,
 // relationship between ObjC standard library headers and other heades,
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -353,6 +353,11 @@
 auto LambdaBodyLength = getLengthToMatchingParen(Current, State.Stack);
 return LambdaBodyLength > getColumnLimit(State);
   }
+  // Check if we want to break before function parameters in declarations
+  if (startsNextParameter(Current, Style) &&
+  Style.AlwaysBreakBeforeFunctionParameters &&
+  State.Line->MustBeDeclaration)
+return true;
   if (Current.MustBreakBefore ||
   (Current.is(TT_InlineASMColon) &&
(Style.BreakBeforeInlineASMColon == FormatStyle::BBIAS_Always ||
@@ -1049,7 +1054,9 @@
 // If we are breaking after '(', '{', '<', or this is the break after a ':'
 // to start a member initializater list in a constructor, this should not
 // be considered bin packing unless the relevant AllowAll option is false or
-// this is a dict/object literal.
+// this is a dict/object literal. Break if
+// AlwaysBreakBeforeFunctionParameters is true and it's a function
+// declaration.
 bool PreviousIsBreakingCto

[PATCH] D125171: Add a new clang-format option AlwaysBreakBeforeFunctionParameters

2023-03-02 Thread jonathan molinatto via Phabricator via cfe-commits
jrmolin added reviewers: MyDeveloperDay, owenpan.
jrmolin added a comment.

I finally found the correct CodeOwners.rst file.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125171/new/

https://reviews.llvm.org/D125171

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


[PATCH] D144638: [lit] Detect Inconsistent File Access Times

2023-03-02 Thread Sam Elliott via Phabricator via cfe-commits
lenary updated this revision to Diff 501838.
lenary marked an inline comment as done.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144638/new/

https://reviews.llvm.org/D144638

Files:
  clang/test/Modules/prune.m
  lld/test/COFF/lto-cache.ll
  lld/test/ELF/lto/cache.ll
  lld/test/MachO/lto-cache.ll
  lld/test/wasm/lto/cache.ll
  llvm/test/ThinLTO/X86/cache.ll
  llvm/test/tools/llvm-objcopy/ELF/strip-preserve-atime.test
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -5,6 +5,7 @@
 import subprocess
 import sys
 import errno
+import tempfile
 
 import lit.util
 from lit.llvm.subst import FindTool
@@ -155,6 +156,40 @@
 self.with_environment(
 'DYLD_INSERT_LIBRARIES', gmalloc_path_str)
 
+if self._has_consistent_atime():
+features.add('consistent-atime')
+
+# Some tests use `touch` to set the access time for a file, and expect no
+# other processes to change this during the test run. This is not always the
+# case, so we have a way to disable these tests on systems where the access
+# might not be preserved.
+def _has_consistent_atime(self):
+# NetBSD: noatime mounts currently inhibit 'touch -a' updates.
+if platform.system() == 'NetBSD':
+return False
+
+# Windows: the last access time is disabled by default in the OS, and
+# the check below is written in terms of unix utilities (touch, ls),
+# which will not work on this platform.
+if platform.system() == 'Windows':
+return False
+
+# Other Platforms: Try to use `touch -a` to set the atime, and then to
+# read it with `ls`. If they don't match, or either process errors, then
+# don't claim that atime is consistent.
+with tempfile.NamedTemporaryFile() as f:
+# Specific date in the past on purpose, based on what is attempted
+# in the tests that do the same thing.
+(_, try_touch_err) = self.get_process_output(["touch", "-a", "-t", "199505050555.55", f.name])
+if try_touch_err != "":
+return False
+
+(touch_res_out, touch_res_err) = self.get_process_output(["ls", "-lu", f.name])
+if touch_res_err != "":
+return False
+
+return re.search(r'\b1995\b', touch_res_out) is not None
+
 def _find_git_windows_unix_tools(self, tools_needed):
 assert(sys.platform == 'win32')
 if sys.version_info.major >= 3:
Index: llvm/test/tools/llvm-objcopy/ELF/strip-preserve-atime.test
===
--- llvm/test/tools/llvm-objcopy/ELF/strip-preserve-atime.test
+++ llvm/test/tools/llvm-objcopy/ELF/strip-preserve-atime.test
@@ -1,7 +1,5 @@
 # Note: ls -lu prints the accessed timestamp
-# NetBSD: noatime mounts currently inhibit 'touch -a' updates
-# Windows: the last access time is disabled by default in the OS
-# UNSUPPORTED: system-netbsd, system-windows
+# REQUIRES: consistent-atime
 
 # Preserve dates when stripping to an output file.
 # RUN: yaml2obj %s -o %t.1.o
Index: llvm/test/ThinLTO/X86/cache.ll
===
--- llvm/test/ThinLTO/X86/cache.ll
+++ llvm/test/ThinLTO/X86/cache.ll
@@ -1,5 +1,4 @@
-; NetBSD: noatime mounts currently inhibit 'touch -a' updates
-; UNSUPPORTED: system-netbsd
+; REQUIRES: consistent-atime
 
 ; The .noindex suffix for output dir is to prevent Spotlight on macOS from
 ; indexing it.
Index: lld/test/wasm/lto/cache.ll
===
--- lld/test/wasm/lto/cache.ll
+++ lld/test/wasm/lto/cache.ll
@@ -1,8 +1,6 @@
 ; RUN: opt -module-hash -module-summary %s -o %t.o
 ; RUN: opt -module-hash -module-summary %p/Inputs/cache.ll -o %t2.o
-; NetBSD: noatime mounts currently inhibit 'touch' from updating atime
-; Windows: no 'touch' command.
-; UNSUPPORTED: system-netbsd, system-windows
+; REQUIRES: consistent-atime
 
 ; RUN: rm -Rf %t.cache && mkdir %t.cache
 ; Create two files that would be removed by cache pruning due to age.
Index: lld/test/MachO/lto-cache.ll
===
--- lld/test/MachO/lto-cache.ll
+++ lld/test/MachO/lto-cache.ll
@@ -1,6 +1,5 @@
 ; REQUIRES: x86
-; NetBSD: noatime mounts currently inhibit 'touch' from updating atime
-; UNSUPPORTED: system-netbsd
+; REQUIRES: consistent-atime
 
 ; RUN: rm -rf %t; split-file %s %t
 ; RUN: opt -module-hash -module-summary %t/foo.ll -o %t/foo.o
Index: lld/test/ELF/lto/cache.ll
===
--- lld/test/ELF/lto/cache.ll
+++ lld/test/ELF/lto/cache.ll
@@ -1,6 +1,5 @@
 ; REQUIRES: x86
-; NetBSD: noatime mounts current

[PATCH] D144638: [lit] Detect Inconsistent File Access Times

2023-03-02 Thread Sam Elliott via Phabricator via cfe-commits
lenary added inline comments.



Comment at: llvm/utils/lit/lit/llvm/config.py:190
+return False
+if "1995" not in touch_res_out:
+return False

michaelplatings wrote:
> This could end up matching the wrong part of the string, for example if the 
> temporary file happened to have 1995 in its name. A regex match for 
> '\b1995\b' would be more reliable.
Done.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144638/new/

https://reviews.llvm.org/D144638

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


[PATCH] D145148: [Clang][CodeGen] Fix this argument type for certain destructors

2023-03-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Ah, this is for the cherry-pick to the 16.x branch -- we actually have a 
different process for that from usual patch submission. 
https://llvm.org/docs/GitHub.html#backporting-fixes-to-the-release-branches is 
the documentation for it, but basically, you should file a new issue on GitHub 
with the description `// cherry-pick 67409911353323ca5edf2049ef0df54132fa1ca7` 
and add it to the 16.x milestone. That should kick off a bot to do the pick for 
you in a custom branch, and that bot will probably fail due to merge conflicts. 
You'll fix the merge conflicts in that branch and eventually that branch is 
what gets merged into the release branch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145148/new/

https://reviews.llvm.org/D145148

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


[PATCH] D142914: [MLIR][OpenMP] Added OMPIRBuilder support for Target Data directives.

2023-03-02 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 501842.
TIFitis added a comment.

Rebased


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142914/new/

https://reviews.llvm.org/D142914

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/include/mlir/Target/LLVMIR/Dialect/OpenMPCommon.h
  mlir/lib/Target/LLVMIR/CMakeLists.txt
  mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMPCommon.cpp
  mlir/test/Target/LLVMIR/omptarget-llvm.mlir

Index: mlir/test/Target/LLVMIR/omptarget-llvm.mlir
===
--- /dev/null
+++ mlir/test/Target/LLVMIR/omptarget-llvm.mlir
@@ -0,0 +1,228 @@
+// RUN: mlir-translate -mlir-to-llvmir -split-input-file %s | FileCheck %s
+
+llvm.func @_QPopenmp_target_data() {
+  %0 = llvm.mlir.constant(1 : i64) : i64
+  %1 = llvm.alloca %0 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array, uniq_name = "_QFopenmp_target_dataEi"} : (i64) -> !llvm.ptr
+  omp.target_data   map((tofrom -> %1 : !llvm.ptr)) {
+%2 = llvm.mlir.constant(99 : i32) : i32
+llvm.store %2, %1 : !llvm.ptr
+omp.terminator
+  }
+  llvm.return
+}
+
+// CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 3]
+// CHECK-LABEL: define void @_QPopenmp_target_data() {
+// CHECK: %[[VAL_0:.*]] = alloca [1 x ptr], align 8
+// CHECK: %[[VAL_1:.*]] = alloca [1 x ptr], align 8
+// CHECK: %[[VAL_2:.*]] = alloca [1 x i64], align 8
+// CHECK: %[[VAL_3:.*]] = alloca i32, i64 1, align 4
+// CHECK: br label %[[VAL_4:.*]]
+// CHECK:   entry:; preds = %[[VAL_5:.*]]
+// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
+// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_6]], align 8
+// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_7]], align 8
+// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
+// CHECK: store i64 ptrtoint (ptr getelementptr (ptr, ptr null, i32 1) to i64), ptr %[[VAL_8]], align 4
+// CHECK: %[[VAL_9:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
+// CHECK: %[[VAL_10:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: %[[VAL_11:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
+// CHECK: call void @__tgt_target_data_begin_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_9]], ptr %[[VAL_10]], ptr %[[VAL_11]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: br label %[[VAL_12:.*]]
+// CHECK:   omp.data.region:  ; preds = %[[VAL_4]]
+// CHECK: store i32 99, ptr %[[VAL_3]], align 4
+// CHECK: br label %[[VAL_13:.*]]
+// CHECK:   omp.region.cont:  ; preds = %[[VAL_12]]
+// CHECK: %[[VAL_14:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
+// CHECK: %[[VAL_15:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: %[[VAL_16:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
+// CHECK: call void @__tgt_target_data_end_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_14]], ptr %[[VAL_15]], ptr %[[VAL_16]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: ret void
+
+// -
+
+llvm.func @_QPopenmp_target_data_loop(%1 : !llvm.ptr>) {
+  %2 = llvm.mlir.constant(1 : i64) : i64
+  %3 = llvm.alloca %2 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array, uniq_name = "_QFopenmp_target_data_loopEi"} : (i64) -> !llvm.ptr
+  omp.target_data   map((from -> %1 : !llvm.ptr>)) {
+%4 = llvm.mlir.constant(1 : i32) : i32
+%5 = llvm.sext %4 : i32 to i64
+%6 = llvm.mlir.constant(1024 : i32) : i32
+%7 = llvm.sext %6 : i32 to i64
+%8 = llvm.mlir.constant(1 : index) : i64
+%9 = llvm.trunc %5 : i64 to i32
+%10 = llvm.sub %7, %5  : i64
+%11 = llvm.add %10, %8  : i64
+llvm.br ^bb1(%5, %9, %11 : i64, i32, i64)
+  ^bb1(%12: i64, %13: i32, %14: i64):  // 2 preds: ^bb0, ^bb2
+%15 = llvm.mlir.constant(0 : index) : i64
+%16 = llvm.icmp "sgt" %14, %15 : i64
+llvm.cond_br %16, ^bb2, ^bb3
+  ^bb2:  // pred: ^bb1
+llvm.store %13, %3 : !llvm.ptr
+%17 = llvm.load %3 : !llvm.ptr
+%18 = llvm.load %3 : !llvm.ptr
+%19 = llvm.sext %18 : i32 to i64
+%20 = llvm.mlir.constant(1 : i64) : i64
+%21 = llvm.sub %19, %20  : i6

[PATCH] D145158: Make clang/test/C/C2x/n2934.c compatible with targets that do not support thread_local storage.

2023-03-02 Thread Fanbo Meng via Phabricator via cfe-commits
fanbo-meng created this revision.
Herald added a project: All.
fanbo-meng requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145158

Files:
  clang/test/C/C2x/n2934.c


Index: clang/test/C/C2x/n2934.c
===
--- clang/test/C/C2x/n2934.c
+++ clang/test/C/C2x/n2934.c
@@ -7,6 +7,7 @@
 
 thread_local struct alignas(int) S { // c2x-warning {{'alignas' is 
incompatible with C standards before C2x}} \
 c2x-warning {{'thread_local' is 
incompatible with C standards before C2x}} \
+c2x-error 0+ {{thread-local storage is 
not supported for the current target}} \
 c17-error {{unknown type name 
'thread_local'}} \
 c17-error {{expected identifier or 
'('}} \
 c17-error {{expected ')'}} \


Index: clang/test/C/C2x/n2934.c
===
--- clang/test/C/C2x/n2934.c
+++ clang/test/C/C2x/n2934.c
@@ -7,6 +7,7 @@
 
 thread_local struct alignas(int) S { // c2x-warning {{'alignas' is incompatible with C standards before C2x}} \
 c2x-warning {{'thread_local' is incompatible with C standards before C2x}} \
+c2x-error 0+ {{thread-local storage is not supported for the current target}} \
 c17-error {{unknown type name 'thread_local'}} \
 c17-error {{expected identifier or '('}} \
 c17-error {{expected ')'}} \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145123: Call MarkVirtualMembersReferenced on an actual class definition

2023-03-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

Thanks! LGTM, though please add a release note about the fix.




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:17940
   LoadExternalVTableUses();
   Class = Class->getCanonicalDecl();
   std::pair::iterator, bool>

sberg wrote:
> That call of `getCanonicalDecl` originated with 
> 
>  "Rework when and how vtables are emitted, by tracking where vtables are", 
> and I wonder if more of the uses of the modified `Class` below suffer from 
> the same issue, that they expect `Class` to represent a definition when it 
> might potentially reference just a declaration.
The only other place the class is being used is in `VTableUses` and 
`Sema::DefineUsedVTables()` does `CXXRecordDecl *Class = 
VTableUses[I].first->getDefinition();` so I think that's safe (if it a bit 
convoluted). So I think this is okay as-is.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145123/new/

https://reviews.llvm.org/D145123

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


[PATCH] D145158: Make clang/test/C/C2x/n2934.c compatible with targets that do not support thread_local storage.

2023-03-02 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan accepted this revision.
abhina.sreeskantharajan added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145158/new/

https://reviews.llvm.org/D145158

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


[clang] 6420daa - Revert "[Sanitizers] Error out for -static-libsan on darwin"

2023-03-02 Thread usama hameed via cfe-commits

Author: usama hameed
Date: 2023-03-02T19:48:38+05:00
New Revision: 6420daab19e8c95f2481090564508eea1996c4de

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

LOG: Revert "[Sanitizers] Error out for -static-libsan on darwin"

This reverts commit 4e7d40e0928cfe448ba947d2a67895fccaa3535f.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/sanitizer-ld.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 3b32227d21acd..4c922650e100f 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -220,8 +220,8 @@ def err_drv_malformed_sanitizer_coverage_ignorelist : Error<
   "malformed sanitizer coverage ignorelist: '%0'">;
 def err_drv_malformed_sanitizer_metadata_ignorelist : Error<
   "malformed sanitizer metadata ignorelist: '%0'">;
-def err_drv_unsupported_static_sanitizer_darwin : Error<
-  "static %0 runtime is not supported on darwin">;
+def err_drv_unsupported_static_ubsan_darwin : Error<
+  "static UndefinedBehaviorSanitizer runtime is not supported on darwin">;
 def err_drv_duplicate_config : Error<
   "no more than one option '--config' is allowed">;
 def err_drv_cannot_open_config_file : Error<

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index b914b1b8f12eb..70882e110fa52 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1215,7 +1215,7 @@ defm xl_pragma_pack : BoolFOption<"xl-pragma-pack",
 def shared_libsan : Flag<["-"], "shared-libsan">,
   HelpText<"Dynamically link the sanitizer runtime">;
 def static_libsan : Flag<["-"], "static-libsan">,
-  HelpText<"Statically link the sanitizer runtime (Not supported for ASan, 
TSan or UBSan on darwin)">;
+  HelpText<"Statically link the sanitizer runtime">;
 def : Flag<["-"], "shared-libasan">, Alias;
 def fasm : Flag<["-"], "fasm">, Group;
 

diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 6cee9c74c7adb..b273f8ba04fda 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1426,42 +1426,24 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList 
&Args,
 
   const SanitizerArgs &Sanitize = getSanitizerArgs(Args);
 
-  if (!Sanitize.needsSharedRt()) {
-const char *sanitizer = nullptr;
-if (Sanitize.needsUbsanRt()) {
-  sanitizer = "UndefinedBehaviorSanitizer";
-} else if (Sanitize.needsAsanRt()) {
-  sanitizer = "AddressSanitizer";
-} else if (Sanitize.needsTsanRt()) {
-  sanitizer = "ThreadSanitizer";
-}
-if (sanitizer) {
-  getDriver().Diag(diag::err_drv_unsupported_static_sanitizer_darwin)
-  << sanitizer;
-  return;
-}
+  if (!Sanitize.needsSharedRt() && Sanitize.needsUbsanRt()) {
+getDriver().Diag(diag::err_drv_unsupported_static_ubsan_darwin);
+return;
   }
 
   if (Sanitize.linkRuntimes()) {
-if (Sanitize.needsAsanRt()) {
-  assert(Sanitize.needsSharedRt() &&
- "Static sanitizer runtimes not supported");
+if (Sanitize.needsAsanRt())
   AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
-}
 if (Sanitize.needsLsanRt())
   AddLinkSanitizerLibArgs(Args, CmdArgs, "lsan");
 if (Sanitize.needsUbsanRt()) {
-  assert(Sanitize.needsSharedRt() &&
- "Static sanitizer runtimes not supported");
-  AddLinkSanitizerLibArgs(
-  Args, CmdArgs,
-  Sanitize.requiresMinimalRuntime() ? "ubsan_minimal" : "ubsan");
+  assert(Sanitize.needsSharedRt() && "Static sanitizer runtimes not 
supported");
+  AddLinkSanitizerLibArgs(Args, CmdArgs,
+  Sanitize.requiresMinimalRuntime() ? 
"ubsan_minimal"
+: "ubsan");
 }
-if (Sanitize.needsTsanRt()) {
-  assert(Sanitize.needsSharedRt() &&
- "Static sanitizer runtimes not supported");
+if (Sanitize.needsTsanRt())
   AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
-}
 if (Sanitize.needsFuzzer() && !Args.hasArg(options::OPT_dynamiclib)) {
   AddLinkSanitizerLibArgs(Args, CmdArgs, "fuzzer", /*shared=*/false);
 

diff  --git a/clang/test/Driver/sanitizer-ld.c 
b/clang/test/Driver/sanitizer-ld.c
index 910b0ed4ff0de..0ba209d870c2a 100644
--- a/clang/test/Driver/sanitizer-ld.c
+++ b/clang/test/Driver/sanitizer-ld.c
@@ -457,18 +457,6 @@
 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-STATIC-DARWIN %s
 // CHECK-UBSAN-STATIC-DARWIN: {{.*}}error: static UndefinedBehavior

[PATCH] D144672: [Sanitizers] Error when attempting to use `static-lsan` with `TSan` or `Asan` on darwin

2023-03-02 Thread Usama Hameed via Phabricator via cfe-commits
usama54321 added a comment.

I have reverted the commit for now


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144672/new/

https://reviews.llvm.org/D144672

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


[clang] d812488 - Call MarkVirtualMembersReferenced on an actual class definition

2023-03-02 Thread Stephan Bergmann via cfe-commits

Author: Stephan Bergmann
Date: 2023-03-02T15:50:12+01:00
New Revision: d812488d3c54c07f24d4bef79e329f17e7f19c3b

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

LOG: Call MarkVirtualMembersReferenced on an actual class definition

...rather than on potentially just a declaration.

Without the fix, the newly added clang/test/SemaCXX/warn-undefined-internal.cpp
failed with

> error: 'warning' diagnostics expected but not seen:
>   File 
> /home/sbergman/github.com/llvm/llvm-project/clang/test/SemaCXX/warn-undefined-internal.cpp
>  Line 12 (directive at 
> /home/sbergman/github.com/llvm/llvm-project/clang/test/SemaCXX/warn-undefined-internal.cpp:13):
>  function 'test2()::S::f' has internal linkage but is not defined
> error: 'note' diagnostics expected but not seen:
>   File 
> /home/sbergman/github.com/llvm/llvm-project/clang/test/SemaCXX/warn-undefined-internal.cpp
>  Line 14 (directive at 
> /home/sbergman/github.com/llvm/llvm-project/clang/test/SemaCXX/warn-undefined-internal.cpp:15):
>  used here

(I ran into this when two LibreOffice Clang plugins produced false positive
warnings, as they relied on Decl::isReferenced() returning true for such virtual
member functions of local classes.)

Differential Revision: https://reviews.llvm.org/D145123

Added: 
clang/test/SemaCXX/warn-undefined-internal.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaDeclCXX.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7dc80a43e5eb..23a3bbd58b96 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -155,6 +155,8 @@ Improvements to Clang's diagnostics
 - Clang now warns by default for C++20 and later about deprecated capture of
   ``this`` with a capture default of ``=``. This warning can be disabled with
   ``-Wno-deprecated-this-capture``.
+- Clang had failed to emit some ``-Wundefined-internal`` for members of a local
+  class if that class was first introduced with a forward declaration.
 
 Bug Fixes in This Version
 -

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index ec85d503ccf8..cf74fcbc4cfa 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -17975,7 +17975,7 @@ void Sema::MarkVTableUsed(SourceLocation Loc, 
CXXRecordDecl *Class,
   // immediately. For all other classes, we mark their virtual members
   // at the end of the translation unit.
   if (Class->isLocalClass())
-MarkVirtualMembersReferenced(Loc, Class);
+MarkVirtualMembersReferenced(Loc, Class->getDefinition());
   else
 VTableUses.push_back(std::make_pair(Class, Loc));
 }

diff  --git a/clang/test/SemaCXX/warn-undefined-internal.cpp 
b/clang/test/SemaCXX/warn-undefined-internal.cpp
new file mode 100644
index ..81dbbba1d001
--- /dev/null
+++ b/clang/test/SemaCXX/warn-undefined-internal.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -verify %s
+
+void test1() {
+  struct S { virtual void f(); };
+  // expected-warning@-1{{function 'test1()::S::f' has internal linkage but is 
not defined}}
+  S s;
+  // expected-note@-1{{used here}}
+}
+
+void test2() {
+  struct S;
+  struct S { virtual void f(); };
+  // expected-warning@-1{{function 'test2()::S::f' has internal linkage but is 
not defined}}
+  S s;
+  // expected-note@-1{{used here}}
+}



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


[PATCH] D145123: Call MarkVirtualMembersReferenced on an actual class definition

2023-03-02 Thread Stephan Bergmann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd812488d3c54: Call MarkVirtualMembersReferenced on an actual 
class definition (authored by sberg).

Changed prior to commit:
  https://reviews.llvm.org/D145123?vs=501669&id=501852#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145123/new/

https://reviews.llvm.org/D145123

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/warn-undefined-internal.cpp


Index: clang/test/SemaCXX/warn-undefined-internal.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-undefined-internal.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -verify %s
+
+void test1() {
+  struct S { virtual void f(); };
+  // expected-warning@-1{{function 'test1()::S::f' has internal linkage but is 
not defined}}
+  S s;
+  // expected-note@-1{{used here}}
+}
+
+void test2() {
+  struct S;
+  struct S { virtual void f(); };
+  // expected-warning@-1{{function 'test2()::S::f' has internal linkage but is 
not defined}}
+  S s;
+  // expected-note@-1{{used here}}
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -17975,7 +17975,7 @@
   // immediately. For all other classes, we mark their virtual members
   // at the end of the translation unit.
   if (Class->isLocalClass())
-MarkVirtualMembersReferenced(Loc, Class);
+MarkVirtualMembersReferenced(Loc, Class->getDefinition());
   else
 VTableUses.push_back(std::make_pair(Class, Loc));
 }
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -155,6 +155,8 @@
 - Clang now warns by default for C++20 and later about deprecated capture of
   ``this`` with a capture default of ``=``. This warning can be disabled with
   ``-Wno-deprecated-this-capture``.
+- Clang had failed to emit some ``-Wundefined-internal`` for members of a local
+  class if that class was first introduced with a forward declaration.
 
 Bug Fixes in This Version
 -


Index: clang/test/SemaCXX/warn-undefined-internal.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-undefined-internal.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -verify %s
+
+void test1() {
+  struct S { virtual void f(); };
+  // expected-warning@-1{{function 'test1()::S::f' has internal linkage but is not defined}}
+  S s;
+  // expected-note@-1{{used here}}
+}
+
+void test2() {
+  struct S;
+  struct S { virtual void f(); };
+  // expected-warning@-1{{function 'test2()::S::f' has internal linkage but is not defined}}
+  S s;
+  // expected-note@-1{{used here}}
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -17975,7 +17975,7 @@
   // immediately. For all other classes, we mark their virtual members
   // at the end of the translation unit.
   if (Class->isLocalClass())
-MarkVirtualMembersReferenced(Loc, Class);
+MarkVirtualMembersReferenced(Loc, Class->getDefinition());
   else
 VTableUses.push_back(std::make_pair(Class, Loc));
 }
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -155,6 +155,8 @@
 - Clang now warns by default for C++20 and later about deprecated capture of
   ``this`` with a capture default of ``=``. This warning can be disabled with
   ``-Wno-deprecated-this-capture``.
+- Clang had failed to emit some ``-Wundefined-internal`` for members of a local
+  class if that class was first introduced with a forward declaration.
 
 Bug Fixes in This Version
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143751: [clang][analyzer][NFC] Refactor code of StdLibraryFunctionsChecker.

2023-03-02 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:271
+
+  private:
+using RangeApplyFunction =

Szelethus wrote:
> balazske wrote:
> > This new private section is the new added code.
> While generalizing code is great, whenever its done by introducing function 
> arguments / lambdas, the code becomes harder to understand. This is fine, as 
> long as this complexity is justified, but I really needed to see what 
> happened in the followup patch to see whats the gain behind this.
> 
> The gain is that you can capture a stream and construct a helpful message as 
> the range is applied. 
> 
> Question: couldn't you just expose a lambda for the specific purpose for 
> string smithing, and only that? Seems like all lambdas contain kind of the 
> same thing: a call to `ConstraintManager::assumeInclusiveRange`. 
> 
> Maybe this design (for the above reasons) is worth documenting.
It looks not easy to change the design, the lambda is not only used for string 
construction and the way the state is applied (only check the state or change 
it too) is different. Probably it is possible but with more additional special 
purpose function parameters that add again complexity. Otherwise the current 
way looks not difficult, just a function that is called on all ranges or 
out-of-ranges, like an iteration. It can be possible to make a function that 
instead of calling lambda returns a list of ranges for the within-range or 
out-of-range case, and then make an iteration over these lists, but this is 
really only more code, and the returned lists are used only for these 
iterations.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143751/new/

https://reviews.llvm.org/D143751

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


[PATCH] D145093: Add map info for dereference pointer.

2023-03-02 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

What result produces `map(a[0][:3]`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145093/new/

https://reviews.llvm.org/D145093

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


[PATCH] D141230: [clang-format-diff.py] give clang-format-diff a job pool (10x speed)

2023-03-02 Thread Sean Maher via Phabricator via cfe-commits
seanptmaher added a comment.

Hey,

Sure. The name is Sean Maher and the email is s...@chromium.org

Thanks for your help.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141230/new/

https://reviews.llvm.org/D141230

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


[PATCH] D143375: clang-tidy: Count template constructors in modernize-use-default-member-init

2023-03-02 Thread Marco Falke via Phabricator via cfe-commits
MarcoFalke updated this revision to Diff 501858.
MarcoFalke added a comment.

mv release note, rebase


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143375/new/

https://reviews.llvm.org/D143375

Files:
  clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp
@@ -60,6 +60,12 @@
 int i;
 };
 
+struct TwoConstructorsTpl {
+  TwoConstructorsTpl() : i{7} {}
+  template  TwoConstructorsTpl(T, int) : i(8) {}
+  int i;
+};
+
 struct PositiveNotDefaultOOLInt {
   PositiveNotDefaultOOLInt(int);
   int i;
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -169,6 +169,11 @@
   ` check.
   Global options of the same name should be used instead.
 
+- In :doc:`modernize-use-default-member-init
+  ` count template
+  constructors toward hand written constructors so that they are skipped if 
more
+  than one exists.
+
 - Fixed reading `HungarianNotation.CString.*` options in
   :doc:`readability-identifier-naming
   ` check.
Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -246,8 +246,12 @@
   // Check whether we have multiple hand-written constructors and bomb out, as
   // it is hard to reconcile their sets of member initializers.
   const auto *ClassDecl = cast(Field->getParent());
-  if (llvm::count_if(ClassDecl->ctors(), [](const CXXConstructorDecl *Ctor) {
-return !Ctor->isCopyOrMoveConstructor();
+  if (llvm::count_if(ClassDecl->decls(), [](const Decl *D) {
+if (const auto *FTD = dyn_cast(D))
+  D = FTD->getTemplatedDecl();
+if (const auto *Ctor = dyn_cast(D))
+  return !Ctor->isCopyOrMoveConstructor();
+return false;
   }) > 1)
 return;
 


Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp
@@ -60,6 +60,12 @@
 int i;
 };
 
+struct TwoConstructorsTpl {
+  TwoConstructorsTpl() : i{7} {}
+  template  TwoConstructorsTpl(T, int) : i(8) {}
+  int i;
+};
+
 struct PositiveNotDefaultOOLInt {
   PositiveNotDefaultOOLInt(int);
   int i;
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -169,6 +169,11 @@
   ` check.
   Global options of the same name should be used instead.
 
+- In :doc:`modernize-use-default-member-init
+  ` count template
+  constructors toward hand written constructors so that they are skipped if more
+  than one exists.
+
 - Fixed reading `HungarianNotation.CString.*` options in
   :doc:`readability-identifier-naming
   ` check.
Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -246,8 +246,12 @@
   // Check whether we have multiple hand-written constructors and bomb out, as
   // it is hard to reconcile their sets of member initializers.
   const auto *ClassDecl = cast(Field->getParent());
-  if (llvm::count_if(ClassDecl->ctors(), [](const CXXConstructorDecl *Ctor) {
-return !Ctor->isCopyOrMoveConstructor();
+  if (llvm::count_if(ClassDecl->decls(), [](const Decl *D) {
+if (const auto *FTD = dyn_cast(D))
+  D = FTD->getTemplatedDecl();
+if (const auto *Ctor = dyn_cast(D))
+  return !Ctor->isCopyOrMoveConstructor();
+return false;
   }) > 1)
 return;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140584: [Clang] Refactor "Designators" into a unified implementation [NFC]

2023-03-02 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

I think these two bug reports: 
https://github.com/llvm/llvm-project/issues/46132 and 
https://github.com/llvm/llvm-project/issues/61118 may be related to this change.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140584/new/

https://reviews.llvm.org/D140584

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


[PATCH] D145138: [clang-tidy] Implement FixIts for C arrays

2023-03-02 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp:94
+
+  auto StartOfFile = SM.getLocForStartOfFile(SM.getFileID(Location));
+  while (Location != StartOfFile) {

Please do not use `auto` unless type is explicitly stated in same statement or 
iterator.



Comment at: clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp:498
+return false;
+  const CXXConstructExpr *ConstructExpr =
+  dyn_cast(SpelledExpr);

`auto` could be used here.



Comment at: clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp:588
+: ClangTidyCheck(Name, Context),
+  IncludeInserter(Options.getLocalOrGlobal("IncludeStyle",
+   utils::IncludeSorter::IS_LLVM),

Should be global option, because it's used in other checks.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-c-arrays.rst:71
 can be either ``char* argv[]`` or ``char** argv``, but cannot be
 ``std::array<>``.

Missing documentation for `IncludeStyle` option if it'll remain local.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145138/new/

https://reviews.llvm.org/D145138

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


[PATCH] D144622: [clang][ASTImporter] Import TemplateName correctly

2023-03-02 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers accepted this revision.
vabridgers added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144622/new/

https://reviews.llvm.org/D144622

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


[PATCH] D144273: [clang][ASTImporter] Add VaList declaration to lookup table.

2023-03-02 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers accepted this revision.
vabridgers added a comment.
This revision is now accepted and ready to land.

LGTM. Let's accept, merge and then watch to make sure we can keep the change.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144273/new/

https://reviews.llvm.org/D144273

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


[PATCH] D145164: [clang][RISCV] Enable -fasynchronous-unwind-tables by default on Linux

2023-03-02 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng created this revision.
kito-cheng added reviewers: asb, luismarques, jrtc27, MaskRay, craig.topper, 
reames.
Herald added subscribers: luke, VincentWu, vkmr, frasercrmck, evandro, apazos, 
sameer.abuasal, pengfei, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, shiva0217, niosHD, 
sabuasal, simoncook, johnrusso, rbar, kristof.beyls, arichardson.
Herald added a project: All.
kito-cheng requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, eopXD.
Herald added a project: clang.

This could improve user experience for stack unwinding, and also this is
enabled by default by X86 and AArch64 and RISC-V GCC.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145164

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/riscv-features.c


Index: clang/test/Driver/riscv-features.c
===
--- clang/test/Driver/riscv-features.c
+++ clang/test/Driver/riscv-features.c
@@ -26,7 +26,8 @@
 // RUN: %clang --target=riscv64-linux -### %s -fsyntax-only 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=DEFAULT-LINUX
 
-// DEFAULT-LINUX: "-target-feature" "+m"
+// DEFAULT-LINUX: "-funwind-tables=2"
+// DEFAULT-LINUX-SAME: "-target-feature" "+m"
 // DEFAULT-LINUX-SAME: "-target-feature" "+a"
 // DEFAULT-LINUX-SAME: "-target-feature" "+f"
 // DEFAULT-LINUX-SAME: "-target-feature" "+d"
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2900,6 +2900,8 @@
   case llvm::Triple::ppcle:
   case llvm::Triple::ppc64:
   case llvm::Triple::ppc64le:
+  case llvm::Triple::riscv32:
+  case llvm::Triple::riscv64:
   case llvm::Triple::x86:
   case llvm::Triple::x86_64:
 return UnwindTableLevel::Asynchronous;


Index: clang/test/Driver/riscv-features.c
===
--- clang/test/Driver/riscv-features.c
+++ clang/test/Driver/riscv-features.c
@@ -26,7 +26,8 @@
 // RUN: %clang --target=riscv64-linux -### %s -fsyntax-only 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=DEFAULT-LINUX
 
-// DEFAULT-LINUX: "-target-feature" "+m"
+// DEFAULT-LINUX: "-funwind-tables=2"
+// DEFAULT-LINUX-SAME: "-target-feature" "+m"
 // DEFAULT-LINUX-SAME: "-target-feature" "+a"
 // DEFAULT-LINUX-SAME: "-target-feature" "+f"
 // DEFAULT-LINUX-SAME: "-target-feature" "+d"
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2900,6 +2900,8 @@
   case llvm::Triple::ppcle:
   case llvm::Triple::ppc64:
   case llvm::Triple::ppc64le:
+  case llvm::Triple::riscv32:
+  case llvm::Triple::riscv64:
   case llvm::Triple::x86:
   case llvm::Triple::x86_64:
 return UnwindTableLevel::Asynchronous;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144977: [analyzer] Fix of the initialization list parsing.

2023-03-02 Thread Domján Dániel via Phabricator via cfe-commits
isuckatcs added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1787
+  if (V &&
+  (!targetType->isStructureOrClassType() && !targetType->isUnionType()))
 return *V;

I assume `targetType` is the type we want to interpret the region as. Below 
this condition we seem to work with arrays. If `targetType` is an array, then 
we return something here instead of going further and returning something else 
we probably want. 

Why aren't we going further in that case?



Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1869
+  // if we are here we have struct or union?
+  if (!VarT->isStructureType()) {
+// TODO: support other options like unions or arrays or VLAs

What about classes? 

```
class A { 
public:
  int x;
};

struct B {
  int x;
}
```

`A` and `B` are technically the same, but `A` will fall into the true branch, 
`B` will fall into the false branch.



Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1891
+ElemExpr = IL->getInit(Idx);
+std::optional ConstVal = svalBuilder.getConstantVal(ElemExpr);
+// if there is no value create a zero one

This crashes if `ElemExpr` is a `nullptr`.



Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1914
+  }
+  RecIter++;
+  continue;

Consider moving this into the for loop to avoid confusion.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144977/new/

https://reviews.llvm.org/D144977

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


[PATCH] D145158: Make clang/test/C/C2x/n2934.c compatible with targets that do not support thread_local storage.

2023-03-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145158/new/

https://reviews.llvm.org/D145158

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


[PATCH] D145057: [clang][ASTImport] Add support for import of empty records

2023-03-02 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:3897
+  if (Err)
+return std::move(Err);
   ToField->setAccess(D->getAccess());

I am not familiar with this use case, is there a path where the attributes are 
read from a `FieldDecl` before return from `VisitFieldDecl`? Probably 
`ImportImpl` is overridden? Importing the attributes here should work but not 
totally sure if it does not cause problems. Problematic case is if the 
attribute has pointer to a `Decl` or `Type` that is imported here in a state 
when the field is already created but not initialized. Another problem is that 
attributes are added a second time in `Import(Decl *)`. Can it work if the 
`ImportAttrs` is made a protected function and called from (overridden) 
`ImportImpl` (still there can be a second import in `Import(Decl *)`?



Comment at: clang/unittests/AST/ASTImporterTest.cpp:8157
+
+  CXXRecordDecl *ToD = cast(Import(FromD, Lang_CXX20));
+  EXPECT_EQ(true, ToD->isEmpty());





Comment at: clang/unittests/AST/ASTImporterTest.cpp:8160
+  for (auto *FD : ToD->fields())
+EXPECT_EQ(true, FD->hasAttr());
+}





Comment at: clang/unittests/AST/ASTImporterTest.cpp:8161
+EXPECT_EQ(true, FD->hasAttr());
+}
+

Does this test fail without the changes applied? And does it not fail after (is 
the "Empty" value copied at import)?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145057/new/

https://reviews.llvm.org/D145057

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


[PATCH] D145150: clang: Emit nofpclass(nan inf) for -ffinite-math-only

2023-03-02 Thread Joshua Cranmer via Phabricator via cfe-commits
jcranmer-intel added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:2212
+static llvm::FPClassTest getNoFPClassTestMask(const LangOptions &LangOpts) {
+  // TODO: Handle -fno-signaling-nans
+  llvm::FPClassTest Mask = llvm::fcNone;

Clang doesn't have support for -f[no-]signaling-nans yet, but the gcc 
documentation for the option states:

> Compile code assuming that IEEE signaling NaNs may generate user-visible 
> traps during floating-point operations.  Setting this option disables 
> optimizations that may change the number of exceptions visible with signaling 
> NaNs.  This option implies -ftrapping-math.

This strikes me as saying that sNaNs are treated as qNaN (akin to the `nsz` 
fast-math flag) rather than saying that it's UB to have `sNaN` as a value, 
thus, I don't think it makes sense for -fno-signaling-nans to translate into a 
`nofpclass` attribute.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145150/new/

https://reviews.llvm.org/D145150

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


[PATCH] D144190: [AIX][clang] Storage Locations for Constant Pointers

2023-03-02 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 updated this revision to Diff 501871.
qiongsiwu1 added a comment.

Updating `-fdata-sections` related comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144190/new/

https://reviews.llvm.org/D144190

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/PowerPC/aix-roptr.c
  clang/test/Driver/ppc-roptr.c

Index: clang/test/Driver/ppc-roptr.c
===
--- /dev/null
+++ clang/test/Driver/ppc-roptr.c
@@ -0,0 +1,18 @@
+// RUN: %clang -### -target powerpc-ibm-aix-xcoff -mroptr %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target powerpc-ibm-aix-xcoff -mroptr -mno-roptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=ROPTR
+// RUN: %clang -### -target powerpc64-ibm-aix-xcoff -mroptr %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target powerpc64-ibm-aix-xcoff -mroptr -mno-roptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=ROPTR
+// CHECK: "-mroptr"
+// CHECK: "-bforceimprw"
+// ROPTR-NOT: "-mroptr"
+// ROPTR-NOT: "-bforceimprw"
+
+char c1 = 10;
+char c2 = 20;
+char* const c1_ptr = &c1;
+
+int main() {
+*(char**)&c1_ptr = &c2;
+}
Index: clang/test/CodeGen/PowerPC/aix-roptr.c
===
--- /dev/null
+++ clang/test/CodeGen/PowerPC/aix-roptr.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple=powerpc-ibm-aix-xcoff -mroptr -fdata-sections \
+// RUN: -S <%s | FileCheck %s --check-prefix=CHECK32
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix-xcoff -mroptr -fdata-sections \
+// RUN: -S <%s | FileCheck %s --check-prefix=CHECK64
+// RUN: not %clang_cc1 -triple=powerpc-ibm-aix-xcoff -mroptr \
+// RUN: -S <%s 2>&1 | FileCheck %s --check-prefix=DATA_SECTION_ERR
+// RUN: not %clang_cc1 -triple=powerpc64-ibm-aix-xcoff -mroptr \
+// RUN: -S <%s 2>&1 | FileCheck %s --check-prefix=DATA_SECTION_ERR
+// RUN: not %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -mroptr \
+// RUN: -S <%s 2>&1 | FileCheck %s --check-prefix=TARGET_ROPTR_ERR
+// RUN: not %clang -target powerpc64le-unknown-linux-gnu -mno-roptr \
+// RUN: -S %s 2>&1 | FileCheck %s --check-prefix=TARGET_NOROPTR_ERR
+// RUN: not %clang -target powerpc-ibm-aix-xcoff -mroptr -shared \
+// RUN: -S %s 2>&1 | FileCheck %s --check-prefix=SHARED_ERR
+// RUN: not %clang -target powerpc64-ibm-aix-xcoff -mroptr -shared \
+// RUN: -S %s 2>&1 | FileCheck %s --check-prefix=SHARED_ERR
+
+char c1 = 10;
+char c2 = 20;
+char* const c1_ptr = &c1;
+// CHECK32: .csect c1_ptr[RO],2
+// CHECK32-NEXT:	.globl	c1_ptr[RO]
+// CHECK32-NEXT:	.align	2
+// CHECK32-NEXT:	.vbyte	4, c1[RW]
+
+// CHECK64: .csect c1_ptr[RO],3
+// CHECK64-NEXT:	.globl	c1_ptr[RO]
+// CHECK64-NEXT:	.align	3
+// CHECK64-NEXT:	.vbyte	8, c1[RW]
+
+// DATA_SECTION_ERR: error: -mroptr is supported only with -fdata-sections
+// TARGET_ROPTR_ERR: error: unsupported option '-mroptr' for target 'powerpc64le-unknown-linux-gnu'
+// TARGET_NOROPTR_ERR: error: unsupported option '-mno-roptr' for target 'powerpc64le-unknown-linux-gnu'
+// SHARED_ERR: error: -mroptr is not suppored with -shared
+
+int main() {
+*(char**)&c1_ptr = &c2;
+}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1560,6 +1560,9 @@
   if (Opts.EnableAIXExtendedAltivecABI)
 GenerateArg(Args, OPT_mabi_EQ_vec_extabi, SA);
 
+  if (Opts.ReadOnlyPointers)
+GenerateArg(Args, OPT_mroptr, SA);
+
   if (!Opts.OptRecordPasses.empty())
 GenerateArg(Args, OPT_opt_record_passes, Opts.OptRecordPasses, SA);
 
@@ -1949,6 +1952,25 @@
 Opts.EnableAIXExtendedAltivecABI = O.matches(OPT_mabi_EQ_vec_extabi);
   }
 
+  if (Arg *A = Args.getLastArg(OPT_mroptr)) {
+if (!T.isOSAIX())
+  Diags.Report(diag::err_drv_unsupported_opt_for_target)
+  << A->getSpelling() << T.str();
+
+// Since the stroage mapping class is specified per csect,
+// without using data sections, it is ambiguous what exactly should
+// be done for the read-only pointers. Using read-only pointers may cause
+// other RO variables in the same csect to become RW when the linker acts
+// upon `-bforceimprw`; therefore, we require that separate data sections
+// are used when `-mroptr` is in effect. We respect the setting of
+// data-sections since we have not found reasons to do otherwise that
+// overcome the user surprise of not respecting the setting.
+if (!Args.hasFlag(OPT_fdata_sections, OPT_fno_data_sections, false))
+  Diags.Report(diag::err_roptr_requires_data_secti

[clang] 65f7a84 - [clang][ExtractAPI] Handle platform specific unavailability correctly

2023-03-02 Thread Daniel Grumberg via cfe-commits

Author: Ankur
Date: 2023-03-02T15:49:46Z
New Revision: 65f7a84cf38b9839de0f29877d5ba4895848ea73

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

LOG: [clang][ExtractAPI] Handle platform specific unavailability correctly

This Patch gives ExtractAPI the ability to emit correct availability 
information for symbols marked as unavailable on a specific platform ( PR#60954 
)

Reviewed By: dang

Differential Revision: https://reviews.llvm.org/D144940

Added: 


Modified: 
clang/include/clang/ExtractAPI/AvailabilityInfo.h
clang/lib/ExtractAPI/AvailabilityInfo.cpp
clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
clang/test/ExtractAPI/availability.c

Removed: 




diff  --git a/clang/include/clang/ExtractAPI/AvailabilityInfo.h 
b/clang/include/clang/ExtractAPI/AvailabilityInfo.h
index a258bc52c125d..0af373135b667 100644
--- a/clang/include/clang/ExtractAPI/AvailabilityInfo.h
+++ b/clang/include/clang/ExtractAPI/AvailabilityInfo.h
@@ -33,12 +33,14 @@ struct AvailabilityInfo {
   VersionTuple Introduced;
   VersionTuple Deprecated;
   VersionTuple Obsoleted;
+  bool Unavailable;
 
   AvailabilityInfo() = default;
 
   AvailabilityInfo(StringRef Domain, VersionTuple I, VersionTuple D,
-   VersionTuple O)
-  : Domain(Domain), Introduced(I), Deprecated(D), Obsoleted(O) {}
+   VersionTuple O, bool U)
+  : Domain(Domain), Introduced(I), Deprecated(D), Obsoleted(O),
+Unavailable(U) {}
 };
 
 class AvailabilitySet {

diff  --git a/clang/lib/ExtractAPI/AvailabilityInfo.cpp 
b/clang/lib/ExtractAPI/AvailabilityInfo.cpp
index ada64cfb92e64..1df852fdbf930 100644
--- a/clang/lib/ExtractAPI/AvailabilityInfo.cpp
+++ b/clang/lib/ExtractAPI/AvailabilityInfo.cpp
@@ -42,8 +42,8 @@ AvailabilitySet::AvailabilitySet(const Decl *Decl) {
   Availability->Obsoleted = Attr->getObsoleted();
   } else {
 Availabilities.emplace_back(Domain, Attr->getIntroduced(),
-Attr->getDeprecated(),
-Attr->getObsoleted());
+Attr->getDeprecated(), 
Attr->getObsoleted(),
+Attr->getUnavailable());
   }
 }
   }

diff  --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp 
b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index 8beb01697bc2e..8a98f5cf0c71f 100644
--- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -171,12 +171,16 @@ serializeAvailability(const AvailabilitySet 
&Availabilities) {
   for (const auto &AvailInfo : Availabilities) {
 Object Availability;
 Availability["domain"] = AvailInfo.Domain;
-serializeObject(Availability, "introducedVersion",
-serializeSemanticVersion(AvailInfo.Introduced));
-serializeObject(Availability, "deprecatedVersion",
-serializeSemanticVersion(AvailInfo.Deprecated));
-serializeObject(Availability, "obsoletedVersion",
-serializeSemanticVersion(AvailInfo.Obsoleted));
+if (AvailInfo.Unavailable)
+  Availability["isUnconditionallyUnavailable"] = true;
+else {
+  serializeObject(Availability, "introducedVersion",
+  serializeSemanticVersion(AvailInfo.Introduced));
+  serializeObject(Availability, "deprecatedVersion",
+  serializeSemanticVersion(AvailInfo.Deprecated));
+  serializeObject(Availability, "obsoletedVersion",
+  serializeSemanticVersion(AvailInfo.Obsoleted));
+}
 AvailabilityArray.emplace_back(std::move(Availability));
   }
 

diff  --git a/clang/test/ExtractAPI/availability.c 
b/clang/test/ExtractAPI/availability.c
index 54dbf5a6cac95..7d071909a092e 100644
--- a/clang/test/ExtractAPI/availability.c
+++ b/clang/test/ExtractAPI/availability.c
@@ -26,6 +26,9 @@ void e(void) __attribute__((deprecated)) 
__attribute__((availability(macos, intr
 void f(void) __attribute__((unavailable)) __attribute__((availability(macos, 
introduced=11.0)));
 
 void d(void) __attribute__((availability(tvos, introduced=15.0)));
+
+void e(void) __attribute__((availability(tvos, unavailable)));
+
 ///expected-no-diagnostics
 
 //--- reference.output.json.in
@@ -391,6 +394,10 @@ void d(void) __attribute__((availability(tvos, 
introduced=15.0)));
 "minor": 0,
 "patch": 0
   }
+},
+{
+  "domain": "tvos",
+  "isUnconditionallyUnavailable": true
 }
   ],
   "declarationFragments": [



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cg

[PATCH] D144940: [clang][ExtractAPI] Handle platform specific unavailability correctly

2023-03-02 Thread Daniel Grumberg via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG65f7a84cf38b: [clang][ExtractAPI] Handle platform specific 
unavailability correctly (authored by Arsenic, committed by dang).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144940/new/

https://reviews.llvm.org/D144940

Files:
  clang/include/clang/ExtractAPI/AvailabilityInfo.h
  clang/lib/ExtractAPI/AvailabilityInfo.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/availability.c


Index: clang/test/ExtractAPI/availability.c
===
--- clang/test/ExtractAPI/availability.c
+++ clang/test/ExtractAPI/availability.c
@@ -26,6 +26,9 @@
 void f(void) __attribute__((unavailable)) __attribute__((availability(macos, 
introduced=11.0)));
 
 void d(void) __attribute__((availability(tvos, introduced=15.0)));
+
+void e(void) __attribute__((availability(tvos, unavailable)));
+
 ///expected-no-diagnostics
 
 //--- reference.output.json.in
@@ -391,6 +394,10 @@
 "minor": 0,
 "patch": 0
   }
+},
+{
+  "domain": "tvos",
+  "isUnconditionallyUnavailable": true
 }
   ],
   "declarationFragments": [
Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
===
--- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -171,12 +171,16 @@
   for (const auto &AvailInfo : Availabilities) {
 Object Availability;
 Availability["domain"] = AvailInfo.Domain;
-serializeObject(Availability, "introducedVersion",
-serializeSemanticVersion(AvailInfo.Introduced));
-serializeObject(Availability, "deprecatedVersion",
-serializeSemanticVersion(AvailInfo.Deprecated));
-serializeObject(Availability, "obsoletedVersion",
-serializeSemanticVersion(AvailInfo.Obsoleted));
+if (AvailInfo.Unavailable)
+  Availability["isUnconditionallyUnavailable"] = true;
+else {
+  serializeObject(Availability, "introducedVersion",
+  serializeSemanticVersion(AvailInfo.Introduced));
+  serializeObject(Availability, "deprecatedVersion",
+  serializeSemanticVersion(AvailInfo.Deprecated));
+  serializeObject(Availability, "obsoletedVersion",
+  serializeSemanticVersion(AvailInfo.Obsoleted));
+}
 AvailabilityArray.emplace_back(std::move(Availability));
   }
 
Index: clang/lib/ExtractAPI/AvailabilityInfo.cpp
===
--- clang/lib/ExtractAPI/AvailabilityInfo.cpp
+++ clang/lib/ExtractAPI/AvailabilityInfo.cpp
@@ -42,8 +42,8 @@
   Availability->Obsoleted = Attr->getObsoleted();
   } else {
 Availabilities.emplace_back(Domain, Attr->getIntroduced(),
-Attr->getDeprecated(),
-Attr->getObsoleted());
+Attr->getDeprecated(), 
Attr->getObsoleted(),
+Attr->getUnavailable());
   }
 }
   }
Index: clang/include/clang/ExtractAPI/AvailabilityInfo.h
===
--- clang/include/clang/ExtractAPI/AvailabilityInfo.h
+++ clang/include/clang/ExtractAPI/AvailabilityInfo.h
@@ -33,12 +33,14 @@
   VersionTuple Introduced;
   VersionTuple Deprecated;
   VersionTuple Obsoleted;
+  bool Unavailable;
 
   AvailabilityInfo() = default;
 
   AvailabilityInfo(StringRef Domain, VersionTuple I, VersionTuple D,
-   VersionTuple O)
-  : Domain(Domain), Introduced(I), Deprecated(D), Obsoleted(O) {}
+   VersionTuple O, bool U)
+  : Domain(Domain), Introduced(I), Deprecated(D), Obsoleted(O),
+Unavailable(U) {}
 };
 
 class AvailabilitySet {


Index: clang/test/ExtractAPI/availability.c
===
--- clang/test/ExtractAPI/availability.c
+++ clang/test/ExtractAPI/availability.c
@@ -26,6 +26,9 @@
 void f(void) __attribute__((unavailable)) __attribute__((availability(macos, introduced=11.0)));
 
 void d(void) __attribute__((availability(tvos, introduced=15.0)));
+
+void e(void) __attribute__((availability(tvos, unavailable)));
+
 ///expected-no-diagnostics
 
 //--- reference.output.json.in
@@ -391,6 +394,10 @@
 "minor": 0,
 "patch": 0
   }
+},
+{
+  "domain": "tvos",
+  "isUnconditionallyUnavailable": true
 }
   ],
   "declarationFragments": [
Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp

[PATCH] D143984: [DebugMetadata] Simplify handling subprogram's retainedNodes field. NFCI (1/7)

2023-03-02 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb added a comment.

Friendly ping.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143984/new/

https://reviews.llvm.org/D143984

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


[PATCH] D145164: [clang][RISCV] Enable -fasynchronous-unwind-tables by default on Linux

2023-03-02 Thread Luís Marques via Phabricator via cfe-commits
luismarques added a comment.

From Kito's comment in D144174 : 
https://github.com/gcc-mirror/gcc/commit/3cd08f7168c196d7a481b9ed9f4289fd1f14eea8


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145164/new/

https://reviews.llvm.org/D145164

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


[clang] be646ef - Make clang/test/C/C2x/n2934.c compatible with targets that do not support thread_local storage.

2023-03-02 Thread Fanbo Meng via cfe-commits

Author: Fanbo Meng
Date: 2023-03-02T11:18:19-05:00
New Revision: be646ef39298503592407fd7eac9ce7fc2ee5f7c

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

LOG: Make clang/test/C/C2x/n2934.c compatible with targets that do not support 
thread_local storage.

Add an optional error check to test case for it to pass on targets that do not 
support thread_local storage.

Reviewed By: aaron.ballman, abhina.sreeskantharajan

Differential Revision: https://reviews.llvm.org/D145158

Added: 


Modified: 
clang/test/C/C2x/n2934.c

Removed: 




diff  --git a/clang/test/C/C2x/n2934.c b/clang/test/C/C2x/n2934.c
index d36e0b76344a3..d967446d8465a 100644
--- a/clang/test/C/C2x/n2934.c
+++ b/clang/test/C/C2x/n2934.c
@@ -7,6 +7,7 @@
 
 thread_local struct alignas(int) S { // c2x-warning {{'alignas' is 
incompatible with C standards before C2x}} \
 c2x-warning {{'thread_local' is 
incompatible with C standards before C2x}} \
+c2x-error 0+ {{thread-local storage is 
not supported for the current target}} \
 c17-error {{unknown type name 
'thread_local'}} \
 c17-error {{expected identifier or 
'('}} \
 c17-error {{expected ')'}} \



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


[PATCH] D145158: Make clang/test/C/C2x/n2934.c compatible with targets that do not support thread_local storage.

2023-03-02 Thread Fanbo Meng via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbe646ef39298: Make clang/test/C/C2x/n2934.c compatible with 
targets that do not support… (authored by fanbo-meng).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145158/new/

https://reviews.llvm.org/D145158

Files:
  clang/test/C/C2x/n2934.c


Index: clang/test/C/C2x/n2934.c
===
--- clang/test/C/C2x/n2934.c
+++ clang/test/C/C2x/n2934.c
@@ -7,6 +7,7 @@
 
 thread_local struct alignas(int) S { // c2x-warning {{'alignas' is 
incompatible with C standards before C2x}} \
 c2x-warning {{'thread_local' is 
incompatible with C standards before C2x}} \
+c2x-error 0+ {{thread-local storage is 
not supported for the current target}} \
 c17-error {{unknown type name 
'thread_local'}} \
 c17-error {{expected identifier or 
'('}} \
 c17-error {{expected ')'}} \


Index: clang/test/C/C2x/n2934.c
===
--- clang/test/C/C2x/n2934.c
+++ clang/test/C/C2x/n2934.c
@@ -7,6 +7,7 @@
 
 thread_local struct alignas(int) S { // c2x-warning {{'alignas' is incompatible with C standards before C2x}} \
 c2x-warning {{'thread_local' is incompatible with C standards before C2x}} \
+c2x-error 0+ {{thread-local storage is not supported for the current target}} \
 c17-error {{unknown type name 'thread_local'}} \
 c17-error {{expected identifier or '('}} \
 c17-error {{expected ')'}} \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141307: [WIP] Add -f[no-]loop-versioning option

2023-03-02 Thread Mats Petersson via Phabricator via cfe-commits
Leporacanthicus updated this revision to Diff 501881.
Leporacanthicus added a comment.

Update for rebase.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141307/new/

https://reviews.llvm.org/D141307

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CodeGenOptions.def
  flang/include/flang/Tools/CLOptions.inc
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90

Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -41,9 +41,11 @@
 ! HELP-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-NEXT: -flogical-abbreviations Enable logical abbreviations
+! HELP-NEXT: -floop-versioning  Create unit-strided versions of loops
 ! HELP-NEXT: -fno-automatic Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE
 ! HELP-NEXT: -fno-color-diagnostics  Disable colors in diagnostics
 ! HELP-NEXT: -fno-integrated-as  Disable the integrated assembler
+! HELP-NEXT: -fno-loop-versioning   Do not create unit-strided loops (default)
 ! HELP-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! HELP-NEXT: -fno-stack-arrays  Allocate array temporaries on the heap (default)
 ! HELP-NEXT: -fopenacc  Enable OpenACC
@@ -130,10 +132,12 @@
 ! HELP-FC1-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-FC1-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-FC1-NEXT: -flogical-abbreviations Enable logical abbreviations
+! HELP-FC1-NEXT: -floop-versioning  Create unit-strided versions of loops
 ! HELP-FC1-NEXT: -fno-analyzed-objects-for-unparse
 ! HELP-FC1-NEXT:Do not use the analyzed objects when unparsing
 ! HELP-FC1-NEXT: -fno-automatic Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE
 ! HELP-FC1-NEXT: -fno-debug-pass-manager Disables debug printing for the new pass manager
+! HELP-FC1-NEXT: -fno-loop-versioning   Do not create unit-strided loops (default)
 ! HELP-FC1-NEXT: -fno-reformat  Dump the cooked character stream in -E mode
 ! HELP-FC1-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! HELP-FC1-NEXT: -fno-stack-arrays  Allocate array temporaries on the heap (default)
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -43,9 +43,11 @@
 ! CHECK-NEXT:Enable support for generating executables (experimental)
 ! CHECK-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! CHECK-NEXT: -flogical-abbreviations Enable logical abbreviations
+! CHECK-NEXT: -floop-versioning  Create unit-strided versions of loops
 ! CHECK-NEXT: -fno-automatic Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE
 ! CHECK-NEXT: -fno-color-diagnostics  Disable colors in diagnostics
 ! CHECK-NEXT: -fno-integrated-as Disable the integrated assembler
+! CHECK-NEXT: -fno-loop-versioning   Do not create unit-strided loops (default)
 ! CHECK-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! CHECK-NEXT: -fno-stack-arrays  Allocate array temporaries on the heap (default)
 ! CHECK-NEXT: -fopenacc  Enable OpenACC
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -546,7 +546,7 @@
 
   // Create the pass pipeline
   fir::createMLIRToLLVMPassPipeline(pm, level, opts.StackArrays,
-opts.Underscoring);
+opts.Underscoring, opts.LoopVersioning);
   mlir::applyPassManagerCLOptions(pm);
 
   // run the pass manager
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -130,6 +130,10 @@
clang::driver::options::OPT_fno_stack_arrays, false)) {
 opts.StackArrays = 1;
   }
+  if (args.hasFlag(clang::driver::options::OPT_floop_versioning,
+   clang::driver::options::OPT_fno_loop_versioning, false)) {
+opts

[PATCH] D145093: Add map info for dereference pointer.

2023-03-02 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added a comment.

In D145093#4164528 , @ABataev wrote:

> What result produces `map(a[0][:3]`?

Yes, that would be another way to fix the runtime problem.  However the 
difficulty is when process array section, section base is different.
with a[0][:3]
the section base is a[0]
with (*a)[:3], the section base is (*a);  It is hard to set a[0] as section 
base during processing the array section.

That is why I am adding dereference pointer not a[0].


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145093/new/

https://reviews.llvm.org/D145093

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


[PATCH] D144967: [PowerPC] Recognize long CPU name for -mtune in Clang

2023-03-02 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added a comment.

Could this be merged into `main` and backported to `release/16.x`? If this 
makes 16.0.0 final, I think the kernel can avoid working around this issue 
altogether, as `-mtune` was only wired up to do something on PowerPC in during 
the 16 development cycle; in prior versions, it was ignored so any value was 
accepted.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144967/new/

https://reviews.llvm.org/D144967

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


[PATCH] D145093: Add map info for dereference pointer.

2023-03-02 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D145093#4164854 , @jyu2 wrote:

> In D145093#4164528 , @ABataev wrote:
>
>> What result produces `map(a[0][:3]`?
>
> Yes, that would be another way to fix the runtime problem.  However the 
> difficulty is when process array section, section base is different.
> with a[0][:3]
> the section base is a[0]
> with (*a)[:3], the section base is (*a);  It is hard to set a[0] as section 
> base during processing the array section.
>
> That is why I am adding dereference pointer not a[0].

I mean we shall emit the same mapping for `(*a)[:3]` and for `a[0][:3]`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145093/new/

https://reviews.llvm.org/D145093

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


[clang] 3711403 - [AMDGPU] Mark mbcnt as convergent

2023-03-02 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2023-03-02T11:56:32-05:00
New Revision: 37114036aa57e53217a57afacd7f47b36114edfb

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

LOG: [AMDGPU] Mark mbcnt as convergent

since it depends on CFG.

Otherwise some passes will try to merge them and cause
incorrect results.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D145072

Added: 


Modified: 
clang/test/CodeGenOpenCL/builtins-amdgcn.cl
llvm/include/llvm/IR/IntrinsicsAMDGPU.td

Removed: 




diff  --git a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
index 094851b218898..ff13357855413 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -676,12 +676,14 @@ kernel void test_gws_sema_p(uint id) {
 
 // CHECK-LABEL: @test_mbcnt_lo(
 // CHECK: call i32 @llvm.amdgcn.mbcnt.lo(i32 %src0, i32 %src1)
+// CHECK: declare i32 @llvm.amdgcn.mbcnt.lo(i32, i32) #[[$MBCNT_ATTRS:[0-9]+]]
 kernel void test_mbcnt_lo(global uint* out, uint src0, uint src1) {
   *out = __builtin_amdgcn_mbcnt_lo(src0, src1);
 }
 
 // CHECK-LABEL: @test_mbcnt_hi(
 // CHECK: call i32 @llvm.amdgcn.mbcnt.hi(i32 %src0, i32 %src1)
+// CHECK: declare i32 @llvm.amdgcn.mbcnt.hi(i32, i32) #[[$MBCNT_ATTRS]]
 kernel void test_mbcnt_hi(global uint* out, uint src0, uint src1) {
   *out = __builtin_amdgcn_mbcnt_hi(src0, src1);
 }
@@ -798,6 +800,7 @@ kernel void test_s_setreg(uint val) {
 // CHECK-DAG: [[$WS_RANGE]] = !{i16 1, i16 1025}
 // CHECK-DAG: attributes #[[$NOUNWIND_READONLY]] = { mustprogress nocallback 
nofree nosync nounwind willreturn memory(read) }
 // CHECK-DAG: attributes #[[$READ_EXEC_ATTRS]] = { convergent }
+// CHECK-DAG: attributes #[[$MBCNT_ATTRS]] = {{.* convergent .*}}
 // CHECK-DAG: ![[$EXEC]] = !{!"exec"}
 // CHECK-DAG: ![[$EXEC_LO]] = !{!"exec_lo"}
 // CHECK-DAG: ![[$EXEC_HI]] = !{!"exec_hi"}

diff  --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td 
b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
index f82682aff7c4d..ba01f383f0ce6 100644
--- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -1570,12 +1570,12 @@ def int_amdgcn_live_mask : DefaultAttrsIntrinsic 
<[llvm_i1_ty],
 def int_amdgcn_mbcnt_lo :
   ClangBuiltin<"__builtin_amdgcn_mbcnt_lo">,
   DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty],
-   [IntrNoMem]>;
+   [IntrNoMem, IntrConvergent]>;
 
 def int_amdgcn_mbcnt_hi :
   ClangBuiltin<"__builtin_amdgcn_mbcnt_hi">,
   DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty],
-[IntrNoMem]>;
+[IntrNoMem, IntrConvergent]>;
 
 // llvm.amdgcn.ds.swizzle src offset
 def int_amdgcn_ds_swizzle :



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


[PATCH] D145093: Add map info for dereference pointer.

2023-03-02 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added a comment.

> I mean we shall emit the same mapping for `(*a)[:3]` and for `a[0][:3]`

Yes I mean emit (*a)[:3] as a[0][:3]

The difficulty is during the process array section of 
OMPArraySectionExpr 0x12aa37e0 '' lvalue

| -ImplicitCastExpr 0x12a8a918 'int *'  |
| `-ArraySubscriptExpr 0x12a8a8d8 'int[3]':'int[3]' lvalue   |
|| 
-ImplicitCastExpr 0x12a8a8c0 'int (*)[3]'   
 |
|| `-DeclRefExpr 
0x12a8a880 'int (*)[3]' lvalue ParmVar 0x12a8a000 'a' 'int (*)[3]' |
| `-IntegerLiteral 0x12a8a8a0 'int' 0|
| -<<>>|
| -IntegerLiteral 0x12a8a8f8 'int' 3 |
|

`-<<>>

It is not easy to set section base as a[0].


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145093/new/

https://reviews.llvm.org/D145093

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


[PATCH] D145072: [AMDGPU] Mark mbcnt as convergent

2023-03-02 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG37114036aa57: [AMDGPU] Mark mbcnt as convergent (authored by 
yaxunl).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145072/new/

https://reviews.llvm.org/D145072

Files:
  clang/test/CodeGenOpenCL/builtins-amdgcn.cl
  llvm/include/llvm/IR/IntrinsicsAMDGPU.td


Index: llvm/include/llvm/IR/IntrinsicsAMDGPU.td
===
--- llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -1570,12 +1570,12 @@
 def int_amdgcn_mbcnt_lo :
   ClangBuiltin<"__builtin_amdgcn_mbcnt_lo">,
   DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty],
-   [IntrNoMem]>;
+   [IntrNoMem, IntrConvergent]>;
 
 def int_amdgcn_mbcnt_hi :
   ClangBuiltin<"__builtin_amdgcn_mbcnt_hi">,
   DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty],
-[IntrNoMem]>;
+[IntrNoMem, IntrConvergent]>;
 
 // llvm.amdgcn.ds.swizzle src offset
 def int_amdgcn_ds_swizzle :
Index: clang/test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- clang/test/CodeGenOpenCL/builtins-amdgcn.cl
+++ clang/test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -676,12 +676,14 @@
 
 // CHECK-LABEL: @test_mbcnt_lo(
 // CHECK: call i32 @llvm.amdgcn.mbcnt.lo(i32 %src0, i32 %src1)
+// CHECK: declare i32 @llvm.amdgcn.mbcnt.lo(i32, i32) #[[$MBCNT_ATTRS:[0-9]+]]
 kernel void test_mbcnt_lo(global uint* out, uint src0, uint src1) {
   *out = __builtin_amdgcn_mbcnt_lo(src0, src1);
 }
 
 // CHECK-LABEL: @test_mbcnt_hi(
 // CHECK: call i32 @llvm.amdgcn.mbcnt.hi(i32 %src0, i32 %src1)
+// CHECK: declare i32 @llvm.amdgcn.mbcnt.hi(i32, i32) #[[$MBCNT_ATTRS]]
 kernel void test_mbcnt_hi(global uint* out, uint src0, uint src1) {
   *out = __builtin_amdgcn_mbcnt_hi(src0, src1);
 }
@@ -798,6 +800,7 @@
 // CHECK-DAG: [[$WS_RANGE]] = !{i16 1, i16 1025}
 // CHECK-DAG: attributes #[[$NOUNWIND_READONLY]] = { mustprogress nocallback 
nofree nosync nounwind willreturn memory(read) }
 // CHECK-DAG: attributes #[[$READ_EXEC_ATTRS]] = { convergent }
+// CHECK-DAG: attributes #[[$MBCNT_ATTRS]] = {{.* convergent .*}}
 // CHECK-DAG: ![[$EXEC]] = !{!"exec"}
 // CHECK-DAG: ![[$EXEC_LO]] = !{!"exec_lo"}
 // CHECK-DAG: ![[$EXEC_HI]] = !{!"exec_hi"}


Index: llvm/include/llvm/IR/IntrinsicsAMDGPU.td
===
--- llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -1570,12 +1570,12 @@
 def int_amdgcn_mbcnt_lo :
   ClangBuiltin<"__builtin_amdgcn_mbcnt_lo">,
   DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty],
-   [IntrNoMem]>;
+   [IntrNoMem, IntrConvergent]>;
 
 def int_amdgcn_mbcnt_hi :
   ClangBuiltin<"__builtin_amdgcn_mbcnt_hi">,
   DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty],
-[IntrNoMem]>;
+[IntrNoMem, IntrConvergent]>;
 
 // llvm.amdgcn.ds.swizzle src offset
 def int_amdgcn_ds_swizzle :
Index: clang/test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- clang/test/CodeGenOpenCL/builtins-amdgcn.cl
+++ clang/test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -676,12 +676,14 @@
 
 // CHECK-LABEL: @test_mbcnt_lo(
 // CHECK: call i32 @llvm.amdgcn.mbcnt.lo(i32 %src0, i32 %src1)
+// CHECK: declare i32 @llvm.amdgcn.mbcnt.lo(i32, i32) #[[$MBCNT_ATTRS:[0-9]+]]
 kernel void test_mbcnt_lo(global uint* out, uint src0, uint src1) {
   *out = __builtin_amdgcn_mbcnt_lo(src0, src1);
 }
 
 // CHECK-LABEL: @test_mbcnt_hi(
 // CHECK: call i32 @llvm.amdgcn.mbcnt.hi(i32 %src0, i32 %src1)
+// CHECK: declare i32 @llvm.amdgcn.mbcnt.hi(i32, i32) #[[$MBCNT_ATTRS]]
 kernel void test_mbcnt_hi(global uint* out, uint src0, uint src1) {
   *out = __builtin_amdgcn_mbcnt_hi(src0, src1);
 }
@@ -798,6 +800,7 @@
 // CHECK-DAG: [[$WS_RANGE]] = !{i16 1, i16 1025}
 // CHECK-DAG: attributes #[[$NOUNWIND_READONLY]] = { mustprogress nocallback nofree nosync nounwind willreturn memory(read) }
 // CHECK-DAG: attributes #[[$READ_EXEC_ATTRS]] = { convergent }
+// CHECK-DAG: attributes #[[$MBCNT_ATTRS]] = {{.* convergent .*}}
 // CHECK-DAG: ![[$EXEC]] = !{!"exec"}
 // CHECK-DAG: ![[$EXEC_LO]] = !{!"exec_lo"}
 // CHECK-DAG: ![[$EXEC_HI]] = !{!"exec_hi"}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144638: [lit] Detect Inconsistent File Access Times

2023-03-02 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings accepted this revision.
michaelplatings added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144638/new/

https://reviews.llvm.org/D144638

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


[PATCH] D145093: Add map info for dereference pointer.

2023-03-02 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D145093#4164877 , @jyu2 wrote:

>> I mean we shall emit the same mapping for `(*a)[:3]` and for `a[0][:3]`
>
> Yes I mean emit (*a)[:3] as a[0][:3]
>
> The difficulty is during the process array section of 
> OMPArraySectionExpr 0x12aa37e0 '' lvalue
>
> | -ImplicitCastExpr 0x12a8a918 'int *'  |
> | `-ArraySubscriptExpr 0x12a8a8d8 'int[3]':'int[3]' lvalue   |
> || 
> -ImplicitCastExpr 0x12a8a8c0 'int (*)[3]' 
>|
> || `-DeclRefExpr 
> 0x12a8a880 'int (*)[3]' lvalue ParmVar 0x12a8a000 'a' 'int (*)[3]' |
> | `-IntegerLiteral 0x12a8a8a0 'int' 0|
> | -<<>>|
> | -IntegerLiteral 0x12a8a8f8 'int' 3 |
> |
>
> `-<<>>
>
> It is not easy to set section base as a[0].

Yes, I understand. And did not ask for it. I just mean that a[0][:3] emits 
different mapping data - TARGET_PAPARM|TO|FROM, PTR_AND_OBJ|TO|FROM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145093/new/

https://reviews.llvm.org/D145093

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


[PATCH] D141389: [DFSAN] Add support for strnlen, strncat, strsep, sscanf and _tolower

2023-03-02 Thread Andrew via Phabricator via cfe-commits
browneee added inline comments.



Comment at: compiler-rt/lib/dfsan/dfsan_custom.cpp:221
+  if (flags().strict_data_dependencies) {
+*ret_label = res ? s_label : 0;
+  } else {

tkuchta wrote:
> browneee wrote:
> > When `res != NULL`, then `res` is derived from `*s`, not from `s`.
> > 
> > e.g.
> > 
> > ```
> > *ret_label = res ? dfsan_get_label(base) : 0;
> > ```
> Apologies for a delay.
> 
> I came across some difficulty with using dfsan_get_label inside the 
> dfsan_custom.cpp file.
> It seems that including the dfsan_interface.h header there, which would be 
> needed for dfsan_get_label, causes other conflicts and build errors.
> Would there be another way to use that function inside dfsan_custom.cpp? 
```
char *base = *s;
```

Here base is loaded, so we can also load the shadow.

`dfsan_get_label(base) == dfsan_read_label(s, sizeof(*s))`

If base was an argument, then it would have a corresponding label argument as 
part of the wrapper function, so you also wouldn't need `dfsan_get_label`.


Repository:
  rCRT Compiler Runtime

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141389/new/

https://reviews.llvm.org/D141389

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


[PATCH] D136864: [Clang] Create opaque type for AArch64 SVE2p1/SME2 svcount_t.

2023-03-02 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:730
   ASTContext::BuiltinVectorTypeInfo Info =
-  CGM.getContext().getBuiltinVectorTypeInfo(BT);
-  unsigned NumElemsPerVG = (Info.EC.getKnownMinValue() * Info.NumVectors) 
/ 2;
+  // For svcount_t, only the lower 16 bits are relevant.
+  BT->getKind() == BuiltinType::SveCount

Given predicates are stored byte wise perhaps it's worth being more explicit 
and saying "only the first 2 bytes are relevant"?



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:739
+  // bitpattern for predicates instead.
+  unsigned NumElems = Info.EC.getKnownMinValue() * Info.NumVectors;
   if (Info.ElementType == CGM.getContext().BoolTy) {

Do we need an assert that `Info.NumVectors` is 1 for `svcount_t`? I don't think 
we plan of having `svcountx2_t`, but if we did then I think this code is 
incorrect because `UpperBound` will not take the padding between the "live 
16bit values" into account? And an assert would at least give us a modicum of 
protection.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136864/new/

https://reviews.llvm.org/D136864

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


[PATCH] D145047: Fix broken link on Clang documentation page

2023-03-02 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson accepted this revision.
royjacobson added a comment.

Thanks! Do you need me to land this for you? If so, could you please provide 
name + email to sign the commit with?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145047/new/

https://reviews.llvm.org/D145047

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


[PATCH] D144672: [Sanitizers] Error when attempting to use `static-lsan` with `TSan` or `Asan` on darwin

2023-03-02 Thread Dave MacLachlan via Phabricator via cfe-commits
dmaclach updated this revision to Diff 501899.
dmaclach added a comment.
Herald added subscribers: Sanitizers, Enna1.

Updated with fixed tests for `replaceable_new_delete.cpp`.

Split `replaceable_new_delete.cpp` into `replaceable_new_delete_shared.cpp` and 
`replaceable_new_delete_static.cpp`.
Static is marked as failing on darwin.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144672/new/

https://reviews.llvm.org/D144672

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/sanitizer-ld.c
  compiler-rt/test/asan/TestCases/replaceable_new_delete.cpp
  compiler-rt/test/asan/TestCases/replaceable_new_delete_shared.cpp
  compiler-rt/test/asan/TestCases/replaceable_new_delete_static.cpp

Index: compiler-rt/test/asan/TestCases/replaceable_new_delete_static.cpp
===
--- /dev/null
+++ compiler-rt/test/asan/TestCases/replaceable_new_delete_static.cpp
@@ -0,0 +1,35 @@
+// Ensure that operator new/delete are still replaceable using static-libsan.
+
+// FIXME: Weak symbols aren't supported on Windows, although some code in
+// compiler-rt already exists to solve this problem. We should probably define
+// the new/delete interceptors as "weak" using those workarounds as well.
+// UNSUPPORTED: target={{.*windows.*}}
+
+// RUN: %clangxx %s -o %t -fsanitize=address -static-libsan && not %run %t 2>&1 | FileCheck %s
+
+// darwin only supports shared-libsan, so this should fail.
+// XFAIL: darwin
+ 
+#include 
+#include 
+#include 
+
+void *operator new[](size_t size) {
+  fprintf(stderr, "replaced new\n");
+  return malloc(size);
+}
+
+void operator delete[](void *ptr) noexcept {
+  fprintf(stderr, "replaced delete\n");
+  return free(ptr);
+}
+
+int main(int argc, char **argv) {
+  // CHECK: replaced new
+  char *x = new char[5];
+  // CHECK: replaced delete
+  delete[] x;
+  // CHECK: ERROR: AddressSanitizer
+  *x = 13;
+  return 0;
+}
Index: compiler-rt/test/asan/TestCases/replaceable_new_delete_shared.cpp
===
--- compiler-rt/test/asan/TestCases/replaceable_new_delete_shared.cpp
+++ compiler-rt/test/asan/TestCases/replaceable_new_delete_shared.cpp
@@ -1,4 +1,4 @@
-// Ensure that operator new/delete are still replaceable.
+// Ensure that operator new/delete are still replaceable using shared-libsan.
 
 // FIXME: Weak symbols aren't supported on Windows, although some code in
 // compiler-rt already exists to solve this problem. We should probably define
@@ -6,7 +6,6 @@
 // UNSUPPORTED: target={{.*windows.*}}
 
 // RUN: %clangxx %s -o %t -fsanitize=address -shared-libsan && not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx %s -o %t -fsanitize=address -static-libsan && not %run %t 2>&1 | FileCheck %s
 
 #include 
 #include 
Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -457,6 +457,18 @@
 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-STATIC-DARWIN %s
 // CHECK-UBSAN-STATIC-DARWIN: {{.*}}error: static UndefinedBehaviorSanitizer runtime is not supported on darwin
 
+// RUN: %clang -fsanitize=address -### %s 2>&1 \
+// RUN: --target=x86_64-apple-darwin -fuse-ld=ld -static-libsan \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-STATIC-DARWIN %s
+// CHECK-ASAN-STATIC-DARWIN: {{.*}}error: static AddressSanitizer runtime is not supported on darwin
+
+// RUN: %clang -fsanitize=thread -### %s 2>&1 \
+// RUN: --target=x86_64-apple-darwin -fuse-ld=ld -static-libsan \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-TSAN-STATIC-DARWIN %s
+// CHECK-TSAN-STATIC-DARWIN: {{.*}}error: static ThreadSanitizer runtime is not supported on darwin
+
 // RUN: %clang -fsanitize=address,undefined -### %s 2>&1 \
 // RUN: --target=i386-unknown-linux -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1426,24 +1426,42 @@
 
   const SanitizerArgs &Sanitize = getSanitizerArgs(Args);
 
-  if (!Sanitize.needsSharedRt() && Sanitize.needsUbsanRt()) {
-getDriver().Diag(diag::err_drv_unsupported_static_ubsan_darwin);
-return;
+  if (!Sanitize.needsSharedRt()) {
+const char *sanitizer = nullptr;
+if (Sanitize.needsUbsanRt()) {
+  sanitizer = "UndefinedBehaviorSanitizer";
+} else if (Sanitize.needsAsanRt()) {
+  sanitizer = "AddressSanitizer";
+} else if (Sanitize.needsTsanRt()) {
+  sanitizer = "ThreadSanitizer";
+}
+if (sanitizer) {
+  getDriver().Diag(diag::err_drv_un

[PATCH] D145148: [Clang][CodeGen] Fix this argument type for certain destructors

2023-03-02 Thread Jacob Young via Phabricator via cfe-commits
jacobly abandoned this revision.
jacobly added a comment.

Following release cherry-pick workflow.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145148/new/

https://reviews.llvm.org/D145148

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


[PATCH] D144273: [clang][ASTImporter] Add VaList declaration to lookup table.

2023-03-02 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy added a comment.

@balazske

> I tried to find out how to add a correct test but could not check if this 
> fails or not on AArch64 platform. [...] I want to touch ASTContext only if a 
> test failure is found on AArch64 that makes it necessary.

It's possible to "simulate" the AArch64 behavior locally by temporarily 
modifying ASTContext.cpp to make `CreateX86_64ABIBuiltinVaListDecl` create the 
`std` namespace on x86_64 (using the code fragment taken from the 
AArch64-specific function). I tried to do this with a simple unit test, but my 
results are inconclusive (my test passed, but I'm not sure that it would've 
reproduced the error).

Consider using this hack to test the commit instead of relying on the centrally 
executed AArch64 tests.




Comment at: clang/test/Import/cxx-valist/Inputs/I1.cpp:1-3
+int *use_new(int N) {
+  return new int [N];
+}

I don't think that this //"import this innocent file before importing `int 
std`"// step is relevant for triggering the potentially problematic behavior 
that I outlined in my comments. Personally I'd remove this file from the commit 
(either keeping the the other two files as a simpler testcase that verifies 
that `int std` can be imported or converting that logic into a unit test); but 
I don't have a complete understanding of the situation, so if you feel that 
this is relevant, then I strongly support keeping it.

However, in that case I'd use a very simple "dummy" function like `int f(int x) 
{ return x; }` instead of this `use_new` to keep this testcase independent of 
the //"does the type of `new` leak the declaration of the `std` namespace?"// 
question. (That was resolved in 2009 by commit [[ 
https://github.com/llvm/llvm-project/commit/87f540608106f28d9319b2148eb1b00192e020c2#diff-af1009156039bf1cca0adb74b8c38c7a4e9eacf7a570f1a47fd95261fe6dfc08
 | 87f54060 ]] but a regression on that front could cause a misleading failure 
of this testcase.) 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144273/new/

https://reviews.llvm.org/D144273

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


[PATCH] D144622: [clang][ASTImporter] Import TemplateName correctly

2023-03-02 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy accepted this revision.
donat.nagy added a comment.

LGTM as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144622/new/

https://reviews.llvm.org/D144622

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


[PATCH] D144903: [X86] Drop single use check for freeze(undef) in LowerAVXCONCAT_VECTORS

2023-03-02 Thread Manuel Brito via Phabricator via cfe-commits
ManuelJBrito added a comment.

I originally reverted it because of the wrong tag, but there were also some 
buildbot failures (see 
https://lab.llvm.org/buildbot/#/builders/139/builds/36736).
It appears to be failing an assert in DiagnosticsEngine::DiagStateMap::append, 
but i'm not very familiar with this part so i will have to investigate further.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144903/new/

https://reviews.llvm.org/D144903

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


[PATCH] D142800: [Clang][Diagnostic] Add `-Wcomparison-op-parentheses` to warn on chained comparisons

2023-03-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D142800#4104241 , @hazohelet wrote:

>> Also, why are these diagnostics off by default? Do we have some idea as to 
>> the false positive rate?
>
> As for the false positive rate, I have checked for instances of this warning 
> in the codebases for 'oneapi-src/oneTBB', 'rui314/mold', and 
> 'microsoft/lightgbm', but did not find any new cases.

Thank you for doing the extra testing! Sorry for the delayed response, this 
review fell off my radar for a bit.

> I also ran a test on  'tensorflow/tensorflow' using gcc '-Wparentheses' and 
> found six lines of code that trigger the new diagnostic. They all relate to 
> checking whether `x` and `y` have the same sign using `x > 0 == y > 0` and 
> alike. I tried to build with tensorflow using clang, but I stumbled upon some 
> errors (for my poor knowledge of bazel configuration), so here I am using gcc.

Thank you for reporting this, that's really good information.

> I set the diagnostic disabled by default for compatibility with gcc. 
> Considering the test against tensorflow above, it would be too noisy if we 
> turned on the suggest-parentheses diagnostic by default (From my best guess, 
> it would generate at least 18 new instances of warning on the tensorflow 
> build for the six lines).
> However, in my opinion, it is reasonable enough to have the diagnostic on 
> chained relational operators enabled by default. The following is an excerpt 
> from the 'Existing Code in C++' section of the proposal document of the 
> introduction of chaining comparison for C++17.
>
>> Overall, what we found was:
>>
>> - Zero instances of chained arithmetic comparisons that are correct today. 
>> That is, intentionally using the current standard behavior.
>> - Four instances of currently-erroneous arithmetic chaining, of the assert(0 
>> <= ratio <= 1.0); variety. These are bugs that compile today but don’t do 
>> what the programmer intended, but with this proposal would change in meaning 
>> to become correct.
>> - Many instances of using successive comparison operators in DSLs that 
>> overloaded these operators to give meaning unrelated to comparisons.
>
> Note that the 'chaining comparisons' in the document are
>
>> - all `==`, such as `a == b == c == d`;
>> - all `{<, <=}`, such as `a < b <= c < d`; and
>> - all `{>, >=}` (e.g., `a >= b > c > d`).
>
> URL: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0893r0.html
>
> Although this paper is five years old now, I think we can conclude chaining 
> relational operators are bug-prone and should be diagnosed by default.
> Also, reading the document above, I think it would be reasonable to suggest 
> adding '&&' in `a == b == c` case, too.

I tend to agree -- I was searching around sourcegraph 
(https://sourcegraph.com/search?q=context:global+lang:C+lang:C%2B%2B+%5BA-Za-z0-9_%5D%2B%5Cs*%28%3D%3D%7C%21%3D%7C%3C%3D%7C%3E%3D%29%5Cs*%5BA-Za-z0-9_%5D%2B%5Cs*%28%3D%3D%7C%21%3D%7C%3C%3D%7C%3E%3D%29&patternType=regexp&sm=1&groupBy=repo)
 and I can't find a whole lot of evidence for chained operators outside of 
comments.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142800/new/

https://reviews.llvm.org/D142800

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


[PATCH] D143704: [Flang] Part one of Feature List action

2023-03-02 Thread Ethan Luis McDonough via Phabricator via cfe-commits
elmcdonough updated this revision to Diff 501919.
elmcdonough added a comment.

Clang format


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143704/new/

https://reviews.llvm.org/D143704

Files:
  flang/examples/CMakeLists.txt
  flang/examples/FeatureList/CMakeLists.txt
  flang/examples/FeatureList/FeatureList.cpp
  flang/test/Examples/feature-list-class.f90
  flang/test/Examples/feature-list-functions.f90

Index: flang/test/Examples/feature-list-functions.f90
===
--- /dev/null
+++ flang/test/Examples/feature-list-functions.f90
@@ -0,0 +1,76 @@
+! UNSUPPORTED: system-windows
+! REQUIRES: plugins, shell, examples
+
+! RUN: %flang_fc1 -load %llvmshlibdir/flangFeatureList.so \
+! RUN:-plugin feature-list %s 2>&1 | FileCheck %s
+
+program list_features_test
+implicit none
+call test_sub(test_func(2, 3), 4)
+contains
+subroutine test_sub(a, b)
+integer, intent(in) :: a, b
+print "(I0)", a + b
+end subroutine
+
+integer function test_func(a, b)
+integer, intent(in) :: a, b
+test_func = a * b
+end function
+end program list_features_test
+
+! CHECK: Name: 19
+! CHECK-NEXT: IntLiteralConstant: 3
+! CHECK-NEXT: LiteralConstant: 4
+! CHECK-NEXT: CharLiteralConstant: 1
+! CHECK-NEXT: FunctionReference: 1
+! CHECK-NEXT: Call: 2
+! CHECK-NEXT: Expr::Multiply: 1
+! CHECK-NEXT: Expr::Add: 1
+! CHECK-NEXT: IntrinsicTypeSpec: 3
+! CHECK-NEXT: IntegerTypeSpec: 3
+! CHECK-NEXT: Format: 1
+! CHECK-NEXT: DataRef: 5
+! CHECK-NEXT: ProcedureDesignator: 2
+! CHECK-NEXT: Designator: 5
+! CHECK-NEXT: ActualArgSpec: 4
+! CHECK-NEXT: ActualArg: 4
+! CHECK-NEXT: Expr: 11
+! CHECK-NEXT: Variable: 1
+! CHECK-NEXT: AttrSpec: 2
+! CHECK-NEXT: IntentSpec: 2
+! CHECK-NEXT: IntentSpec::Intent: 2
+! CHECK-NEXT: DummyArg: 2
+! CHECK-NEXT: DeclarationTypeSpec: 3
+! CHECK-NEXT: ImplicitStmt: 1
+! CHECK-NEXT: ImplicitPart: 3
+! CHECK-NEXT: ImplicitPartStmt: 1
+! CHECK-NEXT: PrefixSpec: 1
+! CHECK-NEXT: OutputItem: 1
+! CHECK-NEXT: AssignmentStmt: 1
+! CHECK-NEXT: ActionStmt: 3
+! CHECK-NEXT: PrintStmt: 1
+! CHECK-NEXT: CallStmt: 1
+! CHECK-NEXT: Block: 3
+! CHECK-NEXT: ContainsStmt: 1
+! CHECK-NEXT: EntityDecl: 4
+! CHECK-NEXT: SpecificationConstruct: 2
+! CHECK-NEXT: TypeDeclarationStmt: 2
+! CHECK-NEXT: DeclarationConstruct: 2
+! CHECK-NEXT: EndFunctionStmt: 1
+! CHECK-NEXT: FunctionStmt: 1
+! CHECK-NEXT: EndSubroutineStmt: 1
+! CHECK-NEXT: SubroutineStmt: 1
+! CHECK-NEXT: ExecutionPartConstruct: 3
+! CHECK-NEXT: ExecutableConstruct: 3
+! CHECK-NEXT: SpecificationPart: 3
+! CHECK-NEXT: FunctionSubprogram: 1
+! CHECK-NEXT: ExecutionPart: 3
+! CHECK-NEXT: InternalSubprogramPart: 1
+! CHECK-NEXT: InternalSubprogram: 2
+! CHECK-NEXT: SubroutineSubprogram: 1
+! CHECK-NEXT: ProgramUnit: 1
+! CHECK-NEXT: MainProgram: 1
+! CHECK-NEXT: Program: 1
+! CHECK-NEXT: EndProgramStmt: 1
+! CHECK-NEXT: ProgramStmt: 1
Index: flang/test/Examples/feature-list-class.f90
===
--- /dev/null
+++ flang/test/Examples/feature-list-class.f90
@@ -0,0 +1,88 @@
+! UNSUPPORTED: system-windows
+! REQUIRES: plugins, shell, examples
+
+! RUN: %flang_fc1 -load %llvmshlibdir/flangFeatureList.so \
+! RUN:-plugin feature-list %s 2>&1 | FileCheck %s
+
+module list_features_test
+implicit none
+
+type :: test_class_1
+integer :: a
+real :: b
+contains
+procedure :: sum => sum_test_class_1
+procedure :: set => set_values_test_class_1
+end type
+contains
+real function sum_test_class_1(self)
+class(test_class_1), intent(in) :: self
+sum_test_class_1 = self%a + self%b
+end function
+
+subroutine set_values_test_class_1(self, a, b)
+class(test_class_1), intent(out) :: self
+integer, intent(in) :: a, b
+self%a = a
+self%b = b
+end subroutine
+end module list_features_test
+
+! CHECK: Name: 32
+! CHECK-NEXT: DerivedTypeSpec: 2
+! CHECK-NEXT: Expr::Add: 1
+! CHECK-NEXT: IntrinsicTypeSpec: 4
+! CHECK-NEXT: IntegerTypeSpec: 2
+! CHECK-NEXT: IntrinsicTypeSpec::Real: 2
+! CHECK-NEXT: DataRef: 11
+! CHECK-NEXT: StructureComponent: 4
+! CHECK-NEXT: Designator: 7
+! CHECK-NEXT: Expr: 5
+! CHECK-NEXT: Variable: 3
+! CHECK-NEXT: AttrSpec: 3
+! CHECK-NEXT: IntentSpec: 3
+! CHECK-NEXT: IntentSpec::Intent: 3
+! CHECK-NEXT: DummyArg: 3
+! CHECK-NEXT: DeclarationTypeSpec: 6
+! CHECK-NEXT: DeclarationTypeSpec::Class: 2
+! CHECK-NEXT: ImplicitStmt: 1
+! CHECK-NEXT: ImplicitPart: 3
+! CHECK-NEXT: ImplicitPartStmt: 1
+! CHECK-NEXT: PrefixSpec: 1
+! CHECK-NEXT: Module: 1
+! CHECK-NEXT: AssignmentStmt: 3
+! CHECK-NEXT: ActionStmt: 3
+! CHECK-NEXT: Block: 2
+! CHECK-NEXT: TypeBoundProcBinding: 2
+! CHECK-NEXT: TypeBoundProcedureStmt: 2
+! CHECK-NEXT: TypeBoundProcDecl: 2
+! CHECK-NEXT: TypeBoundProcedureStmt::WithoutInterface: 2
+! CHECK-NEXT: ComponentO

[PATCH] D144884: [clang-format] Only add pragma continuation indentation for 'omp' clauses

2023-03-02 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/ContinuationIndenter.cpp:1280
+FormatToken *PragmaType = State.Line->First->Next->Next;
+if (PragmaType && PragmaType->TokenText.equals("omp"))
+  return CurrentState.Indent + Style.ContinuationIndentWidth;

can you add a test that covers this?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144884/new/

https://reviews.llvm.org/D144884

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


[PATCH] D144884: [clang-format] Only add pragma continuation indentation for 'omp' clauses

2023-03-02 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/lib/Format/ContinuationIndenter.cpp:1280
+FormatToken *PragmaType = State.Line->First->Next->Next;
+if (PragmaType && PragmaType->TokenText.equals("omp"))
+  return CurrentState.Indent + Style.ContinuationIndentWidth;

MyDeveloperDay wrote:
> can you add a test that covers this?
There is already a test for the `omp` case and this patch added a new one for 
the non-omp case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144884/new/

https://reviews.llvm.org/D144884

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


[PATCH] D145093: Add map info for dereference pointer.

2023-03-02 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 501921.
jyu2 added a comment.

Thanks Alexey for the review.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145093/new/

https://reviews.llvm.org/D145093

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_map_deref_array_codegen.cpp
  openmp/libomptarget/test/mapping/target_derefence_array_pointrs.cpp

Index: openmp/libomptarget/test/mapping/target_derefence_array_pointrs.cpp
===
--- /dev/null
+++ openmp/libomptarget/test/mapping/target_derefence_array_pointrs.cpp
@@ -0,0 +1,33 @@
+// RUN: %libomptarget-compilexx-generic -fopenmp-version=51
+// RUN: %libomptarget-run-generic 2>&1 \
+// RUN: | %fcheck-generic
+
+#include 
+#include 
+
+void foo(int **t1d) {
+  int ***t2d = &t1d;
+  int t3d = &t2d;
+  *t1d = (int *)malloc(3 * sizeof(int));
+  int j;
+
+  for (j = 0; j < 3; j++)
+(*t1d)[j] = 0;
+#pragma omp target map(tofrom : (*t1d)[0 : 3])
+  { (*t1d)[1] = 1; }
+  // CHECK: 1
+  printf("%d\n", (*t1d)[1]);
+#pragma omp target map(tofrom : (**t2d)[0 : 3])
+  { (**t2d)[1] = 2; }
+  // CHECK: 2
+  printf("%d\n", (**t2d)[1]);
+#pragma omp target map(tofrom : (***t3d)[0 : 3])
+  { (***t3d)[1] = 3; }
+  // CHECK: 3
+  printf("%d\n", (***t3d)[1]);
+}
+
+int main() {
+  int *data = 0;
+  foo(&data);
+}
Index: clang/test/OpenMP/target_map_deref_array_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_map_deref_array_codegen.cpp
@@ -0,0 +1,131 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" "pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+extern void *malloc (int __size) throw () __attribute__ ((__malloc__));
+
+void foo(int **t1d)
+{
+  *t1d = (int *) malloc(3 * sizeof(int));
+  for (int j=0; j < 3; j++)
+(*t1d)[j] = 1;
+  #pragma omp target map(to: (*t1d)[0:3])
+(*t1d)[2] = 2;
+}
+
+#endif
+
+// CHECK: @.offload_sizes = private unnamed_addr constant [2 x i64] [i64 8, i64 12]
+// CHECK: @.offload_maptypes = private unnamed_addr constant [2 x i64] [i64 33, i64 17]
+// CHECK-LABEL: define {{[^@]+}}@_Z3fooPPi
+// CHECK-SAME: (ptr noundef [[T1D:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[T1D_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:[[J:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[DOTOFFLOAD_BASEPTRS:%.*]] = alloca [2 x ptr], align 8
+// CHECK-NEXT:[[DOTOFFLOAD_PTRS:%.*]] = alloca [2 x ptr], align 8
+// CHECK-NEXT:[[DOTOFFLOAD_MAPPERS:%.*]] = alloca [2 x ptr], align 8
+// CHECK-NEXT:store ptr [[T1D]], ptr [[T1D_ADDR]], align 8
+// CHECK-NEXT:[[CALL:%.*]] = call noalias noundef ptr @_Z6malloci(i32 noundef signext 12) #[[ATTR3:[0-9]+]]
+// CHECK-NEXT:[[TMP0:%.*]] = load ptr, ptr [[T1D_ADDR]], align 8
+// CHECK-NEXT:store ptr [[CALL]], ptr [[TMP0]], align 8
+// CHECK-NEXT:store i32 0, ptr [[J]], align 4
+// CHECK-NEXT:br label [[FOR_COND:%.*]]
+// CHECK:   for.cond:
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[J]], align 4
+// CHECK-NEXT:[[CMP:%.*]] = icmp slt i32 [[TMP1]], 3
+// CHECK-NEXT:br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END:%.*]]
+// CHECK:   for.body:
+// CHECK-NEXT:[[TMP2:%.*]] = load ptr, ptr [[T1D_ADDR]], align 8
+// CHECK-NEXT:[[TMP3:%.*]] = load ptr, ptr [[TMP2]], align 8
+// CHECK-NEXT:[[TMP4:%.*]] = load i32, ptr [[J]], align 4
+// CHECK-NEXT:[[IDXPROM:%.*]] = sext i32 [[TMP4]] to i64
+// CHECK-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[TMP3]], i64 [[IDXPROM]]
+// CHECK-NEXT:store i32 1, ptr [[ARRAYIDX]], align 4
+// CHECK-NEXT:br label [[FOR_INC:%.*]]
+// CHECK:   for.inc:
+// CHECK-NEXT:[[TMP5:%.*]] = load i32, ptr [[J]], align 4
+// CHECK-NEXT:[[INC:%.*]] = add nsw i32 [[TMP5]], 1
+// CHECK-NEXT:store i32 [[INC]], ptr [[J]], align 4
+// CHECK-NEXT:br label [[FOR_COND]], !llvm.loop [[LOOP4:![0-9]+]]
+// CHECK:   for.end:
+// CHECK-NEXT:[[TMP6:%.*]] = load ptr, ptr [[T1D_ADDR]], align 8
+// CHECK-NEXT:[[TMP7:%.*]] = load ptr, ptr [[T1D_ADDR]], align 8
+// CHECK-NEXT:[[TMP8:%.*]] = load ptr, ptr [[T1D_ADDR]], align 8
+// CHEC

[PATCH] D145093: Add map info for dereference pointer.

2023-03-02 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added a comment.

> Yes, I understand. And did not ask for it. I just mean that a[0][:3] emits 
> different mapping data - TARGET_PAPARM|TO|FROM, PTR_AND_OBJ|TO|FROM

Oh I see.  I was think alloc for adding pointer.  But I now think I should just 
orignal maptype.  Changed thanks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145093/new/

https://reviews.llvm.org/D145093

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


  1   2   >