[PATCH] D103784: [X86] Support __tile_stream_loadd intrinsic for new AMX interface

2021-06-09 Thread Bing Yu via Phabricator via cfe-commits
yubing updated this revision to Diff 350797.
yubing added a comment.

Address yuanke's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103784

Files:
  clang/include/clang/Basic/BuiltinsX86_64.def
  clang/lib/Headers/amxintrin.h
  clang/test/CodeGen/X86/amx_api.c
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/lib/Target/X86/X86ExpandPseudo.cpp
  llvm/lib/Target/X86/X86FastTileConfig.cpp
  llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
  llvm/lib/Target/X86/X86InstrAMX.td
  llvm/lib/Target/X86/X86LowerAMXType.cpp
  llvm/lib/Target/X86/X86PreAMXConfig.cpp
  llvm/lib/Target/X86/X86RegisterInfo.cpp
  llvm/test/CodeGen/X86/AMX/amx-tile-basic.ll

Index: llvm/test/CodeGen/X86/AMX/amx-tile-basic.ll
===
--- llvm/test/CodeGen/X86/AMX/amx-tile-basic.ll
+++ llvm/test/CodeGen/X86/AMX/amx-tile-basic.ll
@@ -23,6 +23,7 @@
 ; CHECK-NEXT:tdpbusd %tmm2, %tmm1, %tmm0
 ; CHECK-NEXT:tdpbuud %tmm2, %tmm1, %tmm0
 ; CHECK-NEXT:tdpbf16ps %tmm2, %tmm1, %tmm0
+; CHECK-NEXT:tileloaddt1 (%rsi,%rdx), %tmm1
 ; CHECK-NEXT:tilestored %tmm0, (%rdi,%rdx)
 ; CHECK-NEXT:tilerelease
 ; CHECK-NEXT:vzeroupper
@@ -35,6 +36,7 @@
   %d2 = call x86_amx @llvm.x86.tdpbusd.internal(i16 8, i16 8, i16 8, x86_amx %d1, x86_amx %a, x86_amx %b)
   %d3 = call x86_amx @llvm.x86.tdpbuud.internal(i16 8, i16 8, i16 8, x86_amx %d2, x86_amx %a, x86_amx %b)
   %d4 = call x86_amx @llvm.x86.tdpbf16ps.internal(i16 8, i16 8, i16 8, x86_amx %d3, x86_amx %a, x86_amx %b)
+  %e = call x86_amx @llvm.x86.tileloaddt164.internal(i16 8, i16 8, i8* %base, i64 %stride)
   call void @llvm.x86.tilestored64.internal(i16 8, i16 8, i8* %pointer, i64 %stride, x86_amx %d4)
 
   ret void
@@ -42,6 +44,7 @@
 
 declare x86_amx @llvm.x86.tilezero.internal(i16, i16)
 declare x86_amx @llvm.x86.tileloadd64.internal(i16, i16, i8*, i64)
+declare x86_amx @llvm.x86.tileloaddt164.internal(i16, i16, i8*, i64)
 declare x86_amx @llvm.x86.tdpbssd.internal(i16, i16, i16, x86_amx, x86_amx, x86_amx)
 declare x86_amx @llvm.x86.tdpbsud.internal(i16, i16, i16, x86_amx, x86_amx, x86_amx)
 declare x86_amx @llvm.x86.tdpbusd.internal(i16, i16, i16, x86_amx, x86_amx, x86_amx)
Index: llvm/lib/Target/X86/X86RegisterInfo.cpp
===
--- llvm/lib/Target/X86/X86RegisterInfo.cpp
+++ llvm/lib/Target/X86/X86RegisterInfo.cpp
@@ -892,6 +892,7 @@
   }
   // We only collect the tile shape that is defined.
   case X86::PTILELOADDV:
+  case X86::PTILELOADDT1V:
   case X86::PTDPBSSDV:
   case X86::PTDPBSUDV:
   case X86::PTDPBUSDV:
Index: llvm/lib/Target/X86/X86PreAMXConfig.cpp
===
--- llvm/lib/Target/X86/X86PreAMXConfig.cpp
+++ llvm/lib/Target/X86/X86PreAMXConfig.cpp
@@ -65,7 +65,8 @@
 }
 
 static bool isTileLoad(IntrinsicInst *II) {
-  return II->getIntrinsicID() == Intrinsic::x86_tileloadd64_internal;
+  return II->getIntrinsicID() == Intrinsic::x86_tileloadd64_internal ||
+ II->getIntrinsicID() == Intrinsic::x86_tileloaddt164_internal;
 }
 
 static bool isTileStore(IntrinsicInst *II) {
Index: llvm/lib/Target/X86/X86LowerAMXType.cpp
===
--- llvm/lib/Target/X86/X86LowerAMXType.cpp
+++ llvm/lib/Target/X86/X86LowerAMXType.cpp
@@ -121,6 +121,7 @@
   default:
 llvm_unreachable("Expect amx intrinsics");
   case Intrinsic::x86_tileloadd64_internal:
+  case Intrinsic::x86_tileloaddt164_internal:
   case Intrinsic::x86_tilestored64_internal: {
 Row = II->getArgOperand(0);
 Col = II->getArgOperand(1);
Index: llvm/lib/Target/X86/X86InstrAMX.td
===
--- llvm/lib/Target/X86/X86InstrAMX.td
+++ llvm/lib/Target/X86/X86InstrAMX.td
@@ -53,6 +53,9 @@
 def PTILELOADDV : PseudoI<(outs TILE:$dst), (ins GR16:$src1,
  GR16:$src2,
  opaquemem:$src3), []>;
+def PTILELOADDT1V : PseudoI<(outs TILE:$dst), (ins GR16:$src1,
+   GR16:$src2,
+   opaquemem:$src3), []>;
 def PTILESTOREDV : PseudoI<(outs), (ins GR16:$src1,
 GR16:$src2, opaquemem:$src3,
 TILE:$src4), []>;
Index: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
===
--- llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -4617,10 +4617,13 @@
   ReplaceNode(Node, Res);
   return;
 }
-case Intrinsic::x86_tileloadd64_internal: {
+case Intrinsic::x86_tileloadd64_internal:
+case Intrinsic::x86_tileloaddt164_internal: {
   if (!Subtarget->hasAMX

[PATCH] D101868: [clang-format] Adds a formatter for aligning arrays of structs

2021-06-09 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:216-221
+struct test demo[] =
+{
+{56,23, "hello"},
+{-1, 93463, "world"},
+{ 7, 5,"!!"}
+};

Don't forget to re-generate .rst.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101868

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


[PATCH] D101868: [clang-format] Adds a formatter for aligning arrays of structs

2021-06-09 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/WhitespaceManager.h:233
 
+  /// Align Array Initializers over all \c Changes
+  void alignArrayInitializers();

Can ensure the comment starts with a capital and finishes with punctuation (I 
personally don't mind but I believe that is the convention)



Comment at: clang/lib/Format/WhitespaceManager.h:274
+
+  /// Get the maximum width of a cell in a sequence of columns
+  template 





Comment at: clang/lib/Format/WhitespaceManager.h:291
+
+  /// Get The maximum width of all columns to a given cell
+  template 





Comment at: clang/lib/Format/WhitespaceManager.h:310
+
+  /// align a split cell with a newline to the first element in the cell
+  void alignToStartOfCell(unsigned Start, unsigned End);





Comment at: clang/lib/Format/WhitespaceManager.h:313
+
+  /// Link the Cell pointers in the list of Cells
+  static CellDescriptions linkCells(CellDescriptions &&CellDesc);




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101868

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


[PATCH] D103784: [X86] Support __tile_stream_loadd intrinsic for new AMX interface

2021-06-09 Thread Bing Yu via Phabricator via cfe-commits
yubing updated this revision to Diff 350803.
yubing added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103784

Files:
  clang/include/clang/Basic/BuiltinsX86_64.def
  clang/lib/Headers/amxintrin.h
  clang/test/CodeGen/X86/amx_api.c
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/lib/Target/X86/X86ExpandPseudo.cpp
  llvm/lib/Target/X86/X86FastTileConfig.cpp
  llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
  llvm/lib/Target/X86/X86InstrAMX.td
  llvm/lib/Target/X86/X86LowerAMXType.cpp
  llvm/lib/Target/X86/X86PreAMXConfig.cpp
  llvm/lib/Target/X86/X86RegisterInfo.cpp
  llvm/test/CodeGen/X86/AMX/amx-tile-basic.ll

Index: llvm/test/CodeGen/X86/AMX/amx-tile-basic.ll
===
--- llvm/test/CodeGen/X86/AMX/amx-tile-basic.ll
+++ llvm/test/CodeGen/X86/AMX/amx-tile-basic.ll
@@ -23,6 +23,7 @@
 ; CHECK-NEXT:tdpbusd %tmm2, %tmm1, %tmm0
 ; CHECK-NEXT:tdpbuud %tmm2, %tmm1, %tmm0
 ; CHECK-NEXT:tdpbf16ps %tmm2, %tmm1, %tmm0
+; CHECK-NEXT:tileloaddt1 (%rsi,%rdx), %tmm1
 ; CHECK-NEXT:tilestored %tmm0, (%rdi,%rdx)
 ; CHECK-NEXT:tilerelease
 ; CHECK-NEXT:vzeroupper
@@ -35,6 +36,7 @@
   %d2 = call x86_amx @llvm.x86.tdpbusd.internal(i16 8, i16 8, i16 8, x86_amx %d1, x86_amx %a, x86_amx %b)
   %d3 = call x86_amx @llvm.x86.tdpbuud.internal(i16 8, i16 8, i16 8, x86_amx %d2, x86_amx %a, x86_amx %b)
   %d4 = call x86_amx @llvm.x86.tdpbf16ps.internal(i16 8, i16 8, i16 8, x86_amx %d3, x86_amx %a, x86_amx %b)
+  %e = call x86_amx @llvm.x86.tileloaddt164.internal(i16 8, i16 8, i8* %base, i64 %stride)
   call void @llvm.x86.tilestored64.internal(i16 8, i16 8, i8* %pointer, i64 %stride, x86_amx %d4)
 
   ret void
@@ -42,6 +44,7 @@
 
 declare x86_amx @llvm.x86.tilezero.internal(i16, i16)
 declare x86_amx @llvm.x86.tileloadd64.internal(i16, i16, i8*, i64)
+declare x86_amx @llvm.x86.tileloaddt164.internal(i16, i16, i8*, i64)
 declare x86_amx @llvm.x86.tdpbssd.internal(i16, i16, i16, x86_amx, x86_amx, x86_amx)
 declare x86_amx @llvm.x86.tdpbsud.internal(i16, i16, i16, x86_amx, x86_amx, x86_amx)
 declare x86_amx @llvm.x86.tdpbusd.internal(i16, i16, i16, x86_amx, x86_amx, x86_amx)
Index: llvm/lib/Target/X86/X86RegisterInfo.cpp
===
--- llvm/lib/Target/X86/X86RegisterInfo.cpp
+++ llvm/lib/Target/X86/X86RegisterInfo.cpp
@@ -892,6 +892,7 @@
   }
   // We only collect the tile shape that is defined.
   case X86::PTILELOADDV:
+  case X86::PTILELOADDT1V:
   case X86::PTDPBSSDV:
   case X86::PTDPBSUDV:
   case X86::PTDPBUSDV:
Index: llvm/lib/Target/X86/X86PreAMXConfig.cpp
===
--- llvm/lib/Target/X86/X86PreAMXConfig.cpp
+++ llvm/lib/Target/X86/X86PreAMXConfig.cpp
@@ -65,7 +65,8 @@
 }
 
 static bool isTileLoad(IntrinsicInst *II) {
-  return II->getIntrinsicID() == Intrinsic::x86_tileloadd64_internal;
+  return II->getIntrinsicID() == Intrinsic::x86_tileloadd64_internal ||
+ II->getIntrinsicID() == Intrinsic::x86_tileloaddt164_internal;
 }
 
 static bool isTileStore(IntrinsicInst *II) {
Index: llvm/lib/Target/X86/X86LowerAMXType.cpp
===
--- llvm/lib/Target/X86/X86LowerAMXType.cpp
+++ llvm/lib/Target/X86/X86LowerAMXType.cpp
@@ -121,6 +121,7 @@
   default:
 llvm_unreachable("Expect amx intrinsics");
   case Intrinsic::x86_tileloadd64_internal:
+  case Intrinsic::x86_tileloaddt164_internal:
   case Intrinsic::x86_tilestored64_internal: {
 Row = II->getArgOperand(0);
 Col = II->getArgOperand(1);
Index: llvm/lib/Target/X86/X86InstrAMX.td
===
--- llvm/lib/Target/X86/X86InstrAMX.td
+++ llvm/lib/Target/X86/X86InstrAMX.td
@@ -53,6 +53,9 @@
 def PTILELOADDV : PseudoI<(outs TILE:$dst), (ins GR16:$src1,
  GR16:$src2,
  opaquemem:$src3), []>;
+def PTILELOADDT1V : PseudoI<(outs TILE:$dst), (ins GR16:$src1,
+   GR16:$src2,
+   opaquemem:$src3), []>;
 def PTILESTOREDV : PseudoI<(outs), (ins GR16:$src1,
 GR16:$src2, opaquemem:$src3,
 TILE:$src4), []>;
Index: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
===
--- llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -4617,10 +4617,13 @@
   ReplaceNode(Node, Res);
   return;
 }
-case Intrinsic::x86_tileloadd64_internal: {
+case Intrinsic::x86_tileloadd64_internal:
+case Intrinsic::x86_tileloaddt164_internal: {
   if (!Subtarget->hasAMXTILE())
 br

[PATCH] D103426: Clang: Extend format string checking to wprintf/wscanf

2021-06-09 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 added a comment.

In D103426#2806391 , @aaron.ballman 
wrote:

> Do you have a reference to the WG14 paper proposing these conversion 
> specifiers?

I've previously written up the proposal, which you actually helped with (thank 
you for that), just submitted a request to Dan Plakosh to get a document number 
and submit it.

Maybe I was a bit optimistic, but I don't think l16 and l32 will be a hard 
sell, but maybe I'm naive haha


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103426

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


[PATCH] D103784: [X86] Support __tile_stream_loadd intrinsic for new AMX interface

2021-06-09 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke accepted this revision.
LuoYuanke added a comment.
This revision is now accepted and ready to land.

LGTM. Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103784

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


[PATCH] D53014: Add CMAKE_BUILD_TYPE to the list of BOOTSTRAP_DEFAULT_PASSTHROUGH variables

2021-06-09 Thread serge via Phabricator via cfe-commits
serge-sans-paille accepted this revision.
serge-sans-paille added a comment.
This revision is now accepted and ready to land.

LGTM, sorry for the late review.


Repository:
  rC Clang

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

https://reviews.llvm.org/D53014

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


[PATCH] D103949: Only consider built-in compound assignment operators for -Wunused-but-set-*

2021-06-09 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg created this revision.
sberg added a reviewer: mbenfield.
sberg added a project: clang.
sberg requested review of this revision.

At least LibreOffice has, for mainly historic reasons that would be hard to 
change now, a class `Any` with an overloaded `operator >>=` that semantically 
does not assign to the LHS but rather extracts into the (by-reference) RHS.  
Which thus caused false positive `-Wunused-but-set-parameter` and 
`-Wunused-but-set-variable` after those have been introduced recently.
This change is more conservative about the assumed semantics of overloaded 
operators, excluding compound assignment operators but keeping plain `operator 
=` ones.  At least for LibreOffice, that strikes a good balance of not 
producing false positives but still finding lots of true ones.


https://reviews.llvm.org/D103949

Files:
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/warn-unused-but-set-variables-cpp.cpp


Index: clang/test/SemaCXX/warn-unused-but-set-variables-cpp.cpp
===
--- clang/test/SemaCXX/warn-unused-but-set-variables-cpp.cpp
+++ clang/test/SemaCXX/warn-unused-but-set-variables-cpp.cpp
@@ -6,6 +6,7 @@
 
 struct __attribute__((warn_unused)) SWarnUnused {
   int j;
+  void operator +=(int);
 };
 
 int f0() {
@@ -48,3 +49,16 @@
   char a[x];
   char b[y];
 }
+
+void f3(int n) {
+  // Don't warn for overloaded compound assignment operators.
+  SWarnUnused swu;
+  swu += n;
+}
+
+template void f4(T n) {
+  // Don't warn for (potentially) overloaded compound assignment operators in
+  // template code.
+  SWarnUnused swu;
+  swu += n;
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -7791,11 +7791,16 @@
 Expr *E, llvm::DenseMap &RefsMinusAssignments) {
   DeclRefExpr *LHS = nullptr;
   if (BinaryOperator *BO = dyn_cast(E)) {
-if (!BO->isAssignmentOp())
+if (BO->getLHS()->getType()->isDependentType() ||
+BO->getRHS()->getType()->isDependentType())
+{
+  if (BO->getOpcode() != BO_Assign)
+return;
+} else if (!BO->isAssignmentOp())
   return;
 LHS = dyn_cast(BO->getLHS());
   } else if (CXXOperatorCallExpr *COCE = dyn_cast(E)) {
-if (!COCE->isAssignmentOp())
+if (COCE->getOperator() != OO_Equal)
   return;
 LHS = dyn_cast(COCE->getArg(0));
   }


Index: clang/test/SemaCXX/warn-unused-but-set-variables-cpp.cpp
===
--- clang/test/SemaCXX/warn-unused-but-set-variables-cpp.cpp
+++ clang/test/SemaCXX/warn-unused-but-set-variables-cpp.cpp
@@ -6,6 +6,7 @@
 
 struct __attribute__((warn_unused)) SWarnUnused {
   int j;
+  void operator +=(int);
 };
 
 int f0() {
@@ -48,3 +49,16 @@
   char a[x];
   char b[y];
 }
+
+void f3(int n) {
+  // Don't warn for overloaded compound assignment operators.
+  SWarnUnused swu;
+  swu += n;
+}
+
+template void f4(T n) {
+  // Don't warn for (potentially) overloaded compound assignment operators in
+  // template code.
+  SWarnUnused swu;
+  swu += n;
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -7791,11 +7791,16 @@
 Expr *E, llvm::DenseMap &RefsMinusAssignments) {
   DeclRefExpr *LHS = nullptr;
   if (BinaryOperator *BO = dyn_cast(E)) {
-if (!BO->isAssignmentOp())
+if (BO->getLHS()->getType()->isDependentType() ||
+BO->getRHS()->getType()->isDependentType())
+{
+  if (BO->getOpcode() != BO_Assign)
+return;
+} else if (!BO->isAssignmentOp())
   return;
 LHS = dyn_cast(BO->getLHS());
   } else if (CXXOperatorCallExpr *COCE = dyn_cast(E)) {
-if (!COCE->isAssignmentOp())
+if (COCE->getOperator() != OO_Equal)
   return;
 LHS = dyn_cast(COCE->getArg(0));
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103878: [clang][RISCV][test] Add more tests of the -mabi and -march options

2021-06-09 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 350828.

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

https://reviews.llvm.org/D103878

Files:
  clang/test/Driver/riscv-abi.c
  clang/test/Driver/riscv-arch.c

Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -39,6 +39,33 @@
 // RUN: %clang -target riscv32-unknown-elf -march=rv32gc -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
 
+// RUN: %clang -target riscv32-unknown-elf -mabi=ilp32 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-ILP32 %s
+
+// CHECK-ILP32: "-target-feature" "+m"
+// CHECK-ILP32-SAME: {{^}} "-target-feature" "+a"
+// CHECK-ILP32-SAME: {{^}} "-target-feature" "+f"
+// CHECK-ILP32-SAME: {{^}} "-target-feature" "+d"
+// CHECK-ILP32-SAME: {{^}} "-target-feature" "+c"
+
+// RUN: %clang -target riscv32-unknown-elf -mabi=ilp32f -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-ILP32F %s
+
+// CHECK-ILP32F: "-target-feature" "+m"
+// CHECK-ILP32F-SAME: {{^}} "-target-feature" "+a"
+// CHECK-ILP32F-SAME: {{^}} "-target-feature" "+f"
+// CHECK-ILP32F-SAME: {{^}} "-target-feature" "+d"
+// CHECK-ILP32F-SAME: {{^}} "-target-feature" "+c"
+
+// RUN: %clang -target riscv32-unknown-elf -mabi=ilp32d -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-ILP32D %s
+
+// CHECK-ILP32D: "-target-feature" "+m"
+// CHECK-ILP32D-SAME: {{^}} "-target-feature" "+a"
+// CHECK-ILP32D-SAME: {{^}} "-target-feature" "+f"
+// CHECK-ILP32D-SAME: {{^}} "-target-feature" "+d"
+// CHECK-ILP32D-SAME: {{^}} "-target-feature" "+c"
+
 // RUN: %clang -target riscv64-unknown-elf -march=rv64i -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang -target riscv64-unknown-elf -march=rv64im -### %s \
@@ -80,6 +107,33 @@
 // RUN: %clang -target riscv64-unknown-elf -march=rv64gc -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck %s
 
+// RUN: %clang -target riscv64-unknown-elf -mabi=lp64 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-LP64 %s
+
+// CHECK-LP64: "-target-feature" "+m"
+// CHECK-LP64-SAME: {{^}} "-target-feature" "+a"
+// CHECK-LP64-SAME: {{^}} "-target-feature" "+f"
+// CHECK-LP64-SAME: {{^}} "-target-feature" "+d"
+// CHECK-LP64-SAME: {{^}} "-target-feature" "+c"
+
+// RUN: %clang -target riscv64-unknown-elf -mabi=lp64f -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-LP64F %s
+
+// CHECK-LP64F: "-target-feature" "+m"
+// CHECK-LP64F-SAME: {{^}} "-target-feature" "+a"
+// CHECK-LP64F-SAME: {{^}} "-target-feature" "+f"
+// CHECK-LP64F-SAME: {{^}} "-target-feature" "+d"
+// CHECK-LP64F-SAME: {{^}} "-target-feature" "+c"
+
+// RUN: %clang -target riscv64-unknown-elf -mabi=lp64d -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-LP64D %s
+
+// CHECK-LP64D: "-target-feature" "+m"
+// CHECK-LP64D-SAME: {{^}} "-target-feature" "+a"
+// CHECK-LP64D-SAME: {{^}} "-target-feature" "+f"
+// CHECK-LP64D-SAME: {{^}} "-target-feature" "+d"
+// CHECK-LP64D-SAME: {{^}} "-target-feature" "+c"
+
 // CHECK-NOT: error: invalid arch name '
 
 // RUN: %clang -target riscv32-unknown-elf -march=rv32 -### %s \
Index: clang/test/Driver/riscv-abi.c
===
--- clang/test/Driver/riscv-abi.c
+++ clang/test/Driver/riscv-abi.c
@@ -2,6 +2,10 @@
 // RUN:   | FileCheck -check-prefix=CHECK-ILP32 %s
 // RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -mabi=ilp32 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ILP32 %s
+// RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -march=rv32imc 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ILP32 %s
+// RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -march=rv32imf 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ILP32 %s
 // RUN: %clang -target riscv32-unknown-elf -x assembler %s -### -o %t.o 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ILP32 %s
 // RUN: %clang -target riscv32-unknown-elf -x assembler %s -### -o %t.o \
@@ -9,6 +13,15 @@
 
 // CHECK-ILP32: "-target-abi" "ilp32"
 
+// RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -march=rv32e -mabi=ilp32e 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ILP32E %s
+// RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -mabi=ilp32e 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ILP32E %s
+// RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -march=rv32e 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ILP32E %s
+
+// CHECK-ILP32E: "-target-abi" "ilp32e"
+
 // RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -march=rv32if -mabi=ilp32f 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ILP32F %s
 
@@ -16,6 +29,10 @@
 
 // RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -march=rv32ifd -mabi=ilp32d 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ILP32D %s
+// RUN: %clang -target riscv32-unknown-elf %s -### -o %t.

[PATCH] D103949: Only consider built-in compound assignment operators for -Wunused-but-set-*

2021-06-09 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

gcc also ignores it?


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

https://reviews.llvm.org/D103949

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


[clang] d806d11 - Interp.h - AddSubMulHelper - avoid APSInt::toString std::string wrapper. NFCI

2021-06-09 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2021-06-09T11:09:31+01:00
New Revision: d806d11b14e1db7d5c5986d563e74ca972f0e5e6

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

LOG: Interp.h - AddSubMulHelper - avoid APSInt::toString std::string wrapper. 
NFCI

Pulled out of D103888 - use the underlying SmallString version directly

Added: 


Modified: 
clang/lib/AST/Interp/Interp.h

Removed: 




diff  --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h
index a63c5a871ba33..e2f7bf0dc26a4 100644
--- a/clang/lib/AST/Interp/Interp.h
+++ b/clang/lib/AST/Interp/Interp.h
@@ -118,7 +118,8 @@ bool AddSubMulHelper(InterpState &S, CodePtr OpPC, unsigned 
Bits, const T &LHS,
   const Expr *E = S.Current->getExpr(OpPC);
   QualType Type = E->getType();
   if (S.checkingForUndefinedBehavior()) {
-auto Trunc = Value.trunc(Result.bitWidth()).toString(10);
+SmallString<32> Trunc;
+Value.trunc(Result.bitWidth()).toString(Trunc, 10);
 auto Loc = E->getExprLoc();
 S.report(Loc, diag::warn_integer_constant_overflow) << Trunc << Type;
 return true;



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


[clang] f3fd36e - JSONNodeDumper.cpp - VisitIntegerLiteral - avoid APSInt::toString std::string wrapper. NFCI

2021-06-09 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2021-06-09T11:09:32+01:00
New Revision: f3fd36e590f4ca36e466801bee40497714df895c

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

LOG: JSONNodeDumper.cpp - VisitIntegerLiteral - avoid APSInt::toString 
std::string wrapper. NFCI

Pulled out of D103888 - use the underlying SmallString version directly

Added: 


Modified: 
clang/lib/AST/JSONNodeDumper.cpp

Removed: 




diff  --git a/clang/lib/AST/JSONNodeDumper.cpp 
b/clang/lib/AST/JSONNodeDumper.cpp
index d2835583a0f2..038aceea54ff 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -1414,9 +1414,10 @@ void JSONNodeDumper::VisitCXXDependentScopeMemberExpr(
 }
 
 void JSONNodeDumper::VisitIntegerLiteral(const IntegerLiteral *IL) {
-  JOS.attribute("value",
-IL->getValue().toString(
-/*Radix=*/10, IL->getType()->isSignedIntegerType()));
+  llvm::SmallString<16> Buffer;
+  IL->getValue().toString(Buffer,
+  /*Radix=*/10, IL->getType()->isSignedIntegerType());
+  JOS.attribute("value", Buffer);
 }
 void JSONNodeDumper::VisitCharacterLiteral(const CharacterLiteral *CL) {
   // FIXME: This should probably print the character literal as a string,



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


[PATCH] D103949: Only consider built-in compound assignment operators for -Wunused-but-set-*

2021-06-09 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg added a comment.

In D103949#2807490 , @xbolva00 wrote:

> gcc also ignores it?

For reasons that I never looked into, GCC never warned for any of these cases.  
The Clang implementation appears to be way more aggressive (in a positive 
sense) to begin with.


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

https://reviews.llvm.org/D103949

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


[PATCH] D103720: [clang] NFC: Rename rvalue to prvalue

2021-06-09 Thread Matheus Izvekov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaef5d8fdc7d0: [clang] NFC: Rename rvalue to prvalue 
(authored by mizvekov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103720

Files:
  clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/ExprObjC.h
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Sema/Initialization.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/ExprConcepts.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ExprObjC.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/Analysis/ThreadSafety.cpp
  clang/lib/CodeGen/CGBlocks.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Frontend/Rewrite/RewriteObjC.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaExprMember.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaFixItUtils.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaPseudoObject.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaStmtAsm.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/test/AST/ast-dump-decl-json.c
  clang/test/AST/ast-dump-decl-json.m
  clang/test/AST/ast-dump-expr-json.c
  clang/test/AST/ast-dump-expr-json.cpp
  clang/test/AST/ast-dump-expr-json.m
  clang/test/AST/ast-dump-funcs-json.cpp
  clang/test/AST/ast-dump-if-json.cpp
  clang/test/AST/ast-dump-objc-arc-json.m
  clang/test/AST/ast-dump-record-definition-data-json.cpp
  clang/test/AST/ast-dump-records-json.cpp
  clang/test/AST/ast-dump-stmt-json.c
  clang/test/AST/ast-dump-stmt-json.cpp
  clang/test/AST/ast-dump-stmt-json.m
  clang/test/AST/ast-dump-template-decls-json.cpp
  clang/test/AST/ast-dump-temporaries-json.cpp
  clang/test/AST/ast-dump-types-errors-json.cpp
  clang/test/AST/multistep-explicit-cast-json.c
  clang/test/AST/multistep-explicit-cast-json.cpp

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


[clang] c25572b - [clang] NFC: rename SK_CastDerivedToBaseRValue to SK_CastDerivedToBasePRValue

2021-06-09 Thread Matheus Izvekov via cfe-commits

Author: Matheus Izvekov
Date: 2021-06-09T12:38:59+02:00
New Revision: c25572bf2993438f24b57d859d072e8b2aa975d2

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

LOG: [clang] NFC: rename SK_CastDerivedToBaseRValue to 
SK_CastDerivedToBasePRValue

This is a follow up to the "rvalue-to-prvalue" rename at D103720.

Signed-off-by: Matheus Izvekov 

Depends on D103720

Reviewed By: rsmith

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

Added: 


Modified: 
clang/include/clang/Sema/Initialization.h
clang/lib/Sema/SemaInit.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Initialization.h 
b/clang/include/clang/Sema/Initialization.h
index 9889d5bcced5..8feb66995f95 100644
--- a/clang/include/clang/Sema/Initialization.h
+++ b/clang/include/clang/Sema/Initialization.h
@@ -804,7 +804,7 @@ class InitializationSequence {
 SK_ResolveAddressOfOverloadedFunction,
 
 /// Perform a derived-to-base cast, producing an rvalue.
-SK_CastDerivedToBaseRValue,
+SK_CastDerivedToBasePRValue,
 
 /// Perform a derived-to-base cast, producing an xvalue.
 SK_CastDerivedToBaseXValue,

diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 430b14853d38..26d681b1340d 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -3457,7 +3457,7 @@ LLVM_DUMP_METHOD void InitializedEntity::dump() const {
 void InitializationSequence::Step::Destroy() {
   switch (Kind) {
   case SK_ResolveAddressOfOverloadedFunction:
-  case SK_CastDerivedToBaseRValue:
+  case SK_CastDerivedToBasePRValue:
   case SK_CastDerivedToBaseXValue:
   case SK_CastDerivedToBaseLValue:
   case SK_BindReference:
@@ -3585,7 +3585,7 @@ void 
InitializationSequence::AddDerivedToBaseCastStep(QualType BaseType,
   Step S;
   switch (VK) {
   case VK_PRValue:
-S.Kind = SK_CastDerivedToBaseRValue;
+S.Kind = SK_CastDerivedToBasePRValue;
 break;
   case VK_XValue: S.Kind = SK_CastDerivedToBaseXValue; break;
   case VK_LValue: S.Kind = SK_CastDerivedToBaseLValue; break;
@@ -8106,7 +8106,7 @@ ExprResult InitializationSequence::Perform(Sema &S,
   // initializer.
   switch (Steps.front().Kind) {
   case SK_ResolveAddressOfOverloadedFunction:
-  case SK_CastDerivedToBaseRValue:
+  case SK_CastDerivedToBasePRValue:
   case SK_CastDerivedToBaseXValue:
   case SK_CastDerivedToBaseLValue:
   case SK_BindReference:
@@ -8191,7 +8191,7 @@ ExprResult InitializationSequence::Perform(Sema &S,
  Step->Function.Function);
   break;
 
-case SK_CastDerivedToBaseRValue:
+case SK_CastDerivedToBasePRValue:
 case SK_CastDerivedToBaseXValue:
 case SK_CastDerivedToBaseLValue: {
   // We have a derived-to-base cast that produces either an rvalue or an
@@ -9617,8 +9617,8 @@ void InitializationSequence::dump(raw_ostream &OS) const {
   OS << "resolve address of overloaded function";
   break;
 
-case SK_CastDerivedToBaseRValue:
-  OS << "derived-to-base (rvalue)";
+case SK_CastDerivedToBasePRValue:
+  OS << "derived-to-base (prvalue)";
   break;
 
 case SK_CastDerivedToBaseXValue:



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


[PATCH] D103933: [clang] NFC: rename SK_CastDerivedToBaseRValue to SK_CastDerivedToBasePRValue

2021-06-09 Thread Matheus Izvekov 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 rGc25572bf2993: [clang] NFC: rename SK_CastDerivedToBaseRValue 
to SK_CastDerivedToBasePRValue (authored by mizvekov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103933

Files:
  clang/include/clang/Sema/Initialization.h
  clang/lib/Sema/SemaInit.cpp


Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -3457,7 +3457,7 @@
 void InitializationSequence::Step::Destroy() {
   switch (Kind) {
   case SK_ResolveAddressOfOverloadedFunction:
-  case SK_CastDerivedToBaseRValue:
+  case SK_CastDerivedToBasePRValue:
   case SK_CastDerivedToBaseXValue:
   case SK_CastDerivedToBaseLValue:
   case SK_BindReference:
@@ -3585,7 +3585,7 @@
   Step S;
   switch (VK) {
   case VK_PRValue:
-S.Kind = SK_CastDerivedToBaseRValue;
+S.Kind = SK_CastDerivedToBasePRValue;
 break;
   case VK_XValue: S.Kind = SK_CastDerivedToBaseXValue; break;
   case VK_LValue: S.Kind = SK_CastDerivedToBaseLValue; break;
@@ -8106,7 +8106,7 @@
   // initializer.
   switch (Steps.front().Kind) {
   case SK_ResolveAddressOfOverloadedFunction:
-  case SK_CastDerivedToBaseRValue:
+  case SK_CastDerivedToBasePRValue:
   case SK_CastDerivedToBaseXValue:
   case SK_CastDerivedToBaseLValue:
   case SK_BindReference:
@@ -8191,7 +8191,7 @@
  Step->Function.Function);
   break;
 
-case SK_CastDerivedToBaseRValue:
+case SK_CastDerivedToBasePRValue:
 case SK_CastDerivedToBaseXValue:
 case SK_CastDerivedToBaseLValue: {
   // We have a derived-to-base cast that produces either an rvalue or an
@@ -9617,8 +9617,8 @@
   OS << "resolve address of overloaded function";
   break;
 
-case SK_CastDerivedToBaseRValue:
-  OS << "derived-to-base (rvalue)";
+case SK_CastDerivedToBasePRValue:
+  OS << "derived-to-base (prvalue)";
   break;
 
 case SK_CastDerivedToBaseXValue:
Index: clang/include/clang/Sema/Initialization.h
===
--- clang/include/clang/Sema/Initialization.h
+++ clang/include/clang/Sema/Initialization.h
@@ -804,7 +804,7 @@
 SK_ResolveAddressOfOverloadedFunction,
 
 /// Perform a derived-to-base cast, producing an rvalue.
-SK_CastDerivedToBaseRValue,
+SK_CastDerivedToBasePRValue,
 
 /// Perform a derived-to-base cast, producing an xvalue.
 SK_CastDerivedToBaseXValue,


Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -3457,7 +3457,7 @@
 void InitializationSequence::Step::Destroy() {
   switch (Kind) {
   case SK_ResolveAddressOfOverloadedFunction:
-  case SK_CastDerivedToBaseRValue:
+  case SK_CastDerivedToBasePRValue:
   case SK_CastDerivedToBaseXValue:
   case SK_CastDerivedToBaseLValue:
   case SK_BindReference:
@@ -3585,7 +3585,7 @@
   Step S;
   switch (VK) {
   case VK_PRValue:
-S.Kind = SK_CastDerivedToBaseRValue;
+S.Kind = SK_CastDerivedToBasePRValue;
 break;
   case VK_XValue: S.Kind = SK_CastDerivedToBaseXValue; break;
   case VK_LValue: S.Kind = SK_CastDerivedToBaseLValue; break;
@@ -8106,7 +8106,7 @@
   // initializer.
   switch (Steps.front().Kind) {
   case SK_ResolveAddressOfOverloadedFunction:
-  case SK_CastDerivedToBaseRValue:
+  case SK_CastDerivedToBasePRValue:
   case SK_CastDerivedToBaseXValue:
   case SK_CastDerivedToBaseLValue:
   case SK_BindReference:
@@ -8191,7 +8191,7 @@
  Step->Function.Function);
   break;
 
-case SK_CastDerivedToBaseRValue:
+case SK_CastDerivedToBasePRValue:
 case SK_CastDerivedToBaseXValue:
 case SK_CastDerivedToBaseLValue: {
   // We have a derived-to-base cast that produces either an rvalue or an
@@ -9617,8 +9617,8 @@
   OS << "resolve address of overloaded function";
   break;
 
-case SK_CastDerivedToBaseRValue:
-  OS << "derived-to-base (rvalue)";
+case SK_CastDerivedToBasePRValue:
+  OS << "derived-to-base (prvalue)";
   break;
 
 case SK_CastDerivedToBaseXValue:
Index: clang/include/clang/Sema/Initialization.h
===
--- clang/include/clang/Sema/Initialization.h
+++ clang/include/clang/Sema/Initialization.h
@@ -804,7 +804,7 @@
 SK_ResolveAddressOfOverloadedFunction,
 
 /// Perform a derived-to-base cast, producing an rvalue.
-SK_CastDerivedToBaseRValue,
+SK_CastDerivedToBasePRValue,
 
 /// Perform a derived-to-base cast, producing an xvalue.
 SK_CastDerivedToBaseXValue,
___
cfe-commits mailing list
cfe-co

[PATCH] D103663: [AMDGPU] Add gfx1013 target

2021-06-09 Thread Jay Foad via Phabricator via cfe-commits
foad added inline comments.



Comment at: llvm/lib/Target/AMDGPU/AMDGPU.td:471
+  "true",
+  "Encoding format GFX10_A"
+>;

bcahoon wrote:
> foad wrote:
> > I realise you're just following the precedent set by GFX10_B, but is this 
> > terminology actually used in any documentation anywhere? And if not could 
> > we describe it a little better here?
> I changed the description to be specific w.r.t what the target feature 
> enables.
Thank you. I think that is much more useful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103663

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


[PATCH] D97869: [OpenCL] Add OpenCL builtin test generator

2021-06-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


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

https://reviews.llvm.org/D97869

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


[PATCH] D103953: Sanitizers.h - remove MathExtras.h include dependency

2021-06-09 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon created this revision.
RKSimon added reviewers: pgousseau, filcab, bkramer.
Herald added a subscriber: dexonsmith.
RKSimon requested review of this revision.
Herald added a project: clang.

We include the MathExtras.h header purely for the countPopulation() method - by 
moving this into Sanitizers.cpp we can remove the use of this costly header.

AFAICT we only ever use isPowerOf2() / countPopulation() insider asserts (see 
the CGExpr.cpp change which I noticed by altering their access to private) so 
this shouldn't have any performance effects on production code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103953

Files:
  clang/include/clang/Basic/Sanitizers.h
  clang/lib/Basic/Sanitizers.cpp
  clang/lib/CodeGen/CGExpr.cpp


Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3126,7 +3126,7 @@
 }
 
 static CheckRecoverableKind getRecoverableKind(SanitizerMask Kind) {
-  assert(Kind.countPopulation() == 1);
+  assert(Kind.isPowerOf2());
   if (Kind == SanitizerKind::Function || Kind == SanitizerKind::Vptr)
 return CheckRecoverableKind::AlwaysRecoverable;
   else if (Kind == SanitizerKind::Return || Kind == SanitizerKind::Unreachable)
Index: clang/lib/Basic/Sanitizers.cpp
===
--- clang/lib/Basic/Sanitizers.cpp
+++ clang/lib/Basic/Sanitizers.cpp
@@ -14,6 +14,7 @@
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/MathExtras.h"
 
 using namespace clang;
 
@@ -57,6 +58,13 @@
 }
 
 namespace clang {
+unsigned SanitizerMask::countPopulation() const {
+  unsigned total = 0;
+  for (const auto &Val : maskLoToHigh)
+total += llvm::countPopulation(Val);
+  return total;
+}
+
 llvm::hash_code hash_value(const clang::SanitizerMask &Arg) {
   return Arg.hash_value();
 }
Index: clang/include/clang/Basic/Sanitizers.h
===
--- clang/include/clang/Basic/Sanitizers.h
+++ clang/include/clang/Basic/Sanitizers.h
@@ -16,7 +16,6 @@
 
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Support/MathExtras.h"
 #include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
 #include 
 #include 
@@ -60,12 +59,7 @@
 return SanitizerMask(mask1, mask2);
   }
 
-  unsigned countPopulation() const {
-unsigned total = 0;
-for (const auto &Val : maskLoToHigh)
-  total += llvm::countPopulation(Val);
-return total;
-  }
+  unsigned countPopulation() const;
 
   void flipAllBits() {
 for (auto &Val : maskLoToHigh)


Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3126,7 +3126,7 @@
 }
 
 static CheckRecoverableKind getRecoverableKind(SanitizerMask Kind) {
-  assert(Kind.countPopulation() == 1);
+  assert(Kind.isPowerOf2());
   if (Kind == SanitizerKind::Function || Kind == SanitizerKind::Vptr)
 return CheckRecoverableKind::AlwaysRecoverable;
   else if (Kind == SanitizerKind::Return || Kind == SanitizerKind::Unreachable)
Index: clang/lib/Basic/Sanitizers.cpp
===
--- clang/lib/Basic/Sanitizers.cpp
+++ clang/lib/Basic/Sanitizers.cpp
@@ -14,6 +14,7 @@
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/MathExtras.h"
 
 using namespace clang;
 
@@ -57,6 +58,13 @@
 }
 
 namespace clang {
+unsigned SanitizerMask::countPopulation() const {
+  unsigned total = 0;
+  for (const auto &Val : maskLoToHigh)
+total += llvm::countPopulation(Val);
+  return total;
+}
+
 llvm::hash_code hash_value(const clang::SanitizerMask &Arg) {
   return Arg.hash_value();
 }
Index: clang/include/clang/Basic/Sanitizers.h
===
--- clang/include/clang/Basic/Sanitizers.h
+++ clang/include/clang/Basic/Sanitizers.h
@@ -16,7 +16,6 @@
 
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Support/MathExtras.h"
 #include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
 #include 
 #include 
@@ -60,12 +59,7 @@
 return SanitizerMask(mask1, mask2);
   }
 
-  unsigned countPopulation() const {
-unsigned total = 0;
-for (const auto &Val : maskLoToHigh)
-  total += llvm::countPopulation(Val);
-return total;
-  }
+  unsigned countPopulation() const;
 
   void flipAllBits() {
 for (auto &Val : maskLoToHigh)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103953: Sanitizers.h - remove MathExtras.h include dependency

2021-06-09 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/lib/CodeGen/CGExpr.cpp:3129
 static CheckRecoverableKind getRecoverableKind(SanitizerMask Kind) {
-  assert(Kind.countPopulation() == 1);
+  assert(Kind.isPowerOf2());
   if (Kind == SanitizerKind::Function || Kind == SanitizerKind::Vptr)

I'm happy to revert this line, its purely to demonstrate that the methods are 
just used in asserts.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103953

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


[PATCH] D97869: [OpenCL] Add OpenCL builtin test generator

2021-06-09 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

@svenvh, are you going to add header-like output emitting?


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

https://reviews.llvm.org/D97869

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


[PATCH] D103953: Sanitizers.h - remove MathExtras.h include dependency

2021-06-09 Thread pierre gousseau via Phabricator via cfe-commits
pgousseau accepted this revision.
pgousseau 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/D103953/new/

https://reviews.llvm.org/D103953

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


[clang] c92f505 - Correct the behavior of va_arg checking in C++

2021-06-09 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-06-09T07:18:32-04:00
New Revision: c92f505346b80fd053ef191bbc66810c9d564b0c

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

LOG: Correct the behavior of va_arg checking in C++

Clang checks whether the type given to va_arg will automatically cause
undefined behavior, but this check was issuing false positives for
enumerations in C++. The issue turned out to be because
typesAreCompatible() in C++ checks whether the types are *the same*, so
this uses custom logic if the type compatibility check fails.

This issue was found by a user on code like:

typedef enum {
  CURLINFO_NONE,
  CURLINFO_EFFECTIVE_URL,
  CURLINFO_LASTONE = 60
} CURLINFO;

...

__builtin_va_arg(list, CURLINFO); // false positive warning

Given that C++ defers to C for the rules around va_arg, the behavior
should be the same in both C and C++ and not diagnose because int and
CURLINFO are "compatible enough" types for va_arg.

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/varargs.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 675041de640c..0431c43a5829 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -15752,8 +15752,46 @@ ExprResult Sema::BuildVAArgExpr(SourceLocation 
BuiltinLoc,
 QualType PromoteType;
 if (TInfo->getType()->isPromotableIntegerType()) {
   PromoteType = Context.getPromotedIntegerType(TInfo->getType());
-  if (Context.typesAreCompatible(PromoteType, TInfo->getType()))
+  // [cstdarg.syn]p1 defers the C++ behavior to what the C standard says,
+  // and C2x 7.16.1.1p2 says, in part:
+  //   If type is not compatible with the type of the actual next argument
+  //   (as promoted according to the default argument promotions), the
+  //   behavior is undefined, except for the following cases:
+  // - both types are pointers to qualified or unqualified versions of
+  //   compatible types;
+  // - one type is a signed integer type, the other type is the
+  //   corresponding unsigned integer type, and the value is
+  //   representable in both types;
+  // - one type is pointer to qualified or unqualified void and the
+  //   other is a pointer to a qualified or unqualified character type.
+  // Given that type compatibility is the primary requirement (ignoring
+  // qualifications), you would think we could call typesAreCompatible()
+  // directly to test this. However, in C++, that checks for *same type*,
+  // which causes false positives when passing an enumeration type to
+  // va_arg. Instead, get the underlying type of the enumeration and pass
+  // that.
+  QualType UnderlyingType = TInfo->getType();
+  if (const auto *ET = UnderlyingType->getAs())
+UnderlyingType = ET->getDecl()->getIntegerType();
+  if (Context.typesAreCompatible(PromoteType, UnderlyingType,
+ /*CompareUnqualified*/ true))
 PromoteType = QualType();
+
+  // If the types are still not compatible, we need to test whether the
+  // promoted type and the underlying type are the same except for
+  // signedness. Ask the AST for the correctly corresponding type and see
+  // if that's compatible.
+  if (!PromoteType.isNull() &&
+  PromoteType->isUnsignedIntegerType() !=
+  UnderlyingType->isUnsignedIntegerType()) {
+UnderlyingType =
+UnderlyingType->isUnsignedIntegerType()
+? Context.getCorrespondingSignedType(UnderlyingType)
+: Context.getCorrespondingUnsignedType(UnderlyingType);
+if (Context.typesAreCompatible(PromoteType, UnderlyingType,
+   /*CompareUnqualified*/ true))
+  PromoteType = QualType();
+  }
 }
 if (TInfo->getType()->isSpecificBuiltinType(BuiltinType::Float))
   PromoteType = Context.DoubleTy;

diff  --git a/clang/test/SemaCXX/varargs.cpp b/clang/test/SemaCXX/varargs.cpp
index 625f1dce18f3..7bec2f1e6303 100644
--- a/clang/test/SemaCXX/varargs.cpp
+++ b/clang/test/SemaCXX/varargs.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -std=c++03 -verify %s
-// RUN: %clang_cc1 -std=c++11 -verify %s
+// RUN: %clang_cc1 -std=c++03 -Wno-c++11-extensions -triple i386-pc-unknown 
-verify %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin9 -verify %s
 
 __builtin_va_list ap;
 
@@ -28,6 +28,33 @@ void record_context(int a, ...) {
   };
 }
 
+// Ensure the correct behavior for promotable type UB checking.
+void promotable(int a, ...) {
+  enum Unscoped1 { One = 0x7FFF };
+  (void)__builtin_va_arg(ap, Unscoped1); // ok
+
+  enum Unscoped2 { Two = 0x

[PATCH] D103611: Correct the behavior of va_arg checking in C++

2021-06-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thank you for the reviews, @efriedma! I have committed in 
c92f505346b80fd053ef191bbc66810c9d564b0c 



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

https://reviews.llvm.org/D103611

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


[PATCH] D103949: Only consider built-in compound assignment operators for -Wunused-but-set-*

2021-06-09 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Ok thanks for info. We should follow gcc in this case.


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

https://reviews.llvm.org/D103949

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


[PATCH] D97869: [OpenCL] Add OpenCL builtin test generator

2021-06-09 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added a comment.

In D97869#2807627 , @azabaznov wrote:

> @svenvh, are you going to add header-like output emitting?

Yes, I can add that if there is interest.  I already have it on a local branch, 
so if there is interest (and it seems there is? :-)), then I will rebase that, 
tidy it up, and create a separate review.


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

https://reviews.llvm.org/D97869

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


[PATCH] D97869: [OpenCL] Add OpenCL builtin test generator

2021-06-09 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

In D97869#2807654 , @svenvh wrote:

> In D97869#2807627 , @azabaznov wrote:
>
>> @svenvh, are you going to add header-like output emitting?
>
> Yes, I can add that if there is interest.  I already have it on a local 
> branch, so if there is interest (and it seems there is? :-)), then I will 
> rebase that, tidy it up, and create a separate review.

Sounds great :) Thanks! Yeah, it may be needed as alternative testing of 
changes of opencl-h and testing OpenCL TableGen header as well.


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

https://reviews.llvm.org/D97869

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


[PATCH] D102689: [C++] Ignore top-level qualifiers in casts

2021-06-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/test/SemaCXX/warn-reinterpret-base-class.cpp:301
 
-  // expected-warning@+2 {{'reinterpret_cast' to class 'L' (aka 'const F 
*volatile') from its base at non-zero offset 'E *' behaves differently from 
'static_cast'}}
+  // expected-warning@+2 {{'reinterpret_cast' to class 'K' (aka 'const F *') 
from its base at non-zero offset 'E *' behaves differently from 'static_cast'}}
   // expected-note@+1 {{use 'static_cast' to adjust the pointer correctly 
while downcasting}}

I wonder if there is a way to track the original type for the diagnostic? Or 
maybe it is intuitive enough considering the quoted spec wording...


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

https://reviews.llvm.org/D102689

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


[PATCH] D102850: [C++4OpenCL] Fix overloading resolution of addrspace constructors

2021-06-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/Sema/SemaOverload.cpp:9870
 
+  if (S.getLangOpts().OpenCL) {
+if (const auto *CD1 = 
dyn_cast_or_null(Cand1.Function)) {

Anastasia wrote:
> olestrohm wrote:
> > Anastasia wrote:
> > > olestrohm wrote:
> > > > Anastasia wrote:
> > > > > olestrohm wrote:
> > > > > > Anastasia wrote:
> > > > > > > I think we should remove the OpenCL check since it is not OpenCL 
> > > > > > > specific rule and you are using common helpers indeed!
> > > > > > > 
> > > > > > > I also wonder if this should be applied to all member functions 
> > > > > > > not only ctors since `isBetterOverloadCandidate` should be used 
> > > > > > > for everything?
> > > > > > > 
> > > > > > > However it seems that other members are already handled somehow 
> > > > > > > https://godbolt.org/z/MrWKPKed7. Do you know where this handling 
> > > > > > > comes from?
> > > > > > It's handled in SemaOverload.cpp:1 in 
> > > > > > `OverloadCandidateSet::BestViableFunction` which checks if the 
> > > > > > given function is viable or not. For member functions the address 
> > > > > > space they're defined in and the address space of the variable have 
> > > > > > to match. Therefore only one of them is valid at a time and they 
> > > > > > never get checked against each other in `isBetterOverloadCandidate`.
> > > > > I am quite sure that for the example above both `__private` and 
> > > > > `__generic `overloads are viable. In fact, if you remove the 
> > > > > `__private` overload the `__generic` one gets picked.
> > > > > 
> > > > > So I think the logic should be checking for compatibility rather than 
> > > > > the exact match i.e. using `isAddressSpaceSupersetOf` although it 
> > > > > might not be calling that helper directly but through the other 
> > > > > Qualifier logic.
> > > > Ah, I think I checked it wrong last time. Going through it again it's 
> > > > actually determined by `QualType::isMoreQualifiedThan` in the end. I'll 
> > > > look into it more.
> > > So did you happen to find where the address space ranking for the members 
> > > is currently happening for this test case https://godbolt.org/z/MrWKPKed7?
> > > 
> > > I just want to make sure we don't add any redundant checks... so if let's 
> > > say we already have a similar logic elsewhere it would be better if we 
> > > attempt to generalize it or move it entirely here if it's doable. In 
> > > general, we should try to use general qualifier logic if it works instead 
> > > of specializing for address spaces.
> > It's handled on line 9661 with a call to 
> > CompareImplicitConversionSequences, which then goes through a couple of 
> > checks and discovers that the return type of one of the functions is more 
> > specialized than the other. However this uses the Conversions part of the 
> > candidates, which the constructors don't have.
> > 
> > I did attempt to generalize this further than address spaces, but that 
> > caused some tests to fail, so I think it makes sense to only check address 
> > spaces here.
> Ah I see. Is it because the object parameter is not added implicitly in the 
> ctors?
> 
> If this is only working for ctors I wonder if we should cast to 
> `CXXConstructorDecl` instead of `CXXMethodDecl` or/and also add a comment 
> explaining that?
ok, let's also add a comment explaining that ctors are handled separately from 
the other members because they don't have an object parameter created 
explicitly (if that is the reason).


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

https://reviews.llvm.org/D102850

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


[PATCH] D102689: [C++] Ignore top-level qualifiers in casts

2021-06-09 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm added inline comments.



Comment at: clang/test/SemaCXX/warn-reinterpret-base-class.cpp:301
 
-  // expected-warning@+2 {{'reinterpret_cast' to class 'L' (aka 'const F 
*volatile') from its base at non-zero offset 'E *' behaves differently from 
'static_cast'}}
+  // expected-warning@+2 {{'reinterpret_cast' to class 'K' (aka 'const F *') 
from its base at non-zero offset 'E *' behaves differently from 'static_cast'}}
   // expected-note@+1 {{use 'static_cast' to adjust the pointer correctly 
while downcasting}}

Anastasia wrote:
> I wonder if there is a way to track the original type for the diagnostic? Or 
> maybe it is intuitive enough considering the quoted spec wording...
This actually already happens with the source type too.
const short s = 0;
reinterpret_cast(s);

gives the error "reinterpret_cast from 'short' to 'int' is not allowed", so 
while this is definitely worse, it's a general problem with reinterpret_cast.


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

https://reviews.llvm.org/D102689

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


[PATCH] D103911: [OpenCL] Add support of __opencl_c_images feature macro

2021-06-09 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added inline comments.



Comment at: clang/test/SemaOpenCL/unsupported-image.cl:1
+// RUN: %clang_cc1 -verify -cl-std=CL3.0 -cl-ext=-__opencl_c_images %s
+// RUN: %clang_cc1 -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images %s

Should we add `-triple spir`, as some of the image types (e.g. msaa) are part 
of an extension that may not be available for every default triple?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103911

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


[PATCH] D103401: [OpenCL] Add support of __opencl_c_generic_address_space feature macro

2021-06-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/Basic/TargetInfo.cpp:405
+  const auto &OpenCLFeaturesMap = getSupportedOpenCLOpts();
+  Opts.OpenCLGenericAddressSpace = hasFeatureEnabled(
+  OpenCLFeaturesMap, "__opencl_c_generic_address_space");

azabaznov wrote:
> Anastasia wrote:
> > azabaznov wrote:
> > > Anastasia wrote:
> > > > svenvh wrote:
> > > > > This means we now have two separate places that set 
> > > > > `OpenCLGenericAddressSpace`, the other place being in 
> > > > > `CompilerInvocation::setLangDefaults()`.  That feels like a 
> > > > > maintenance hazard.  Do you think it makes sense to set this field in 
> > > > > one single place instead?
> > > > I think we should try to set it in `CompilerInvocation.cpp` directly, 
> > > > we should be able to query `TargetOptions` there. Although that place 
> > > > is expected to be for the language-specific defaults but we broke the 
> > > > standard flow by having the language mode controlled by the target 
> > > > settings anyway.
> > > > 
> > > > I can't remember though why we have decided to add dedicated `LangOpts` 
> > > > entries for generic address space instead of just using `OpenCLOptions` 
> > > > from `Sema`? I think it simplifies the handling of some builtin 
> > > > functions?
> > > > This means we now have two separate places that set 
> > > > OpenCLGenericAddressSpace, the other place being in 
> > > > CompilerInvocation::setLangDefaults(). That feels like a maintenance 
> > > > hazard. Do you think it makes sense to set this field in one single 
> > > > place instead?
> > > 
> > > >I think we should try to set it in CompilerInvocation.cpp directly, we 
> > > >should be able to query TargetOptions there. 
> > > 
> > > I don't think that we are able to access target options at that stage 
> > > without modifying current interfaces.  
> > > `CompilerInvocation::setLangDefaults()` is a static member function.
> > > 
> > > > I can't remember though why we have decided to add dedicated LangOpts 
> > > > entries for generic address space instead of just using OpenCLOptions 
> > > > from Sema? I think it simplifies the handling of some builtin functions?
> > > 
> > > That's correct. Also, the idea was to reuse generic keyword in other 
> > > languages.
> > > I don't think that we are able to access target options at that stage 
> > > without modifying current interfaces. 
> > > CompilerInvocation::setLangDefaults() is a static member function.
> > 
> > I wonder if the function is static due to an old interface or something 
> > because it seems to be only called from `CompilerInvocation::ParseLangArgs` 
> > which isn't a static member as far as I can see. I wonder if it should just 
> > become a non-static member instead?
> > 
> Actually `CompilerInvocation::ParseLangArgs` is static as well. Anyway, I 
> think this change would be really impactful. I believe `::adjust` is a 
> prefect place to coordinate language options with target information (at 
> least for now).
Apart from that `::adjust` was just introduced as a hack to mitigate the fact 
that the original clang flow was designed to set the types differently and now 
we are extending the hack to cover more areas.

Technically to adhere to clang flow we should probably set those options as 
target options but when we prototyped that it was too hard to condition the 
clang builtins on such options or something?

This way or another there seems to be more refactoring needed to preserve the 
flow fully. I think this at least deserves a `FIXME` comment to explain why we 
are ending up with the design that requires overriding the `LangOpts` here and 
also highlighting the fact that we have two places where it is set.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103401

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


[PATCH] D103911: [OpenCL] Add support of __opencl_c_images feature macro

2021-06-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/test/SemaOpenCL/unsupported-image.cl:1
+// RUN: %clang_cc1 -verify -cl-std=CL3.0 -cl-ext=-__opencl_c_images %s
+// RUN: %clang_cc1 -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images %s

svenvh wrote:
> Should we add `-triple spir`, as some of the image types (e.g. msaa) are part 
> of an extension that may not be available for every default triple?
yes, the test might fail in some bots otherwise...


Btw it would be good to test that 3d images work correctly for OpenCL 3. Would 
it work if we add `RUN` line with `CL3.0` into 
`test/SemaOpenCL/access-qualifier.cl` or are we missing some more work to 
enable the test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103911

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


[PATCH] D103911: [OpenCL] Add support of __opencl_c_images feature macro

2021-06-09 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added inline comments.



Comment at: clang/test/SemaOpenCL/unsupported-image.cl:1
+// RUN: %clang_cc1 -verify -cl-std=CL3.0 -cl-ext=-__opencl_c_images %s
+// RUN: %clang_cc1 -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images %s

Anastasia wrote:
> svenvh wrote:
> > Should we add `-triple spir`, as some of the image types (e.g. msaa) are 
> > part of an extension that may not be available for every default triple?
> yes, the test might fail in some bots otherwise...
> 
> 
> Btw it would be good to test that 3d images work correctly for OpenCL 3. 
> Would it work if we add `RUN` line with `CL3.0` into 
> `test/SemaOpenCL/access-qualifier.cl` or are we missing some more work to 
> enable the test?
> Should we add -triple spir, as some of the image types (e.g. msaa) are part 
> of an extension that may not be available for every default triple?

> yes, the test might fail in some bots otherwise...

Yes, that's correct. Thanks. Now it works locally because the default triple I 
have is x86 which supports all the extensions as well as SPIR.

> Btw it would be good to test that 3d images work correctly for OpenCL 3. 
> Would it work if we add RUN line with CL3.0 into 
> test/SemaOpenCL/access-qualifier.cl or are we missing some more work to 
> enable the test?

Yeah, to properly test 3d images actually we need to add `__opencl_c_images` 
support first, because `__opencl_c_3d_image_writes` depends on it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103911

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


[clang] 64dbd64 - [clang-cl] Parse /await:strict, new in MSVC 16.10

2021-06-09 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-06-09T14:27:05+02:00
New Revision: 64dbd649cf661cbca5e8670d220aec40d6892572

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

LOG: [clang-cl] Parse /await:strict, new in MSVC 16.10

Added: 


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

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index bae7426bc64e3..55391cf2dac1d 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6200,6 +6200,7 @@ def _SLASH_Zo_ : CLIgnoredFlag<"Zo-">;
 // Unsupported:
 
 def _SLASH_await : CLFlag<"await">;
+def _SLASH_await_COLON : CLJoined<"await:">;
 def _SLASH_constexpr : CLJoined<"constexpr:">;
 def _SLASH_AI : CLJoinedOrSeparate<"AI">;
 def _SLASH_Bt : CLFlag<"Bt">;

diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index f60c2b6147022..d1bd6f5146b4d 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -420,6 +420,7 @@
 // (/Zs is for syntax-only)
 // RUN: %clang_cl /Zs \
 // RUN: /await \
+// RUN: /await:strict \
 // RUN: /constexpr:depth1000 /constexpr:backtrace1000 /constexpr:steps1000 
\
 // RUN: /AIfoo \
 // RUN: /AI foo_does_not_exist \



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


[PATCH] D103623: [Clang] Test case for -Wunused-but-set-variable, warn for volatile.

2021-06-09 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg accepted this revision.
sberg 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/D103623/new/

https://reviews.llvm.org/D103623

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


[PATCH] D103958: [WIP] Support MustControl conditional control attribute

2021-06-09 Thread Marco Elver via Phabricator via cfe-commits
melver created this revision.
Herald added subscribers: dexonsmith, jfb, hiraditya.
Herald added a reviewer: aaron.ballman.
melver requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, jdoerfert.
Herald added projects: clang, LLVM.

[ WIP, only high-level comments for now ]

Introduce a new attribute, 'MustControl'/'mustcontrol', which denotes that a
conditional control statement must result in true control-flow and not
be optimized away. The attribute otherwise has no semantic relevance.

However, the existence of a true branch is of relevance when branch
execution has side-effects on machine state that the programmer is
interested in, for example in OS kernels.

The Linux kernel, for one, relies on the existence of true conditional
branches for the enforcement of memory orders, per Linux-kernel memory
consistency model (LKMM) [1]. With the 'mustcontrol' attribute, Clang
would provide a primitive required for the Linux kernel to ensure a true
branch is emitted without resorting to inline assembly (which often
results in poor codegen). The primitive is simple and low-level enough,
that the compiler can remain blissfully unaware of the LKMM and leave
the semantics of Linux's memory model to the kernel community.

[1] https://lkml.kernel.org/r/yln8dzbnwvqrq...@hirez.programming.kicks-ass.net


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103958

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/CodeGenCXX/attr-mustcontrol.cpp
  llvm/include/llvm/IR/FixedMetadataKinds.def
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/MDBuilder.h
  llvm/lib/CodeGen/BranchFolding.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/IR/MDBuilder.cpp

Index: llvm/lib/IR/MDBuilder.cpp
===
--- llvm/lib/IR/MDBuilder.cpp
+++ llvm/lib/IR/MDBuilder.cpp
@@ -56,6 +56,8 @@
   return MDNode::get(Context, None);
 }
 
+MDNode *MDBuilder::createMustControl() { return MDNode::get(Context, None); }
+
 MDNode *MDBuilder::createFunctionEntryCount(
 uint64_t Count, bool Synthetic,
 const DenseSet *Imports) {
Index: llvm/lib/IR/IRBuilder.cpp
===
--- llvm/lib/IR/IRBuilder.cpp
+++ llvm/lib/IR/IRBuilder.cpp
@@ -960,7 +960,7 @@
   if (MDFrom) {
 MDNode *Prof = MDFrom->getMetadata(LLVMContext::MD_prof);
 MDNode *Unpred = MDFrom->getMetadata(LLVMContext::MD_unpredictable);
-Sel = addBranchMetadata(Sel, Prof, Unpred);
+Sel = addBranchMetadata(Sel, Prof, Unpred, nullptr /*TODO*/);
   }
   if (isa(Sel))
 setFPAttrs(Sel, nullptr /* MDNode* */, FMF);
Index: llvm/lib/CodeGen/BranchFolding.cpp
===
--- llvm/lib/CodeGen/BranchFolding.cpp
+++ llvm/lib/CodeGen/BranchFolding.cpp
@@ -1217,7 +1217,19 @@
 // Blocks should be considered empty if they contain only debug info;
 // else the debug info would affect codegen.
 static bool IsEmptyBlock(MachineBasicBlock *MBB) {
-  return MBB->getFirstNonDebugInstr(true) == MBB->end();
+  if (MBB->getFirstNonDebugInstr(true) != MBB->end())
+return false;
+
+  // Even though this block is empty, check if we should preserve it.
+  if (const auto *BB = MBB->getBasicBlock()) {
+for (const BasicBlock *PredBB : predecessors(BB)) {
+  const auto *PredBr = dyn_cast(PredBB->getTerminator());
+  if (PredBr && PredBr->getMetadata(LLVMContext::MD_mustcontrol))
+return false;
+}
+  }
+
+  return true;
 }
 
 // Blocks with only debug info and branches should be considered the same
Index: llvm/include/llvm/IR/MDBuilder.h
===
--- llvm/include/llvm/IR/MDBuilder.h
+++ llvm/include/llvm/IR/MDBuilder.h
@@ -66,6 +66,9 @@
   /// Return metadata specifying that a branch or switch is unpredictable.
   MDNode *createUnpredictable();
 
+  /// Return metadata specifying that a branch or switch must not be removed.
+  MDNode *createMustControl();
+
   /// Return metadata containing the entry \p Count for a function, a boolean
   /// \Synthetic indicating whether the counts were synthetized, and the
   /// GUIDs stored in \p Imports that need to be imported for sample PGO, to
Index: llvm/include/llvm/IR/Intrinsics.td
===
--- llvm/include/llvm/IR/Intrinsics.td
+++ llvm/include/llvm/IR/Intrinsics.td
@@ -1326,7 +1326,8 @@
 // has having opaque side effects. This may be inserted into loops to ensure
 // that they are not removed even if they turn out to be empty, for languages
 // which specify that infinite loops must be preserved.
-def int_sideeffect : DefaultAttrsIntrinsic<[], [], [IntrInaccessibleMemOnly, IntrWillReturn]>;
+def int_sideeffect : Defau

[clang] c1cd743 - [clang] p1099 using-enum feature macro & web page

2021-06-09 Thread Nathan Sidwell via cfe-commits

Author: Nathan Sidwell
Date: 2021-06-09T05:40:53-07:00
New Revision: c1cd743519af3978b944df88f57c6e523caa10dc

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

LOG: [clang] p1099 using-enum feature macro & web page

This completes the series implementing p1099, by adding the feature
macro and updating the web page.

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

Added: 


Modified: 
clang/lib/Frontend/InitPreprocessor.cpp
clang/test/Lexer/cxx-features.cpp
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 8e63046f4ab22..e03f831c8becb 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -594,7 +594,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const 
LangOptions &LangOpts,
 Builder.defineMacro("__cpp_designated_initializers", "201707L");
 Builder.defineMacro("__cpp_impl_three_way_comparison", "201907L");
 //Builder.defineMacro("__cpp_modules", "201907L");
-//Builder.defineMacro("__cpp_using_enum", "201907L");
+Builder.defineMacro("__cpp_using_enum", "201907L");
   }
   // C++2b features.
   if (LangOpts.CPlusPlus2b)

diff  --git a/clang/test/Lexer/cxx-features.cpp 
b/clang/test/Lexer/cxx-features.cpp
index 22ac5567c1d86..8f283dd8c8d9f 100644
--- a/clang/test/Lexer/cxx-features.cpp
+++ b/clang/test/Lexer/cxx-features.cpp
@@ -98,8 +98,7 @@
 #error "wrong value for __cpp_modules"
 #endif
 
-#if check(using_enum, 0, 0, 0, 0, 0, 0)
-// FIXME: 201907 in C++20
+#if check(using_enum, 0, 0, 0, 0, 201907, 201907)
 #error "wrong value for __cpp_using_enum"
 #endif
 

diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 0660816b83c18..fc94282311561 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -1205,7 +1205,7 @@ C++20 implementation status
 
   using enum
   https://wg21.link/p1099r5";>P1099R5
-  No
+  Clang 13
 
 
   Class template argument deduction for aggregates



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


[PATCH] D102242: [clang] p1099 5/5: feature macro & web page

2021-06-09 Thread Nathan Sidwell via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc1cd743519af: [clang] p1099 using-enum feature macro & 
web page (authored by urnathan).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102242

Files:
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/www/cxx_status.html


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1205,7 +1205,7 @@
 
   using enum
   https://wg21.link/p1099r5";>P1099R5
-  No
+  Clang 13
 
 
   Class template argument deduction for aggregates
Index: clang/test/Lexer/cxx-features.cpp
===
--- clang/test/Lexer/cxx-features.cpp
+++ clang/test/Lexer/cxx-features.cpp
@@ -98,8 +98,7 @@
 #error "wrong value for __cpp_modules"
 #endif
 
-#if check(using_enum, 0, 0, 0, 0, 0, 0)
-// FIXME: 201907 in C++20
+#if check(using_enum, 0, 0, 0, 0, 201907, 201907)
 #error "wrong value for __cpp_using_enum"
 #endif
 
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -594,7 +594,7 @@
 Builder.defineMacro("__cpp_designated_initializers", "201707L");
 Builder.defineMacro("__cpp_impl_three_way_comparison", "201907L");
 //Builder.defineMacro("__cpp_modules", "201907L");
-//Builder.defineMacro("__cpp_using_enum", "201907L");
+Builder.defineMacro("__cpp_using_enum", "201907L");
   }
   // C++2b features.
   if (LangOpts.CPlusPlus2b)


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1205,7 +1205,7 @@
 
   using enum
   https://wg21.link/p1099r5";>P1099R5
-  No
+  Clang 13
 
 
   Class template argument deduction for aggregates
Index: clang/test/Lexer/cxx-features.cpp
===
--- clang/test/Lexer/cxx-features.cpp
+++ clang/test/Lexer/cxx-features.cpp
@@ -98,8 +98,7 @@
 #error "wrong value for __cpp_modules"
 #endif
 
-#if check(using_enum, 0, 0, 0, 0, 0, 0)
-// FIXME: 201907 in C++20
+#if check(using_enum, 0, 0, 0, 0, 201907, 201907)
 #error "wrong value for __cpp_using_enum"
 #endif
 
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -594,7 +594,7 @@
 Builder.defineMacro("__cpp_designated_initializers", "201707L");
 Builder.defineMacro("__cpp_impl_three_way_comparison", "201907L");
 //Builder.defineMacro("__cpp_modules", "201907L");
-//Builder.defineMacro("__cpp_using_enum", "201907L");
+Builder.defineMacro("__cpp_using_enum", "201907L");
   }
   // C++2b features.
   if (LangOpts.CPlusPlus2b)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103958: [WIP] Support MustControl conditional control attribute

2021-06-09 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

This is missing langref changes, and a RFC to llvm-dev.
I'm rather skeptical of this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103958

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


[PATCH] D99436: [OPENMP]Fix PR49366: crash on VLAs in task untied regions.

2021-06-09 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 350870.
ABataev added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99436

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/OpenMP/task_messages.cpp
  clang/test/OpenMP/taskloop_loop_messages.cpp

Index: clang/test/OpenMP/taskloop_loop_messages.cpp
===
--- clang/test/OpenMP/taskloop_loop_messages.cpp
+++ clang/test/OpenMP/taskloop_loop_messages.cpp
@@ -691,7 +691,7 @@
 
 void test_loop_eh() {
   const int N = 100;
-  float a[N], b[N], c[N];
+  float a[N], b[N], c[N]; // expected-note {{declared here}}
 #pragma omp parallel
 #pragma omp taskloop
   for (int i = 0; i < 10; i++) {
@@ -729,6 +729,13 @@
   void g() { throw 0; }
 };
   }
+// expected-error@+5 {{variable length arrays are not supported in OpenMP tasking regions with 'untied' clause}}
+// expected-note@+4 {{read of non-constexpr variable 'c' is not allowed in a constant expression}}
+#pragma omp taskloop untied
+  {
+  for (int i = 0; i < 10; ++i)
+int array[(int)c[0]];
+  }
 }
 
 void test_loop_firstprivate_lastprivate() {
Index: clang/test/OpenMP/task_messages.cpp
===
--- clang/test/OpenMP/task_messages.cpp
+++ clang/test/OpenMP/task_messages.cpp
@@ -173,7 +173,7 @@
   int &b = a;
   S sa;
   S &sb = sa;
-  int r;
+  int r; // expected-note {{declared here}}
 #pragma omp task { // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
   foo();
 #pragma omp task( // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
@@ -330,6 +330,12 @@
 // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'mergeable' clause}}
 #pragma omp task mergeable mergeable
   ++r;
+// expected-error@+4 {{variable length arrays are not supported in OpenMP tasking regions with 'untied' clause}}
+// expected-note@+3 {{read of non-const variable 'r' is not allowed in a constant expression}}
+#pragma omp task untied
+  {
+int array[r];
+  }
   volatile omp_event_handle_t evt;
   omp_event_handle_t sevt;
   const omp_event_handle_t cevt = evt;
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2428,6 +2428,9 @@
   } else if (isSFINAEContext()) {
 VLADiag = diag::err_vla_in_sfinae;
 VLAIsError = true;
+  } else if (getLangOpts().OpenMP && isInOpenMPTaskUntiedContext()) {
+VLADiag = diag::err_openmp_vla_in_task_untied;
+VLAIsError = true;
   } else {
 VLADiag = diag::ext_vla;
 VLAIsError = false;
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -174,6 +174,7 @@
 bool HasMutipleLoops = false;
 const Decl *PossiblyLoopCounter = nullptr;
 bool NowaitRegion = false;
+bool UntiedRegion = false;
 bool CancelRegion = false;
 bool LoopStart = false;
 bool BodyComplete = false;
@@ -841,6 +842,15 @@
   return Parent->NowaitRegion;
 return false;
   }
+  /// Marks current region as untied (it has a 'untied' clause).
+  void setUntiedRegion(bool IsUntied = true) {
+getTopOfStack().UntiedRegion = IsUntied;
+  }
+  /// Return true if current region is untied.
+  bool isUntiedRegion() const {
+const SharingMapTy *Top = getTopOfStackOrNull();
+return Top ? Top->UntiedRegion : false;
+  }
   /// Marks parent region as cancel region.
   void setParentCancelRegion(bool Cancel = true) {
 if (SharingMapTy *Parent = getSecondOnStackOrNull())
@@ -2154,6 +2164,11 @@
   return DSAStack->getNestingLevel();
 }
 
+bool Sema::isInOpenMPTaskUntiedContext() const {
+  return isOpenMPTaskingDirective(DSAStack->getCurrentDirective()) &&
+ DSAStack->isUntiedRegion();
+}
+
 bool Sema::isInOpenMPTargetExecutionDirective() const {
   return (isOpenMPTargetExecutionDirective(DSAStack->getCurrentDirective()) &&
   !DSAStack->isClauseParsingMode()) ||
@@ -14673,6 +14688,7 @@
 
 OMPClause *Sema::ActOnOpenMPUntiedClause(SourceLocation StartLoc,
  SourceLocation EndLoc) {
+  DSAStack->setUntiedRegion();
   return new (Context) OMPUntiedClause(StartLoc, EndLoc);
 }
 
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -10496,6 +10496,10 @@
   void finalizeOpenMPDelayedAnalysis(const FunctionDecl *Caller,
  const FunctionDecl *Callee,
  SourceLocation Loc);
+
+  /// Return true 

[PATCH] D88174: [Sema] Address-space sensitive check for unbounded arrays (v2)

2021-06-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM! Thank you for the fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88174

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


[PATCH] D103426: Clang: Extend format string checking to wprintf/wscanf

2021-06-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D103426#2807245 , @MarcusJohnson91 
wrote:

> In D103426#2806391 , @aaron.ballman 
> wrote:
>
>> Do you have a reference to the WG14 paper proposing these conversion 
>> specifiers?
>
> I've previously written up the proposal, which you actually helped with 
> (thank you for that), just submitted a request to Dan Plakosh to get a 
> document number and submit it.

Thanks! Once it's submitted and available on the committee webpage, can you 
post a link to it in this review? That'd help assess whether the implementation 
matches the proposal or not.

> Maybe I was a bit optimistic, but I don't think l16 and l32 will be a hard 
> sell, but maybe I'm naive haha

There's never a shortage of surprises when it comes to standardization efforts. 
:-D


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103426

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


[PATCH] D103961: [analyzer] Extract InlinedFunctionCallHandler

2021-06-09 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, xazax.hun, martong, steakhal, Szelethus, 
manas, RedDocMD.
Herald added subscribers: ASDenysPetrov, dkrupp, donat.nagy, mikhail.ramalho, 
a.sidorin, rnkovacs, szepet, baloghadamsoftware.
vsavchenko 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/D103961

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -937,91 +937,6 @@
 ID.AddBoolean(EnableNullFPSuppression);
   }
 
-  /// Adds a ReturnVisitor if the given statement represents a call that was
-  /// inlined.
-  ///
-  /// This will search back through the ExplodedGraph, starting from the given
-  /// node, looking for when the given statement was processed. If it turns out
-  /// the statement is a call that was inlined, we add the visitor to the
-  /// bug report, so it can print a note later.
-  static void addVisitorIfNecessary(TrackerRef ParentTracker,
-const ExplodedNode *Node, const Stmt *S,
-PathSensitiveBugReport &BR,
-bool InEnableNullFPSuppression,
-bugreporter::TrackingKind TKind) {
-if (!CallEvent::isCallStmt(S))
-  return;
-
-// First, find when we processed the statement.
-// If we work with a 'CXXNewExpr' that is going to be purged away before
-// its call take place. We would catch that purge in the last condition
-// as a 'StmtPoint' so we have to bypass it.
-const bool BypassCXXNewExprEval = isa(S);
-
-// This is moving forward when we enter into another context.
-const StackFrameContext *CurrentSFC = Node->getStackFrame();
-
-do {
-  // If that is satisfied we found our statement as an inlined call.
-  if (Optional CEE = Node->getLocationAs())
-if (CEE->getCalleeContext()->getCallSite() == S)
-  break;
-
-  // Try to move forward to the end of the call-chain.
-  Node = Node->getFirstPred();
-  if (!Node)
-break;
-
-  const StackFrameContext *PredSFC = Node->getStackFrame();
-
-  // If that is satisfied we found our statement.
-  // FIXME: This code currently bypasses the call site for the
-  //conservatively evaluated allocator.
-  if (!BypassCXXNewExprEval)
-if (Optional SP = Node->getLocationAs())
-  // See if we do not enter into another context.
-  if (SP->getStmt() == S && CurrentSFC == PredSFC)
-break;
-
-  CurrentSFC = PredSFC;
-} while (Node->getStackFrame() == CurrentSFC);
-
-// Next, step over any post-statement checks.
-while (Node && Node->getLocation().getAs())
-  Node = Node->getFirstPred();
-if (!Node)
-  return;
-
-// Finally, see if we inlined the call.
-Optional CEE = Node->getLocationAs();
-if (!CEE)
-  return;
-
-const StackFrameContext *CalleeContext = CEE->getCalleeContext();
-if (CalleeContext->getCallSite() != S)
-  return;
-
-// Check the return value.
-ProgramStateRef State = Node->getState();
-SVal RetVal = Node->getSVal(S);
-
-// Handle cases where a reference is returned and then immediately used.
-if (cast(S)->isGLValue())
-  if (Optional LValue = RetVal.getAs())
-RetVal = State->getSVal(*LValue);
-
-// See if the return value is NULL. If so, suppress the report.
-AnalyzerOptions &Options = State->getAnalysisManager().options;
-
-bool EnableNullFPSuppression = false;
-if (InEnableNullFPSuppression && Options.ShouldSuppressNullReturnPaths)
-  if (Optional RetLoc = RetVal.getAs())
-EnableNullFPSuppression = State->isNull(*RetLoc).isConstrainedTrue();
-
-BR.addVisitor(ParentTracker, CalleeContext,
- EnableNullFPSuppression, Options, TKind);
-  }
-
   PathDiagnosticPieceRef visitNodeInitial(const ExplodedNode *N,
   BugReporterContext &BRC,
   PathSensitiveBugReport &BR) {
@@ -2233,6 +2148,96 @@
   }
 };
 
+/// Adds a ReturnVisitor if the given statement represents a call that was
+/// inlined.
+///
+/// This will search back through the ExplodedGraph, starting from the given
+/// node, looking for when the given statement was processed. If it turns out
+/// the statement is a call that was inlined, we add the visitor to the
+/// bug report, so it can print a note later.
+class InlinedFunctionCallHandler final : public ExpressionHandler {
+  using ExpressionHandler::ExpressionHandler;
+
+  Tracker::Result handle(const Expr *E, const ExplodedNode *In

[PATCH] D103962: [C++4OpenCL] Fix qualifiers check on binding references to temporaries

2021-06-09 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm created this revision.
olestrohm added reviewers: Anastasia, svenvh.
olestrohm added a project: clang.
Herald added subscribers: ldrumm, yaxunl.
olestrohm requested review of this revision.
Herald added a subscriber: cfe-commits.

Fixing the qualifiers check from PR49733.

It would be great to add some test, to increase the coverage, and because the 
erroneous check doesn't seem to trigger in any tests.
However I couldn't come up with a case that did trigger it, so it may be that 
it can't happen, or at least is very unlikely.

Fixes: PR49733


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103962

Files:
  clang/lib/Sema/SemaInit.cpp


Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -5063,9 +5063,9 @@
   //than, cv2; otherwise, the program is ill-formed.
   unsigned T1CVRQuals = T1Quals.getCVRQualifiers();
   unsigned T2CVRQuals = T2Quals.getCVRQualifiers();
-  if ((RefRelationship == Sema::Ref_Related &&
-   (T1CVRQuals | T2CVRQuals) != T1CVRQuals) ||
-  !T1Quals.isAddressSpaceSupersetOf(T2Quals)) {
+  if (RefRelationship == Sema::Ref_Related &&
+  ((T1CVRQuals | T2CVRQuals) != T1CVRQuals ||
+   !T1Quals.isAddressSpaceSupersetOf(T2Quals))) {
 
Sequence.SetFailed(InitializationSequence::FK_ReferenceInitDropsQualifiers);
 return;
   }


Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -5063,9 +5063,9 @@
   //than, cv2; otherwise, the program is ill-formed.
   unsigned T1CVRQuals = T1Quals.getCVRQualifiers();
   unsigned T2CVRQuals = T2Quals.getCVRQualifiers();
-  if ((RefRelationship == Sema::Ref_Related &&
-   (T1CVRQuals | T2CVRQuals) != T1CVRQuals) ||
-  !T1Quals.isAddressSpaceSupersetOf(T2Quals)) {
+  if (RefRelationship == Sema::Ref_Related &&
+  ((T1CVRQuals | T2CVRQuals) != T1CVRQuals ||
+   !T1Quals.isAddressSpaceSupersetOf(T2Quals))) {
 Sequence.SetFailed(InitializationSequence::FK_ReferenceInitDropsQualifiers);
 return;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97869: [OpenCL] Add OpenCL builtin test generator

2021-06-09 Thread Sven van Haastregt 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 rG8866793b4e0a: [OpenCL] Add OpenCL builtin test generator 
(authored by svenvh).
Herald added a subscriber: ldrumm.
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D97869?vs=350314&id=350874#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97869

Files:
  clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -122,6 +122,8 @@
 
 void EmitClangOpenCLBuiltins(llvm::RecordKeeper &Records,
  llvm::raw_ostream &OS);
+void EmitClangOpenCLBuiltinTests(llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
 
 void EmitClangDataCollectors(llvm::RecordKeeper &Records,
  llvm::raw_ostream &OS);
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -63,6 +63,7 @@
   GenClangCommentCommandInfo,
   GenClangCommentCommandList,
   GenClangOpenCLBuiltins,
+  GenClangOpenCLBuiltinTests,
   GenArmNeon,
   GenArmFP16,
   GenArmBF16,
@@ -194,6 +195,8 @@
"documentation comments"),
 clEnumValN(GenClangOpenCLBuiltins, "gen-clang-opencl-builtins",
"Generate OpenCL builtin declaration handlers"),
+clEnumValN(GenClangOpenCLBuiltinTests, "gen-clang-opencl-builtin-tests",
+   "Generate OpenCL builtin declaration tests"),
 clEnumValN(GenArmNeon, "gen-arm-neon", "Generate arm_neon.h for clang"),
 clEnumValN(GenArmFP16, "gen-arm-fp16", "Generate arm_fp16.h for clang"),
 clEnumValN(GenArmBF16, "gen-arm-bf16", "Generate arm_bf16.h for clang"),
@@ -371,6 +374,9 @@
   case GenClangOpenCLBuiltins:
 EmitClangOpenCLBuiltins(Records, OS);
 break;
+  case GenClangOpenCLBuiltinTests:
+EmitClangOpenCLBuiltinTests(Records, OS);
+break;
   case GenClangSyntaxNodeList:
 EmitClangSyntaxNodeList(Records, OS);
 break;
Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -228,6 +228,64 @@
   // same entry ().
   MapVector SignatureListMap;
 };
+
+// OpenCL builtin test generator.  This class processes the same TableGen input
+// as BuiltinNameEmitter, but generates a .cl file that contains a call to each
+// builtin function described in the .td input.
+class OpenCLBuiltinTestEmitter {
+public:
+  OpenCLBuiltinTestEmitter(RecordKeeper &Records, raw_ostream &OS)
+  : Records(Records), OS(OS) {}
+
+  // Entrypoint to generate the functions for testing all OpenCL builtin
+  // functions.
+  void emit();
+
+private:
+  struct TypeFlags {
+TypeFlags() : IsConst(false), IsVolatile(false), IsPointer(false) {}
+bool IsConst : 1;
+bool IsVolatile : 1;
+bool IsPointer : 1;
+StringRef AddrSpace;
+  };
+
+  // Return a string representation of the given type, such that it can be
+  // used as a type in OpenCL C code.
+  std::string getTypeString(const Record *Type, TypeFlags Flags,
+int VectorSize) const;
+
+  // Return the type(s) and vector size(s) for the given type.  For
+  // non-GenericTypes, the resulting vectors will contain 1 element.  For
+  // GenericTypes, the resulting vectors typically contain multiple elements.
+  void getTypeLists(Record *Type, TypeFlags &Flags,
+std::vector &TypeList,
+std::vector &VectorList) const;
+
+  // Expand the TableGen Records representing a builtin function signature into
+  // one or more function signatures.  Return them as a vector of a vector of
+  // strings, with each string containing an OpenCL C type and optional
+  // qualifiers.
+  //
+  // The Records may contain GenericTypes, which expand into multiple
+  // signatures.  Repeated occurrences of GenericType in a signature expand to
+  // the same types.  For example [char, FGenType, FGenType] expands to:
+  //   [char, float, float]
+  //   [char, float2, float2]
+  //   [char, float3, float3]
+  //   ...
+  void
+  expandTypesInSignature(const std::vector &Signature,
+ SmallVectorImpl> &Types);
+
+  // Contains OpenCL builtin functions and related information, stored as
+  // Record instances. They are coming from the associated TableGen file.
+  RecordKeeper &Records;
+
+  // The output f

[clang] 8866793 - [OpenCL] Add OpenCL builtin test generator

2021-06-09 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-06-09T14:03:58+01:00
New Revision: 8866793b4e0abd31e4f57abf9ba832d691a3a3e1

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

LOG: [OpenCL] Add OpenCL builtin test generator

Add a new clang-tblgen flag `-gen-clang-opencl-builtin-tests` that
generates a .cl file containing calls to every builtin function
defined in the .td input.

This patch does not add any use of the new flag yet, so the only way
to obtain a generated test file is through a manual invocation of
clang-tblgen.  A test making use of this emitter will be added in a
followup commit.

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

Added: 


Modified: 
clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
clang/utils/TableGen/TableGen.cpp
clang/utils/TableGen/TableGenBackends.h

Removed: 




diff  --git a/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp 
b/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
index 91227797a757f..5de034df348e8 100644
--- a/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ b/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -228,6 +228,64 @@ class BuiltinNameEmitter {
   // same entry ().
   MapVector SignatureListMap;
 };
+
+// OpenCL builtin test generator.  This class processes the same TableGen input
+// as BuiltinNameEmitter, but generates a .cl file that contains a call to each
+// builtin function described in the .td input.
+class OpenCLBuiltinTestEmitter {
+public:
+  OpenCLBuiltinTestEmitter(RecordKeeper &Records, raw_ostream &OS)
+  : Records(Records), OS(OS) {}
+
+  // Entrypoint to generate the functions for testing all OpenCL builtin
+  // functions.
+  void emit();
+
+private:
+  struct TypeFlags {
+TypeFlags() : IsConst(false), IsVolatile(false), IsPointer(false) {}
+bool IsConst : 1;
+bool IsVolatile : 1;
+bool IsPointer : 1;
+StringRef AddrSpace;
+  };
+
+  // Return a string representation of the given type, such that it can be
+  // used as a type in OpenCL C code.
+  std::string getTypeString(const Record *Type, TypeFlags Flags,
+int VectorSize) const;
+
+  // Return the type(s) and vector size(s) for the given type.  For
+  // non-GenericTypes, the resulting vectors will contain 1 element.  For
+  // GenericTypes, the resulting vectors typically contain multiple elements.
+  void getTypeLists(Record *Type, TypeFlags &Flags,
+std::vector &TypeList,
+std::vector &VectorList) const;
+
+  // Expand the TableGen Records representing a builtin function signature into
+  // one or more function signatures.  Return them as a vector of a vector of
+  // strings, with each string containing an OpenCL C type and optional
+  // qualifiers.
+  //
+  // The Records may contain GenericTypes, which expand into multiple
+  // signatures.  Repeated occurrences of GenericType in a signature expand to
+  // the same types.  For example [char, FGenType, FGenType] expands to:
+  //   [char, float, float]
+  //   [char, float2, float2]
+  //   [char, float3, float3]
+  //   ...
+  void
+  expandTypesInSignature(const std::vector &Signature,
+ SmallVectorImpl> &Types);
+
+  // Contains OpenCL builtin functions and related information, stored as
+  // Record instances. They are coming from the associated TableGen file.
+  RecordKeeper &Records;
+
+  // The output file.
+  raw_ostream &OS;
+};
+
 } // namespace
 
 void BuiltinNameEmitter::Emit() {
@@ -861,7 +919,230 @@ static void OCL2Qual(Sema &S, const OpenCLTypeStruct &Ty,
   OS << "\n} // OCL2Qual\n";
 }
 
+std::string OpenCLBuiltinTestEmitter::getTypeString(const Record *Type,
+TypeFlags Flags,
+int VectorSize) const {
+  std::string S;
+  if (Type->getValueAsBit("IsConst") || Flags.IsConst) {
+S += "const ";
+  }
+  if (Type->getValueAsBit("IsVolatile") || Flags.IsVolatile) {
+S += "volatile ";
+  }
+
+  auto PrintAddrSpace = [&S](StringRef AddrSpace) {
+S += StringSwitch(AddrSpace)
+ .Case("clang::LangAS::opencl_private", "__private")
+ .Case("clang::LangAS::opencl_global", "__global")
+ .Case("clang::LangAS::opencl_constant", "__constant")
+ .Case("clang::LangAS::opencl_local", "__local")
+ .Case("clang::LangAS::opencl_generic", "__generic")
+ .Default("__private");
+S += " ";
+  };
+  if (Flags.IsPointer) {
+PrintAddrSpace(Flags.AddrSpace);
+  } else if (Type->getValueAsBit("IsPointer")) {
+PrintAddrSpace(Type->getValueAsString("AddrSpace"));
+  }
+
+  StringRef Acc = Type->getValueAsString("AccessQualifier");
+  if (Acc != "") {
+S += StringSwitch(Acc)
+

[clang] 206a66d - Sanitizers.h - remove MathExtras.h include dependency

2021-06-09 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2021-06-09T14:38:20+01:00
New Revision: 206a66de5902b2b6dc0c62c4a25526d7e7f24186

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

LOG: Sanitizers.h - remove MathExtras.h include dependency

The MathExtras.h header is included purely for the countPopulation() method - 
by moving this into Sanitizers.cpp we can remove the use of this costly header.

We only ever use isPowerOf2() / countPopulation() inside asserts so this 
shouldn't have any performance effects on production code.

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

Added: 


Modified: 
clang/include/clang/Basic/Sanitizers.h
clang/lib/Basic/Sanitizers.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Sanitizers.h 
b/clang/include/clang/Basic/Sanitizers.h
index 1acce0a6e09e..82e5a73dee2e 100644
--- a/clang/include/clang/Basic/Sanitizers.h
+++ b/clang/include/clang/Basic/Sanitizers.h
@@ -16,7 +16,6 @@
 
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Support/MathExtras.h"
 #include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
 #include 
 #include 
@@ -60,12 +59,7 @@ class SanitizerMask {
 return SanitizerMask(mask1, mask2);
   }
 
-  unsigned countPopulation() const {
-unsigned total = 0;
-for (const auto &Val : maskLoToHigh)
-  total += llvm::countPopulation(Val);
-return total;
-  }
+  unsigned countPopulation() const;
 
   void flipAllBits() {
 for (auto &Val : maskLoToHigh)

diff  --git a/clang/lib/Basic/Sanitizers.cpp b/clang/lib/Basic/Sanitizers.cpp
index d8de850485eb..3a3b24a62e11 100644
--- a/clang/lib/Basic/Sanitizers.cpp
+++ b/clang/lib/Basic/Sanitizers.cpp
@@ -14,6 +14,7 @@
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/MathExtras.h"
 
 using namespace clang;
 
@@ -57,6 +58,13 @@ llvm::hash_code SanitizerMask::hash_value() const {
 }
 
 namespace clang {
+unsigned SanitizerMask::countPopulation() const {
+  unsigned total = 0;
+  for (const auto &Val : maskLoToHigh)
+total += llvm::countPopulation(Val);
+  return total;
+}
+
 llvm::hash_code hash_value(const clang::SanitizerMask &Arg) {
   return Arg.hash_value();
 }



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


[PATCH] D103953: Sanitizers.h - remove MathExtras.h include dependency

2021-06-09 Thread Simon Pilgrim via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG206a66de5902: Sanitizers.h - remove MathExtras.h include 
dependency (authored by RKSimon).

Changed prior to commit:
  https://reviews.llvm.org/D103953?vs=350845&id=350882#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103953

Files:
  clang/include/clang/Basic/Sanitizers.h
  clang/lib/Basic/Sanitizers.cpp


Index: clang/lib/Basic/Sanitizers.cpp
===
--- clang/lib/Basic/Sanitizers.cpp
+++ clang/lib/Basic/Sanitizers.cpp
@@ -14,6 +14,7 @@
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/MathExtras.h"
 
 using namespace clang;
 
@@ -57,6 +58,13 @@
 }
 
 namespace clang {
+unsigned SanitizerMask::countPopulation() const {
+  unsigned total = 0;
+  for (const auto &Val : maskLoToHigh)
+total += llvm::countPopulation(Val);
+  return total;
+}
+
 llvm::hash_code hash_value(const clang::SanitizerMask &Arg) {
   return Arg.hash_value();
 }
Index: clang/include/clang/Basic/Sanitizers.h
===
--- clang/include/clang/Basic/Sanitizers.h
+++ clang/include/clang/Basic/Sanitizers.h
@@ -16,7 +16,6 @@
 
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Support/MathExtras.h"
 #include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
 #include 
 #include 
@@ -60,12 +59,7 @@
 return SanitizerMask(mask1, mask2);
   }
 
-  unsigned countPopulation() const {
-unsigned total = 0;
-for (const auto &Val : maskLoToHigh)
-  total += llvm::countPopulation(Val);
-return total;
-  }
+  unsigned countPopulation() const;
 
   void flipAllBits() {
 for (auto &Val : maskLoToHigh)


Index: clang/lib/Basic/Sanitizers.cpp
===
--- clang/lib/Basic/Sanitizers.cpp
+++ clang/lib/Basic/Sanitizers.cpp
@@ -14,6 +14,7 @@
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/MathExtras.h"
 
 using namespace clang;
 
@@ -57,6 +58,13 @@
 }
 
 namespace clang {
+unsigned SanitizerMask::countPopulation() const {
+  unsigned total = 0;
+  for (const auto &Val : maskLoToHigh)
+total += llvm::countPopulation(Val);
+  return total;
+}
+
 llvm::hash_code hash_value(const clang::SanitizerMask &Arg) {
   return Arg.hash_value();
 }
Index: clang/include/clang/Basic/Sanitizers.h
===
--- clang/include/clang/Basic/Sanitizers.h
+++ clang/include/clang/Basic/Sanitizers.h
@@ -16,7 +16,6 @@
 
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Support/MathExtras.h"
 #include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
 #include 
 #include 
@@ -60,12 +59,7 @@
 return SanitizerMask(mask1, mask2);
   }
 
-  unsigned countPopulation() const {
-unsigned total = 0;
-for (const auto &Val : maskLoToHigh)
-  total += llvm::countPopulation(Val);
-return total;
-  }
+  unsigned countPopulation() const;
 
   void flipAllBits() {
 for (auto &Val : maskLoToHigh)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93525: [clang-offload-bundler] Add unbundling of archives containing bundled object files into device specific archives

2021-06-09 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 350883.
saiislam added a comment.

1. Removed TargetID support, to be reviewed in a followup patch.
2. Added OffloadTargetInfo class to encapsulate handling of bundle entry ID 
components: OffloadKind, Triple, GPUArch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93525

Files:
  clang/docs/ClangOffloadBundler.rst
  clang/test/Driver/clang-offload-bundler.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -14,6 +14,7 @@
 ///
 //===--===//
 
+#include "clang/Basic/TargetID.h"
 #include "clang/Basic/Version.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
@@ -22,14 +23,18 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/Object/Archive.h"
+#include "llvm/Object/ArchiveWriter.h"
 #include "llvm/Object/Binary.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Host.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
@@ -82,6 +87,7 @@
"  bc  - llvm-bc\n"
"  s   - assembler\n"
"  o   - object\n"
+   "  a   - archive of objects\n"
"  gch - precompiled-header\n"
"  ast - clang AST file"),
   cl::cat(ClangOffloadBundlerCategory));
@@ -120,20 +126,49 @@
 /// Path to the current binary.
 static std::string BundlerExecutable;
 
-/// Obtain the offload kind and real machine triple out of the target
-/// information specified by the user.
-static void getOffloadKindAndTriple(StringRef Target, StringRef &OffloadKind,
-StringRef &Triple) {
-  auto KindTriplePair = Target.split('-');
-  OffloadKind = KindTriplePair.first;
-  Triple = KindTriplePair.second;
-}
-static bool hasHostKind(StringRef Target) {
+/// Obtain the offload kind, real machine triple, and an optional GPUArch
+/// out of the target information specified by the user.
+/// Bundle Entry ID (or, Offload Target String) has following components:
+///  * Offload Kind - Host, OpenMP, or HIP
+///  * Triple - Standard LLVM Triple
+///  * GPUArch (Optional) - Processor name, like gfx906 or sm_30
+/// In presence of Proc, the Triple should contain separator "-" for all
+/// standard four components, even if they are empty.
+struct OffloadTargetInfo {
   StringRef OffloadKind;
-  StringRef Triple;
-  getOffloadKindAndTriple(Target, OffloadKind, Triple);
-  return OffloadKind == "host";
-}
+  llvm::Triple Triple;
+  StringRef GPUArch;
+
+  OffloadTargetInfo(const StringRef Target) {
+SmallVector Components;
+Target.split(Components, '-', 5);
+Components.resize(6);
+this->OffloadKind = Components[0];
+this->Triple = llvm::Triple(Components[1], Components[2], Components[3],
+Components[4]);
+this->GPUArch = Components[5];
+  }
+
+  bool hasHostKind() const { return this->OffloadKind == "host"; }
+
+  bool isOffloadKindValid() const {
+return OffloadKind == "host" || OffloadKind == "openmp" ||
+   OffloadKind == "hip" || OffloadKind == "hipv4";
+  }
+
+  bool isTripleValid() const {
+return !Triple.str().empty() && Triple.getArch() != Triple::UnknownArch;
+  }
+
+  bool operator==(const OffloadTargetInfo &Target) const {
+return OffloadKind == Target.OffloadKind &&
+   Triple.isCompatibleWith(Target.Triple) && GPUArch == Target.GPUArch;
+  }
+
+  std::string str() {
+return Twine(OffloadKind + "-" + Triple.str() + "-" + GPUArch).str();
+  }
+};
 
 /// Generic file handler interface.
 class FileHandler {
@@ -160,7 +195,7 @@
   virtual Error ReadBundleEnd(MemoryBuffer &Input) = 0;
 
   /// Read the current bundle and write the result into the stream \a OS.
-  virtual Error ReadBundle(raw_fd_ostream &OS, MemoryBuffer &Input) = 0;
+  virtual Error ReadBundle(raw_ostream &OS, MemoryBuffer &Input) = 0;
 
   /// Write the header of the bundled file to \a OS based on the information
   /// gathered from \a Inputs.
@@ -375,7 +410,7 @@
 return Error::success();
   }
 
-  Error ReadBundle(raw_fd_ostream &OS, MemoryBuffer &Input) final {
+  Error ReadBundle(raw_ostream &OS, MemoryBuffer &Input) final {
 assert(CurBundleInfo != BundlesInfo.end() && "Inv

[PATCH] D93525: [clang-offload-bundler] Add unbundling of archives containing bundled object files into device specific archives

2021-06-09 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 350884.
saiislam added a comment.

Removed unused header.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93525

Files:
  clang/docs/ClangOffloadBundler.rst
  clang/test/Driver/clang-offload-bundler.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -22,14 +22,18 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/Object/Archive.h"
+#include "llvm/Object/ArchiveWriter.h"
 #include "llvm/Object/Binary.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Host.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
@@ -82,6 +86,7 @@
"  bc  - llvm-bc\n"
"  s   - assembler\n"
"  o   - object\n"
+   "  a   - archive of objects\n"
"  gch - precompiled-header\n"
"  ast - clang AST file"),
   cl::cat(ClangOffloadBundlerCategory));
@@ -120,20 +125,49 @@
 /// Path to the current binary.
 static std::string BundlerExecutable;
 
-/// Obtain the offload kind and real machine triple out of the target
-/// information specified by the user.
-static void getOffloadKindAndTriple(StringRef Target, StringRef &OffloadKind,
-StringRef &Triple) {
-  auto KindTriplePair = Target.split('-');
-  OffloadKind = KindTriplePair.first;
-  Triple = KindTriplePair.second;
-}
-static bool hasHostKind(StringRef Target) {
+/// Obtain the offload kind, real machine triple, and an optional GPUArch
+/// out of the target information specified by the user.
+/// Bundle Entry ID (or, Offload Target String) has following components:
+///  * Offload Kind - Host, OpenMP, or HIP
+///  * Triple - Standard LLVM Triple
+///  * GPUArch (Optional) - Processor name, like gfx906 or sm_30
+/// In presence of Proc, the Triple should contain separator "-" for all
+/// standard four components, even if they are empty.
+struct OffloadTargetInfo {
   StringRef OffloadKind;
-  StringRef Triple;
-  getOffloadKindAndTriple(Target, OffloadKind, Triple);
-  return OffloadKind == "host";
-}
+  llvm::Triple Triple;
+  StringRef GPUArch;
+
+  OffloadTargetInfo(const StringRef Target) {
+SmallVector Components;
+Target.split(Components, '-', 5);
+Components.resize(6);
+this->OffloadKind = Components[0];
+this->Triple = llvm::Triple(Components[1], Components[2], Components[3],
+Components[4]);
+this->GPUArch = Components[5];
+  }
+
+  bool hasHostKind() const { return this->OffloadKind == "host"; }
+
+  bool isOffloadKindValid() const {
+return OffloadKind == "host" || OffloadKind == "openmp" ||
+   OffloadKind == "hip" || OffloadKind == "hipv4";
+  }
+
+  bool isTripleValid() const {
+return !Triple.str().empty() && Triple.getArch() != Triple::UnknownArch;
+  }
+
+  bool operator==(const OffloadTargetInfo &Target) const {
+return OffloadKind == Target.OffloadKind &&
+   Triple.isCompatibleWith(Target.Triple) && GPUArch == Target.GPUArch;
+  }
+
+  std::string str() {
+return Twine(OffloadKind + "-" + Triple.str() + "-" + GPUArch).str();
+  }
+};
 
 /// Generic file handler interface.
 class FileHandler {
@@ -160,7 +194,7 @@
   virtual Error ReadBundleEnd(MemoryBuffer &Input) = 0;
 
   /// Read the current bundle and write the result into the stream \a OS.
-  virtual Error ReadBundle(raw_fd_ostream &OS, MemoryBuffer &Input) = 0;
+  virtual Error ReadBundle(raw_ostream &OS, MemoryBuffer &Input) = 0;
 
   /// Write the header of the bundled file to \a OS based on the information
   /// gathered from \a Inputs.
@@ -375,7 +409,7 @@
 return Error::success();
   }
 
-  Error ReadBundle(raw_fd_ostream &OS, MemoryBuffer &Input) final {
+  Error ReadBundle(raw_ostream &OS, MemoryBuffer &Input) final {
 assert(CurBundleInfo != BundlesInfo.end() && "Invalid reader info!");
 StringRef FC = Input.getBuffer();
 OS.write(FC.data() + CurBundleInfo->second.Offset,
@@ -538,7 +572,7 @@
 
   Error ReadBundleEnd(MemoryBuffer &Input) final { return Error::success(); }
 
-  Error ReadBundle(raw_fd_ostream &OS, MemoryBuffer &Input) final {
+  Error ReadBundle(raw_ostream &OS, MemoryBuffer &Input) final {
 Expected ContentOrErr = CurrentSection->getCo

[PATCH] D103958: [WIP] Support MustControl conditional control attribute

2021-06-09 Thread Marco Elver via Phabricator via cfe-commits
melver added a comment.

In D103958#2807811 , @lebedev.ri 
wrote:

> This is missing langref changes, and a RFC to llvm-dev.

We're not there yet, but will send something. Having real code helped me 
understand what out the myriad of options that were discussed were actually 
reasonable to implement. (Perhaps I should have uploaded WIP code elsewhere, 
sorry about that.)

> I'm rather skeptical of this.

We're trying to solve a serious problem, and the Linux kernel is an important 
usecase. We'd be very glad to hear constructive criticism, the LKML thread is 
still ongoing: 
https://lore.kernel.org/linux-arch/yln8dzbnwvqrq...@hirez.programming.kicks-ass.net/

Thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103958

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


[PATCH] D93525: [clang-offload-bundler] Add unbundling of archives containing bundled object files into device specific archives

2021-06-09 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Thanks for splitting this. I quickly went over it only.




Comment at: clang/docs/ClangOffloadBundler.rst:137
+
+  myarch--myOS-
 

not needed here.



Comment at: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp:1431
+   ? UnbundleArchive()
+   : Unbundle ? UnbundleFiles() : BundleFiles();
+  });

By now, a proper conditional seems appropriate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93525

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


[PATCH] D103934: clang/darwin: use response files with ld64

2021-06-09 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

Nice :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103934

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


[PATCH] D103958: [WIP] Support MustControl conditional control attribute

2021-06-09 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

WIP here is fine, would help to include a test that shows/explains what problem 
is actually solved though. I don't understand form this patch alone.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103958

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


[PATCH] D103888: [ADT] Remove APInt/APSInt toString() std::string variants

2021-06-09 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon updated this revision to Diff 350893.
RKSimon added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103888

Files:
  clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/Hover.cpp
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/AST/ASTDiagnostic.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Analysis/ThreadSafetyCommon.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Lex/PPExpressions.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaStmtAsm.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/unittests/StaticAnalyzer/RangeSetTest.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTestPostOrderVisitor.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksCommon.h
  llvm/include/llvm/ADT/APInt.h
  llvm/include/llvm/ADT/APSInt.h
  llvm/include/llvm/ADT/StringExtras.h
  llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/Support/APInt.cpp
  llvm/lib/Target/X86/X86MCInstLower.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
  llvm/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
  llvm/tools/llvm-pdbutil/MinimalTypeDumper.cpp
  llvm/unittests/ADT/APIntTest.cpp

Index: llvm/unittests/ADT/APIntTest.cpp
===
--- llvm/unittests/ADT/APIntTest.cpp
+++ llvm/unittests/ADT/APIntTest.cpp
@@ -9,6 +9,7 @@
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/Twine.h"
 #include "gtest/gtest.h"
 #include 
@@ -1461,7 +1462,7 @@
   APInt ValC(65, 0);
   ValC = ValA * ValB;
   ValA *= ValB;
-  EXPECT_EQ(ValA.toString(10, false), ValC.toString(10, false));
+  EXPECT_EQ(toString(ValA, 10, false), toString(ValC, 10, false));
 }
 
 TEST(APIntTest, Rotate) {
Index: llvm/tools/llvm-pdbutil/MinimalTypeDumper.cpp
===
--- llvm/tools/llvm-pdbutil/MinimalTypeDumper.cpp
+++ llvm/tools/llvm-pdbutil/MinimalTypeDumper.cpp
@@ -557,7 +557,7 @@
 Error MinimalTypeDumpVisitor::visitKnownMember(CVMemberRecord &CVR,
EnumeratorRecord &Enum) {
   P.format(" [{0} = {1}]", Enum.Name,
-   Enum.Value.toString(10, Enum.Value.isSigned()));
+   toString(Enum.Value, 10, Enum.Value.isSigned()));
   return Error::success();
 }
 
Index: llvm/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
===
--- llvm/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
+++ llvm/tools/llvm-pdbutil/MinimalSymbolDumper.cpp
@@ -559,7 +559,7 @@
   P.format(" `{0}`", Constant.Name);
   AutoIndent Indent(P, 7);
   P.formatLine("type = {0}, value = {1}", typeIndex(Constant.Type),
-   Constant.Value.toString(10));
+   toString(Constant.Value, 10));
   return Error::success();
 }
 
Index: llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
===
--- llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
+++ llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
@@ -255,7 +255,7 @@
  raw_ostream &Out) {
 YamlContext &Context = getTypedContext(Ctx);
 Out << Context.getRegName(RV.Register) << "=0x"
-<< RV.Value.toString(kRadix, kSigned);
+<< toString(RV.Value, kRadix, kSigned);
   }
 
   static StringRef input(StringRef String, void *Ctx,
Index: llvm/lib/Transforms/IPO/OpenMPOpt.cpp
===
--- llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -585,7 +585,7 @@
   return ORA << "OpenMP ICV " << ore::NV("OpenMPICV", ICVInfo.Name)
  << " Value: "
  << (ICVInfo.InitValue
- ? ICVInfo.InitValue->getValue().toString(10, true)
+ ? toString(ICVInfo.InitValue->getVal

[PATCH] D99675: [llvm][clang] Create new intrinsic llvm.arith.fence to control FP optimization at expression level

2021-06-09 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: llvm/docs/LangRef.rst:21195
+'``llvm.arithmetic_fence``' Intrinsic
+^^
+

pengfei wrote:
> Should be equal to the text?
Yeah, a good catch. But I initially meant `^^^` should be equal to the title. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99675

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


[PATCH] D93525: [clang-offload-bundler] Add unbundling of archives containing bundled object files into device specific archives

2021-06-09 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 350897.
saiislam added a comment.

Removed Triple format example from documentation and simplified conditional 
calling of bundling/unbundling functions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93525

Files:
  clang/docs/ClangOffloadBundler.rst
  clang/test/Driver/clang-offload-bundler.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -22,14 +22,18 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/Object/Archive.h"
+#include "llvm/Object/ArchiveWriter.h"
 #include "llvm/Object/Binary.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Host.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
@@ -82,6 +86,7 @@
"  bc  - llvm-bc\n"
"  s   - assembler\n"
"  o   - object\n"
+   "  a   - archive of objects\n"
"  gch - precompiled-header\n"
"  ast - clang AST file"),
   cl::cat(ClangOffloadBundlerCategory));
@@ -120,20 +125,49 @@
 /// Path to the current binary.
 static std::string BundlerExecutable;
 
-/// Obtain the offload kind and real machine triple out of the target
-/// information specified by the user.
-static void getOffloadKindAndTriple(StringRef Target, StringRef &OffloadKind,
-StringRef &Triple) {
-  auto KindTriplePair = Target.split('-');
-  OffloadKind = KindTriplePair.first;
-  Triple = KindTriplePair.second;
-}
-static bool hasHostKind(StringRef Target) {
+/// Obtain the offload kind, real machine triple, and an optional GPUArch
+/// out of the target information specified by the user.
+/// Bundle Entry ID (or, Offload Target String) has following components:
+///  * Offload Kind - Host, OpenMP, or HIP
+///  * Triple - Standard LLVM Triple
+///  * GPUArch (Optional) - Processor name, like gfx906 or sm_30
+/// In presence of Proc, the Triple should contain separator "-" for all
+/// standard four components, even if they are empty.
+struct OffloadTargetInfo {
   StringRef OffloadKind;
-  StringRef Triple;
-  getOffloadKindAndTriple(Target, OffloadKind, Triple);
-  return OffloadKind == "host";
-}
+  llvm::Triple Triple;
+  StringRef GPUArch;
+
+  OffloadTargetInfo(const StringRef Target) {
+SmallVector Components;
+Target.split(Components, '-', 5);
+Components.resize(6);
+this->OffloadKind = Components[0];
+this->Triple = llvm::Triple(Components[1], Components[2], Components[3],
+Components[4]);
+this->GPUArch = Components[5];
+  }
+
+  bool hasHostKind() const { return this->OffloadKind == "host"; }
+
+  bool isOffloadKindValid() const {
+return OffloadKind == "host" || OffloadKind == "openmp" ||
+   OffloadKind == "hip" || OffloadKind == "hipv4";
+  }
+
+  bool isTripleValid() const {
+return !Triple.str().empty() && Triple.getArch() != Triple::UnknownArch;
+  }
+
+  bool operator==(const OffloadTargetInfo &Target) const {
+return OffloadKind == Target.OffloadKind &&
+   Triple.isCompatibleWith(Target.Triple) && GPUArch == Target.GPUArch;
+  }
+
+  std::string str() {
+return Twine(OffloadKind + "-" + Triple.str() + "-" + GPUArch).str();
+  }
+};
 
 /// Generic file handler interface.
 class FileHandler {
@@ -160,7 +194,7 @@
   virtual Error ReadBundleEnd(MemoryBuffer &Input) = 0;
 
   /// Read the current bundle and write the result into the stream \a OS.
-  virtual Error ReadBundle(raw_fd_ostream &OS, MemoryBuffer &Input) = 0;
+  virtual Error ReadBundle(raw_ostream &OS, MemoryBuffer &Input) = 0;
 
   /// Write the header of the bundled file to \a OS based on the information
   /// gathered from \a Inputs.
@@ -375,7 +409,7 @@
 return Error::success();
   }
 
-  Error ReadBundle(raw_fd_ostream &OS, MemoryBuffer &Input) final {
+  Error ReadBundle(raw_ostream &OS, MemoryBuffer &Input) final {
 assert(CurBundleInfo != BundlesInfo.end() && "Invalid reader info!");
 StringRef FC = Input.getBuffer();
 OS.write(FC.data() + CurBundleInfo->second.Offset,
@@ -538,7 +572,7 @@
 
   Error ReadBundleEnd(MemoryBuffer &Input) final { return Error::success(); }
 
-  Error ReadBundle(raw_fd_ostream &OS, MemoryBuffer &Input) final {
+  Error ReadBundle(

[PATCH] D101139: Create install targets for scan-build-py.

2021-06-09 Thread Anders Waldenborg via Phabricator via cfe-commits
wanders added a comment.

I think this looks good. I can't vouch for the cmake changes.

However there seems like diff is based on something that already has moved 
parts into libexec. It doesn't apply cleanly here - and buildkite seems to 
complain too. Make sure you have the complete diff.


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

https://reviews.llvm.org/D101139

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


[PATCH] D103314: [Analyzer][solver] Simplify existing constraints when a new constraint is added

2021-06-09 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 350898.
martong added a comment.

- Simplify the symbol before eq tracking as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103314

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/find-binop-constraints.cpp

Index: clang/test/Analysis/find-binop-constraints.cpp
===
--- /dev/null
+++ clang/test/Analysis/find-binop-constraints.cpp
@@ -0,0 +1,163 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -verify
+
+void clang_analyzer_eval(bool);
+void clang_analyzer_warnIfReached();
+
+int test_legacy_behavior(int x, int y) {
+  if (y != 0)
+return 0;
+  if (x + y != 0)
+return 0;
+  clang_analyzer_eval(x + y == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+  return y / (x + y);  // expected-warning{{Division by zero}}
+}
+
+int test_rhs_further_constrained(int x, int y) {
+  if (x + y != 0)
+return 0;
+  if (y != 0)
+return 0;
+  clang_analyzer_eval(x + y == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+  return 0;
+}
+
+int test_lhs_further_constrained(int x, int y) {
+  if (x + y != 0)
+return 0;
+  if (x != 0)
+return 0;
+  clang_analyzer_eval(x + y == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(x == 0); // expected-warning{{TRUE}}
+  return 0;
+}
+
+int test_lhs_and_rhs_further_constrained(int x, int y) {
+  if (x % y != 1)
+return 0;
+  if (x != 1)
+return 0;
+  if (y != 2)
+return 0;
+  clang_analyzer_eval(x % y == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(y == 2); // expected-warning{{TRUE}}
+  return 0;
+}
+
+int test_commutativity(int x, int y) {
+  if (x + y != 0)
+return 0;
+  if (y != 0)
+return 0;
+  clang_analyzer_eval(y + x == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+  return 0;
+}
+
+int test_binop_when_height_is_2_r(int a, int x, int y, int z) {
+  switch (a) {
+  case 1: {
+if (x + y + z != 0)
+  return 0;
+if (z != 0)
+  return 0;
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(z == 0); // expected-warning{{TRUE}}
+break;
+  }
+  case 2: {
+if (x + y + z != 0)
+  return 0;
+if (y != 0)
+  return 0;
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+break;
+  }
+  case 3: {
+if (x + y + z != 0)
+  return 0;
+if (x != 0)
+  return 0;
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(x == 0); // expected-warning{{TRUE}}
+break;
+  }
+  case 4: {
+if (x + y + z != 0)
+  return 0;
+if (x + y != 0)
+  return 0;
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(x + y == 0); // expected-warning{{TRUE}}
+break;
+  }
+  case 5: {
+if (z != 0)
+  return 0;
+if (x + y + z != 0)
+  return 0;
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+if (y != 0)
+  return 0;
+clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+break;
+  }
+
+  }
+  return 0;
+}
+
+void test_equivalence_classes_are_updated(int a, int b, int c, int d) {
+  if (a + b != c)
+return;
+  if (a != d)
+return;
+  if (b != 0)
+return;
+  clang_analyzer_eval(c == d); // expected-warning{{TRUE}}
+  // Keep the symbols and the constraints! alive.
+  (void)(a * b * c * d);
+  return;
+}
+
+void test_contradiction(int a, int b, int c, int d) {
+  if (a + b != c)
+return;
+  if (a == c)
+return;
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+
+  // Bring in the contradiction.
+  if (b != 0)
+return;
+  clang_analyzer_warnIfReached(); // no-warning, i.e. UNREACHABLE
+  // Keep the symbols and the constraints! alive.
+  (void)(a * b * c * d);
+  return;
+}
+
+void test_deferred_contradiction(int e0, int b0, int b1) {
+
+  int e1 = e0 - b0; // e1 is bound to (reg_$0) - (reg_$1)
+  (void)(b0 == 2);
+
+  int e2 = e1 - b1;
+  if (e2 > 0) { // b1 != e1
+clang_analyzer_warnIfReached();   // expected-warning{{REACHABLE}}
+// Here, e1 is still bound to (reg_$0) - (reg_$1) but we
+// should be able to simplify it to (reg_$0) - 2 and thus realize
+// the contradiction.
+if (b1 == e1) {
+ 

[PATCH] D103314: [Analyzer][solver] Simplify existing constraints when a new constraint is added

2021-06-09 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D103314#2798968 , @martong wrote:

> In D103314#2790868 , @vsavchenko 
> wrote:
>
>> Awesome!
>> I know, I said that we are ready to land, but I think I was too excited 
>> about this change. We probably should have some data on how it performs on 
>> real-life codebases.
>
> Just some quick update on the status of this patch. I've done some 
> measurements on smaller open source C projects (e.g tmux) and didn't see any 
> noticeable slow-down. However, I've run into a bad-bad assertion failure in 
> my favorite Checker (StdLibraryFu...). The assertion indicates that neither 
> !State nor State is feasible, so this throws me back to the debugger for a 
> while.

Finally, I could boil down the infeasible parent state problem and added a test 
case `test_deferred_contradiction` to catch that. The solution is surprisingly 
simple: just try to simplify the symbolic expression of an equivalency before 
we start to update the State with the equivalency info.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103314

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


[PATCH] D101237: [lldb] Fix [[no_unique_address]] and libstdc++ 11's std::unique_ptr

2021-06-09 Thread Jan Kratochvil via Phabricator via cfe-commits
jankratochvil updated this revision to Diff 350900.
jankratochvil edited the summary of this revision.
jankratochvil added a comment.

This patch now requires: D101236 , D103910 
 and D103966 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101237

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
  lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/test/Shell/Expr/no_unique_address.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp

Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1603,12 +1603,16 @@
   } else {
 addUInt(MemberDie, dwarf::DW_AT_data_bit_offset, None, Offset);
   }
+  assert(!(DT->getFlags() & DINode::FlagIsZeroSize) &&
+ "bitfields cannot have [[no_unique_address]]");
 } else {
   // This is not a bitfield.
   OffsetInBytes = DT->getOffsetInBits() / 8;
   if (AlignInBytes)
 addUInt(MemberDie, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
 AlignInBytes);
+  if (DT->getFlags() & DINode::FlagIsZeroSize)
+addUInt(MemberDie, dwarf::DW_AT_byte_size, None, 0);
 }
 
 if (DD->getDwarfVersion() <= 2) {
Index: lldb/test/Shell/Expr/no_unique_address.cpp
===
--- /dev/null
+++ lldb/test/Shell/Expr/no_unique_address.cpp
@@ -0,0 +1,15 @@
+// Test LLDB does not assert on miscalculated field offsets.
+
+// RUN: %clang_host %s -g -c -o %t.o
+// RUN: %lldb %t.o -o "p c.c" -o exit | FileCheck %s
+
+// CHECK: (lldb) p c.c
+// CHECK-NEXT: (char) $0 = '\0'
+
+struct A {};
+struct B {
+  [[no_unique_address]] A a;
+};
+struct C : B {
+  char c;
+} c;
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -843,11 +843,10 @@
CompilerType *child_type = nullptr);
 
   // Modifying RecordType
-  static clang::FieldDecl *AddFieldToRecordType(const CompilerType &type,
-llvm::StringRef name,
-const CompilerType &field_type,
-lldb::AccessType access,
-uint32_t bitfield_bit_size);
+  static clang::FieldDecl *
+  AddFieldToRecordType(const CompilerType &type, llvm::StringRef name,
+   const CompilerType &field_type, lldb::AccessType access,
+   uint32_t bitfield_bit_size, bool IsZeroSize = false);
 
   static void BuildIndirectFields(const CompilerType &type);
 
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7164,7 +7164,7 @@
 clang::FieldDecl *TypeSystemClang::AddFieldToRecordType(
 const CompilerType &type, llvm::StringRef name,
 const CompilerType &field_clang_type, AccessType access,
-uint32_t bitfield_bit_size) {
+uint32_t bitfield_bit_size, bool IsZeroSize) {
   if (!type.IsValid() || !field_clang_type.IsValid())
 return nullptr;
   TypeSystemClang *ast =
@@ -7196,6 +7196,8 @@
 if (bit_width)
   field->setBitWidth(bit_width);
 SetMemberOwningModule(field, record_decl);
+if (IsZeroSize)
+  field->addAttr(NoUniqueAddressAttr::CreateImplicit(ast->getASTContext()));
 
 if (name.empty()) {
   // Determine whether this field corresponds to an anonymous struct or
Index: lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
===
--- lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -1264,8 +1264,10 @@
   if (location_type == PDB_LocType::ThisRel)
 bit_size *= 8;
 
+  bool IsZeroSize = false; // FIXME: Is there [[no_unique_address]] in PDB?
   auto decl = TypeSystemClang::AddFieldToRecordType(
-  record_type, member_name.c_str(), member_comp_type, access, bit_size);
+  record_type, member_name.c_str()

[PATCH] D103967: [Analyzer][solver] Add dump methods for (dis)equality classes.

2021-06-09 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: vsavchenko, NoQ, steakhal.
Herald added subscribers: manas, ASDenysPetrov, gamesh411, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, 
xazax.hun, whisperity.
Herald added a reviewer: Szelethus.
martong requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This proved to be very useful during debugging.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103967

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp


Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -584,6 +584,11 @@
   LLVM_NODISCARD static inline Optional
   areEqual(ProgramStateRef State, SymbolRef First, SymbolRef Second);
 
+  void dumpToStream(ProgramStateRef State, raw_ostream &os) const;
+  LLVM_DUMP_METHOD void dump(ProgramStateRef State) const {
+dumpToStream(State, llvm::errs());
+  }
+
   /// Check equivalence data for consistency.
   LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED static bool
   isClassDataConsistent(ProgramStateRef State);
@@ -644,6 +649,46 @@
 // Constraint functions
 
//===--===//
 
+/// Dump all equivalence classes.
+LLVM_DUMP_METHOD static void dumpEqToStream(ProgramStateRef State,
+raw_ostream &os) {
+  ClassMembersTy Members = State->get();
+  for (std::pair ClassToSymbolSet : Members) {
+EquivalenceClass Class = ClassToSymbolSet.first;
+Class.dumpToStream(State, os);
+os << "\n";
+  }
+}
+LLVM_DUMP_METHOD static void dumpEq(ProgramStateRef State) {
+  dumpEqToStream(State, llvm::errs());
+}
+
+/// Dump all equivalence classes along with their disequivalent classes if they
+/// have any.
+LLVM_DUMP_METHOD static void dumpDisEqToStream(ProgramStateRef State,
+   raw_ostream &os) {
+  DisequalityMapTy Disequalities = State->get();
+  for (std::pair ClassToDisEqSet : Disequalities) {
+EquivalenceClass Class = ClassToDisEqSet.first;
+Class.dumpToStream(State, os);
+ClassSet DisequalClasses = ClassToDisEqSet.second;
+if (!DisequalClasses.isEmpty()) {
+  for (EquivalenceClass DisEqClass : DisequalClasses) {
+os << "DisequalTo:\n";
+DisEqClass.dumpToStream(State, os);
+  }
+}
+os << "\n";
+  }
+}
+LLVM_DUMP_METHOD static void dumpDisEq(ProgramStateRef State) {
+  dumpDisEqToStream(State, llvm::errs());
+}
+
+//===--===//
+// Constraint functions
+//===--===//
+
 LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED bool
 areFeasible(ConstraintRangeTy Constraints) {
   return llvm::none_of(
@@ -1589,6 +1634,15 @@
 // EqualityClass implementation details
 
//===--===//
 
+LLVM_DUMP_METHOD void EquivalenceClass::dumpToStream(ProgramStateRef State,
+ raw_ostream &os) const {
+  SymbolSet ClassMembers = getClassMembers(State);
+  for (const SymbolRef &MemberSym : ClassMembers) {
+MemberSym->dump();
+os << "\n";
+  }
+}
+
 inline EquivalenceClass EquivalenceClass::find(ProgramStateRef State,
SymbolRef Sym) {
   // We store far from all Symbol -> Class mappings


Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -584,6 +584,11 @@
   LLVM_NODISCARD static inline Optional
   areEqual(ProgramStateRef State, SymbolRef First, SymbolRef Second);
 
+  void dumpToStream(ProgramStateRef State, raw_ostream &os) const;
+  LLVM_DUMP_METHOD void dump(ProgramStateRef State) const {
+dumpToStream(State, llvm::errs());
+  }
+
   /// Check equivalence data for consistency.
   LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED static bool
   isClassDataConsistent(ProgramStateRef State);
@@ -644,6 +649,46 @@
 // Constraint functions
 //===--===//
 
+/// Dump all equivalence classes.
+LLVM_DUMP_METHOD static void dumpEqToStream(ProgramStateRef State,
+raw_ostream &os) {
+  ClassMembersTy Members = State->get();
+  for (std::pair ClassToSymbolSet : Members) {
+EquivalenceClass Class = ClassToSymbolSet.first;
+Class.dumpToStream(State, os);
+o

[PATCH] D103967: [Analyzer][solver] Add dump methods for (dis)equality classes.

2021-06-09 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 350905.
martong added a comment.

- Change comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103967

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp


Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -584,6 +584,11 @@
   LLVM_NODISCARD static inline Optional
   areEqual(ProgramStateRef State, SymbolRef First, SymbolRef Second);
 
+  void dumpToStream(ProgramStateRef State, raw_ostream &os) const;
+  LLVM_DUMP_METHOD void dump(ProgramStateRef State) const {
+dumpToStream(State, llvm::errs());
+  }
+
   /// Check equivalence data for consistency.
   LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED static bool
   isClassDataConsistent(ProgramStateRef State);
@@ -640,6 +645,46 @@
   uintptr_t ID;
 };
 
+//===--===//
+// Dump functions
+//===--===//
+
+/// Dump all equivalence classes.
+LLVM_DUMP_METHOD static void dumpEqToStream(ProgramStateRef State,
+raw_ostream &os) {
+  ClassMembersTy Members = State->get();
+  for (std::pair ClassToSymbolSet : Members) {
+EquivalenceClass Class = ClassToSymbolSet.first;
+Class.dumpToStream(State, os);
+os << "\n";
+  }
+}
+LLVM_DUMP_METHOD static void dumpEq(ProgramStateRef State) {
+  dumpEqToStream(State, llvm::errs());
+}
+
+/// Dump all equivalence classes along with their disequivalent classes if they
+/// have any.
+LLVM_DUMP_METHOD static void dumpDisEqToStream(ProgramStateRef State,
+   raw_ostream &os) {
+  DisequalityMapTy Disequalities = State->get();
+  for (std::pair ClassToDisEqSet : Disequalities) {
+EquivalenceClass Class = ClassToDisEqSet.first;
+Class.dumpToStream(State, os);
+ClassSet DisequalClasses = ClassToDisEqSet.second;
+if (!DisequalClasses.isEmpty()) {
+  for (EquivalenceClass DisEqClass : DisequalClasses) {
+os << "DisequalTo:\n";
+DisEqClass.dumpToStream(State, os);
+  }
+}
+os << "\n";
+  }
+}
+LLVM_DUMP_METHOD static void dumpDisEq(ProgramStateRef State) {
+  dumpDisEqToStream(State, llvm::errs());
+}
+
 
//===--===//
 // Constraint functions
 
//===--===//
@@ -1589,6 +1634,15 @@
 // EqualityClass implementation details
 
//===--===//
 
+LLVM_DUMP_METHOD void EquivalenceClass::dumpToStream(ProgramStateRef State,
+ raw_ostream &os) const {
+  SymbolSet ClassMembers = getClassMembers(State);
+  for (const SymbolRef &MemberSym : ClassMembers) {
+MemberSym->dump();
+os << "\n";
+  }
+}
+
 inline EquivalenceClass EquivalenceClass::find(ProgramStateRef State,
SymbolRef Sym) {
   // We store far from all Symbol -> Class mappings


Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -584,6 +584,11 @@
   LLVM_NODISCARD static inline Optional
   areEqual(ProgramStateRef State, SymbolRef First, SymbolRef Second);
 
+  void dumpToStream(ProgramStateRef State, raw_ostream &os) const;
+  LLVM_DUMP_METHOD void dump(ProgramStateRef State) const {
+dumpToStream(State, llvm::errs());
+  }
+
   /// Check equivalence data for consistency.
   LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED static bool
   isClassDataConsistent(ProgramStateRef State);
@@ -640,6 +645,46 @@
   uintptr_t ID;
 };
 
+//===--===//
+// Dump functions
+//===--===//
+
+/// Dump all equivalence classes.
+LLVM_DUMP_METHOD static void dumpEqToStream(ProgramStateRef State,
+raw_ostream &os) {
+  ClassMembersTy Members = State->get();
+  for (std::pair ClassToSymbolSet : Members) {
+EquivalenceClass Class = ClassToSymbolSet.first;
+Class.dumpToStream(State, os);
+os << "\n";
+  }
+}
+LLVM_DUMP_METHOD static void dumpEq(ProgramStateRef State) {
+  dumpEqToStream(State, llvm::errs());
+}
+
+/// Dump all equivalence classes along with their disequivalent classes if they
+/// have any.
+L

[PATCH] D102782: Add support for Warning Flag "-Wstack-usage="

2021-06-09 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic added a comment.

@bruno all tests are passing, could you take another look when you have a 
chance?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102782

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


[PATCH] D103792: [clang][AST] Set correct DeclContext in ASTImporter lookup table for template params.

2021-06-09 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 350906.
balazske added a comment.

Add test for deduction guides.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103792

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -4368,6 +4368,247 @@
   EXPECT_EQ(ToD->getNumTemplateParameterLists(), 1u);
 }
 
+const internal::VariadicDynCastAllOfMatcher
+varTemplateDecl;
+
+const internal::VariadicDynCastAllOfMatcher<
+Decl, VarTemplatePartialSpecializationDecl>
+varTemplatePartialSpecializationDecl;
+
+TEST_P(ASTImporterOptionSpecificTestBase,
+   FunctionTemplateParameterDeclContext) {
+  constexpr auto Code =
+  R"(
+  template
+  void f() {};
+  )";
+
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU, functionTemplateDecl(hasName("f")));
+
+  ASSERT_EQ(FromD->getTemplateParameters()->getParam(0)->getDeclContext(),
+FromD->getTemplatedDecl());
+
+  auto *ToD = Import(FromD, Lang_CXX11);
+  EXPECT_EQ(ToD->getTemplateParameters()->getParam(0)->getDeclContext(),
+ToD->getTemplatedDecl());
+  EXPECT_TRUE(SharedStatePtr->getLookupTable()->contains(
+  ToD->getTemplatedDecl(), ToD->getTemplateParameters()->getParam(0)));
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase, ClassTemplateParameterDeclContext) {
+  constexpr auto Code =
+  R"(
+  template
+  struct S {};
+  template
+  struct S {};
+  )";
+
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+
+  auto *FromD = FirstDeclMatcher().match(
+  FromTU, classTemplateDecl(hasName("S")));
+  auto *FromDPart =
+  FirstDeclMatcher().match(
+  FromTU, classTemplatePartialSpecializationDecl(hasName("S")));
+
+  ASSERT_EQ(FromD->getTemplateParameters()->getParam(0)->getDeclContext(),
+FromD->getTemplatedDecl());
+  ASSERT_EQ(FromDPart->getTemplateParameters()->getParam(0)->getDeclContext(),
+FromDPart);
+
+  auto *ToD = Import(FromD, Lang_CXX11);
+  auto *ToDPart = Import(FromDPart, Lang_CXX11);
+
+  EXPECT_EQ(ToD->getTemplateParameters()->getParam(0)->getDeclContext(),
+ToD->getTemplatedDecl());
+  EXPECT_TRUE(SharedStatePtr->getLookupTable()->contains(
+  ToD->getTemplatedDecl(), ToD->getTemplateParameters()->getParam(0)));
+
+  EXPECT_EQ(ToDPart->getTemplateParameters()->getParam(0)->getDeclContext(),
+ToDPart);
+  EXPECT_TRUE(SharedStatePtr->getLookupTable()->contains(
+  ToDPart, ToDPart->getTemplateParameters()->getParam(0)));
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase,
+   CXXDeductionGuideTemplateParameterDeclContext) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  template  struct A {
+A(T);
+  };
+  A a{(int)0};
+  )",
+  Lang_CXX17, "input.cc");
+  /*
+  |-ClassTemplateDecl 0x13f2dd0  line:2:36 A
+  | |-TemplateTypeParmDecl 0x13f2c80  col:26 referenced typename
+  depth 0 index 0 T
+
+  |-FunctionTemplateDecl 0x13f3630  col:9 implicit
+   | |-TemplateTypeParmDecl 0x13f2c80 
+  col:26 referenced typename depth 0 index 0 T | |-CXXDeductionGuideDecl
+  0x13f3578  col:9 implicit  'auto (T)
+  -> A' | | `-ParmVarDecl 0x13f3480  col:12 'T' |
+  `-CXXDeductionGuideDecl 0x14548e8  col:9 implicit used
+   'auto (int) -> A' |   |-TemplateArgument type
+  'int' |   | `-BuiltinType 0x13de020 'int' |   `-ParmVarDecl 0x1454698 
+  col:12 'int':'int'
+  `-FunctionTemplateDecl 0x13f3848  col:36 implicit 
+|-TemplateTypeParmDecl 0x13f2c80  col:26 referenced typename
+  depth 0 index 0 T
+`-CXXDeductionGuideDecl 0x13f3790  col:36 implicit  'auto (A) -> A'
+  `-ParmVarDecl 0x13f3728  col:36 'A'
+  */
+  auto *FromD1 = FirstDeclMatcher().match(
+  FromTU, cxxDeductionGuideDecl());
+  auto *FromD2 = LastDeclMatcher().match(
+  FromTU, cxxDeductionGuideDecl());
+
+  NamedDecl *P1 =
+  FromD1->getDescribedFunctionTemplate()->getTemplateParameters()->getParam(
+  0);
+  NamedDecl *P2 =
+  FromD2->getDescribedFunctionTemplate()->getTemplateParameters()->getParam(
+  0);
+  DeclContext *DC = P1->getDeclContext();
+
+  ASSERT_EQ(P1, P2);
+  ASSERT_TRUE(DC == FromD1 || DC == FromD2);
+
+  auto *ToD1 = Import(FromD1, Lang_CXX17);
+  auto *ToD2 = Import(FromD2, Lang_CXX17);
+  ASSERT_TRUE(ToD1 && ToD2);
+
+  P1 = ToD1->getDescribedFunctionTemplate()->getTemplateParameters()->getParam(
+  0);
+  P2 = ToD2->getDescribedFunctionTemplate()->getTemplateParameters()->getParam(
+  0);
+  DC = P1->getDeclContext();
+
+  EXPECT_EQ(P1, P2);
+  EXPECT_TRUE(DC == ToD1 || DC == ToD2);
+
+  ASTImporterLookupTable *Tbl = SharedStatePtr->getLookupTable();
+  if (Tbl->contains(ToD1, P1)) {
+EXPECT_FALSE(Tbl->c

[PATCH] D90835: [clang-tidy] Ignore diagnostics due to macro expansion from not-interested headers

2021-06-09 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

This needs to explain why the existing functionality isn't sufficient - if the 
header is really not from this project,
then it should be included via `-isystem`, and that will naturally suppress all 
diagnostics from it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90835

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


[PATCH] D103792: [clang][AST] Set correct DeclContext in ASTImporter lookup table for template params.

2021-06-09 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked an inline comment as done.
balazske added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:6005
 
+  // Template parameters for a CXXDeductionGuideDecl are re-used by the
+  // non-deduction-guide-decl template. That template is imported too, and

shafik wrote:
> Is this case covered in the tests?
This test was left out but added now. But test `CTADImplicit` does fail if the 
import of `FunctionTemplateDecl` is handled similarly as the other cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103792

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


[PATCH] D103792: [clang][AST] Set correct DeclContext in ASTImporter lookup table for template params.

2021-06-09 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked an inline comment as done.
balazske added inline comments.



Comment at: clang/unittests/AST/ASTImporterTest.cpp:4468
+  `-ParmVarDecl 0x13f3728  col:36 'A'
+  */
+  auto *FromD1 = FirstDeclMatcher().match(

This should not have been reformatted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103792

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


[PATCH] D103911: [OpenCL] Add support of __opencl_c_images feature macro

2021-06-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/test/SemaOpenCL/unsupported-image.cl:1
+// RUN: %clang_cc1 -verify -cl-std=CL3.0 -cl-ext=-__opencl_c_images %s
+// RUN: %clang_cc1 -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images %s

azabaznov wrote:
> Anastasia wrote:
> > svenvh wrote:
> > > Should we add `-triple spir`, as some of the image types (e.g. msaa) are 
> > > part of an extension that may not be available for every default triple?
> > yes, the test might fail in some bots otherwise...
> > 
> > 
> > Btw it would be good to test that 3d images work correctly for OpenCL 3. 
> > Would it work if we add `RUN` line with `CL3.0` into 
> > `test/SemaOpenCL/access-qualifier.cl` or are we missing some more work to 
> > enable the test?
> > Should we add -triple spir, as some of the image types (e.g. msaa) are part 
> > of an extension that may not be available for every default triple?
> 
> > yes, the test might fail in some bots otherwise...
> 
> Yes, that's correct. Thanks. Now it works locally because the default triple 
> I have is x86 which supports all the extensions as well as SPIR.
> 
> > Btw it would be good to test that 3d images work correctly for OpenCL 3. 
> > Would it work if we add RUN line with CL3.0 into 
> > test/SemaOpenCL/access-qualifier.cl or are we missing some more work to 
> > enable the test?
> 
> Yeah, to properly test 3d images actually we need to add `__opencl_c_images` 
> support first, because `__opencl_c_3d_image_writes` depends on it
Ok, I see. This can go to separate commits then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103911

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


[PATCH] D90835: [clang-tidy] Ignore diagnostics due to macro expansion from not-interested headers

2021-06-09 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

In D90835#2808153 , @lebedev.ri wrote:

> This needs to explain why the existing functionality isn't sufficient - if 
> the header is really not from this project,
> then it should be included via `-isystem`, and that will naturally suppress 
> all diagnostics from it.

The diagnostics are reported in the place of macro expansion i.e. user sources. 
It doesn't matter how they get included via -isystem or -I.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90835

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


[PATCH] D102782: Add support for Warning Flag "-Wstack-usage="

2021-06-09 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:79-80
 
+- ``-Wstack-usage=`` warn if stack usage of user functions might
+  exceed .
+

Does this mean:
- Warn if the size of any single function's stack frame (including temporaries 
and local variables, but not parameters or return addresses) exceeds 
.
- Warn if the size of any single function's stack frame (including parameters 
and return addresses) exceeds .
- Warn if the total stack usage of the longest visible call chain in this 
translation unit might exceed .
?




Comment at: clang/test/Frontend/backend-stack-usage-diagnostic.c:19-23
+// WARN: warning: stack frame size of {{[0-9]+}} bytes in function 
'test_square'
+// IGNORE-NOT:  stack frame size of {{[0-9]+}} bytes in function 'test_square'
+int test_square(int num) {
+  return num * num;
+}

This function has no "stack frame" in the usual sense of the word, because it's 
just
```
movl%edi, %eax
imull   %edi, %eax
ret
```
So am I correct to infer that the `-Wstack-usage=` option includes the size of 
the return address in its computations? So the stack usage of this function 
would be computed as "8 bytes" because the `callq` instruction pushes 8 bytes 
on the stack?
This seems eminently reasonable to me, but non-obvious, and should get some 
user-facing documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102782

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


[PATCH] D101868: [clang-format] Adds a formatter for aligning arrays of structs

2021-06-09 Thread Fred Grim via Phabricator via cfe-commits
feg208 updated this revision to Diff 350910.
feg208 marked 4 inline comments as done.
feg208 added a comment.

Gets some of the formatting issues. Still chasing a test issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101868

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/TokenAnnotator.h
  clang/lib/Format/WhitespaceManager.cpp
  clang/lib/Format/WhitespaceManager.h
  clang/test/Format/struct-array-initializer-left.cpp
  clang/test/Format/struct-array-initializer-right.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -16602,6 +16602,407 @@
getLLVMStyle());
 }
 
+TEST_F(FormatTest, CatchAlignArrayOfStructuresRightAlignment) {
+  auto Style = getLLVMStyle();
+  Style.AlignArrayOfStructures = FormatStyle::AIAS_Right;
+  Style.AlignConsecutiveAssignments =
+  FormatStyle::AlignConsecutiveStyle::ACS_Consecutive;
+  Style.AlignConsecutiveDeclarations =
+  FormatStyle::AlignConsecutiveStyle::ACS_Consecutive;
+  verifyFormat("struct test demo[] = {\n"
+   "{56,23, \"hello\"},\n"
+   "{-1, 93463, \"world\"},\n"
+   "{ 7, 5,\"!!\"}\n"
+   "};\n",
+   Style);
+
+  verifyFormat("struct test demo[] = {\n"
+   "{56,23, \"hello\"}, // first line\n"
+   "{-1, 93463, \"world\"}, // second line\n"
+   "{ 7, 5,\"!!\"}  // third line\n"
+   "};\n",
+   Style);
+
+  verifyFormat("struct test demo[4] = {\n"
+   "{ 56,23, 21,   \"oh\"}, // first line\n"
+   "{ -1, 93463, 22,   \"my\"}, // second line\n"
+   "{  7, 5,  1, \"goodness\"}  // third line\n"
+   "{234, 5,  1, \"gracious\"}  // fourth line\n"
+   "};\n",
+   Style);
+
+  verifyFormat("struct test demo[3] = {\n"
+   "{56,23, \"hello\"},\n"
+   "{-1, 93463, \"world\"},\n"
+   "{ 7, 5,\"!!\"}\n"
+   "};\n",
+   Style);
+
+  verifyFormat("struct test demo[3] = {\n"
+   "{int{56},23, \"hello\"},\n"
+   "{int{-1}, 93463, \"world\"},\n"
+   "{ int{7}, 5,\"!!\"}\n"
+   "};\n",
+   Style);
+
+  verifyFormat("struct test demo[] = {\n"
+   "{56,23, \"hello\"},\n"
+   "{-1, 93463, \"world\"},\n"
+   "{ 7, 5,\"!!\"},\n"
+   "};\n",
+   Style);
+
+  verifyFormat("test demo[] = {\n"
+   "{56,23, \"hello\"},\n"
+   "{-1, 93463, \"world\"},\n"
+   "{ 7, 5,\"!!\"},\n"
+   "};\n",
+   Style);
+
+  verifyFormat("demo = std::array{\n"
+   "test{56,23, \"hello\"},\n"
+   "test{-1, 93463, \"world\"},\n"
+   "test{ 7, 5,\"!!\"},\n"
+   "};\n",
+   Style);
+
+  verifyFormat("test demo[] = {\n"
+   "{56,23, \"hello\"},\n"
+   "#if X\n"
+   "{-1, 93463, \"world\"},\n"
+   "#endif\n"
+   "{ 7, 5,\"!!\"}\n"
+   "};\n",
+   Style);
+
+  verifyFormat(
+  "test demo[] = {\n"
+  "{ 7,23,\n"
+  " \"hello world i am a very long line that really, in any\"\n"
+  " \"just world, ought to be split over multiple lines\"},\n"
+  "{-1, 93463,  \"world\"},\n"
+  "{56, 5, \"!!\"}\n"
+  "};\n",
+  Style);
+
+  verifyFormat("return GradForUnaryCwise(g, {\n"
+   "{{\"sign\"}, \"Sign\",  "
+   "  {\"x\", \"dy\"}},\n"
+   "{  {\"dx\"},  \"Mul\", {\"dy\""
+   ", \"sign\"}},\n"
+   "});\n",
+   Style);
+
+  Style.ColumnLimit = 0;
+  EXPECT_EQ(
+  "test demo[] = {\n"
+  "{56,23, \"hello world i am a very long line that really, "
+  "in any just world, ought to be split over multiple lines\"},\n"
+  "{-1, 93463,  "
+  " \"world\"},\n"
+  "{ 7, 5,  "
+  " 

[PATCH] D101868: [clang-format] Adds a formatter for aligning arrays of structs

2021-06-09 Thread Fred Grim via Phabricator via cfe-commits
feg208 added a comment.

Got some changes. The failing test is an open issue




Comment at: clang/docs/ClangFormatStyleOptions.rst:216-221
+struct test demo[] =
+{
+{56,23, "hello"},
+{-1, 93463, "world"},
+{ 7, 5,"!!"}
+};

curdeius wrote:
> Don't forget to re-generate .rst.
I am sorry. I am not entirely sure what to check here? Should I regenerate the 
docs for the site and just ensure that they look ok?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101868

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


[PATCH] D103314: [Analyzer][solver] Simplify existing constraints when a new constraint is added

2021-06-09 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

OK, we definitely need to know about performance.
Plus, I'm still curious about the crash.  I didn't get how simplification 
helped/caused that crash.

I have one thought here. If the lack of simplification indeed caused the crash, 
we are in trouble with this patch.  IMO simplification in just one place should 
make it better, but shouldn't produce infeasible states for us.  In other 
words, any number simplifications is a conservative operation that makes our 
lives a bit better.  The moment they become a requirement (i.e. simplifications 
call for more simplifications or we crash) this solution from this patch has to 
become much harder.  This is because whenever we do `merge`, we essentially can 
create another situation when we find out that some symbolic expression is a 
constant.  Let's say that we are merging classes `A` and `B` which have 
constraints `[INT_MIN, 42]` and `[42, INT_MAX]`.  After the merge, we are 
positive that all the members of this new class are equal to 42.  And if so, we 
can further simplify classes and their members.  This algorithm turns into a 
fixed point algorithm, which has a good chance to sabotage our performance.

This being said, can we re-iterate on that crash and the proposed fix in much 
more detail?




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1789
+  if (DisequalToOther.contains(*this))
+return nullptr;
   if (!DisequalToOther.isEmpty()) {

very opinionated nit: can you please add extra new line after this?



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1976-1986
+  Optional KnownClassEquality =
+  isEqualTo(State, ClassOfSimplifiedSym);
+  if (KnownClassEquality) {
+// The classes are already equal, there is no need to merge.
+if (*KnownClassEquality == true)
+  continue;
+// We are about to add the newly simplified symbol to this equivalence

Now, since you put this logic into `merge`, you can just merge.



Comment at: clang/test/Analysis/find-binop-constraints.cpp:150
+  int e1 = e0 - b0; // e1 is bound to (reg_$0) - (reg_$1)
+  (void)(b0 == 2);
+

It's not really connected to your patch, but this confuses me!  Why does the 
analyzer think that `b0` is guaranteed to be 2 after this statement.  Even if 
we eagerly assume here, shouldn't it mean that there are still two paths `b0 == 
2` and `b0 != 2`?



Comment at: clang/test/Analysis/find-binop-constraints.cpp:155-158
+// Here, e1 is still bound to (reg_$0) - (reg_$1) but we
+// should be able to simplify it to (reg_$0) - 2 and thus realize
+// the contradiction.
+if (b1 == e1) {

Hmm, I don't see how simplification helped here.

After the previous `if` statement, we should have had two equivalence classes 
known to be disequal: `reg_$2` and `(reg_$0) - (reg_$1)`.
Further, we directly compare these two symbols.  We can figure it out without 
any simplifications.

Am I missing something here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103314

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


[PATCH] D99675: [llvm][clang] Create new intrinsic llvm.arithmetic.fence to control FP optimization at expression level

2021-06-09 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 350912.
mibintc retitled this revision from "[llvm][clang] Create new intrinsic 
llvm.arith.fence to control FP optimization at expression level" to 
"[llvm][clang] Create new intrinsic llvm.arithmetic.fence to control FP 
optimization at expression level".
mibintc added a comment.

Correct small formatting issue in LangRef.rst thanks @pengfei


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99675

Files:
  llvm/docs/LangRef.rst
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/SelectionDAGISel.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Support/TargetOpcodes.def
  llvm/include/llvm/Target/Target.td
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/test/CodeGen/X86/arithmetic_fence.ll
  llvm/test/CodeGen/X86/arithmetic_fence2.ll

Index: llvm/test/CodeGen/X86/arithmetic_fence2.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/arithmetic_fence2.ll
@@ -0,0 +1,170 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X64
+
+define double @f1(double %a) {
+; X86-LABEL: f1:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:movsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:mulsd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
+; X86-NEXT:movsd %xmm0, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f1:
+; X64:   # %bb.0:
+; X64-NEXT:mulsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %a
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %1, %2
+  ret double %3
+}
+
+define double @f2(double %a) {
+; X86-LABEL: f2:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebp
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:.cfi_offset %ebp, -8
+; X86-NEXT:movl %esp, %ebp
+; X86-NEXT:.cfi_def_cfa_register %ebp
+; X86-NEXT:andl $-8, %esp
+; X86-NEXT:subl $8, %esp
+; X86-NEXT:movsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT:addsd %xmm0, %xmm0
+; X86-NEXT:movapd %xmm0, %xmm1
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:addsd %xmm0, %xmm1
+; X86-NEXT:movsd %xmm1, (%esp)
+; X86-NEXT:fldl (%esp)
+; X86-NEXT:movl %ebp, %esp
+; X86-NEXT:popl %ebp
+; X86-NEXT:.cfi_def_cfa %esp, 4
+; X86-NEXT:retl
+;
+; X64-LABEL: f2:
+; X64:   # %bb.0:
+; X64-NEXT:addsd %xmm0, %xmm0
+; X64-NEXT:movapd %xmm0, %xmm1
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:addsd %xmm0, %xmm1
+; X64-NEXT:movapd %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast double %a, %a
+  %t = call double @llvm.arithmetic.fence.f64(double %1)
+  %2 = fadd fast double %a, %a
+  %3 = fadd fast double %t, %2
+  ret double %3
+}
+
+define <2 x float> @f3(<2 x float> %a) {
+; X86-LABEL: f3:
+; X86:   # %bb.0:
+; X86-NEXT:mulps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
+; X86-NEXT:retl
+;
+; X64-LABEL: f3:
+; X64:   # %bb.0:
+; X64-NEXT:mulps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast <2 x float> %a, %a
+  %2 = fadd fast <2 x float> %a, %a
+  %3 = fadd fast <2 x float> %1, %2
+  ret <2 x float> %3
+}
+
+define <2 x float> @f4(<2 x float> %a) {
+; X86-LABEL: f4:
+; X86:   # %bb.0:
+; X86-NEXT:addps %xmm0, %xmm0
+; X86-NEXT:movaps %xmm0, %xmm1
+; X86-NEXT:#ARITH_FENCE
+; X86-NEXT:addps %xmm0, %xmm1
+; X86-NEXT:movaps %xmm1, %xmm0
+; X86-NEXT:retl
+;
+; X64-LABEL: f4:
+; X64:   # %bb.0:
+; X64-NEXT:addps %xmm0, %xmm0
+; X64-NEXT:movaps %xmm0, %xmm1
+; X64-NEXT:#ARITH_FENCE
+; X64-NEXT:addps %xmm0, %xmm1
+; X64-NEXT:movaps %xmm1, %xmm0
+; X64-NEXT:retq
+  %1 = fadd fast <2 x float> %a, %a
+  %t = call <2 x float> @llvm.arithmetic.fence.v2f32(<2 x float> %1)
+  %2 = fadd fast <2 x float> %a, %a
+  %3 = fadd fast <2 x float> %t, %2
+  ret <2 x float> %3
+}
+
+define <8 x float> @f5(<8 x float> %a) {
+; X86-LABEL: f5:
+; X86:   # %bb.0:
+; X86-NEXT:movaps {{.*#+}} xmm2 = [4.0E+0,4.0E+0,4.0E+0,4.0E+0]
+; X86-NEXT:mulps %xmm2, %xmm0
+; X86-NEXT:mulps %xmm2, %xmm1
+; X86-NEXT:retl
+;
+; X64-LABEL: f5:
+; X6

[PATCH] D103495: [static initializers] Emit global_ctors and global_dtors in reverse order when init_array is not used.

2021-06-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a subscriber: probinson.
rnk added a comment.

In D103495#2806097 , @jyknight wrote:

> Won't this change cause weird effects with LTO, when you're merging multiple 
> TUs' global_ctors arrays before emitting? Won't this end up reversing the 
> order of the files, as well as the order of the functions within a single 
> file? That does not seem likely to be expected, right?

True, I think that is an issue, and that probably does affect Sony's actual 
customers. I hear games tend to use regular LTO, so this will in fact reverse 
the order of initialization between object files for those users. The only 
solution I can think of would be to bring the LTO library into the game. It 
must know whether .ctors of .init_array are in use, since it generates code and 
it has to pick the section. To ensure that initialization of objects happens in 
reverse command line order as expected of users of -fno-init-array, the linker 
would join global_ctors in reverse order. That's not elegant. It encodes this 
knowledge in two places instead of one. But it does move in the direction of 
making things more defined, more deterministic, and that seems like a good 
thing.

So, a question for @wolfgangp and @probinson , do we need to make adjustments 
to the LTO library, or is this OK as is?

I think for non-Sony users we can accept the change in initialization order.


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

https://reviews.llvm.org/D103495

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


[clang] 1c7f339 - clang/darwin: use response files with ld64

2021-06-09 Thread Keith Smiley via cfe-commits

Author: Keith Smiley
Date: 2021-06-09T09:04:37-07:00
New Revision: 1c7f3395b8ec52462220898495883ec570390367

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

LOG: clang/darwin: use response files with ld64

This crasher was fixed with Xcode 13.0 beta 1 / ld64 705. This is an
updated revert of https://reviews.llvm.org/D92357

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 5ccd2300afd39..8a0c4721eea0e 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -711,10 +711,7 @@ void darwin::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   }
 
   ResponseFileSupport ResponseSupport;
-  if (LinkerIsLLDDarwinNew) {
-// Xcode12's ld64 added support for @response files, but it's crashy:
-// https://openradar.appspot.com/radar?id=4933317065441280
-// FIXME: Pass this for ld64 once it no longer crashes.
+  if (Version[0] >= 705 || LinkerIsLLDDarwinNew) {
 ResponseSupport = ResponseFileSupport::AtFileUTF8();
   } else {
 // For older versions of the linker, use the legacy filelist method 
instead.



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


[PATCH] D103934: clang/darwin: use response files with ld64

2021-06-09 Thread Keith Smiley 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 rG1c7f3395b8ec: clang/darwin: use response files with ld64 
(authored by keith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103934

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -711,10 +711,7 @@
   }
 
   ResponseFileSupport ResponseSupport;
-  if (LinkerIsLLDDarwinNew) {
-// Xcode12's ld64 added support for @response files, but it's crashy:
-// https://openradar.appspot.com/radar?id=4933317065441280
-// FIXME: Pass this for ld64 once it no longer crashes.
+  if (Version[0] >= 705 || LinkerIsLLDDarwinNew) {
 ResponseSupport = ResponseFileSupport::AtFileUTF8();
   } else {
 // For older versions of the linker, use the legacy filelist method 
instead.


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -711,10 +711,7 @@
   }
 
   ResponseFileSupport ResponseSupport;
-  if (LinkerIsLLDDarwinNew) {
-// Xcode12's ld64 added support for @response files, but it's crashy:
-// https://openradar.appspot.com/radar?id=4933317065441280
-// FIXME: Pass this for ld64 once it no longer crashes.
+  if (Version[0] >= 705 || LinkerIsLLDDarwinNew) {
 ResponseSupport = ResponseFileSupport::AtFileUTF8();
   } else {
 // For older versions of the linker, use the legacy filelist method instead.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103949: Only consider built-in compound assignment operators for -Wunused-but-set-*

2021-06-09 Thread Michael Benfield via Phabricator via cfe-commits
mbenfield added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:7794-7798
+if (BO->getLHS()->getType()->isDependentType() ||
+BO->getRHS()->getType()->isDependentType())
+{
+  if (BO->getOpcode() != BO_Assign)
+return;

Would you mind elaborating on the need for this code? IIUC, you're concerned 
about overloaded operators, but won't such operators always be covered by the 
`CXXOperatorCallExpr` case below? 


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

https://reviews.llvm.org/D103949

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


[PATCH] D101868: [clang-format] Adds a formatter for aligning arrays of structs

2021-06-09 Thread Fred Grim via Phabricator via cfe-commits
feg208 updated this revision to Diff 350920.
feg208 added a comment.

Fixes the busted test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101868

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/TokenAnnotator.h
  clang/lib/Format/WhitespaceManager.cpp
  clang/lib/Format/WhitespaceManager.h
  clang/test/Format/struct-array-initializer.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -16602,6 +16602,407 @@
getLLVMStyle());
 }
 
+TEST_F(FormatTest, CatchAlignArrayOfStructuresRightAlignment) {
+  auto Style = getLLVMStyle();
+  Style.AlignArrayOfStructures = FormatStyle::AIAS_Right;
+  Style.AlignConsecutiveAssignments =
+  FormatStyle::AlignConsecutiveStyle::ACS_Consecutive;
+  Style.AlignConsecutiveDeclarations =
+  FormatStyle::AlignConsecutiveStyle::ACS_Consecutive;
+  verifyFormat("struct test demo[] = {\n"
+   "{56,23, \"hello\"},\n"
+   "{-1, 93463, \"world\"},\n"
+   "{ 7, 5,\"!!\"}\n"
+   "};\n",
+   Style);
+
+  verifyFormat("struct test demo[] = {\n"
+   "{56,23, \"hello\"}, // first line\n"
+   "{-1, 93463, \"world\"}, // second line\n"
+   "{ 7, 5,\"!!\"}  // third line\n"
+   "};\n",
+   Style);
+
+  verifyFormat("struct test demo[4] = {\n"
+   "{ 56,23, 21,   \"oh\"}, // first line\n"
+   "{ -1, 93463, 22,   \"my\"}, // second line\n"
+   "{  7, 5,  1, \"goodness\"}  // third line\n"
+   "{234, 5,  1, \"gracious\"}  // fourth line\n"
+   "};\n",
+   Style);
+
+  verifyFormat("struct test demo[3] = {\n"
+   "{56,23, \"hello\"},\n"
+   "{-1, 93463, \"world\"},\n"
+   "{ 7, 5,\"!!\"}\n"
+   "};\n",
+   Style);
+
+  verifyFormat("struct test demo[3] = {\n"
+   "{int{56},23, \"hello\"},\n"
+   "{int{-1}, 93463, \"world\"},\n"
+   "{ int{7}, 5,\"!!\"}\n"
+   "};\n",
+   Style);
+
+  verifyFormat("struct test demo[] = {\n"
+   "{56,23, \"hello\"},\n"
+   "{-1, 93463, \"world\"},\n"
+   "{ 7, 5,\"!!\"},\n"
+   "};\n",
+   Style);
+
+  verifyFormat("test demo[] = {\n"
+   "{56,23, \"hello\"},\n"
+   "{-1, 93463, \"world\"},\n"
+   "{ 7, 5,\"!!\"},\n"
+   "};\n",
+   Style);
+
+  verifyFormat("demo = std::array{\n"
+   "test{56,23, \"hello\"},\n"
+   "test{-1, 93463, \"world\"},\n"
+   "test{ 7, 5,\"!!\"},\n"
+   "};\n",
+   Style);
+
+  verifyFormat("test demo[] = {\n"
+   "{56,23, \"hello\"},\n"
+   "#if X\n"
+   "{-1, 93463, \"world\"},\n"
+   "#endif\n"
+   "{ 7, 5,\"!!\"}\n"
+   "};\n",
+   Style);
+
+  verifyFormat(
+  "test demo[] = {\n"
+  "{ 7,23,\n"
+  " \"hello world i am a very long line that really, in any\"\n"
+  " \"just world, ought to be split over multiple lines\"},\n"
+  "{-1, 93463,  \"world\"},\n"
+  "{56, 5, \"!!\"}\n"
+  "};\n",
+  Style);
+
+  verifyFormat("return GradForUnaryCwise(g, {\n"
+   "{{\"sign\"}, \"Sign\",  "
+   "  {\"x\", \"dy\"}},\n"
+   "{  {\"dx\"},  \"Mul\", {\"dy\""
+   ", \"sign\"}},\n"
+   "});\n",
+   Style);
+
+  Style.ColumnLimit = 0;
+  EXPECT_EQ(
+  "test demo[] = {\n"
+  "{56,23, \"hello world i am a very long line that really, "
+  "in any just world, ought to be split over multiple lines\"},\n"
+  "{-1, 93463,  "
+  " \"world\"},\n"
+  "{ 7, 5,  "
+  "\"!!\"},\n"
+  "};",
+  format("test demo[] = {{56, 23, \"hello world i am a very long line "
+ "that really, in

[PATCH] D101868: [clang-format] Adds a formatter for aligning arrays of structs

2021-06-09 Thread Fred Grim via Phabricator via cfe-commits
feg208 updated this revision to Diff 350924.
feg208 added a comment.

Ick. Missed a semi colon in the test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101868

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/TokenAnnotator.h
  clang/lib/Format/WhitespaceManager.cpp
  clang/lib/Format/WhitespaceManager.h
  clang/test/Format/struct-array-initializer.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -16602,6 +16602,407 @@
getLLVMStyle());
 }
 
+TEST_F(FormatTest, CatchAlignArrayOfStructuresRightAlignment) {
+  auto Style = getLLVMStyle();
+  Style.AlignArrayOfStructures = FormatStyle::AIAS_Right;
+  Style.AlignConsecutiveAssignments =
+  FormatStyle::AlignConsecutiveStyle::ACS_Consecutive;
+  Style.AlignConsecutiveDeclarations =
+  FormatStyle::AlignConsecutiveStyle::ACS_Consecutive;
+  verifyFormat("struct test demo[] = {\n"
+   "{56,23, \"hello\"},\n"
+   "{-1, 93463, \"world\"},\n"
+   "{ 7, 5,\"!!\"}\n"
+   "};\n",
+   Style);
+
+  verifyFormat("struct test demo[] = {\n"
+   "{56,23, \"hello\"}, // first line\n"
+   "{-1, 93463, \"world\"}, // second line\n"
+   "{ 7, 5,\"!!\"}  // third line\n"
+   "};\n",
+   Style);
+
+  verifyFormat("struct test demo[4] = {\n"
+   "{ 56,23, 21,   \"oh\"}, // first line\n"
+   "{ -1, 93463, 22,   \"my\"}, // second line\n"
+   "{  7, 5,  1, \"goodness\"}  // third line\n"
+   "{234, 5,  1, \"gracious\"}  // fourth line\n"
+   "};\n",
+   Style);
+
+  verifyFormat("struct test demo[3] = {\n"
+   "{56,23, \"hello\"},\n"
+   "{-1, 93463, \"world\"},\n"
+   "{ 7, 5,\"!!\"}\n"
+   "};\n",
+   Style);
+
+  verifyFormat("struct test demo[3] = {\n"
+   "{int{56},23, \"hello\"},\n"
+   "{int{-1}, 93463, \"world\"},\n"
+   "{ int{7}, 5,\"!!\"}\n"
+   "};\n",
+   Style);
+
+  verifyFormat("struct test demo[] = {\n"
+   "{56,23, \"hello\"},\n"
+   "{-1, 93463, \"world\"},\n"
+   "{ 7, 5,\"!!\"},\n"
+   "};\n",
+   Style);
+
+  verifyFormat("test demo[] = {\n"
+   "{56,23, \"hello\"},\n"
+   "{-1, 93463, \"world\"},\n"
+   "{ 7, 5,\"!!\"},\n"
+   "};\n",
+   Style);
+
+  verifyFormat("demo = std::array{\n"
+   "test{56,23, \"hello\"},\n"
+   "test{-1, 93463, \"world\"},\n"
+   "test{ 7, 5,\"!!\"},\n"
+   "};\n",
+   Style);
+
+  verifyFormat("test demo[] = {\n"
+   "{56,23, \"hello\"},\n"
+   "#if X\n"
+   "{-1, 93463, \"world\"},\n"
+   "#endif\n"
+   "{ 7, 5,\"!!\"}\n"
+   "};\n",
+   Style);
+
+  verifyFormat(
+  "test demo[] = {\n"
+  "{ 7,23,\n"
+  " \"hello world i am a very long line that really, in any\"\n"
+  " \"just world, ought to be split over multiple lines\"},\n"
+  "{-1, 93463,  \"world\"},\n"
+  "{56, 5, \"!!\"}\n"
+  "};\n",
+  Style);
+
+  verifyFormat("return GradForUnaryCwise(g, {\n"
+   "{{\"sign\"}, \"Sign\",  "
+   "  {\"x\", \"dy\"}},\n"
+   "{  {\"dx\"},  \"Mul\", {\"dy\""
+   ", \"sign\"}},\n"
+   "});\n",
+   Style);
+
+  Style.ColumnLimit = 0;
+  EXPECT_EQ(
+  "test demo[] = {\n"
+  "{56,23, \"hello world i am a very long line that really, "
+  "in any just world, ought to be split over multiple lines\"},\n"
+  "{-1, 93463,  "
+  " \"world\"},\n"
+  "{ 7, 5,  "
+  "\"!!\"},\n"
+  "};",
+  format("test demo[] = {{56, 23, \"hello world i am a very long line "
+ "

[PATCH] D103314: [Analyzer][solver] Simplify existing constraints when a new constraint is added

2021-06-09 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 2 inline comments as done.
martong added a comment.

> I have one thought here. If the lack of simplification indeed caused the 
> crash, we are in trouble with this patch. IMO simplification in just one 
> place should make it better, but shouldn't produce infeasible states for us. 
> In other words, any number simplifications is a conservative operation that 
> makes our lives a bit better. The moment they become a requirement (i.e. 
> simplifications call for more simplifications or we crash) this solution from 
> this patch has to become much harder. This is because whenever we do merge, 
> we essentially can create another situation when we find out that some 
> symbolic expression is a constant. Let's say that we are merging classes A 
> and B which have constraints [INT_MIN, 42] and [42, INT_MAX]. After the 
> merge, we are positive that all the members of this new class are equal to 
> 42. And if so, we can further simplify classes and their members. This 
> algorithm turns into a fixed point algorithm, which has a good chance to 
> sabotage our performance.

Yes, good point(s). I am trying to avoid turning into a fixed point algorithm 
by directly iterating over the equivalence classes instead of reusing the 
existing track mechanism. On the other hand, perhaps with some budge the 
fixpoint algo would be worth to experiment with.




Comment at: clang/test/Analysis/find-binop-constraints.cpp:150
+  int e1 = e0 - b0; // e1 is bound to (reg_$0) - (reg_$1)
+  (void)(b0 == 2);
+

vsavchenko wrote:
> It's not really connected to your patch, but this confuses me!  Why does the 
> analyzer think that `b0` is guaranteed to be 2 after this statement.  Even if 
> we eagerly assume here, shouldn't it mean that there are still two paths `b0 
> == 2` and `b0 != 2`?
Don't be puzzled by this. This indeed bifurcates. The interesting path is where 
`b0 == 2` is true.

I am going to update this line with `if (b0 ==2) {` to achieve a similar 
effect. (I was using creduce and tried to simplify even more after that, but i 
missed this.)



Comment at: clang/test/Analysis/find-binop-constraints.cpp:155-158
+// Here, e1 is still bound to (reg_$0) - (reg_$1) but we
+// should be able to simplify it to (reg_$0) - 2 and thus realize
+// the contradiction.
+if (b1 == e1) {

vsavchenko wrote:
> Hmm, I don't see how simplification helped here.
> 
> After the previous `if` statement, we should have had two equivalence classes 
> known to be disequal: `reg_$2` and `(reg_$0) - (reg_$1 b0>)`.
> Further, we directly compare these two symbols.  We can figure it out without 
> any simplifications.
> 
> Am I missing something here?
When we evaluate `e2 > 0` then we will set `e1` as disequal to `b1`. However, 
at this point because of the eager constant folding `e1` is `e0 - 2` (on the 
path where `b0 == 2` is true). 

So, when we evaluate `b1 == e1` then this is the diseq info we have in the 
State (I used `dumpDisEq` from D103967):
```
reg_$2
DisequalTo:
(reg_$0) - 2

(reg_$0) - 2
DisequalTo:
reg_$2
```

And indeed we ask directly whether the LHS (`reg_$2`) is equal to 
RHS`(reg_$0) - (reg_$1)`.  This is because the `DeclRefExpr` of 
`e1` is still bound to SVal which originates from the time before we 
constrained b0 to 2. With other words: the `Environment` is not changed by 
introducing a new constraint.

BTW, this test fails even in llvm/main.





Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103314

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


[PATCH] D103967: [Analyzer][solver] Add dump methods for (dis)equality classes.

2021-06-09 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

This is definitely useful!  Thanks!
I was just wondering if we should add it into the state printer instead.  @NoQ 
what's your take on this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103967

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


[PATCH] D101139: Create install targets for scan-build-py.

2021-06-09 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D101139

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


[clang] 8908903 - Corrects some minor issues with the CXX status page.

2021-06-09 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-06-09T13:38:41-04:00
New Revision: 8908903eacb0e0a79c004e49959f860b5c0e4d53

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

LOG: Corrects some minor issues with the CXX status page.

1) Adds some  tags where they were missing.
2) Documents that C++14 is the current default language mode, not C++98

Added: 


Modified: 
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index fc94282311561..1b761be8b22ae 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -90,12 +90,11 @@ C++11 implementation status
 
 Clang 3.3 and later implement all of the https://www.iso.org/standard/50372.html";>ISO
-  C++ 2011 standard.
+  C++ 2011 standard.
 
-By default, Clang builds C++ code according to the C++98 standard, with many
-C++11 features accepted as extensions. You can use Clang in C++11 mode with the
--std=c++11 option. Clang's C++11 mode can be used
-with https://libcxx.llvm.org/";>libc++ or with gcc's libstdc++.
+You can use Clang in C++11 mode with the -std=c++11
+option. Clang's C++11 mode can be used with
+https://libcxx.llvm.org/";>libc++ or with gcc's libstdc++.
 
 
 List of features and minimum Clang version with support
@@ -497,9 +496,10 @@ C++14 implementation status
 
 Clang 3.4 and later implement all of the https://www.iso.org/standard/64029.html";>ISO
-C++ 2014 standard.
+C++ 2014 standard.
 
-You can use Clang in C++14 mode with the -std=c++14 option
+By default, Clang builds C++ code according to the C++14 standard.
+You can use Clang in C++14 mode with the -std=c++14 option
 (use -std=c++1y in Clang 3.4 and earlier).
 
 
@@ -591,7 +591,7 @@ C++14 implementation status
 C++17 implementation status
 
 Clang 5 and later implement all the features of the
-https://www.iso.org/standard/68564.html";>ISO C++ 2017 standard.
+https://www.iso.org/standard/68564.html";>ISO C++ 2017 
standard.
 
 You can use Clang in C++17 mode with the -std=c++17 option
 (use -std=c++1z in Clang 4 and earlier).
@@ -856,7 +856,7 @@ C++17 implementation status
 C++20 implementation status
 
 Clang has support for some of the features of the
-https://www.iso.org/standard/79358.html";>ISO C++ 2020 standard.
+https://www.iso.org/standard/79358.html";>ISO C++ 2020 
standard.
 
 You can use Clang in C++20 mode with the -std=c++20 option
 (use -std=c++2a in Clang 9 and earlier).
@@ -1253,7 +1253,7 @@ C++20 implementation status
 C++2b implementation status
 
 Clang has support for some of the features of the C++ standard following
-C++20, informally referred to as C++2b.
+C++20, informally referred to as C++2b.
 
 You can use Clang in C++2b mode with the -std=c++2b option.
 



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


[PATCH] D103894: NarrowingConversionsCheck should support inhibiting conversions of mixed integer and floating point types with WarnOnEquivalentBitWidth=0.

2021-06-09 Thread Stephen Concannon via Phabricator via cfe-commits
Stephen updated this revision to Diff 350950.
Stephen added a comment.

Fix the expected error messages.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103894

Files:
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-equivalentbitwidth-option.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-equivalentbitwidth-option.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-equivalentbitwidth-option.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-equivalentbitwidth-option.cpp
@@ -18,19 +18,21 @@
 
   float f;
   i = f;
-  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion 
from 'float' to signed type 'int' is implementation-defined 
[cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion 
from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
   // DISABLED: Warning disabled with WarnOnEquivalentBitWidth=0.
+
   f = i;
-  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion 
from 'int' to signed type 'float' is implementation-defined 
[cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion 
from 'int' to 'float' [cppcoreguidelines-narrowing-conversions]
   // DISABLED: Warning disabled with WarnOnEquivalentBitWidth=0.
 
   long long ll;
   double d;
   ll = d;
-  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:8: warning: narrowing conversion 
from 'double' to signed type 'long long' is implementation-defined 
[cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:8: warning: narrowing conversion 
from 'double' to 'long long' [cppcoreguidelines-narrowing-conversions]
   // DISABLED: Warning disabled with WarnOnEquivalentBitWidth=0.
+
   d = ll;
-  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion 
from 'long long' to signed type 'double' is implementation-defined 
[cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion 
from 'long long' to 'double' [cppcoreguidelines-narrowing-conversions]
   // DISABLED: Warning disabled with WarnOnEquivalentBitWidth=0.
 }
 


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-equivalentbitwidth-option.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-equivalentbitwidth-option.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-equivalentbitwidth-option.cpp
@@ -18,19 +18,21 @@
 
   float f;
   i = f;
-  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion from 'float' to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion from 'float' to 'int' [cppcoreguidelines-narrowing-conversions]
   // DISABLED: Warning disabled with WarnOnEquivalentBitWidth=0.
+
   f = i;
-  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion from 'int' to signed type 'float' is implementation-defined [cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion from 'int' to 'float' [cppcoreguidelines-narrowing-conversions]
   // DISABLED: Warning disabled with WarnOnEquivalentBitWidth=0.
 
   long long ll;
   double d;
   ll = d;
-  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:8: warning: narrowing conversion from 'double' to signed type 'long long' is implementation-defined [cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:8: warning: narrowing conversion from 'double' to 'long long' [cppcoreguidelines-narrowing-conversions]
   // DISABLED: Warning disabled with WarnOnEquivalentBitWidth=0.
+
   d = ll;
-  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion from 'long long' to signed type 'double' is implementation-defined [cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion from 'long long' to 'double' [cppcoreguidelines-narrowing-conversions]
   // DISABLED: Warning disabled with WarnOnEquivalentBitWidth=0.
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103845: [compiler-rt][hwasan] Add newline between record_addr lines on frame record dumps

2021-06-09 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

Thanks for tracking this down. It seems best to change the Printf call to add 
the newline, since otherwise it looks like you'd be adding a spurious newline 
to the other callers of `RenderFrame` on Fuchsia.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103845

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


[clang] 64b2fb7 - [CSSPGO] Emit mangled dwarf names for line tables debug option under -fpseudo-probe-for-profiling

2021-06-09 Thread Hongtao Yu via cfe-commits

Author: Hongtao Yu
Date: 2021-06-09T10:46:03-07:00
New Revision: 64b2fb7967a749b83f59656f0cd2f4d00501efaa

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

LOG: [CSSPGO] Emit mangled dwarf names for line tables debug option under 
-fpseudo-probe-for-profiling

Reviewed By: wenlei

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

Added: 
clang/test/CodeGen/debug-info-pseudo-probe.cpp

Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 1367ef46d85d..080d494a2830 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3551,6 +3551,7 @@ void CGDebugInfo::collectFunctionDeclProps(GlobalDecl GD, 
llvm::DIFile *Unit,
   if (LinkageName == Name || (!CGM.getCodeGenOpts().EmitGcovArcs &&
   !CGM.getCodeGenOpts().EmitGcovNotes &&
   !CGM.getCodeGenOpts().DebugInfoForProfiling &&
+  !CGM.getCodeGenOpts().PseudoProbeForProfiling &&
   DebugKind <= 
codegenoptions::DebugLineTablesOnly))
 LinkageName = StringRef();
 

diff  --git a/clang/test/CodeGen/debug-info-pseudo-probe.cpp 
b/clang/test/CodeGen/debug-info-pseudo-probe.cpp
new file mode 100644
index ..78a684cd1f39
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-pseudo-probe.cpp
@@ -0,0 +1,12 @@
+// This test checks if a symbol gets mangled dwarf names with 
-fpseudo-probe-for-profiling option.
+// RUN: %clang_cc1 -triple x86_64 -x c++ -S -emit-llvm 
-debug-info-kind=line-tables-only -o - < %s | FileCheck %s --check-prefix=PLAIN
+// RUN: %clang_cc1 -triple x86_64 -x c++  -S -emit-llvm 
-debug-info-kind=line-tables-only -fpseudo-probe-for-profiling -o - < %s | 
FileCheck %s --check-prefix=MANGLE
+
+int foo() {
+  return 0;
+}
+
+// PLAIN: define dso_local i32 @_Z3foov()
+// PLAIN: distinct !DISubprogram(name: "foo", scope:
+// MANGLE: define dso_local i32 @_Z3foov()
+// MANGLE: distinct !DISubprogram(name: "foo", linkageName: "_Z3foov"



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


[PATCH] D103909: [CSSPGO] Emit mangled dwarf names for line tables debug option under -fpseudo-probe-for-profiling

2021-06-09 Thread Hongtao Yu 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 rG64b2fb7967a7: [CSSPGO] Emit mangled dwarf names for line 
tables debug option under -fpseudo… (authored by hoy).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103909

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-pseudo-probe.cpp


Index: clang/test/CodeGen/debug-info-pseudo-probe.cpp
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-pseudo-probe.cpp
@@ -0,0 +1,12 @@
+// This test checks if a symbol gets mangled dwarf names with 
-fpseudo-probe-for-profiling option.
+// RUN: %clang_cc1 -triple x86_64 -x c++ -S -emit-llvm 
-debug-info-kind=line-tables-only -o - < %s | FileCheck %s --check-prefix=PLAIN
+// RUN: %clang_cc1 -triple x86_64 -x c++  -S -emit-llvm 
-debug-info-kind=line-tables-only -fpseudo-probe-for-profiling -o - < %s | 
FileCheck %s --check-prefix=MANGLE
+
+int foo() {
+  return 0;
+}
+
+// PLAIN: define dso_local i32 @_Z3foov()
+// PLAIN: distinct !DISubprogram(name: "foo", scope:
+// MANGLE: define dso_local i32 @_Z3foov()
+// MANGLE: distinct !DISubprogram(name: "foo", linkageName: "_Z3foov"
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3551,6 +3551,7 @@
   if (LinkageName == Name || (!CGM.getCodeGenOpts().EmitGcovArcs &&
   !CGM.getCodeGenOpts().EmitGcovNotes &&
   !CGM.getCodeGenOpts().DebugInfoForProfiling &&
+  !CGM.getCodeGenOpts().PseudoProbeForProfiling &&
   DebugKind <= 
codegenoptions::DebugLineTablesOnly))
 LinkageName = StringRef();
 


Index: clang/test/CodeGen/debug-info-pseudo-probe.cpp
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-pseudo-probe.cpp
@@ -0,0 +1,12 @@
+// This test checks if a symbol gets mangled dwarf names with -fpseudo-probe-for-profiling option.
+// RUN: %clang_cc1 -triple x86_64 -x c++ -S -emit-llvm -debug-info-kind=line-tables-only -o - < %s | FileCheck %s --check-prefix=PLAIN
+// RUN: %clang_cc1 -triple x86_64 -x c++  -S -emit-llvm -debug-info-kind=line-tables-only -fpseudo-probe-for-profiling -o - < %s | FileCheck %s --check-prefix=MANGLE
+
+int foo() {
+  return 0;
+}
+
+// PLAIN: define dso_local i32 @_Z3foov()
+// PLAIN: distinct !DISubprogram(name: "foo", scope:
+// MANGLE: define dso_local i32 @_Z3foov()
+// MANGLE: distinct !DISubprogram(name: "foo", linkageName: "_Z3foov"
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3551,6 +3551,7 @@
   if (LinkageName == Name || (!CGM.getCodeGenOpts().EmitGcovArcs &&
   !CGM.getCodeGenOpts().EmitGcovNotes &&
   !CGM.getCodeGenOpts().DebugInfoForProfiling &&
+  !CGM.getCodeGenOpts().PseudoProbeForProfiling &&
   DebugKind <= codegenoptions::DebugLineTablesOnly))
 LinkageName = StringRef();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99696: [clang] NRVO: Improvements and handling of more cases.

2021-06-09 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone accepted this revision.
Quuxplusone added a comment.
This revision is now accepted and ready to land.

@mizvekov, my understanding is:

- D99696  was temporarily blocked on D103720 
, but now D103720 
 is landed and D99696 
 is unblocked
- D99696  is a codegen improvement in all 
language modes, and is also blocking D99005 
- D99005  is blocking our getting experience 
with p2266  for C++23

IMHO we should just plow ahead here. @aaronpuchert what's your take on D99696 
 at this point; is it good to go or still 
unresolved issues?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99696

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


[PATCH] D103982: [clang] Make CXXDefaultArgExpr inherit dependence from the inner Expr

2021-06-09 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
adamcz added a reviewer: hokein.
adamcz requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Before this change, CXXDefaultArgExpr would always have
ExprDependence::None. This can lead to issues when, for example, the
inner expression is RecoveryExpr and yet containsErrors() on the default
expression is false.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103982

Files:
  clang/include/clang/AST/ComputeDependence.h
  clang/include/clang/AST/ExprCXX.h
  clang/lib/AST/ComputeDependence.cpp
  clang/test/AST/ast-dump-default-arg-dep.cpp


Index: clang/test/AST/ast-dump-default-arg-dep.cpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-default-arg-dep.cpp
@@ -0,0 +1,10 @@
+// RUN: not %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -ast-dump 
-frecovery-ast %s | FileCheck %s
+
+// CXXDefaultArgExpr should inherit dependence from the inner Expr, in this 
case
+// RecoveryExpr.
+void fun(int arg = foo());
+
+void test() {
+  fun();
+}
+// CHECK: -CXXDefaultArgExpr 0x{{[^ ]*}} <> '' 
contains-errors lvalue
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -748,6 +748,10 @@
   return E->getExpr()->getDependence();
 }
 
+ExprDependence clang::computeDependence(CXXDefaultArgExpr *E) {
+  return E->getExpr()->getDependence();
+}
+
 ExprDependence clang::computeDependence(LambdaExpr *E,
 bool ContainsUnexpandedParameterPack) {
   auto D = toExprDependence(E->getType()->getDependence());
Index: clang/include/clang/AST/ExprCXX.h
===
--- clang/include/clang/AST/ExprCXX.h
+++ clang/include/clang/AST/ExprCXX.h
@@ -1257,7 +1257,7 @@
  Param->getDefaultArg()->getObjectKind()),
 Param(Param), UsedContext(UsedContext) {
 CXXDefaultArgExprBits.Loc = Loc;
-setDependence(ExprDependence::None);
+setDependence(computeDependence(this));
   }
 
 public:
Index: clang/include/clang/AST/ComputeDependence.h
===
--- clang/include/clang/AST/ComputeDependence.h
+++ clang/include/clang/AST/ComputeDependence.h
@@ -71,6 +71,7 @@
 class DependentScopeDeclRefExpr;
 class CXXConstructExpr;
 class CXXDefaultInitExpr;
+class CXXDefaultArgExpr;
 class LambdaExpr;
 class CXXUnresolvedConstructExpr;
 class CXXDependentScopeMemberExpr;
@@ -156,6 +157,7 @@
 ExprDependence computeDependence(DependentScopeDeclRefExpr *E);
 ExprDependence computeDependence(CXXConstructExpr *E);
 ExprDependence computeDependence(CXXDefaultInitExpr *E);
+ExprDependence computeDependence(CXXDefaultArgExpr *E);
 ExprDependence computeDependence(LambdaExpr *E,
  bool ContainsUnexpandedParameterPack);
 ExprDependence computeDependence(CXXUnresolvedConstructExpr *E);


Index: clang/test/AST/ast-dump-default-arg-dep.cpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-default-arg-dep.cpp
@@ -0,0 +1,10 @@
+// RUN: not %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -ast-dump -frecovery-ast %s | FileCheck %s
+
+// CXXDefaultArgExpr should inherit dependence from the inner Expr, in this case
+// RecoveryExpr.
+void fun(int arg = foo());
+
+void test() {
+  fun();
+}
+// CHECK: -CXXDefaultArgExpr 0x{{[^ ]*}} <> '' contains-errors lvalue
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -748,6 +748,10 @@
   return E->getExpr()->getDependence();
 }
 
+ExprDependence clang::computeDependence(CXXDefaultArgExpr *E) {
+  return E->getExpr()->getDependence();
+}
+
 ExprDependence clang::computeDependence(LambdaExpr *E,
 bool ContainsUnexpandedParameterPack) {
   auto D = toExprDependence(E->getType()->getDependence());
Index: clang/include/clang/AST/ExprCXX.h
===
--- clang/include/clang/AST/ExprCXX.h
+++ clang/include/clang/AST/ExprCXX.h
@@ -1257,7 +1257,7 @@
  Param->getDefaultArg()->getObjectKind()),
 Param(Param), UsedContext(UsedContext) {
 CXXDefaultArgExprBits.Loc = Loc;
-setDependence(ExprDependence::None);
+setDependence(computeDependence(this));
   }
 
 public:
Index: clang/include/clang/AST/ComputeDependence.h
===
--- clang/include/clang/AST/ComputeDependence.h
+++ clang/include/clang/AST/ComputeDependence.h
@@ -71,6 +71,7 @@
 class DependentScopeDeclRefExpr;
 class CXXConstructExpr;
 class CXXDefaultInitExpr;
+class CXXDefaultArgExpr;

[PATCH] D101868: [clang-format] Adds a formatter for aligning arrays of structs

2021-06-09 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:216-221
+struct test demo[] =
+{
+{56,23, "hello"},
+{-1, 93463, "world"},
+{ 7, 5,"!!"}
+};

feg208 wrote:
> curdeius wrote:
> > Don't forget to re-generate .rst.
> I am sorry. I am not entirely sure what to check here? Should I regenerate 
> the docs for the site and just ensure that they look ok?
It seems that you modified Format.h but didn't re-run 
`clang/docs/tools/dump_format_style.py` (example for `Left` is actually 
right-aligned).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101868

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


[PATCH] D103314: [Analyzer][solver] Simplify existing constraints when a new constraint is added

2021-06-09 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 2 inline comments as done.
martong added inline comments.



Comment at: clang/test/Analysis/find-binop-constraints.cpp:155-158
+// Here, e1 is still bound to (reg_$0) - (reg_$1) but we
+// should be able to simplify it to (reg_$0) - 2 and thus realize
+// the contradiction.
+if (b1 == e1) {

martong wrote:
> vsavchenko wrote:
> > Hmm, I don't see how simplification helped here.
> > 
> > After the previous `if` statement, we should have had two equivalence 
> > classes known to be disequal: `reg_$2` and `(reg_$0) - 
> > (reg_$1)`.
> > Further, we directly compare these two symbols.  We can figure it out 
> > without any simplifications.
> > 
> > Am I missing something here?
> When we evaluate `e2 > 0` then we will set `e1` as disequal to `b1`. However, 
> at this point because of the eager constant folding `e1` is `e0 - 2` (on the 
> path where `b0 == 2` is true). 
> 
> So, when we evaluate `b1 == e1` then this is the diseq info we have in the 
> State (I used `dumpDisEq` from D103967):
> ```
> reg_$2
> DisequalTo:
> (reg_$0) - 2
> 
> (reg_$0) - 2
> DisequalTo:
> reg_$2
> ```
> 
> And indeed we ask directly whether the LHS (`reg_$2`) is equal to 
> RHS`(reg_$0) - (reg_$1)`.  This is because the `DeclRefExpr` 
> of `e1` is still bound to SVal which originates from the time before we 
> constrained b0 to 2. With other words: the `Environment` is not changed by 
> introducing a new constraint.
> 
> BTW, this test fails even in llvm/main.
> 
> 
> 
>  With other words: the Environment is not changed by introducing a new 
> constraint.

This suggests that another approach could be to do change the `Environment` 
when we add a new constraint. I am not sure about the pros/cons atm, but might 
be worth to experiment. What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103314

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


[PATCH] D103825: [clang] Do not crash when ArgTy is null in CheckArgAlignment

2021-06-09 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz added a comment.

Thanks Haojian!
I sent out https://reviews.llvm.org/D103982 for the CXXDefaultArgExpr. I'll 
update this change after I submit that one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103825

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


[PATCH] D103314: [Analyzer][solver] Simplify existing constraints when a new constraint is added

2021-06-09 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

> OK, we definitely need to know about performance.

Couldn't agree more. I am in the middle of a performance measurement that I do 
with csa-testbench (on 
memchached,tmux,curl,twin,redis,vim,openssl,sqlite,ffmpeg,postgresql,tinyxml2,libwebm,xerces,bitcoin,protobuf).
 Hopefully I can give you some results soon.

> Plus, I'm still curious about the crash. I didn't get how simplification 
> helped/caused that crash.

So, the crash was actually an assertion failure in StdLibraryFunctionsChecker, 
which came when I made a test analysis run on the twin project. The assertion 
was here:

  if (FailureSt && !SuccessSt) {
if (ExplodedNode *N = C.generateErrorNode(NewState))
  reportBug(Call, N, Constraint.get(), Summary, C);
break;
  } else {
// We will apply the constraint even if we cannot reason about the
// argument. This means both SuccessSt and FailureSt can be true. If we
// weren't applying the constraint that would mean that symbolic
// execution continues on a code whose behaviour is undefined.
assert(SuccessSt);   // 
<- This fired 
!!!
NewState = SuccessSt;
  }

With multiple creduce iterations below is a minimal example with 
StdLibraryFunctionsChecker. That crashed when we applied the `BufferSize` 
constraint of `fread`.

  typedef int FILE;
  long b;
  unsigned long fread(void *__restrict, unsigned long, unsigned long,
  FILE *__restrict);
  void foo();
  void c(int *a, int e0) {
  
int e1 = e0 - b;
b == 2;
foo();
  
int e2 = e1 - b;
if (e2 > 0 && b == e1) {
  (void)a; (void)e1; (void)c;
  fread(a, sizeof(char), e1, c);
}
  }

Turned out, the checker had the assertion because before applying the arg 
constraint and its negated counterpart, the state was already infeasible. (But 
the analyzer recognized this only when it added the new assumptions when 
checking the applicability of the arg constraint.)
Thus, I could remove `fread` and the Checker from the problem set and could 
create the test case that synthesizes the unfeasible state.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103314

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


[PATCH] D103314: [Analyzer][solver] Simplify existing constraints when a new constraint is added

2021-06-09 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 350966.
martong marked an inline comment as done.
martong added a comment.

- Remove isEqualTo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103314

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/find-binop-constraints.cpp

Index: clang/test/Analysis/find-binop-constraints.cpp
===
--- /dev/null
+++ clang/test/Analysis/find-binop-constraints.cpp
@@ -0,0 +1,163 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -verify
+
+void clang_analyzer_eval(bool);
+void clang_analyzer_warnIfReached();
+
+int test_legacy_behavior(int x, int y) {
+  if (y != 0)
+return 0;
+  if (x + y != 0)
+return 0;
+  clang_analyzer_eval(x + y == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+  return y / (x + y);  // expected-warning{{Division by zero}}
+}
+
+int test_rhs_further_constrained(int x, int y) {
+  if (x + y != 0)
+return 0;
+  if (y != 0)
+return 0;
+  clang_analyzer_eval(x + y == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+  return 0;
+}
+
+int test_lhs_further_constrained(int x, int y) {
+  if (x + y != 0)
+return 0;
+  if (x != 0)
+return 0;
+  clang_analyzer_eval(x + y == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(x == 0); // expected-warning{{TRUE}}
+  return 0;
+}
+
+int test_lhs_and_rhs_further_constrained(int x, int y) {
+  if (x % y != 1)
+return 0;
+  if (x != 1)
+return 0;
+  if (y != 2)
+return 0;
+  clang_analyzer_eval(x % y == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(y == 2); // expected-warning{{TRUE}}
+  return 0;
+}
+
+int test_commutativity(int x, int y) {
+  if (x + y != 0)
+return 0;
+  if (y != 0)
+return 0;
+  clang_analyzer_eval(y + x == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+  return 0;
+}
+
+int test_binop_when_height_is_2_r(int a, int x, int y, int z) {
+  switch (a) {
+  case 1: {
+if (x + y + z != 0)
+  return 0;
+if (z != 0)
+  return 0;
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(z == 0); // expected-warning{{TRUE}}
+break;
+  }
+  case 2: {
+if (x + y + z != 0)
+  return 0;
+if (y != 0)
+  return 0;
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+break;
+  }
+  case 3: {
+if (x + y + z != 0)
+  return 0;
+if (x != 0)
+  return 0;
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(x == 0); // expected-warning{{TRUE}}
+break;
+  }
+  case 4: {
+if (x + y + z != 0)
+  return 0;
+if (x + y != 0)
+  return 0;
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(x + y == 0); // expected-warning{{TRUE}}
+break;
+  }
+  case 5: {
+if (z != 0)
+  return 0;
+if (x + y + z != 0)
+  return 0;
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+if (y != 0)
+  return 0;
+clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(z == 0); // expected-warning{{TRUE}}
+clang_analyzer_eval(x + y + z == 0); // expected-warning{{TRUE}}
+break;
+  }
+
+  }
+  return 0;
+}
+
+void test_equivalence_classes_are_updated(int a, int b, int c, int d) {
+  if (a + b != c)
+return;
+  if (a != d)
+return;
+  if (b != 0)
+return;
+  clang_analyzer_eval(c == d); // expected-warning{{TRUE}}
+  // Keep the symbols and the constraints! alive.
+  (void)(a * b * c * d);
+  return;
+}
+
+void test_contradiction(int a, int b, int c, int d) {
+  if (a + b != c)
+return;
+  if (a == c)
+return;
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+
+  // Bring in the contradiction.
+  if (b != 0)
+return;
+  clang_analyzer_warnIfReached(); // no-warning, i.e. UNREACHABLE
+  // Keep the symbols and the constraints! alive.
+  (void)(a * b * c * d);
+  return;
+}
+
+void test_deferred_contradiction(int e0, int b0, int b1) {
+
+  int e1 = e0 - b0; // e1 is bound to (reg_$0) - (reg_$1)
+  (void)(b0 == 2);
+
+  int e2 = e1 - b1;
+  if (e2 > 0) { // b1 != e1
+clang_analyzer_warnIfReached();   // expected-warning{{REACHABLE}}
+// Here, e1 is still bound to (reg_$0) - (reg_$1) but we
+// should be able to simplify it to (reg_$0) - 2 and thus realize
+// the contradiction.
+if (b1

[PATCH] D103314: [Analyzer][solver] Simplify existing constraints when a new constraint is added

2021-06-09 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1789
+  if (DisequalToOther.contains(*this))
+return nullptr;
   if (!DisequalToOther.isEmpty()) {

vsavchenko wrote:
> very opinionated nit: can you please add extra new line after this?
Sure.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1976-1986
+  Optional KnownClassEquality =
+  isEqualTo(State, ClassOfSimplifiedSym);
+  if (KnownClassEquality) {
+// The classes are already equal, there is no need to merge.
+if (*KnownClassEquality == true)
+  continue;
+// We are about to add the newly simplified symbol to this equivalence

vsavchenko wrote:
> Now, since you put this logic into `merge`, you can just merge.
Wow, good catch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103314

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


[PATCH] D101139: Create install targets for scan-build-py.

2021-06-09 Thread Daniel via Phabricator via cfe-commits
isthismyaccount added a comment.

Thanks for the reviews. I'll take over this and try to get the merge conflicts 
resolved.


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

https://reviews.llvm.org/D101139

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


[PATCH] D103958: [WIP] Support MustControl conditional control attribute

2021-06-09 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

The first talk from https://www.youtube.com/watch?v=FFjV9f_Ub9o 
(https://github.com/ClangBuiltLinux/plumbers-2020-slides/blob/master/LPC_2020_--_Dependency_ordering.pdf)
 might be helpful to link to at some point from the commit message, for a 
little additional context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103958

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


  1   2   >