[PATCH] D97182: [clang] fix cmake wrong variable name from RTLIBS to RTLIB

2021-02-22 Thread Philip Lassen via Phabricator via cfe-commits
philass updated this revision to Diff 325690.
philass added a comment.

Rerun failed build that may be fixed in

https://reviews.llvm.org/rG4827492d9fcfe4ac5df4f319e935e33bec946195


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

https://reviews.llvm.org/D97182

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -262,7 +262,7 @@
 if (CLANG_DEFAULT_UNWINDLIB STREQUAL "")
   if (CLANG_DEFAULT_RTLIB STREQUAL "libgcc")
 set (CLANG_DEFAULT_UNWINDLIB "libgcc" CACHE STRING "" FORCE)
-  elseif (CLANG_DEFAULT_RTLIBS STREQUAL "libunwind")
+  elseif (CLANG_DEFAULT_RTLIB STREQUAL "libunwind")
 set (CLANG_DEFAULT_UNWINDLIB "none" CACHE STRING "" FORCE)
   endif()
 endif()


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -262,7 +262,7 @@
 if (CLANG_DEFAULT_UNWINDLIB STREQUAL "")
   if (CLANG_DEFAULT_RTLIB STREQUAL "libgcc")
 set (CLANG_DEFAULT_UNWINDLIB "libgcc" CACHE STRING "" FORCE)
-  elseif (CLANG_DEFAULT_RTLIBS STREQUAL "libunwind")
+  elseif (CLANG_DEFAULT_RTLIB STREQUAL "libunwind")
 set (CLANG_DEFAULT_UNWINDLIB "none" CACHE STRING "" FORCE)
   endif()
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96320: [ThinLTO, NewPM] Run OptimizerLastEPCallbacks from buildThinLTOPreLinkDefaultPipeline

2021-02-22 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

Sorry, just got back from vacation, I'll try to take a look tomorrow


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96320

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


[PATCH] D96110: [X86] Pass to transform tdpbf16ps intrinsics to scalar operation.

2021-02-22 Thread Bing Yu via Phabricator via cfe-commits
yubing updated this revision to Diff 325688.
yubing added a comment.

Modify some comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96110

Files:
  clang/include/clang/Basic/BuiltinsX86_64.def
  clang/lib/Headers/amxintrin.h
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/lib/Target/X86/X86ExpandPseudo.cpp
  llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
  llvm/lib/Target/X86/X86InstrAMX.td
  llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
  llvm/lib/Target/X86/X86LowerAMXType.cpp
  llvm/lib/Target/X86/X86PreTileConfig.cpp
  llvm/lib/Target/X86/X86RegisterInfo.cpp
  llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll

Index: llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
===
--- llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
+++ llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
@@ -97,8 +97,8 @@
   ret void
 }
 
-define dso_local void @test_amx_dp(i16 signext %row, i16 signext %col, i16 signext %k, <256 x i32> %c, <256 x i32> %a, <256 x i32> %b, <256 x i32>* %vptr) #0 {
-; CHECK-LABEL: @test_amx_dp(
+define dso_local void @test_amx_dpbssd(i16 signext %row, i16 signext %col, i16 signext %k, <256 x i32> %c, <256 x i32> %a, <256 x i32> %b, <256 x i32>* %vptr) #0 {
+; CHECK-LABEL: @test_amx_dpbssd(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[A_AMX:%.*]] = bitcast <256 x i32> [[A:%.*]] to x86_amx
 ; CHECK-NEXT:[[B_AMX:%.*]] = bitcast <256 x i32> [[B:%.*]] to x86_amx
@@ -172,6 +172,84 @@
   ret void
 }
 
+define dso_local void @test_amx_dpbf16ps(i16 signext %row, i16 signext %col, i16 signext %k, <256 x i32> %c, <256 x i32> %a, <256 x i32> %b, <256 x i32>* %vptr) #0 {
+; CHECK-LABEL: @test_amx_dpbf16ps(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[A_AMX:%.*]] = bitcast <256 x i32> [[A:%.*]] to x86_amx
+; CHECK-NEXT:[[B_AMX:%.*]] = bitcast <256 x i32> [[B:%.*]] to x86_amx
+; CHECK-NEXT:[[C_AMX:%.*]] = bitcast <256 x i32> [[C:%.*]] to x86_amx
+; CHECK-NEXT:[[TMP0:%.*]] = lshr i16 [[COL:%.*]], 2
+; CHECK-NEXT:[[TMP1:%.*]] = lshr i16 [[K:%.*]], 2
+; CHECK-NEXT:br label [[TDPBF16PS_SCALARIZE_ROWS_HEADER:%.*]]
+; CHECK:   tdpbf16ps.scalarize.rows.header:
+; CHECK-NEXT:[[TDPBF16PS_SCALARIZE_ROWS_IV:%.*]] = phi i16 [ 0, [[ENTRY:%.*]] ], [ [[TDPBF16PS_SCALARIZE_ROWS_STEP:%.*]], [[TDPBF16PS_SCALARIZE_ROWS_LATCH:%.*]] ]
+; CHECK-NEXT:[[VEC_C_PHI_ROW:%.*]] = phi <256 x i32> [ [[C]], [[ENTRY]] ], [ [[TMP21:%.*]], [[TDPBF16PS_SCALARIZE_ROWS_LATCH]] ]
+; CHECK-NEXT:[[VEC_D_PHI_ROW:%.*]] = phi <256 x i32> [ zeroinitializer, [[ENTRY]] ], [ [[TMP22:%.*]], [[TDPBF16PS_SCALARIZE_ROWS_LATCH]] ]
+; CHECK-NEXT:br label [[TDPBF16PS_SCALARIZE_ROWS_BODY:%.*]]
+; CHECK:   tdpbf16ps.scalarize.rows.body:
+; CHECK-NEXT:br label [[TDPBF16PS_SCALARIZE_COLS_HEADER:%.*]]
+; CHECK:   tdpbf16ps.scalarize.cols.header:
+; CHECK-NEXT:[[TDPBF16PS_SCALARIZE_COLS_IV:%.*]] = phi i16 [ 0, [[TDPBF16PS_SCALARIZE_ROWS_BODY]] ], [ [[TDPBF16PS_SCALARIZE_COLS_STEP:%.*]], [[TDPBF16PS_SCALARIZE_COLS_LATCH:%.*]] ]
+; CHECK-NEXT:[[VEC_C_PHI_COL:%.*]] = phi <256 x i32> [ [[VEC_C_PHI_ROW]], [[TDPBF16PS_SCALARIZE_ROWS_BODY]] ], [ [[TMP21]], [[TDPBF16PS_SCALARIZE_COLS_LATCH]] ]
+; CHECK-NEXT:[[VEC_D_PHI_COL:%.*]] = phi <256 x i32> [ [[VEC_D_PHI_ROW]], [[TDPBF16PS_SCALARIZE_ROWS_BODY]] ], [ [[TMP22]], [[TDPBF16PS_SCALARIZE_COLS_LATCH]] ]
+; CHECK-NEXT:br label [[TDPBF16PS_SCALARIZE_COLS_BODY:%.*]]
+; CHECK:   tdpbf16ps.scalarize.cols.body:
+; CHECK-NEXT:br label [[TDPBF16PS_SCALARIZE_INNER_HEADER:%.*]]
+; CHECK:   tdpbf16ps.scalarize.inner.header:
+; CHECK-NEXT:[[TDPBF16PS_SCALARIZE_INNER_IV:%.*]] = phi i16 [ 0, [[TDPBF16PS_SCALARIZE_COLS_BODY]] ], [ [[TDPBF16PS_SCALARIZE_INNER_STEP:%.*]], [[TDPBF16PS_SCALARIZE_INNER_LATCH:%.*]] ]
+; CHECK-NEXT:[[VEC_C_INNER_PHI:%.*]] = phi <256 x i32> [ [[VEC_C_PHI_COL]], [[TDPBF16PS_SCALARIZE_COLS_BODY]] ], [ [[TMP21]], [[TDPBF16PS_SCALARIZE_INNER_LATCH]] ]
+; CHECK-NEXT:[[VEC_D_INNER_PHI:%.*]] = phi <256 x i32> [ [[VEC_D_PHI_COL]], [[TDPBF16PS_SCALARIZE_COLS_BODY]] ], [ [[TMP22]], [[TDPBF16PS_SCALARIZE_INNER_LATCH]] ]
+; CHECK-NEXT:br label [[TDPBF16PS_SCALARIZE_INNER_BODY:%.*]]
+; CHECK:   tdpbf16ps.scalarize.inner.body:
+; CHECK-NEXT:[[TMP2:%.*]] = mul i16 [[TDPBF16PS_SCALARIZE_ROWS_IV]], 16
+; CHECK-NEXT:[[TMP3:%.*]] = add i16 [[TMP2]], [[TDPBF16PS_SCALARIZE_COLS_IV]]
+; CHECK-NEXT:[[TMP4:%.*]] = mul i16 [[TDPBF16PS_SCALARIZE_ROWS_IV]], 16
+; CHECK-NEXT:[[TMP5:%.*]] = add i16 [[TMP4]], [[TDPBF16PS_SCALARIZE_INNER_IV]]
+; CHECK-NEXT:[[TMP6:%.*]] = mul i16 [[TDPBF16PS_SCALARIZE_INNER_IV]], 16
+; CHECK-NEXT:[[TMP7:%.*]] = add i16 [[TMP6]], [[TDPBF16PS_SCALARIZE_COLS_IV]]
+; CHECK-NEXT:[[TMP8:%.*]] = extractelement <256 x i32> [[VEC_C_INNER_PHI]], i16 [[TMP3]]
+; CHECK-NEXT:[[TMP9:%.*]] = bitcast i32 [[TMP8]] to float
+; CHECK-NEXT:[[TMP10:%.*]] = 

[PATCH] D97259: [X86] Support amx-int8 intrinsic.

2021-02-22 Thread LiuChen via Phabricator via cfe-commits
LiuChen3 added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsX86_64.def:106
 TARGET_BUILTIN(__builtin_ia32_tdpbssd_internal, "V256iUsUsUsV256iV256iV256i", 
"n", "amx-int8")
+
+TARGET_BUILTIN(__builtin_ia32_tdpbsud_internal, "V256iUsUsUsV256iV256iV256i", 
"n", "amx-int8")

Forgot to delete the blank line. I will delete these in next patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97259

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


[PATCH] D97259: [X86] Support amx-int8 intrinsic.

2021-02-22 Thread LiuChen via Phabricator via cfe-commits
LiuChen3 created this revision.
Herald added subscribers: pengfei, hiraditya.
LiuChen3 requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Adding support for intrinsics of TDPBSUD/TDPBUSD/TDPBUUD.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97259

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/X86ISelDAGToDAG.cpp
  llvm/lib/Target/X86/X86InstrAMX.td
  llvm/lib/Target/X86/X86LowerAMXType.cpp
  llvm/lib/Target/X86/X86PreTileConfig.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
@@ -19,6 +19,9 @@
 ; CHECK-NEXT:tileloadd (%rsi,%rdx), %tmm1
 ; CHECK-NEXT:tileloadd (%rsi,%rdx), %tmm2
 ; CHECK-NEXT:tdpbssd %tmm2, %tmm1, %tmm0
+; CHECK-NEXT:tdpbsud %tmm2, %tmm1, %tmm0
+; CHECK-NEXT:tdpbusd %tmm2, %tmm1, %tmm0
+; CHECK-NEXT:tdpbuud %tmm2, %tmm1, %tmm0
 ; CHECK-NEXT:tilestored %tmm0, (%rdi,%rdx)
 ; CHECK-NEXT:tilerelease
 ; CHECK-NEXT:vzeroupper
@@ -26,8 +29,11 @@
   %c = call x86_amx @llvm.x86.tilezero.internal(i16 8, i16 8)
   %a = call x86_amx @llvm.x86.tileloadd64.internal(i16 8, i16 8, i8* %base, i64 %stride)
   %b = call x86_amx @llvm.x86.tileloadd64.internal(i16 8, i16 8, i8* %base, i64 %stride)
-  %d = call x86_amx @llvm.x86.tdpbssd.internal(i16 8, i16 8, i16 8, x86_amx %c, x86_amx %a, x86_amx %b)
-  call void @llvm.x86.tilestored64.internal(i16 8, i16 8, i8* %pointer, i64 %stride, x86_amx %d)
+  %d0 = call x86_amx @llvm.x86.tdpbssd.internal(i16 8, i16 8, i16 8, x86_amx %c, x86_amx %a, x86_amx %b)
+  %d1 = call x86_amx @llvm.x86.tdpbsud.internal(i16 8, i16 8, i16 8, x86_amx %d0, x86_amx %a, x86_amx %b)
+  %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)
+  call void @llvm.x86.tilestored64.internal(i16 8, i16 8, i8* %pointer, i64 %stride, x86_amx %d3)
 
   ret void
 }
@@ -35,4 +41,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.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)
+declare x86_amx @llvm.x86.tdpbuud.internal(i16, i16, i16, x86_amx, x86_amx, x86_amx)
 declare void @llvm.x86.tilestored64.internal(i16, i16, i8*, i64, x86_amx)
Index: llvm/lib/Target/X86/X86RegisterInfo.cpp
===
--- llvm/lib/Target/X86/X86RegisterInfo.cpp
+++ llvm/lib/Target/X86/X86RegisterInfo.cpp
@@ -884,6 +884,9 @@
   // We only collect the tile shape that is defined.
   case X86::PTILELOADDV:
   case X86::PTDPBSSDV:
+  case X86::PTDPBSUDV:
+  case X86::PTDPBUSDV:
+  case X86::PTDPBUUDV:
   case X86::PTILEZEROV:
 MachineOperand  = MI->getOperand(1);
 MachineOperand  = MI->getOperand(2);
Index: llvm/lib/Target/X86/X86PreTileConfig.cpp
===
--- llvm/lib/Target/X86/X86PreTileConfig.cpp
+++ llvm/lib/Target/X86/X86PreTileConfig.cpp
@@ -155,6 +155,9 @@
 llvm_unreachable("Unexpected machine instruction on tile");
   case X86::PTILELOADDV:
   case X86::PTDPBSSDV:
+  case X86::PTDPBSUDV:
+  case X86::PTDPBUSDV:
+  case X86::PTDPBUUDV:
   case X86::PTILEZEROV:
 MachineOperand  = const_cast(MI.getOperand(1));
 MachineOperand  = const_cast(MI.getOperand(2));
@@ -249,6 +252,9 @@
   case X86::PTILELOADDV:
   case X86::PTILESTOREDV:
   case X86::PTDPBSSDV:
+  case X86::PTDPBSUDV:
+  case X86::PTDPBUSDV:
+  case X86::PTDPBUUDV:
   case X86::PTILEZEROV:
 return true;
   }
Index: llvm/lib/Target/X86/X86LowerAMXType.cpp
===
--- llvm/lib/Target/X86/X86LowerAMXType.cpp
+++ llvm/lib/Target/X86/X86LowerAMXType.cpp
@@ -67,7 +67,10 @@
   }
   // a * b + c
   // The shape depends on which operand.
-  case Intrinsic::x86_tdpbssd_internal: {
+  case Intrinsic::x86_tdpbssd_internal:
+  case Intrinsic::x86_tdpbsud_internal:
+  case Intrinsic::x86_tdpbusd_internal:
+  case Intrinsic::x86_tdpbuud_internal: {
 switch (OpNo) {
 case 3:
   Row = II->getArgOperand(0);
Index: llvm/lib/Target/X86/X86InstrAMX.td
===
--- llvm/lib/Target/X86/X86InstrAMX.td
+++ 

[PATCH] D96110: [X86] Pass to transform tdpbf16ps intrinsics to scalar operation.

2021-02-22 Thread Bing Yu via Phabricator via cfe-commits
yubing updated this revision to Diff 325685.
yubing added a comment.

Fix incorrect naming for dpbf16's bb


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96110

Files:
  clang/include/clang/Basic/BuiltinsX86_64.def
  clang/lib/Headers/amxintrin.h
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/lib/Target/X86/X86ExpandPseudo.cpp
  llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
  llvm/lib/Target/X86/X86InstrAMX.td
  llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
  llvm/lib/Target/X86/X86LowerAMXType.cpp
  llvm/lib/Target/X86/X86PreTileConfig.cpp
  llvm/lib/Target/X86/X86RegisterInfo.cpp
  llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll

Index: llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
===
--- llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
+++ llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
@@ -97,8 +97,8 @@
   ret void
 }
 
-define dso_local void @test_amx_dp(i16 signext %row, i16 signext %col, i16 signext %k, <256 x i32> %c, <256 x i32> %a, <256 x i32> %b, <256 x i32>* %vptr) #0 {
-; CHECK-LABEL: @test_amx_dp(
+define dso_local void @test_amx_dpbssd(i16 signext %row, i16 signext %col, i16 signext %k, <256 x i32> %c, <256 x i32> %a, <256 x i32> %b, <256 x i32>* %vptr) #0 {
+; CHECK-LABEL: @test_amx_dpbssd(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[A_AMX:%.*]] = bitcast <256 x i32> [[A:%.*]] to x86_amx
 ; CHECK-NEXT:[[B_AMX:%.*]] = bitcast <256 x i32> [[B:%.*]] to x86_amx
@@ -172,6 +172,84 @@
   ret void
 }
 
+define dso_local void @test_amx_dpbf16ps(i16 signext %row, i16 signext %col, i16 signext %k, <256 x i32> %c, <256 x i32> %a, <256 x i32> %b, <256 x i32>* %vptr) #0 {
+; CHECK-LABEL: @test_amx_dpbf16ps(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[A_AMX:%.*]] = bitcast <256 x i32> [[A:%.*]] to x86_amx
+; CHECK-NEXT:[[B_AMX:%.*]] = bitcast <256 x i32> [[B:%.*]] to x86_amx
+; CHECK-NEXT:[[C_AMX:%.*]] = bitcast <256 x i32> [[C:%.*]] to x86_amx
+; CHECK-NEXT:[[TMP0:%.*]] = lshr i16 [[COL:%.*]], 2
+; CHECK-NEXT:[[TMP1:%.*]] = lshr i16 [[K:%.*]], 2
+; CHECK-NEXT:br label [[TDPBF16PS_SCALARIZE_ROWS_HEADER:%.*]]
+; CHECK:   tdpbf16ps.scalarize.rows.header:
+; CHECK-NEXT:[[TDPBF16PS_SCALARIZE_ROWS_IV:%.*]] = phi i16 [ 0, [[ENTRY:%.*]] ], [ [[TDPBF16PS_SCALARIZE_ROWS_STEP:%.*]], [[TDPBF16PS_SCALARIZE_ROWS_LATCH:%.*]] ]
+; CHECK-NEXT:[[VEC_C_PHI_ROW:%.*]] = phi <256 x i32> [ [[C]], [[ENTRY]] ], [ [[TMP21:%.*]], [[TDPBF16PS_SCALARIZE_ROWS_LATCH]] ]
+; CHECK-NEXT:[[VEC_D_PHI_ROW:%.*]] = phi <256 x i32> [ zeroinitializer, [[ENTRY]] ], [ [[TMP22:%.*]], [[TDPBF16PS_SCALARIZE_ROWS_LATCH]] ]
+; CHECK-NEXT:br label [[TDPBF16PS_SCALARIZE_ROWS_BODY:%.*]]
+; CHECK:   tdpbf16ps.scalarize.rows.body:
+; CHECK-NEXT:br label [[TDPBF16PS_SCALARIZE_COLS_HEADER:%.*]]
+; CHECK:   tdpbf16ps.scalarize.cols.header:
+; CHECK-NEXT:[[TDPBF16PS_SCALARIZE_COLS_IV:%.*]] = phi i16 [ 0, [[TDPBF16PS_SCALARIZE_ROWS_BODY]] ], [ [[TDPBF16PS_SCALARIZE_COLS_STEP:%.*]], [[TDPBF16PS_SCALARIZE_COLS_LATCH:%.*]] ]
+; CHECK-NEXT:[[VEC_C_PHI_COL:%.*]] = phi <256 x i32> [ [[VEC_C_PHI_ROW]], [[TDPBF16PS_SCALARIZE_ROWS_BODY]] ], [ [[TMP21]], [[TDPBF16PS_SCALARIZE_COLS_LATCH]] ]
+; CHECK-NEXT:[[VEC_D_PHI_COL:%.*]] = phi <256 x i32> [ [[VEC_D_PHI_ROW]], [[TDPBF16PS_SCALARIZE_ROWS_BODY]] ], [ [[TMP22]], [[TDPBF16PS_SCALARIZE_COLS_LATCH]] ]
+; CHECK-NEXT:br label [[TDPBF16PS_SCALARIZE_COLS_BODY:%.*]]
+; CHECK:   tdpbf16ps.scalarize.cols.body:
+; CHECK-NEXT:br label [[TDPBF16PS_SCALARIZE_INNER_HEADER:%.*]]
+; CHECK:   tdpbf16ps.scalarize.inner.header:
+; CHECK-NEXT:[[TDPBF16PS_SCALARIZE_INNER_IV:%.*]] = phi i16 [ 0, [[TDPBF16PS_SCALARIZE_COLS_BODY]] ], [ [[TDPBF16PS_SCALARIZE_INNER_STEP:%.*]], [[TDPBF16PS_SCALARIZE_INNER_LATCH:%.*]] ]
+; CHECK-NEXT:[[VEC_C_INNER_PHI:%.*]] = phi <256 x i32> [ [[VEC_C_PHI_COL]], [[TDPBF16PS_SCALARIZE_COLS_BODY]] ], [ [[TMP21]], [[TDPBF16PS_SCALARIZE_INNER_LATCH]] ]
+; CHECK-NEXT:[[VEC_D_INNER_PHI:%.*]] = phi <256 x i32> [ [[VEC_D_PHI_COL]], [[TDPBF16PS_SCALARIZE_COLS_BODY]] ], [ [[TMP22]], [[TDPBF16PS_SCALARIZE_INNER_LATCH]] ]
+; CHECK-NEXT:br label [[TDPBF16PS_SCALARIZE_INNER_BODY:%.*]]
+; CHECK:   tdpbf16ps.scalarize.inner.body:
+; CHECK-NEXT:[[TMP2:%.*]] = mul i16 [[TDPBF16PS_SCALARIZE_ROWS_IV]], 16
+; CHECK-NEXT:[[TMP3:%.*]] = add i16 [[TMP2]], [[TDPBF16PS_SCALARIZE_COLS_IV]]
+; CHECK-NEXT:[[TMP4:%.*]] = mul i16 [[TDPBF16PS_SCALARIZE_ROWS_IV]], 16
+; CHECK-NEXT:[[TMP5:%.*]] = add i16 [[TMP4]], [[TDPBF16PS_SCALARIZE_INNER_IV]]
+; CHECK-NEXT:[[TMP6:%.*]] = mul i16 [[TDPBF16PS_SCALARIZE_INNER_IV]], 16
+; CHECK-NEXT:[[TMP7:%.*]] = add i16 [[TMP6]], [[TDPBF16PS_SCALARIZE_COLS_IV]]
+; CHECK-NEXT:[[TMP8:%.*]] = extractelement <256 x i32> [[VEC_C_INNER_PHI]], i16 [[TMP3]]
+; CHECK-NEXT:[[TMP9:%.*]] = bitcast i32 [[TMP8]] to float
+; CHECK-NEXT:

[PATCH] D91844: [llvm][clang] Add checks for the smart pointers with the possibility to be null

2021-02-22 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie abandoned this revision.
OikawaKirie added a comment.

Split to

- D97251  
(clang/utils/TableGen/ClangAttrEmitter.cpp)
- D97185  
(llvm/lib/DWARFLinker/DWARFLinker.cpp)
- D97254  
(llvm/lib/LTO/ThinLTOCodeGenerator.cpp)
- D97255  
(llvm/lib/Support/VirtualFileSystem.cpp)
- D97258  (llvm/tools/llvm-link/llvm-link.cpp)

And the last one (llvm/utils/TableGen/OptParserEmitter.cpp) has been fixed by 
others.

Please review the new revisions, and this revision will be closed.

Thanks to all reviewers and sorry for the delay.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91844

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


[PATCH] D65616: Ignore -fsemantic-interposition/-fno-semantic-interposition flag for gcc compatibility

2021-02-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay commandeered this revision.
MaskRay edited reviewers, added: Romain-Geissler-1A; removed: MaskRay.
MaskRay added a comment.
This revision is now accepted and ready to land.
Herald added subscribers: jansvoboda11, dang.

Implemented by 2820a2ca3a0e69c3f301845420e00672251b 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65616

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


[PATCH] D96110: [X86] Pass to transform tdpbf16ps intrinsics to scalar operation.

2021-02-22 Thread Bing Yu via Phabricator via cfe-commits
yubing updated this revision to Diff 325683.
yubing added a comment.

Rebase and add a testcase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96110

Files:
  clang/include/clang/Basic/BuiltinsX86_64.def
  clang/lib/Headers/amxintrin.h
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/lib/Target/X86/X86ExpandPseudo.cpp
  llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
  llvm/lib/Target/X86/X86InstrAMX.td
  llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
  llvm/lib/Target/X86/X86LowerAMXType.cpp
  llvm/lib/Target/X86/X86PreTileConfig.cpp
  llvm/lib/Target/X86/X86RegisterInfo.cpp
  llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll

Index: llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
===
--- llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
+++ llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
@@ -97,8 +97,8 @@
   ret void
 }
 
-define dso_local void @test_amx_dp(i16 signext %row, i16 signext %col, i16 signext %k, <256 x i32> %c, <256 x i32> %a, <256 x i32> %b, <256 x i32>* %vptr) #0 {
-; CHECK-LABEL: @test_amx_dp(
+define dso_local void @test_amx_dpbssd(i16 signext %row, i16 signext %col, i16 signext %k, <256 x i32> %c, <256 x i32> %a, <256 x i32> %b, <256 x i32>* %vptr) #0 {
+; CHECK-LABEL: @test_amx_dpbssd(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[A_AMX:%.*]] = bitcast <256 x i32> [[A:%.*]] to x86_amx
 ; CHECK-NEXT:[[B_AMX:%.*]] = bitcast <256 x i32> [[B:%.*]] to x86_amx
@@ -172,6 +172,84 @@
   ret void
 }
 
+define dso_local void @test_amx_dpbf16ps(i16 signext %row, i16 signext %col, i16 signext %k, <256 x i32> %c, <256 x i32> %a, <256 x i32> %b, <256 x i32>* %vptr) #0 {
+; CHECK-LABEL: @test_amx_dpbf16ps(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[A_AMX:%.*]] = bitcast <256 x i32> [[A:%.*]] to x86_amx
+; CHECK-NEXT:[[B_AMX:%.*]] = bitcast <256 x i32> [[B:%.*]] to x86_amx
+; CHECK-NEXT:[[C_AMX:%.*]] = bitcast <256 x i32> [[C:%.*]] to x86_amx
+; CHECK-NEXT:[[TMP0:%.*]] = lshr i16 [[COL:%.*]], 2
+; CHECK-NEXT:[[TMP1:%.*]] = lshr i16 [[K:%.*]], 2
+; CHECK-NEXT:br label [[TILEDPBSSD_SCALARIZE_ROWS_HEADER:%.*]]
+; CHECK:   tiledpbssd.scalarize.rows.header:
+; CHECK-NEXT:[[TILEDPBSSD_SCALARIZE_ROWS_IV:%.*]] = phi i16 [ 0, [[ENTRY:%.*]] ], [ [[TILEDPBSSD_SCALARIZE_ROWS_STEP:%.*]], [[TILEDPBSSD_SCALARIZE_ROWS_LATCH:%.*]] ]
+; CHECK-NEXT:[[VEC_C_PHI_ROW:%.*]] = phi <256 x i32> [ [[C]], [[ENTRY]] ], [ [[TMP21:%.*]], [[TILEDPBSSD_SCALARIZE_ROWS_LATCH]] ]
+; CHECK-NEXT:[[VEC_D_PHI_ROW:%.*]] = phi <256 x i32> [ zeroinitializer, [[ENTRY]] ], [ [[TMP22:%.*]], [[TILEDPBSSD_SCALARIZE_ROWS_LATCH]] ]
+; CHECK-NEXT:br label [[TILEDPBSSD_SCALARIZE_ROWS_BODY:%.*]]
+; CHECK:   tiledpbssd.scalarize.rows.body:
+; CHECK-NEXT:br label [[TILEDPBSSD_SCALARIZE_COLS_HEADER:%.*]]
+; CHECK:   tiledpbssd.scalarize.cols.header:
+; CHECK-NEXT:[[TILEDPBSSD_SCALARIZE_COLS_IV:%.*]] = phi i16 [ 0, [[TILEDPBSSD_SCALARIZE_ROWS_BODY]] ], [ [[TILEDPBSSD_SCALARIZE_COLS_STEP:%.*]], [[TILEDPBSSD_SCALARIZE_COLS_LATCH:%.*]] ]
+; CHECK-NEXT:[[VEC_C_PHI_COL:%.*]] = phi <256 x i32> [ [[VEC_C_PHI_ROW]], [[TILEDPBSSD_SCALARIZE_ROWS_BODY]] ], [ [[TMP21]], [[TILEDPBSSD_SCALARIZE_COLS_LATCH]] ]
+; CHECK-NEXT:[[VEC_D_PHI_COL:%.*]] = phi <256 x i32> [ [[VEC_D_PHI_ROW]], [[TILEDPBSSD_SCALARIZE_ROWS_BODY]] ], [ [[TMP22]], [[TILEDPBSSD_SCALARIZE_COLS_LATCH]] ]
+; CHECK-NEXT:br label [[TILEDPBSSD_SCALARIZE_COLS_BODY:%.*]]
+; CHECK:   tiledpbssd.scalarize.cols.body:
+; CHECK-NEXT:br label [[TILEDPBSSD_SCALARIZE_INNER_HEADER:%.*]]
+; CHECK:   tiledpbssd.scalarize.inner.header:
+; CHECK-NEXT:[[TILEDPBSSD_SCALARIZE_INNER_IV:%.*]] = phi i16 [ 0, [[TILEDPBSSD_SCALARIZE_COLS_BODY]] ], [ [[TILEDPBSSD_SCALARIZE_INNER_STEP:%.*]], [[TILEDPBSSD_SCALARIZE_INNER_LATCH:%.*]] ]
+; CHECK-NEXT:[[VEC_C_INNER_PHI:%.*]] = phi <256 x i32> [ [[VEC_C_PHI_COL]], [[TILEDPBSSD_SCALARIZE_COLS_BODY]] ], [ [[TMP21]], [[TILEDPBSSD_SCALARIZE_INNER_LATCH]] ]
+; CHECK-NEXT:[[VEC_D_INNER_PHI:%.*]] = phi <256 x i32> [ [[VEC_D_PHI_COL]], [[TILEDPBSSD_SCALARIZE_COLS_BODY]] ], [ [[TMP22]], [[TILEDPBSSD_SCALARIZE_INNER_LATCH]] ]
+; CHECK-NEXT:br label [[TILEDPBSSD_SCALARIZE_INNER_BODY:%.*]]
+; CHECK:   tiledpbssd.scalarize.inner.body:
+; CHECK-NEXT:[[TMP2:%.*]] = mul i16 [[TILEDPBSSD_SCALARIZE_ROWS_IV]], 16
+; CHECK-NEXT:[[TMP3:%.*]] = add i16 [[TMP2]], [[TILEDPBSSD_SCALARIZE_COLS_IV]]
+; CHECK-NEXT:[[TMP4:%.*]] = mul i16 [[TILEDPBSSD_SCALARIZE_ROWS_IV]], 16
+; CHECK-NEXT:[[TMP5:%.*]] = add i16 [[TMP4]], [[TILEDPBSSD_SCALARIZE_INNER_IV]]
+; CHECK-NEXT:[[TMP6:%.*]] = mul i16 [[TILEDPBSSD_SCALARIZE_INNER_IV]], 16
+; CHECK-NEXT:[[TMP7:%.*]] = add i16 [[TMP6]], [[TILEDPBSSD_SCALARIZE_COLS_IV]]
+; CHECK-NEXT:[[TMP8:%.*]] = extractelement <256 x i32> [[VEC_C_INNER_PHI]], i16 [[TMP3]]
+; CHECK-NEXT:[[TMP9:%.*]] = bitcast i32 [[TMP8]] to float

[PATCH] D90972: [clang-tidy] Install run-clang-tidy.py in bin/ as run-clang-tidy

2021-02-22 Thread Florian Schmaus via Phabricator via cfe-commits
Flow added a comment.

In D90972#2580020 , @njames93 wrote:

> In D90972#2446448 , @Flow wrote:
>
>> In D90972#2394516 , @JonasToth 
>> wrote:
>>
>>> LGTM! thanks for fixing.
>>
>> I am unable to commit this myself. The latest version of this change 
>> 
>>  can be found in the install-run-clang-tidy-into-bin 
>> 
>>  on my LLVM fork .
>
> Noticed this is a little stale, Do you still want this landing?

This probably was not addressed to me, but yes I want this to land but need 
someone to sponsor the commit. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90972

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


[PATCH] D94376: [MemCpyOpt] Enable MemorySSA by default

2021-02-22 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

In D94376#2579242 , @nikic wrote:

> @uabelho Thanks for the report! This issue should be resolved by 
> https://github.com/llvm/llvm-project/commit/4125afc35723b490556f7a38f7835f0914f70292.

Yep, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94376

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


[PATCH] D93594: [X86] Pass to transform amx intrinsics to scalar operation.

2021-02-22 Thread Bing Yu via Phabricator via cfe-commits
yubing marked 13 inline comments as done.
yubing added inline comments.



Comment at: llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp:487
+  SmallVector WorkList;
+  for (BasicBlock *BB : depth_first()) {
+for (BasicBlock::iterator II = BB->begin(), IE = BB->end(); II != IE;) {

LuoYuanke wrote:
> Do we iterate the instructions in topology order or in post order?
It should be pre-order since we need to handle cases without bitcasts, such as, 
amx-low-intrinsics-no-bitcast.ll


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93594

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


[PATCH] D93594: [X86] Pass to transform amx intrinsics to scalar operation.

2021-02-22 Thread Bing Yu via Phabricator via cfe-commits
yubing updated this revision to Diff 325670.
yubing added a comment.

Address comments above


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93594

Files:
  llvm/include/llvm/CodeGen/Passes.h
  llvm/lib/Target/X86/CMakeLists.txt
  llvm/lib/Target/X86/X86.h
  llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
  llvm/lib/Target/X86/X86LowerAMXType.cpp
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/X86/AMX/amx-low-intrinsics-no-bitcast.ll
  llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
  llvm/test/CodeGen/X86/AMX/amx-type.ll
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/tools/opt/opt.cpp

Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -497,7 +497,7 @@
   "expand-reductions","indirectbr-expand",
   "generic-to-nvvm",  "expandmemcmp",
   "loop-reduce",  "lower-amx-type",
-  "polyhedral-info"};
+  "lower-amx-intrinsics", "polyhedral-info"};
   for (const auto  : PassNamePrefix)
 if (Pass.startswith(P))
   return true;
Index: llvm/test/CodeGen/X86/O0-pipeline.ll
===
--- llvm/test/CodeGen/X86/O0-pipeline.ll
+++ llvm/test/CodeGen/X86/O0-pipeline.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; When EXPENSIVE_CHECKS are enabled, the machine verifier appears between each
 ; pass. Ignore it with 'grep -v'.
 ; RUN: llc -mtriple=x86_64-- -O0 -debug-pass=Structure < %s -o /dev/null 2>&1 \
@@ -18,6 +19,9 @@
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Expand Atomic instructions
+; CHECK-NEXT:   Dominator Tree Construction
+; CHECK-NEXT:   Natural Loop Information
+; CHECK-NEXT:   Lower AMX intrinsics
 ; CHECK-NEXT:   Lower AMX type for load/store
 ; CHECK-NEXT:   Module Verifier
 ; CHECK-NEXT:   Lower Garbage Collection Instructions
Index: llvm/test/CodeGen/X86/AMX/amx-type.ll
===
--- llvm/test/CodeGen/X86/AMX/amx-type.ll
+++ llvm/test/CodeGen/X86/AMX/amx-type.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -lower-amx-type %s -S | FileCheck %s
+; RUN: opt --codegen-opt-level=2 -mtriple=x86_64 -lower-amx-type %s -S | FileCheck %s
 
 %struct.__tile_str = type { i16, i16, <256 x i32> }
 
Index: llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
@@ -0,0 +1,237 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -mtriple=x86_64 -lower-amx-intrinsics %s -S | FileCheck %s
+
+define dso_local void @test_amx_load_non_O0(i16 signext %row, i16 signext %col, i8 *%ptr, i64 %stride, <256 x i32>* %vptr) {
+; CHECK-LABEL: @test_amx_load_non_O0(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[TMP0:%.*]] = lshr i16 [[COL:%.*]], 2
+; CHECK-NEXT:[[TMP1:%.*]] = lshr i64 [[STRIDE:%.*]], 2
+; CHECK-NEXT:br label [[TILELOAD_SCALARIZE_ROWS_HEADER:%.*]]
+; CHECK:   tileload.scalarize.rows.header:
+; CHECK-NEXT:[[TILELOAD_SCALARIZE_ROWS_IV:%.*]] = phi i16 [ 0, [[ENTRY:%.*]] ], [ [[TILELOAD_SCALARIZE_ROWS_STEP:%.*]], [[TILELOAD_SCALARIZE_ROWS_LATCH:%.*]] ]
+; CHECK-NEXT:[[VEC_PHI_ROW:%.*]] = phi <256 x i32> [ zeroinitializer, [[ENTRY]] ], [ [[TMP11:%.*]], [[TILELOAD_SCALARIZE_ROWS_LATCH]] ]
+; CHECK-NEXT:br label [[TILELOAD_SCALARIZE_ROWS_BODY:%.*]]
+; CHECK:   tileload.scalarize.rows.body:
+; CHECK-NEXT:br label [[TILELOAD_SCALARIZE_COLS_HEADER:%.*]]
+; CHECK:   tileload.scalarize.cols.header:
+; CHECK-NEXT:[[TILELOAD_SCALARIZE_COLS_IV:%.*]] = phi i16 [ 0, [[TILELOAD_SCALARIZE_ROWS_BODY]] ], [ [[TILELOAD_SCALARIZE_COLS_STEP:%.*]], [[TILELOAD_SCALARIZE_COLS_LATCH:%.*]] ]
+; CHECK-NEXT:[[VEC_PHI:%.*]] = phi <256 x i32> [ [[VEC_PHI_ROW]], [[TILELOAD_SCALARIZE_ROWS_BODY]] ], [ [[TMP11]], [[TILELOAD_SCALARIZE_COLS_LATCH]] ]
+; CHECK-NEXT:br label [[TILELOAD_SCALARIZE_COLS_BODY:%.*]]
+; CHECK:   tileload.scalarize.cols.body:
+; CHECK-NEXT:[[TMP2:%.*]] = zext i16 [[TILELOAD_SCALARIZE_ROWS_IV]] to i64
+; CHECK-NEXT:[[TMP3:%.*]] = zext i16 [[TILELOAD_SCALARIZE_COLS_IV]] to i64
+; CHECK-NEXT:[[TMP4:%.*]] = mul i64 [[TMP2]], [[TMP1]]
+; CHECK-NEXT:[[TMP5:%.*]] = add i64 [[TMP4]], [[TMP3]]
+; CHECK-NEXT:[[TMP6:%.*]] = bitcast i8* [[PTR:%.*]] to i32*
+; CHECK-NEXT:[[TMP7:%.*]] = getelementptr i32, i32* [[TMP6]], i64 [[TMP5]]
+; CHECK-NEXT:[[TMP8:%.*]] = mul i16 [[TILELOAD_SCALARIZE_ROWS_IV]], 16
+; CHECK-NEXT:[[TMP9:%.*]] = add i16 [[TMP8]], [[TILELOAD_SCALARIZE_COLS_IV]]
+; CHECK-NEXT:[[TMP10:%.*]] = load i32, i32* [[TMP7]], align 4
+; CHECK-NEXT:

[PATCH] D95409: [clang] implicitly delete space ship operator with function pointers

2021-02-22 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Thanks, this looks fine. I wish we had a better way to determine whether a 
builtin comparison is usable without actually building a use of it. :-(

In D95409#2565227 , @mizvekov wrote:

> By the way I realize I may not have put the new tests in the appropriate 
> place. Any guidance there welcome.

I've suggested better locations.




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:7680-7681
   S.LookupOverloadedBinOp(CandidateSet, OO, Fns, Args);
-else {
+else if (OO == OO_EqualEqual ||
+ !Args[0]->getType()->isFunctionPointerType()) {
   // FIXME: We determine whether this is a valid expression by checking to

Please can you extend the FIXME comment below to call out that relational 
comparisons on a function pointer is the one known case where there is a 
builtin candidate that can't actually be used?



Comment at: clang/test/CXX/class/class.compare/class.compare.default/p6.cpp:1
+// RUN: %clang_cc1 -std=c++2a -verify %s
+

Hm, I don't think this is the right place for this test. The `A` test is a test 
for [class.compare.default]p2 (which disallows reference members). The `B`, 
`C`, and `D` tests are for [class.eq]p2 (which requires `xi == xi` to be a 
usable expression). Can you move the tests to those places?



Comment at: clang/test/CXX/class/class.compare/class.spaceship/p4.cpp:19
+  auto operator<=>(A const &) const = default; // expected-warning 
{{explicitly defaulted three-way comparison operator is implicitly deleted}}
+  const int  = 0;// expected-note {{defaulted 
'operator<=>' is implicitly deleted because class 'A' has a reference member}}
+};

Similar to above, this is [class.compare.default]p2.



Comment at: clang/test/CXX/class/class.compare/class.spaceship/p4.cpp:34
+  auto operator<=>(D const &) const = default; // expected-warning 
{{explicitly defaulted three-way comparison operator is implicitly deleted}}
+  int D::*a;   // expected-note {{defaulted 
'operator<=>' is implicitly deleted because there is no viable comparison 
function for member 'a'}}
+};

... and these are [class.spaceship]p2 ("The operator function is defined as 
deleted if that expression is not usable")


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95409

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


[PATCH] D97251: [llvm] Add assertions for the smart pointers with the possibility to be null in ClangAttrEmitter

2021-02-22 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie added a comment.

As a recursive function it is, the original patch in D91844 
 was adding assertions where the function is 
called other places in the file.

To confirm it will not lead to a crash here, I re-build my code base with clang 
and clang-tools-extra enabled. Everything seems to be good.

What do you think about the assertion? Should it be located just here or where 
the function is called?

Refer to D91844  for more details about the 
previous version.




Comment at: clang/utils/TableGen/ClangAttrEmitter.cpp:1364
 
+  assert(Ptr && "Cannot create argument.");
+

Just as what has been suggested by @dexonsmith in D91844, I add the assertion 
here. However, as a recursive function it is (line 1359), I still concern 
whether the assertion here will lead to a crash.

What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97251

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


[PATCH] D97251: [llvm] Add assertions for the smart pointers with the possibility to be null in ClangAttrEmitter

2021-02-22 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie created this revision.
OikawaKirie added reviewers: dexonsmith, aaron.ballman, pcc.
OikawaKirie added a project: clang.
OikawaKirie requested review of this revision.
Herald added a subscriber: cfe-commits.

Split from D91844 .

The return value of createArgument in file 
clang/utils/TableGen/ClangAttrEmitter.cpp. Although there are a lot of checks 
in the function, nullptr is still possible to be returned.
In this patch, I added an assertion to confirm that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97251

Files:
  clang/utils/TableGen/ClangAttrEmitter.cpp


Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -1361,6 +1361,8 @@
 }
   }
 
+  assert(Ptr && "Cannot create argument.");
+
   if (Ptr && Arg.getValueAsBit("Optional"))
 Ptr->setOptional(true);
 


Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -1361,6 +1361,8 @@
 }
   }
 
+  assert(Ptr && "Cannot create argument.");
+
   if (Ptr && Arg.getValueAsBit("Optional"))
 Ptr->setOptional(true);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97137: Bug fix of clang-format, the AlignConsecutiveDeclarations option doesn't handle pointer properly

2021-02-22 Thread Darwin Xu via Phabricator via cfe-commits
darwin added a comment.

In D97137#2579669 , 
@HazardyKnusperkeks wrote:

> You should mark comments as done, if they are.
>
> Does your modification maybe add something to the alignment which is not a 
> declaration?
>
>   int a;
>   double b;
>   a * b;
>
> How is that formatted? Yeah unlikely that something like that is in code, but 
> it could be if `operator*` has side effects and one does not need the result.

Good question.

I've tested the original code and the modified code, both will generate the 
same result:

  inta;
  double b;
  a* b;

I understand the expected format should be:

  inta;
  double b;
  a* b;

Maybe we can register another bug to track it.

For the side effects, I couldn't answer this yet since I am no expert. Can 
someone take a deep look of it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97137

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


[PATCH] D97246: [ASTMatchers] Fix matching failure in IgnoreUnlessSpelledInSource mode

2021-02-22 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: klimek, steveire, aaron.ballman.
njames93 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

For the hasAnyCtorInitializer matcher, the matcher finds the first innermatch 
that is successful.
Then it checks if it should be ignored, and if so, the whole match fails.
This opens up an issue when an implicit initializer matchers the inner matcher 
but is disregarded for being implicit, preventing an explicit initializer 
matching.

This also happens with the hasMethod matcher, although I can't get a test to 
fail using that.
Presumably because implicit methods are generated after all explicit methods.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97246

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -3276,6 +3276,18 @@
  hasExplicitSpecifier(callExpr(has(declRefExpr()),
 true, {"-std=c++20"}));
   }
+  Code = R"cpp(
+struct Foo{
+  int A = 4, B;
+  Foo() : B(5) {}
+};
+  )cpp";
+  {
+auto M =
+cxxConstructorDecl(hasAnyConstructorInitializer(cxxCtorInitializer()));
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_TRUE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
 }
 
 template 
Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -792,6 +792,12 @@
   return End;
 }
 
+inline bool isSpelledInSource(const Decl *Node) { return !Node->isImplicit(); }
+
+inline bool isSpelledInSource(const CXXCtorInitializer *Node) {
+  return Node->isWritten();
+}
+
 /// Finds the first node in a pointer range that matches the given
 /// matcher.
 template 
@@ -808,6 +814,26 @@
   return End;
 }
 
+/// Finds the first node in a pointer range that matches the given
+/// matcher. Ignores any nodes that aren't spelled in source if Finder is ignore
+/// them.
+template 
+IteratorT matchesFirstInPointerRangeIgnoreUnspelled(
+const MatcherT , IteratorT Start, IteratorT End,
+ASTMatchFinder *Finder, BoundNodesTreeBuilder *Builder) {
+  bool IgnoreIsSpelledInSource = Finder->isTraversalIgnoringImplicitNodes();
+  for (IteratorT I = Start; I != End; ++I) {
+if (IgnoreIsSpelledInSource && !isSpelledInSource(*I))
+  continue;
+BoundNodesTreeBuilder Result(*Builder);
+if (Matcher.matches(**I, Finder, )) {
+  *Builder = std::move(Result);
+  return I;
+}
+  }
+  return End;
+}
+
 template ::value>
   * = nullptr>
 inline bool isDefaultedHelper(const T *) {
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -3293,13 +3293,10 @@
 AST_MATCHER_P(CXXRecordDecl, hasMethod, internal::Matcher,
   InnerMatcher) {
   BoundNodesTreeBuilder Result(*Builder);
-  auto MatchIt = matchesFirstInPointerRange(InnerMatcher, Node.method_begin(),
-Node.method_end(), Finder, );
+  auto MatchIt = matchesFirstInPointerRangeIgnoreUnspelled(
+  InnerMatcher, Node.method_begin(), Node.method_end(), Finder, );
   if (MatchIt == Node.method_end())
 return false;
-
-  if (Finder->isTraversalIgnoringImplicitNodes() && (*MatchIt)->isImplicit())
-return false;
   *Builder = std::move(Result);
   return true;
 }
@@ -4358,11 +4355,9 @@
 ///   record matches Foo, hasAnyConstructorInitializer matches foo_(1)
 AST_MATCHER_P(CXXConstructorDecl, hasAnyConstructorInitializer,
   internal::Matcher, InnerMatcher) {
-  auto MatchIt = matchesFirstInPointerRange(InnerMatcher, Node.init_begin(),
-Node.init_end(), Finder, Builder);
-  if (MatchIt == Node.init_end())
-return false;
-  return (*MatchIt)->isWritten() || !Finder->isTraversalIgnoringImplicitNodes();
+  auto MatchIt = matchesFirstInPointerRangeIgnoreUnspelled(
+  InnerMatcher, Node.init_begin(), Node.init_end(), Finder, Builder);
+  return MatchIt != Node.init_end();
 }
 
 /// Matches the field declaration of a constructor initializer.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93446: [RISCV] Add vadd with mask and without mask builtin.

2021-02-22 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsRISCV.def:1
+#if defined(BUILTIN) && !defined(RISCVV_BUILTIN)
+#define RISCVV_BUILTIN(ID, TYPE, ATTRS) BUILTIN(ID, TYPE, ATTRS)

Need copyright header



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11133
+// RISC-V V-extension
+def err_riscvv_builtin_not_useable : Error<
+   "builtin requires 'V' extension support to be enabled">;

I'm not sure that's the right spelling of useable. It can also be spelled 
usable. But it doesn't appear in the message so maybe the name should be closer 
to wording of the message? Maybe err_riscv_builtin_requires_v. That makes it 
like err_mips_builtin_requires_dsp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93446

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


[PATCH] D97101: [Coverage] Emit zero count gap region between statements if first statements contains return, throw, goto, co_return

2021-02-22 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments.



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:559
 
-  /// Location of the last terminated region.
-  Optional> LastTerminatedRegion;
+  /// If there is a return, co_return, goto or throw inside.
+  bool HasTerminateStmt = false;

nit: Whether the visitor is at a ... stmt?



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:593
   MostRecentLocation = *StartLoc;
-  completeDeferred(Count, MostRecentLocation);
 }
 

Does this mean a deferred gap region following a `break;` statement won't be 
completed before the next region is pushed?



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:942
 pushRegion(Counter::getZero());
-auto  = getRegion();
-ZeroRegion.setDeferred(true);
-LastTerminatedRegion = {EndLoc, RegionStack.size()};
+if (!HasTerminateStmt) {
+  auto  = getRegion();

What's supposed to be the difference between the zero region pushed after a 
`return;` vs. after a `break;`?



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:1057
+if (SaveTerminateStmt)
+  HasTerminateStmt = true;
 handleFileExit(getEnd(S));

Can this replace all of the machinery around DeferredRegions? It'd be nice to 
just have one way to set up gaps between statements.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97101

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


[PATCH] D96816: [ObjC] Encode pointers to C++ classes as "^v" if the encoded string would otherwise include template specialization types

2021-02-22 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

I managed to reproduce the failure by building everything with 
`-DLLVM_APPEND_VC_REV=NO`.

What I found was that any `BENIGN_LANGOPT` added to `LangOptions.def` would 
cause the test to fail since `CompilerInvocation::getModuleHash` doesn't use 
the option to compute the hash if it's a `BENIGN_LANGOPT`. The test was added a 
month ago, so I think my commit was the first to cause the failure. If I use 
`LANGOPT` instead of `BENIGN_LANGOPT`, the test passes.

The description of `BENIGN_LANGOPT` says "for options that don't affect the 
construction of the AST in any way" and since the option can change the AST 
(e.g., the value of `unsigned length = sizeof(@encode(S));` will differ 
depending on whether the member for the option is set or not), I think I should 
have used `LANGOPT` instead of `BENIGN_LANGOPT`.

Since this is something that is easy to overlook, should there be a comment to 
remind people to update the version whenever they add a `BENIGN_LANGOPT`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96816

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


[PATCH] D97243: [clang-tidy] Remove IncludeInserter from MoveConstructorInit check.

2021-02-22 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 325626.
njames93 added a comment.

Remove unnessary headers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97243

Files:
  clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp
  clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.h
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/performance-move-constructor-init.rst

Index: clang-tools-extra/docs/clang-tidy/checks/performance-move-constructor-init.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/performance-move-constructor-init.rst
+++ clang-tools-extra/docs/clang-tidy/checks/performance-move-constructor-init.rst
@@ -8,11 +8,3 @@
 The check flags user-defined move constructors that have a ctor-initializer
 initializing a member or base class through a copy constructor instead of a
 move constructor.
-
-Options

-
-.. option:: IncludeStyle
-
-   A string specifying which include-style is used, `llvm` or `google`. Default
-   is `llvm`.
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -265,7 +265,7 @@
`performance-inefficient-string-concatenation `_,
`performance-inefficient-vector-operation `_, "Yes"
`performance-move-const-arg `_, "Yes"
-   `performance-move-constructor-init `_, "Yes"
+   `performance-move-constructor-init `_,
`performance-no-automatic-move `_,
`performance-no-int-to-ptr `_,
`performance-noexcept-move-constructor `_, "Yes"
@@ -332,7 +332,7 @@
`cert-fio38-c `_, `misc-non-copyable-objects `_,
`cert-msc30-c `_, `cert-msc50-cpp `_,
`cert-msc32-c `_, `cert-msc51-cpp `_,
-   `cert-oop11-cpp `_, `performance-move-constructor-init `_, "Yes"
+   `cert-oop11-cpp `_, `performance-move-constructor-init `_,
`cert-oop54-cpp `_, `bugprone-unhandled-self-assignment `_,
`cert-pos44-c `_, `bugprone-bad-signal-to-kill-thread `_,
`cert-pos47-c `_, `concurrency-thread-canceltype-asynchronous `_,
Index: clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.h
===
--- clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.h
+++ clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.h
@@ -10,9 +10,6 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_MOVECONSTRUCTORINITCHECK_H
 
 #include "../ClangTidyCheck.h"
-#include "../utils/IncludeInserter.h"
-
-#include 
 
 namespace clang {
 namespace tidy {
@@ -31,12 +28,6 @@
   }
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
-  void registerPPCallbacks(const SourceManager , Preprocessor *PP,
-   Preprocessor *ModuleExpanderPP) override;
-  void storeOptions(ClangTidyOptions::OptionMap ) override;
-
-private:
-  utils::IncludeInserter Inserter;
 };
 
 } // namespace performance
Index: clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp
+++ clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp
@@ -10,9 +10,6 @@
 #include "../utils/Matchers.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/Frontend/CompilerInstance.h"
-#include "clang/Lex/Lexer.h"
-#include "clang/Lex/Preprocessor.h"
 
 using namespace clang::ast_matchers;
 
@@ -22,9 +19,7 @@
 
 MoveConstructorInitCheck::MoveConstructorInitCheck(StringRef Name,
ClangTidyContext *Context)
-: ClangTidyCheck(Name, Context),
-  Inserter(Options.getLocalOrGlobal("IncludeStyle",
-utils::IncludeSorter::IS_LLVM)) {}
+: ClangTidyCheck(Name, Context) {}
 
 void MoveConstructorInitCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
@@ -88,15 +83,6 @@
   }
 }
 
-void MoveConstructorInitCheck::registerPPCallbacks(
-const SourceManager , Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
-  Inserter.registerPreprocessor(PP);
-}
-
-void MoveConstructorInitCheck::storeOptions(ClangTidyOptions::OptionMap ) {
-  Options.store(Opts, "IncludeStyle", Inserter.getStyle());
-}
-
 } // namespace performance
 } // namespace tidy
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97243: [clang-tidy] Remove IncludeInserter from MoveConstructorInit check.

2021-02-22 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: alexfh, aaron.ballman.
Herald added a subscriber: xazax.hun.
njames93 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This check registers an IncludeInserter, however the check itself doesn't 
actually emit any fixes or includes, so the inserter is redundant.

>From what I can tell the fixes were removed in D26453 
>(rL290051 
>) but the inserter was left in, probably an 
>oversight.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97243

Files:
  clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp
  clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.h
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/performance-move-constructor-init.rst


Index: 
clang-tools-extra/docs/clang-tidy/checks/performance-move-constructor-init.rst
===
--- 
clang-tools-extra/docs/clang-tidy/checks/performance-move-constructor-init.rst
+++ 
clang-tools-extra/docs/clang-tidy/checks/performance-move-constructor-init.rst
@@ -8,11 +8,3 @@
 The check flags user-defined move constructors that have a ctor-initializer
 initializing a member or base class through a copy constructor instead of a
 move constructor.
-
-Options

-
-.. option:: IncludeStyle
-
-   A string specifying which include-style is used, `llvm` or `google`. Default
-   is `llvm`.
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -265,7 +265,7 @@
`performance-inefficient-string-concatenation 
`_,
`performance-inefficient-vector-operation 
`_, "Yes"
`performance-move-const-arg `_, "Yes"
-   `performance-move-constructor-init 
`_, "Yes"
+   `performance-move-constructor-init 
`_,
`performance-no-automatic-move `_,
`performance-no-int-to-ptr `_,
`performance-noexcept-move-constructor 
`_, "Yes"
@@ -332,7 +332,7 @@
`cert-fio38-c `_, `misc-non-copyable-objects 
`_,
`cert-msc30-c `_, `cert-msc50-cpp 
`_,
`cert-msc32-c `_, `cert-msc51-cpp 
`_,
-   `cert-oop11-cpp `_, `performance-move-constructor-init 
`_, "Yes"
+   `cert-oop11-cpp `_, `performance-move-constructor-init 
`_,
`cert-oop54-cpp `_, 
`bugprone-unhandled-self-assignment `_,
`cert-pos44-c `_, `bugprone-bad-signal-to-kill-thread 
`_,
`cert-pos47-c `_, 
`concurrency-thread-canceltype-asynchronous 
`_,
Index: clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.h
===
--- clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.h
+++ clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.h
@@ -31,12 +31,6 @@
   }
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
-  void registerPPCallbacks(const SourceManager , Preprocessor *PP,
-   Preprocessor *ModuleExpanderPP) override;
-  void storeOptions(ClangTidyOptions::OptionMap ) override;
-
-private:
-  utils::IncludeInserter Inserter;
 };
 
 } // namespace performance
Index: clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp
+++ clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp
@@ -22,9 +22,7 @@
 
 MoveConstructorInitCheck::MoveConstructorInitCheck(StringRef Name,
ClangTidyContext *Context)
-: ClangTidyCheck(Name, Context),
-  Inserter(Options.getLocalOrGlobal("IncludeStyle",
-utils::IncludeSorter::IS_LLVM)) {}
+: ClangTidyCheck(Name, Context) {}
 
 void MoveConstructorInitCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
@@ -88,15 +86,6 @@
   }
 }
 
-void MoveConstructorInitCheck::registerPPCallbacks(
-const SourceManager , Preprocessor *PP, Preprocessor *ModuleExpanderPP) 
{
-  Inserter.registerPreprocessor(PP);
-}
-
-void MoveConstructorInitCheck::storeOptions(ClangTidyOptions::OptionMap ) 
{
-  Options.store(Opts, "IncludeStyle", Inserter.getStyle());
-}
-
 } // namespace performance
 } // namespace tidy
 } // namespace clang


Index: clang-tools-extra/docs/clang-tidy/checks/performance-move-constructor-init.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/performance-move-constructor-init.rst
+++ clang-tools-extra/docs/clang-tidy/checks/performance-move-constructor-init.rst
@@ -8,11 +8,3 @@
 The check flags 

[PATCH] D97204: [RFC] Clang 64-bit source locations

2021-02-22 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added a comment.

Hi @miyuki,

> A major thing worth noting is that 64-bit source locations will
> require an ABI breakage in libclang. This patch changes the bit width
> in libclang unconditionally, rather than making it configurable.

Is it possible to make the libclang change configurable as well? A libclang ABI 
breakage would be problematic for us at Apple. We support dynamically loading 
and using multiple libclang dylibs from different toolchains, which can be 
different clang versions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97204

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


[PATCH] D97121: [clang-tidy] Add a single fix mode to clang-tidy

2021-02-22 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 325622.
njames93 added a comment.

Add include insertion test for clangd showing it attaching the include for 
multiple warnings.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97121

Files:
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
  clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp
  clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
  clang-tools-extra/clang-tidy/utils/IncludeInserter.h
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
@@ -30,8 +30,9 @@
 public:
   IncludeInserterCheckBase(StringRef CheckName, ClangTidyContext *Context,
utils::IncludeSorter::IncludeStyle Style =
-   utils::IncludeSorter::IS_Google)
-  : ClangTidyCheck(CheckName, Context), Inserter(Style) {}
+   utils::IncludeSorter::IS_Google,
+   bool SingleFixMode = false)
+  : ClangTidyCheck(CheckName, Context), Inserter(Style, SingleFixMode) {}
 
   void registerPPCallbacks(const SourceManager , Preprocessor *PP,
Preprocessor *ModuleExpanderPP) override {
@@ -85,6 +86,18 @@
   }
 };
 
+class MultipleHeaderSingleInserterCheck : public IncludeInserterCheckBase {
+public:
+  MultipleHeaderSingleInserterCheck(StringRef CheckName,
+ClangTidyContext *Context)
+  : IncludeInserterCheckBase(CheckName, Context,
+ utils::IncludeSorter::IS_Google, true) {}
+
+  std::vector headersToInclude() const override {
+return {"path/to/header.h", "path/to/header2.h", "path/to/header.h"};
+  }
+};
+
 class CSystemIncludeInserterCheck : public IncludeInserterCheckBase {
 public:
   CSystemIncludeInserterCheck(StringRef CheckName, ClangTidyContext *Context)
@@ -246,6 +259,41 @@
 PreCode, "clang_tidy/tests/insert_includes_test_input2.cc"));
 }
 
+TEST(IncludeInserterTest, InsertMultipleIncludesNoDeduplicate) {
+  const char *PreCode = R"(
+#include "clang_tidy/tests/insert_includes_test_header.h"
+
+#include 
+#include 
+
+#include "path/to/a/header.h"
+
+void foo() {
+  int a = 0;
+})";
+  // FIXME ClangFormat bug - https://bugs.llvm.org/show_bug.cgi?id=49298
+  // clang-format off
+  const char *PostCode = R"(
+#include "clang_tidy/tests/insert_includes_test_header.h"
+
+#include 
+#include 
+
+#include "path/to/a/header.h"
+#include "path/to/header.h"
+#include "path/to/header2.h"
+#include "path/to/header.h"
+
+void foo() {
+  int a = 0;
+})";
+  // clang-format on
+
+  EXPECT_EQ(PostCode,
+runCheckOnCode(
+PreCode, "clang_tidy/tests/insert_includes_test_input2.cc"));
+}
+
 TEST(IncludeInserterTest, InsertBeforeFirstNonSystemInclude) {
   const char *PreCode = R"(
 #include "clang_tidy/tests/insert_includes_test_header.h"
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -517,6 +517,67 @@
   ElementsAre(Diag(Main.range(), "do not use 'else' after 'return'")));
 }
 
+TEST(DiagnosticTest, ClangTidySingleFixMode) {
+  Annotations Main(R"cpp($MathHeader[[]]
+struct Foo{
+  int A, B;
+  Foo()$Fix[[]] {
+$A[[A = 1;]]
+$B[[B = 1;]]
+  }
+};
+void InitVariables() {
+  float $C[[C]]$CFix[[]];
+  double $D[[D]]$DFix[[]];
+}
+  )cpp");
+  TestTU TU = 

[clang] 7c83799 - [MacroExpansionContext] Fix a warning.

2021-02-22 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2021-02-22T16:54:57-08:00
New Revision: 7c83799fd838df3ed00ead500997168ed3f1bd17

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

LOG: [MacroExpansionContext] Fix a warning.

This patch fixes:

  error: private field 'PP' is not used [-Werror,-Wunused-private-field]

Added: 


Modified: 
clang/lib/Analysis/MacroExpansionContext.cpp

Removed: 




diff  --git a/clang/lib/Analysis/MacroExpansionContext.cpp 
b/clang/lib/Analysis/MacroExpansionContext.cpp
index bb5095a114cb..f261ba8d5389 100644
--- a/clang/lib/Analysis/MacroExpansionContext.cpp
+++ b/clang/lib/Analysis/MacroExpansionContext.cpp
@@ -46,6 +46,7 @@ class MacroExpansionRangeRecorder : public PPCallbacks {
   return SM.getExpansionLoc(Range.getEnd()).getLocWithOffset(1);
 }();
 
+(void)PP;
 LLVM_DEBUG(llvm::dbgs() << "MacroExpands event: '";
dumpTokenInto(PP, llvm::dbgs(), MacroName);
llvm::dbgs()



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


[PATCH] D93003: [libunwind] unw_* alias fixes for ELF and Mach-O

2021-02-22 Thread Ryan Prichard 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 rG729899f7b6bf: [libunwind] unw_* alias fixes for ELF and 
Mach-O (authored by rprichard).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93003

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  libunwind/CMakeLists.txt
  libunwind/src/CMakeLists.txt
  libunwind/src/assembly.h
  libunwind/src/config.h
  llvm/utils/gn/secondary/libunwind/src/BUILD.gn

Index: llvm/utils/gn/secondary/libunwind/src/BUILD.gn
===
--- llvm/utils/gn/secondary/libunwind/src/BUILD.gn
+++ llvm/utils/gn/secondary/libunwind/src/BUILD.gn
@@ -111,7 +111,7 @@
   if (!invoker.export) {
 cflags = [ "-fvisibility=hidden" ]
 cflags_cc = [ "-fvisibility-global-new-delete-hidden" ]
-defines = [ "_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS" ]
+defines = [ "_LIBUNWIND_HIDE_SYMBOLS" ]
   }
   deps = [ "//compiler-rt/lib/builtins" ]
   configs += [ ":unwind_config" ]
Index: libunwind/src/config.h
===
--- libunwind/src/config.h
+++ libunwind/src/config.h
@@ -52,7 +52,8 @@
   #endif
 #endif
 
-#if defined(_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
+#if defined(_LIBUNWIND_HIDE_SYMBOLS)
+  // The CMake file passes -fvisibility=hidden to control ELF/Mach-O visibility.
   #define _LIBUNWIND_EXPORT
   #define _LIBUNWIND_HIDDEN
 #else
@@ -70,11 +71,15 @@
 #define SYMBOL_NAME(name) XSTR(__USER_LABEL_PREFIX__) #name
 
 #if defined(__APPLE__)
+#if defined(_LIBUNWIND_HIDE_SYMBOLS)
+#define _LIBUNWIND_ALIAS_VISIBILITY(name) __asm__(".private_extern " name)
+#else
+#define _LIBUNWIND_ALIAS_VISIBILITY(name)
+#endif
 #define _LIBUNWIND_WEAK_ALIAS(name, aliasname) \
   __asm__(".globl " SYMBOL_NAME(aliasname));   \
   __asm__(SYMBOL_NAME(aliasname) " = " SYMBOL_NAME(name)); \
-  extern "C" _LIBUNWIND_EXPORT __typeof(name) aliasname\
-  __attribute__((weak_import));
+  _LIBUNWIND_ALIAS_VISIBILITY(SYMBOL_NAME(aliasname));
 #elif defined(__ELF__)
 #define _LIBUNWIND_WEAK_ALIAS(name, aliasname) \
   extern "C" _LIBUNWIND_EXPORT __typeof(name) aliasname\
Index: libunwind/src/assembly.h
===
--- libunwind/src/assembly.h
+++ libunwind/src/assembly.h
@@ -70,12 +70,15 @@
 #if defined(__APPLE__)
 
 #define SYMBOL_IS_FUNC(name)
-#define EXPORT_SYMBOL(name)
 #define HIDDEN_SYMBOL(name) .private_extern name
-#define WEAK_SYMBOL(name) .weak_reference name
+#if defined(_LIBUNWIND_HIDE_SYMBOLS)
+#define EXPORT_SYMBOL(name) HIDDEN_SYMBOL(name)
+#else
+#define EXPORT_SYMBOL(name)
+#endif
 #define WEAK_ALIAS(name, aliasname)\
   .globl SYMBOL_NAME(aliasname) SEPARATOR  \
-  WEAK_SYMBOL(aliasname) SEPARATOR \
+  EXPORT_SYMBOL(SYMBOL_NAME(aliasname)) SEPARATOR  \
   SYMBOL_NAME(aliasname) = SYMBOL_NAME(name)
 
 #define NO_EXEC_STACK_DIRECTIVE
@@ -87,17 +90,23 @@
 #else
 #define SYMBOL_IS_FUNC(name) .type name,@function
 #endif
-#define EXPORT_SYMBOL(name)
 #define HIDDEN_SYMBOL(name) .hidden name
+#if defined(_LIBUNWIND_HIDE_SYMBOLS)
+#define EXPORT_SYMBOL(name) HIDDEN_SYMBOL(name)
+#else
+#define EXPORT_SYMBOL(name)
+#endif
 #define WEAK_SYMBOL(name) .weak name
 
 #if defined(__hexagon__)
-#define WEAK_ALIAS(name, aliasname) \
-  WEAK_SYMBOL(aliasname) SEPARATOR \
+#define WEAK_ALIAS(name, aliasname)\
+  EXPORT_SYMBOL(SYMBOL_NAME(aliasname)) SEPARATOR  \
+  WEAK_SYMBOL(SYMBOL_NAME(aliasname)) SEPARATOR\
   .equiv SYMBOL_NAME(aliasname), SYMBOL_NAME(name)
 #else
 #define WEAK_ALIAS(name, aliasname)\
-  WEAK_SYMBOL(aliasname) SEPARATOR \
+  EXPORT_SYMBOL(SYMBOL_NAME(aliasname)) SEPARATOR  \
+  WEAK_SYMBOL(SYMBOL_NAME(aliasname)) SEPARATOR\
   SYMBOL_NAME(aliasname) = SYMBOL_NAME(name)
 #endif
 
@@ -119,7 +128,7 @@
   .section .drectve,"yn" SEPARATOR \
   .ascii "-export:", #name, "\0" SEPARATOR \
   .text
-#if defined(_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
+#if defined(_LIBUNWIND_HIDE_SYMBOLS)
 #define EXPORT_SYMBOL(name)
 #else
 #define EXPORT_SYMBOL(name) EXPORT_SYMBOL2(name)
Index: libunwind/src/CMakeLists.txt

[libunwind] 729899f - [libunwind] unw_* alias fixes for ELF and Mach-O

2021-02-22 Thread Ryan Prichard via cfe-commits

Author: Ryan Prichard
Date: 2021-02-22T16:54:05-08:00
New Revision: 729899f7b6bf6aff65988d895d7a639391a67608

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

LOG: [libunwind] unw_* alias fixes for ELF and Mach-O

Rename the CMake option, LIBUNWIND_HERMETIC_STATIC_LIBRARY, to
LIBUNWIND_HIDE_SYMBOLS. Rename the C macro define,
_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS, to _LIBUNWIND_HIDE_SYMBOLS,
because now the macro adds a .hidden directive rather than merely
suppress visibility annotations.

For ELF, when LIBUNWIND_HIDE_SYMBOLS is enabled, mark unw_getcontext as
hidden. This symbol is the only one defined using src/assembly.h's
WEAK_ALIAS macro. Other unw_* weak aliases are defined in C++ and are
already hidden.

Mach-O doesn't support weak aliases, so remove .weak_reference and
weak_import. When LIBUNWIND_HIDE_SYMBOLS is enabled, output
.private_extern for the unw_* aliases.

In assembly.h, add missing SYMBOL_NAME macro invocations, which are
used to prefix symbol names with '_' on some targets.

Fixes PR46709.

Reviewed By: #libunwind, phosek, compnerd, steven_wu

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
libunwind/CMakeLists.txt
libunwind/src/CMakeLists.txt
libunwind/src/assembly.h
libunwind/src/config.h
llvm/utils/gn/secondary/libunwind/src/BUILD.gn

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 1c14d2fec404..7f84f74d348f 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -179,7 +179,7 @@ if(FUCHSIA_SDK)
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_SYSROOT 
${FUCHSIA_${target}_SYSROOT} CACHE PATH "")
 set(RUNTIMES_${target}-unknown-fuchsia_COMPILER_RT_USE_BUILTINS_LIBRARY ON 
CACHE BOOL "")
 set(RUNTIMES_${target}-unknown-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE 
BOOL "")
-set(RUNTIMES_${target}-unknown-fuchsia_LIBUNWIND_HERMETIC_STATIC_LIBRARY 
ON CACHE BOOL "")
+set(RUNTIMES_${target}-unknown-fuchsia_LIBUNWIND_HIDE_SYMBOLS ON CACHE 
BOOL "")
 set(RUNTIMES_${target}-unknown-fuchsia_LIBUNWIND_INSTALL_STATIC_LIBRARY 
OFF CACHE BOOL "")
 set(RUNTIMES_${target}-unknown-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE 
BOOL "")
 set(RUNTIMES_${target}-unknown-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON 
CACHE BOOL "")

diff  --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index 140700030aff..628f0aaa0506 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -102,7 +102,7 @@ elseif(LIBUNWIND_BUILD_32_BITS)
   message(FATAL_ERROR "LIBUNWIND_BUILD_32_BITS=ON is not supported on this 
platform.")
 endif()
 
-option(LIBUNWIND_HERMETIC_STATIC_LIBRARY
+option(LIBUNWIND_HIDE_SYMBOLS
   "Do not export any symbols from the static library." OFF)
 
 
#===
@@ -321,7 +321,7 @@ endif()
 
 # Disable DLL annotations on Windows for static builds.
 if (WIN32 AND LIBUNWIND_ENABLE_STATIC AND NOT LIBUNWIND_ENABLE_SHARED)
-  add_definitions(-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
+  add_definitions(-D_LIBUNWIND_HIDE_SYMBOLS)
 endif()
 
 if (LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)

diff  --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index a7045d2c317f..f59dfdde9f03 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -164,11 +164,11 @@ if (LIBUNWIND_ENABLE_STATIC)
 LINKER_LANGUAGE C
 OUTPUT_NAME "unwind")
 
-  if(LIBUNWIND_HERMETIC_STATIC_LIBRARY)
+  if(LIBUNWIND_HIDE_SYMBOLS)
 append_flags_if_supported(UNWIND_STATIC_LIBRARY_FLAGS -fvisibility=hidden)
 append_flags_if_supported(UNWIND_STATIC_LIBRARY_FLAGS 
-fvisibility-global-new-delete-hidden)
 target_compile_options(unwind_static PRIVATE 
${UNWIND_STATIC_LIBRARY_FLAGS})
-target_compile_definitions(unwind_static PRIVATE 
_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
+target_compile_definitions(unwind_static PRIVATE _LIBUNWIND_HIDE_SYMBOLS)
   endif()
 
   list(APPEND LIBUNWIND_BUILD_TARGETS "unwind_static")

diff  --git a/libunwind/src/assembly.h b/libunwind/src/assembly.h
index f2f7c848307e..dcd38198501c 100644
--- a/libunwind/src/assembly.h
+++ b/libunwind/src/assembly.h
@@ -70,12 +70,15 @@
 #if defined(__APPLE__)
 
 #define SYMBOL_IS_FUNC(name)
-#define EXPORT_SYMBOL(name)
 #define HIDDEN_SYMBOL(name) .private_extern name
-#define WEAK_SYMBOL(name) .weak_reference name
+#if defined(_LIBUNWIND_HIDE_SYMBOLS)
+#define EXPORT_SYMBOL(name) HIDDEN_SYMBOL(name)
+#else
+#define EXPORT_SYMBOL(name)
+#endif
 #define WEAK_ALIAS(name, aliasname)
\
   .globl SYMBOL_NAME(aliasname) SEPARATOR 

[clang] 729899f - [libunwind] unw_* alias fixes for ELF and Mach-O

2021-02-22 Thread Ryan Prichard via cfe-commits

Author: Ryan Prichard
Date: 2021-02-22T16:54:05-08:00
New Revision: 729899f7b6bf6aff65988d895d7a639391a67608

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

LOG: [libunwind] unw_* alias fixes for ELF and Mach-O

Rename the CMake option, LIBUNWIND_HERMETIC_STATIC_LIBRARY, to
LIBUNWIND_HIDE_SYMBOLS. Rename the C macro define,
_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS, to _LIBUNWIND_HIDE_SYMBOLS,
because now the macro adds a .hidden directive rather than merely
suppress visibility annotations.

For ELF, when LIBUNWIND_HIDE_SYMBOLS is enabled, mark unw_getcontext as
hidden. This symbol is the only one defined using src/assembly.h's
WEAK_ALIAS macro. Other unw_* weak aliases are defined in C++ and are
already hidden.

Mach-O doesn't support weak aliases, so remove .weak_reference and
weak_import. When LIBUNWIND_HIDE_SYMBOLS is enabled, output
.private_extern for the unw_* aliases.

In assembly.h, add missing SYMBOL_NAME macro invocations, which are
used to prefix symbol names with '_' on some targets.

Fixes PR46709.

Reviewed By: #libunwind, phosek, compnerd, steven_wu

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
libunwind/CMakeLists.txt
libunwind/src/CMakeLists.txt
libunwind/src/assembly.h
libunwind/src/config.h
llvm/utils/gn/secondary/libunwind/src/BUILD.gn

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 1c14d2fec404..7f84f74d348f 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -179,7 +179,7 @@ if(FUCHSIA_SDK)
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_SYSROOT 
${FUCHSIA_${target}_SYSROOT} CACHE PATH "")
 set(RUNTIMES_${target}-unknown-fuchsia_COMPILER_RT_USE_BUILTINS_LIBRARY ON 
CACHE BOOL "")
 set(RUNTIMES_${target}-unknown-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE 
BOOL "")
-set(RUNTIMES_${target}-unknown-fuchsia_LIBUNWIND_HERMETIC_STATIC_LIBRARY 
ON CACHE BOOL "")
+set(RUNTIMES_${target}-unknown-fuchsia_LIBUNWIND_HIDE_SYMBOLS ON CACHE 
BOOL "")
 set(RUNTIMES_${target}-unknown-fuchsia_LIBUNWIND_INSTALL_STATIC_LIBRARY 
OFF CACHE BOOL "")
 set(RUNTIMES_${target}-unknown-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE 
BOOL "")
 set(RUNTIMES_${target}-unknown-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON 
CACHE BOOL "")

diff  --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index 140700030aff..628f0aaa0506 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -102,7 +102,7 @@ elseif(LIBUNWIND_BUILD_32_BITS)
   message(FATAL_ERROR "LIBUNWIND_BUILD_32_BITS=ON is not supported on this 
platform.")
 endif()
 
-option(LIBUNWIND_HERMETIC_STATIC_LIBRARY
+option(LIBUNWIND_HIDE_SYMBOLS
   "Do not export any symbols from the static library." OFF)
 
 
#===
@@ -321,7 +321,7 @@ endif()
 
 # Disable DLL annotations on Windows for static builds.
 if (WIN32 AND LIBUNWIND_ENABLE_STATIC AND NOT LIBUNWIND_ENABLE_SHARED)
-  add_definitions(-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
+  add_definitions(-D_LIBUNWIND_HIDE_SYMBOLS)
 endif()
 
 if (LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)

diff  --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index a7045d2c317f..f59dfdde9f03 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -164,11 +164,11 @@ if (LIBUNWIND_ENABLE_STATIC)
 LINKER_LANGUAGE C
 OUTPUT_NAME "unwind")
 
-  if(LIBUNWIND_HERMETIC_STATIC_LIBRARY)
+  if(LIBUNWIND_HIDE_SYMBOLS)
 append_flags_if_supported(UNWIND_STATIC_LIBRARY_FLAGS -fvisibility=hidden)
 append_flags_if_supported(UNWIND_STATIC_LIBRARY_FLAGS 
-fvisibility-global-new-delete-hidden)
 target_compile_options(unwind_static PRIVATE 
${UNWIND_STATIC_LIBRARY_FLAGS})
-target_compile_definitions(unwind_static PRIVATE 
_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
+target_compile_definitions(unwind_static PRIVATE _LIBUNWIND_HIDE_SYMBOLS)
   endif()
 
   list(APPEND LIBUNWIND_BUILD_TARGETS "unwind_static")

diff  --git a/libunwind/src/assembly.h b/libunwind/src/assembly.h
index f2f7c848307e..dcd38198501c 100644
--- a/libunwind/src/assembly.h
+++ b/libunwind/src/assembly.h
@@ -70,12 +70,15 @@
 #if defined(__APPLE__)
 
 #define SYMBOL_IS_FUNC(name)
-#define EXPORT_SYMBOL(name)
 #define HIDDEN_SYMBOL(name) .private_extern name
-#define WEAK_SYMBOL(name) .weak_reference name
+#if defined(_LIBUNWIND_HIDE_SYMBOLS)
+#define EXPORT_SYMBOL(name) HIDDEN_SYMBOL(name)
+#else
+#define EXPORT_SYMBOL(name)
+#endif
 #define WEAK_ALIAS(name, aliasname)
\
   .globl SYMBOL_NAME(aliasname) SEPARATOR 

[PATCH] D93003: [libunwind] unw_* alias fixes for ELF and Mach-O

2021-02-22 Thread Ryan Prichard via Phabricator via cfe-commits
rprichard added a comment.

The coff-dwarf.test buildbot failures were fixed by 
https://github.com/llvm/llvm-project/commit/0fd7c31a098efdfaa5a57dbac6e9c0921b00a999
 (on Feb 11).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93003

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


[PATCH] D97138: [clang][flang] Improve the consistency of the code-base

2021-02-22 Thread Shao-Ce Sun via Phabricator via cfe-commits
achieveartificialintelligence added a comment.

In D97138#2578563 , @awarzynski wrote:

> Thank you for submitting this @achieveartificialintelligence !
>
> The aim of these changes is to improve the consistency of the code-base with 
> respect to the coding standards documented separately for Clang 
>  and Flang 
> . 
> I think that this is a very positive suggestion, but would like to request a 
> few refinements before this is ready:
>
> - Please note that in LLVM/Clang, variables names start with upper case (so 
> it should be int `main(int Argc, const char **Argv)` instead of `main(int 
> argc, const char **argv)` ). link 
> 
> - In Flang the rules are slightly different, and the variable names start 
> with a lower case (so it should be int `main(int Argc, const char **Argv)` 
> instead of `main(int argc, const char **argv)` ). link 
> 
> - Your commit message refers to _a driver_, but in fact you are updating 2 
> specific drivers: Clang compiler driver and Flang compiler driver - could you 
> clarify?
> - Your commit message refers to `argc_` specifically, but you are updating 
> `argc_`, `argv_` and `Argv/argv` too.
>
> Personally I'd prefer `ArgC/argC` and `ArgV/argV` for input parameters and 
> `ArgValues/argValues` for the local variable. This way it would be more 
> self-explanatory. But that's a matter of style. As long as this is consistent 
> with the coding standards, I think that this should be accepted.

Thank you very much for your comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97138

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


[PATCH] D97138: [clang][flang] Improve the consistency of the code-base

2021-02-22 Thread Shao-Ce Sun via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 325609.
achieveartificialintelligence retitled this revision from "[Driver] replace 
argc_ with argc" to "[clang][flang] Improve the consistency of the code-base".
achieveartificialintelligence edited the summary of this revision.
achieveartificialintelligence removed a reviewer: jhenderson.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97138

Files:
  clang/tools/driver/driver.cpp
  flang/tools/flang-driver/driver.cpp

Index: flang/tools/flang-driver/driver.cpp
===
--- flang/tools/flang-driver/driver.cpp
+++ flang/tools/flang-driver/driver.cpp
@@ -66,27 +66,27 @@
   return 1;
 }
 
-int main(int argc_, const char **argv_) {
+int main(int argC, const char **argV) {
 
   // Initialize variables to call the driver
-  llvm::InitLLVM x(argc_, argv_);
-  llvm::SmallVector argv(argv_, argv_ + argc_);
+  llvm::InitLLVM x(argC, argV);
+  llvm::SmallVector argValues(argV, argV + argC);
 
   clang::driver::ParsedClangName targetandMode("flang", "--driver-mode=flang");
-  std::string driverPath = GetExecutablePath(argv[0]);
+  std::string driverPath = GetExecutablePath(argValues[0]);
 
   // Check if flang-new is in the frontend mode
-  auto firstArg = std::find_if(
-  argv.begin() + 1, argv.end(), [](const char *a) { return a != nullptr; });
-  if (firstArg != argv.end()) {
-if (llvm::StringRef(argv[1]).startswith("-cc1")) {
-  llvm::errs() << "error: unknown integrated tool '" << argv[1] << "'. "
-   << "Valid tools include '-fc1'.\n";
+  auto firstArg = std::find_if(argValues.begin() + 1, argValues.end(),
+  [](const char *a) { return a != nullptr; });
+  if (firstArg != argValues.end()) {
+if (llvm::StringRef(argValues[1]).startswith("-cc1")) {
+  llvm::errs() << "error: unknown integrated tool '" << argValues[1]
+   << "'. " << "Valid tools include '-fc1'.\n";
   return 1;
 }
 // Call flang-new frontend
-if (llvm::StringRef(argv[1]).startswith("-fc1")) {
-  return ExecuteFC1Tool(argv);
+if (llvm::StringRef(argValues[1]).startswith("-fc1")) {
+  return ExecuteFC1Tool(argValues);
 }
   }
 
@@ -94,14 +94,14 @@
 
   // Create DiagnosticsEngine for the compiler driver
   llvm::IntrusiveRefCntPtr diagOpts =
-  CreateAndPopulateDiagOpts(argv);
+  CreateAndPopulateDiagOpts(argValues);
   llvm::IntrusiveRefCntPtr diagID(
   new clang::DiagnosticIDs());
   Fortran::frontend::TextDiagnosticPrinter *diagClient =
   new Fortran::frontend::TextDiagnosticPrinter(llvm::errs(), &*diagOpts);
 
   diagClient->set_prefix(
-  std::string(llvm::sys::path::stem(GetExecutablePath(argv[0];
+  std::string(llvm::sys::path::stem(GetExecutablePath(argValues[0];
 
   clang::DiagnosticsEngine diags(diagID, &*diagOpts, diagClient);
 
@@ -110,7 +110,7 @@
   llvm::sys::getDefaultTargetTriple(), diags, "flang LLVM compiler");
   theDriver.setTargetAndMode(targetandMode);
   std::unique_ptr c(
-  theDriver.BuildCompilation(argv));
+  theDriver.BuildCompilation(argValues));
   llvm::SmallVector, 4>
   failingCommands;
 
Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -340,25 +340,25 @@
   return 1;
 }
 
-int main(int argc_, const char **argv_) {
+int main(int Argc, const char **Argv) {
   noteBottomOfStack();
-  llvm::InitLLVM X(argc_, argv_);
+  llvm::InitLLVM X(Argc, Argv);
   llvm::setBugReportMsg("PLEASE submit a bug report to " BUG_REPORT_URL
 " and include the crash backtrace, preprocessed "
 "source, and associated run script.\n");
-  SmallVector argv(argv_, argv_ + argc_);
+  SmallVector ArgValues(Argv, Argv + Argc);
 
   if (llvm::sys::Process::FixupStandardFileDescriptors())
 return 1;
 
   llvm::InitializeAllTargets();
-  auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(argv[0]);
+  auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(ArgValues[0]);
 
   llvm::BumpPtrAllocator A;
   llvm::StringSaver Saver(A);
 
   // Parse response files using the GNU syntax, unless we're in CL mode. There
-  // are two ways to put clang in CL compatibility mode: argv[0] is either
+  // are two ways to put clang in CL compatibility mode: ArgValues[0] is either
   // clang-cl or cl, or --driver-mode=cl is on the command line. The normal
   // command line parsing can't happen until after response file parsing, so we
   // have to manually search for a --driver-mode=cl argument the hard way.
@@ -366,22 +366,22 @@
   // response files written by clang will tokenize the same way in either mode.
   bool ClangCLMode = false;
   if (StringRef(TargetAndMode.DriverMode).equals("--driver-mode=cl") ||
-  

[PATCH] D97121: [clang-tidy] Add a single fix mode to clang-tidy

2021-02-22 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 325608.
njames93 marked 2 inline comments as done.
njames93 added a comment.

Add test cases to clangd showing the improved behaviour of fix-its.
Rebased.
Update some comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97121

Files:
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
  clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp
  clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
  clang-tools-extra/clang-tidy/utils/IncludeInserter.h
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
@@ -30,8 +30,9 @@
 public:
   IncludeInserterCheckBase(StringRef CheckName, ClangTidyContext *Context,
utils::IncludeSorter::IncludeStyle Style =
-   utils::IncludeSorter::IS_Google)
-  : ClangTidyCheck(CheckName, Context), Inserter(Style) {}
+   utils::IncludeSorter::IS_Google,
+   bool SingleFixMode = false)
+  : ClangTidyCheck(CheckName, Context), Inserter(Style, SingleFixMode) {}
 
   void registerPPCallbacks(const SourceManager , Preprocessor *PP,
Preprocessor *ModuleExpanderPP) override {
@@ -85,6 +86,18 @@
   }
 };
 
+class MultipleHeaderSingleInserterCheck : public IncludeInserterCheckBase {
+public:
+  MultipleHeaderSingleInserterCheck(StringRef CheckName,
+ClangTidyContext *Context)
+  : IncludeInserterCheckBase(CheckName, Context,
+ utils::IncludeSorter::IS_Google, true) {}
+
+  std::vector headersToInclude() const override {
+return {"path/to/header.h", "path/to/header2.h", "path/to/header.h"};
+  }
+};
+
 class CSystemIncludeInserterCheck : public IncludeInserterCheckBase {
 public:
   CSystemIncludeInserterCheck(StringRef CheckName, ClangTidyContext *Context)
@@ -246,6 +259,41 @@
 PreCode, "clang_tidy/tests/insert_includes_test_input2.cc"));
 }
 
+TEST(IncludeInserterTest, InsertMultipleIncludesNoDeduplicate) {
+  const char *PreCode = R"(
+#include "clang_tidy/tests/insert_includes_test_header.h"
+
+#include 
+#include 
+
+#include "path/to/a/header.h"
+
+void foo() {
+  int a = 0;
+})";
+  // FIXME ClangFormat bug - https://bugs.llvm.org/show_bug.cgi?id=49298
+  // clang-format off
+  const char *PostCode = R"(
+#include "clang_tidy/tests/insert_includes_test_header.h"
+
+#include 
+#include 
+
+#include "path/to/a/header.h"
+#include "path/to/header.h"
+#include "path/to/header2.h"
+#include "path/to/header.h"
+
+void foo() {
+  int a = 0;
+})";
+  // clang-format on
+
+  EXPECT_EQ(PostCode,
+runCheckOnCode(
+PreCode, "clang_tidy/tests/insert_includes_test_input2.cc"));
+}
+
 TEST(IncludeInserterTest, InsertBeforeFirstNonSystemInclude) {
   const char *PreCode = R"(
 #include "clang_tidy/tests/insert_includes_test_header.h"
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -517,6 +517,44 @@
   ElementsAre(Diag(Main.range(), "do not use 'else' after 'return'")));
 }
 
+TEST(DiagnosticTest, ClangTidySingleFixMode) {
+  Annotations Main(R"cpp(
+struct Foo{
+  int A, B;
+  Foo()$Fix[[]] {
+$A[[A = 1;]]
+$B[[B = 1;]]
+  }
+};
+  )cpp");
+  TestTU TU = TestTU::withCode(Main.code());
+  TU.ClangTidyProvider =
+  

[PATCH] D97121: [clang-tidy] Add a single fix mode to clang-tidy

2021-02-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp:81
+if (InsertedHeaders[FileID].contains(Header))
+  return llvm::None;
+  } else if (!InsertedHeaders[FileID].insert(Header).second)

njames93 wrote:
> steveire wrote:
> > The comment and the code seem to me to be opposites. The code says "if 
> > `SingleFixMode` is true and we have already inserted the header,  don't 
> > insert it again." The comment says that "`SingleFixMode` does not prevent 
> > inserting it again" -- The comment seems to be the opposite of the code?
> That't not what the code is saying, the magic is clear in the else branch. If 
> SingleFixMode is enabled we are only querying the set, If its disabled then 
> we are updating the set. 
> The real shortfall is the map is called InsertedHeaders which is not a good 
> reflection of what it actually contains. It actually contains all the headers 
> included in each file. Which in `Multi` fix mode gets updated with each 
> include insertion.
Ah, the "and we have already inserted the header, don't insert it again" is not 
true because we never do an `insert` in `SingleFixMode`.

Perhaps update the comment to say that the InsertedHeaders is never added to in 
`SingleFixMode`, so it only contains the headers that are already there? If 
something like that is true.




Comment at: clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp:94
+  : IncludeInserterCheckBase(CheckName, Context,
+ utils::IncludeSorter::IS_Google, true) {}
+

I think the `true` here points to this being a boolean trap. Consider using an 
enum for the parameter instead.



Comment at: clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp:285
+#include "path/to/header2.h"
+#include "path/to/header.h"
+

I still find it really confusing that the "single inserter" mode results in 
multiple of the same header being added.  Perhaps the names should be along the 
lines of "duplicating" and "deduplicating" instead of "single" and "multi"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97121

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


[PATCH] D97121: [clang-tidy] Add a single fix mode to clang-tidy

2021-02-22 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp:81
+if (InsertedHeaders[FileID].contains(Header))
+  return llvm::None;
+  } else if (!InsertedHeaders[FileID].insert(Header).second)

steveire wrote:
> The comment and the code seem to me to be opposites. The code says "if 
> `SingleFixMode` is true and we have already inserted the header,  don't 
> insert it again." The comment says that "`SingleFixMode` does not prevent 
> inserting it again" -- The comment seems to be the opposite of the code?
That't not what the code is saying, the magic is clear in the else branch. If 
SingleFixMode is enabled we are only querying the set, If its disabled then we 
are updating the set. 
The real shortfall is the map is called InsertedHeaders which is not a good 
reflection of what it actually contains. It actually contains all the headers 
included in each file. Which in `Multi` fix mode gets updated with each include 
insertion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97121

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


[clang] e8617f2 - DebugInfo: Emit "LocalToUnit" flag on local member function decls.

2021-02-22 Thread James Y Knight via cfe-commits

Author: James Y Knight
Date: 2021-02-22T18:47:15-05:00
New Revision: e8617f2f1870022b7dd076bf43c7aaee30831197

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

LOG: DebugInfo: Emit "LocalToUnit" flag on local member function decls.

Follow-up to fe2dcd89acfd9301a230e38e9030734553baa8dc.

Update test per review comments, restoring the "D" type to its
original state, and adding new "L" type. (Sorry, this was intended to
be included in the prior commit)

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

Added: 


Modified: 
clang/test/CodeGenCXX/debug-info-class.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/debug-info-class.cpp 
b/clang/test/CodeGenCXX/debug-info-class.cpp
index 1e271be94a9d..a1ef0962dd9d 100644
--- a/clang/test/CodeGenCXX/debug-info-class.cpp
+++ b/clang/test/CodeGenCXX/debug-info-class.cpp
@@ -24,14 +24,12 @@ struct C {
 C::~C() {
 }
 
-namespace {
 struct D {
-  D() {}
-  virtual ~D() {}
+  D();
+  virtual ~D();
   void func() {
   }
 };
-} // namespace
 
 struct E {
   E();
@@ -73,6 +71,13 @@ struct A {
   }
 };
 
+namespace {
+struct L {
+  void func() {
+  }
+};
+}
+
 void f1() {
   D x;
   x.func();
@@ -81,6 +86,8 @@ void f1() {
   F::inner z;
   K k;
   k.func();
+  L l;
+  l.func();
 }
 
 int main(int argc, char **argv) {
@@ -137,12 +144,11 @@ int main(int argc, char **argv) {
 // CHECK-SAME: DIFlagStaticMember
 // CHECK: [[C_DTOR]] = !DISubprogram(name: "~C"
 
-// CHECK: [[D:![0-9]+]] = distinct !DICompositeType(tag: 
DW_TAG_structure_type, name: "D"
+// CHECK: [[D:![0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: 
"D"
 // CHECK-SAME: size:
+// CHECK-SAME: DIFlagFwdDecl
 // CHECK-NOT:  identifier:
 // CHECK-SAME: ){{$}}
-// CHECK: [[D_FUNC_DECL:![0-9]*]] = !DISubprogram(name: "func",{{.*}} scope: 
[[D]]
-// CHECK-SAME: DISPFlagLocalToUnit
 
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "E"
 // CHECK-SAME: DIFlagFwdDecl
@@ -153,11 +159,21 @@ int main(int argc, char **argv) {
 // CHECK-SAME: identifier: "_ZTS1K"
 // CHECK-SAME: ){{$}}
 
+// CHECK: [[L:![0-9]+]] = distinct !DICompositeType(tag: 
DW_TAG_structure_type, name: "L"
+// CHECK-SAME: ){{$}}
+// CHECK: [[L_FUNC_DECL:![0-9]*]] = !DISubprogram(name: "func",{{.*}} scope: 
[[L]]
+// CHECK-SAME: DISPFlagLocalToUnit
+
 // CHECK: !DISubprogram(name: "func",{{.*}} scope: [[D]]
+// CHECK-SAME:  DISPFlagDefinition
+// CHECK-SAME:  declaration: [[D_FUNC_DECL:![0-9]*]]
+// CHECK: [[D_FUNC_DECL]] = !DISubprogram(name: "func",{{.*}} scope: [[D]]
+
+// CHECK: !DISubprogram(name: "func",{{.*}} scope: [[L]]
 // CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-SAME:  declaration: [[D_FUNC_DECL]]
+// CHECK-SAME:  declaration: [[L_FUNC_DECL]]
 
-// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "inner",{{.*}} 
line: 52
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "inner",{{.*}} 
line: 50
 // CHECK-NOT: DIFlagFwdDecl
 // CHECK-SAME: elements: [[G_INNER_MEM:![0-9]*]]
 // CHECK-SAME: identifier: "_ZTSN1G5innerE"
@@ -173,5 +189,5 @@ int main(int argc, char **argv) {
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "A"
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "HdrSize"
 //
-// CHECK: ![[EXCEPTLOC]] = !DILocation(line: 93,
-// CHECK: ![[RETLOC]] = !DILocation(line: 92,
+// CHECK: ![[EXCEPTLOC]] = !DILocation(line: 100,
+// CHECK: ![[RETLOC]] = !DILocation(line: 99,



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


[PATCH] D97121: [clang-tidy] Add a single fix mode to clang-tidy

2021-02-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidyCheck.h:514
   const LangOptions () const { return Context->getLangOpts(); }
+  /// Returns true when the check is ran in a use case when only 1 fix will be
+  /// applied at a time.

Very minor, but I think this should be `run`.



Comment at: clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp:81
+if (InsertedHeaders[FileID].contains(Header))
+  return llvm::None;
+  } else if (!InsertedHeaders[FileID].insert(Header).second)

The comment and the code seem to me to be opposites. The code says "if 
`SingleFixMode` is true and we have already inserted the header,  don't insert 
it again." The comment says that "`SingleFixMode` does not prevent inserting it 
again" -- The comment seems to be the opposite of the code?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97121

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


[PATCH] D97233: Support `#pragma clang section` directives on MachO targets

2021-02-22 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 325599.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97233

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGenCXX/clang-sections.cpp
  clang/test/Sema/pragma-clang-section-macho.c
  llvm/include/llvm/MC/MCSectionMachO.h
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/MC/MCParser/DarwinAsmParser.cpp
  llvm/lib/MC/MCSectionMachO.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/CodeGen/AArch64/clang-section-macho.ll

Index: llvm/test/CodeGen/AArch64/clang-section-macho.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/clang-section-macho.ll
@@ -0,0 +1,11 @@
+;RUN: llc -mtriple=arm64-apple-ios %s -o - | FileCheck %s
+
+define dso_local void @foo() #0 {
+entry:
+  ret void
+}
+
+attributes #0 = { "implicit-section-name"="__TEXT,__mytext" }
+
+; CHECK:  .section	__TEXT,__mytext
+; CHECK-NEXT: .globl	_foo
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1899,9 +1899,11 @@
   StringRef ParsedSegment, ParsedSection;
   unsigned TAA = 0, StubSize = 0;
   bool TAAParsed;
-  std::string ErrorCode = MCSectionMachO::ParseSectionSpecifier(
-  Section, ParsedSegment, ParsedSection, TAA, TAAParsed, StubSize);
-  assert(ErrorCode.empty() && "Invalid section specifier.");
+  cantFail(MCSectionMachO::ParseSectionSpecifier(Section,
+ ParsedSegment,
+ ParsedSection,
+ TAA, TAAParsed,
+ StubSize));
 
   // Ignore the globals from the __OBJC section. The ObjC runtime assumes
   // those conform to /usr/lib/objc/runtime.h, so we can't add redzones to
Index: llvm/lib/MC/MCSectionMachO.cpp
===
--- llvm/lib/MC/MCSectionMachO.cpp
+++ llvm/lib/MC/MCSectionMachO.cpp
@@ -174,12 +174,12 @@
 /// flavored .s file.  If successful, this fills in the specified Out
 /// parameters and returns an empty string.  When an invalid section
 /// specifier is present, this returns a string indicating the problem.
-std::string MCSectionMachO::ParseSectionSpecifier(StringRef Spec,// In.
-  StringRef ,// Out.
-  StringRef ,// Out.
-  unsigned  ,// Out.
-  bool  ,  // Out.
-  unsigned  ) { // Out.
+Error MCSectionMachO::ParseSectionSpecifier(StringRef Spec,// In.
+StringRef ,// Out.
+StringRef ,// Out.
+unsigned  ,// Out.
+bool  ,  // Out.
+unsigned  ) { // Out.
   TAAParsed = false;
 
   SmallVector SplitSpec;
@@ -194,25 +194,23 @@
   StringRef Attrs = GetEmptyOrTrim(3);
   StringRef StubSizeStr = GetEmptyOrTrim(4);
 
-  // Verify that the segment is present and not too long.
-  if (Segment.empty() || Segment.size() > 16)
-return "mach-o section specifier requires a segment whose length is "
-   "between 1 and 16 characters";
-
-  // Verify that the section is present and not too long.
+  // Verify that the section is present.
   if (Section.empty())
-return "mach-o section specifier requires a segment and section "
-   "separated by a comma";
+return createStringError(inconvertibleErrorCode(),
+ "mach-o section specifier requires a segment "
+ "and section separated by a comma");
 
+  // Verify that the section is not too long.
   if (Section.size() > 16)
-return "mach-o section specifier requires a section whose length is "
-   "between 1 and 16 characters";
+return createStringError(inconvertibleErrorCode(),
+ "mach-o section specifier requires a section "
+ "whose length is between 1 and 16 characters");
 
   // If there is no comma after the section, we're done.
   TAA = 0;
   StubSize = 0;
   if (SectionType.empty())
-return "";
+return Error::success();
 
   // Figure 

[PATCH] D97121: [clang-tidy] Add a single fix mode to clang-tidy

2021-02-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

I just tried to apply this, but I think it conflicts with your other change to 
`PreferMemberInitializerCheck.cpp`. Please rebase it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97121

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


[PATCH] D97233: Support `#pragma clang section` directives on MachO targets

2021-02-22 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs added inline comments.



Comment at: llvm/test/CodeGen/AArch64/clang-section-macho.ll:8
+
+attributes #0 = { "implicit-section-name"="TEXT,mytext" }
+

`"__TEXT,__mytext"`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97233

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


[PATCH] D97233: Support `#pragma clang section` directives on MachO targets

2021-02-22 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs created this revision.
jroelofs added reviewers: t.p.northover, javed.absar, rogfer01.
Herald added a subscriber: hiraditya.
Herald added a reviewer: aaron.ballman.
jroelofs requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97233

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGenCXX/clang-sections.cpp
  clang/test/Sema/pragma-clang-section-macho.c
  llvm/include/llvm/MC/MCSectionMachO.h
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/MC/MCParser/DarwinAsmParser.cpp
  llvm/lib/MC/MCSectionMachO.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/CodeGen/AArch64/clang-section-macho.ll

Index: llvm/test/CodeGen/AArch64/clang-section-macho.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/clang-section-macho.ll
@@ -0,0 +1,11 @@
+;RUN: llc -mtriple=arm64-apple-ios %s -o - | FileCheck %s
+
+define dso_local void @foo() #0 {
+entry:
+  ret void
+}
+
+attributes #0 = { "implicit-section-name"="TEXT,mytext" }
+
+; CHECK:  .section	TEXT,mytext
+; CHECK-NEXT: .globl	_foo
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1899,9 +1899,11 @@
   StringRef ParsedSegment, ParsedSection;
   unsigned TAA = 0, StubSize = 0;
   bool TAAParsed;
-  std::string ErrorCode = MCSectionMachO::ParseSectionSpecifier(
-  Section, ParsedSegment, ParsedSection, TAA, TAAParsed, StubSize);
-  assert(ErrorCode.empty() && "Invalid section specifier.");
+  cantFail(MCSectionMachO::ParseSectionSpecifier(Section,
+ ParsedSegment,
+ ParsedSection,
+ TAA, TAAParsed,
+ StubSize));
 
   // Ignore the globals from the __OBJC section. The ObjC runtime assumes
   // those conform to /usr/lib/objc/runtime.h, so we can't add redzones to
Index: llvm/lib/MC/MCSectionMachO.cpp
===
--- llvm/lib/MC/MCSectionMachO.cpp
+++ llvm/lib/MC/MCSectionMachO.cpp
@@ -174,12 +174,12 @@
 /// flavored .s file.  If successful, this fills in the specified Out
 /// parameters and returns an empty string.  When an invalid section
 /// specifier is present, this returns a string indicating the problem.
-std::string MCSectionMachO::ParseSectionSpecifier(StringRef Spec,// In.
-  StringRef ,// Out.
-  StringRef ,// Out.
-  unsigned  ,// Out.
-  bool  ,  // Out.
-  unsigned  ) { // Out.
+Error MCSectionMachO::ParseSectionSpecifier(StringRef Spec,// In.
+StringRef ,// Out.
+StringRef ,// Out.
+unsigned  ,// Out.
+bool  ,  // Out.
+unsigned  ) { // Out.
   TAAParsed = false;
 
   SmallVector SplitSpec;
@@ -194,25 +194,23 @@
   StringRef Attrs = GetEmptyOrTrim(3);
   StringRef StubSizeStr = GetEmptyOrTrim(4);
 
-  // Verify that the segment is present and not too long.
-  if (Segment.empty() || Segment.size() > 16)
-return "mach-o section specifier requires a segment whose length is "
-   "between 1 and 16 characters";
-
-  // Verify that the section is present and not too long.
+  // Verify that the section is present.
   if (Section.empty())
-return "mach-o section specifier requires a segment and section "
-   "separated by a comma";
+return createStringError(inconvertibleErrorCode(),
+ "mach-o section specifier requires a segment "
+ "and section separated by a comma");
 
+  // Verify that the section is not too long.
   if (Section.size() > 16)
-return "mach-o section specifier requires a section whose length is "
-   "between 1 and 16 characters";
+return createStringError(inconvertibleErrorCode(),
+ "mach-o section specifier requires a section "
+ "whose length is between 1 and 16 

[PATCH] D97094: [Driver] Print process statistics report on CC_PRINT_PROC_STAT env variable.

2021-02-22 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:1107
+CCPrintProcessStats = true;
+  Args.ClaimAllArgs(options::OPT_fproc_stat_report);
+  Args.ClaimAllArgs(options::OPT_fproc_stat_report_EQ);

Please remove, `getLastArg` already claims all arguments for this option.



Comment at: clang/lib/Driver/Driver.cpp:4031
+
+  // Use FinalOutput variable to get the output file name.
+  const char *LinkingOutput = nullptr;

I think the code below is safe-explanatory, I don't think you need this 
comment, it doesn't add much value.



Comment at: clang/lib/Driver/Driver.cpp:4050
<< ", mem=" << ProcStat->PeakMemory << " Kb\n";
-  }
-  if (!StatReportFile.empty()) {
+  } else {
 // CSV format.

The previous behavior was printing both the output and the CSV file when 
specifying `-fproc-stat-report -fproc-stat-report=file.csv`, now it would only 
emit the CSV, is that intended? @sepavloff what do you think?



Comment at: clang/test/Driver/cc-print-proc-stat.c:1
+// RUN: env CC_PRINT_PROC_STAT=1 \
+// RUN: CC_PRINT_PROC_STAT_FILE=%t.csv \

Could you please expand a bit the test to entirely cover all the codepaths 
above?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97094

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


[PATCH] D96147: [SEMA] Added warn_decl_shadow support for structured bindings

2021-02-22 Thread David Crook via Phabricator via cfe-commits
Vexthil added a comment.

.. And yes I will need someone to commit this for me I believe once you are 
happy with it.


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

https://reviews.llvm.org/D96147

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


[PATCH] D96044: DebugInfo: Emit "LocalToUnit" flag on local member function decls.

2021-02-22 Thread James Y Knight 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 rGfe2dcd89acfd: DebugInfo: Emit LocalToUnit flag 
on local member function decls. (authored by jyknight).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96044

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-class.cpp


Index: clang/test/CodeGenCXX/debug-info-class.cpp
===
--- clang/test/CodeGenCXX/debug-info-class.cpp
+++ clang/test/CodeGenCXX/debug-info-class.cpp
@@ -24,12 +24,14 @@
 C::~C() {
 }
 
+namespace {
 struct D {
-  D();
-  virtual ~D();
+  D() {}
+  virtual ~D() {}
   void func() {
   }
 };
+} // namespace
 
 struct E {
   E();
@@ -135,11 +137,13 @@
 // CHECK-SAME: DIFlagStaticMember
 // CHECK: [[C_DTOR]] = !DISubprogram(name: "~C"
 
-// CHECK: [[D:![0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: 
"D"
+// CHECK: [[D:![0-9]+]] = distinct !DICompositeType(tag: 
DW_TAG_structure_type, name: "D"
 // CHECK-SAME: size:
-// CHECK-SAME: DIFlagFwdDecl
 // CHECK-NOT:  identifier:
 // CHECK-SAME: ){{$}}
+// CHECK: [[D_FUNC_DECL:![0-9]*]] = !DISubprogram(name: "func",{{.*}} scope: 
[[D]]
+// CHECK-SAME: DISPFlagLocalToUnit
+
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "E"
 // CHECK-SAME: DIFlagFwdDecl
 // CHECK-NOT:  identifier:
@@ -150,11 +154,10 @@
 // CHECK-SAME: ){{$}}
 
 // CHECK: !DISubprogram(name: "func",{{.*}} scope: [[D]]
-// CHECK-SAME:  DISPFlagDefinition
-// CHECK-SAME:  declaration: [[D_FUNC_DECL:![0-9]*]]
-// CHECK: [[D_FUNC_DECL]] = !DISubprogram(name: "func",{{.*}} scope: [[D]]
+// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-SAME:  declaration: [[D_FUNC_DECL]]
 
-// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "inner",{{.*}} 
line: 50
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "inner",{{.*}} 
line: 52
 // CHECK-NOT: DIFlagFwdDecl
 // CHECK-SAME: elements: [[G_INNER_MEM:![0-9]*]]
 // CHECK-SAME: identifier: "_ZTSN1G5innerE"
@@ -170,5 +173,5 @@
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "A"
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "HdrSize"
 //
-// CHECK: ![[EXCEPTLOC]] = !DILocation(line: 91,
-// CHECK: ![[RETLOC]] = !DILocation(line: 90,
+// CHECK: ![[EXCEPTLOC]] = !DILocation(line: 93,
+// CHECK: ![[RETLOC]] = !DILocation(line: 92,
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1782,6 +1782,8 @@
 Flags |= llvm::DINode::FlagLValueReference;
   if (Method->getRefQualifier() == RQ_RValue)
 Flags |= llvm::DINode::FlagRValueReference;
+  if (!Method->isExternallyVisible())
+SPFlags |= llvm::DISubprogram::SPFlagLocalToUnit;
   if (CGM.getLangOpts().Optimize)
 SPFlags |= llvm::DISubprogram::SPFlagOptimized;
 


Index: clang/test/CodeGenCXX/debug-info-class.cpp
===
--- clang/test/CodeGenCXX/debug-info-class.cpp
+++ clang/test/CodeGenCXX/debug-info-class.cpp
@@ -24,12 +24,14 @@
 C::~C() {
 }
 
+namespace {
 struct D {
-  D();
-  virtual ~D();
+  D() {}
+  virtual ~D() {}
   void func() {
   }
 };
+} // namespace
 
 struct E {
   E();
@@ -135,11 +137,13 @@
 // CHECK-SAME: DIFlagStaticMember
 // CHECK: [[C_DTOR]] = !DISubprogram(name: "~C"
 
-// CHECK: [[D:![0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "D"
+// CHECK: [[D:![0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "D"
 // CHECK-SAME: size:
-// CHECK-SAME: DIFlagFwdDecl
 // CHECK-NOT:  identifier:
 // CHECK-SAME: ){{$}}
+// CHECK: [[D_FUNC_DECL:![0-9]*]] = !DISubprogram(name: "func",{{.*}} scope: [[D]]
+// CHECK-SAME: DISPFlagLocalToUnit
+
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "E"
 // CHECK-SAME: DIFlagFwdDecl
 // CHECK-NOT:  identifier:
@@ -150,11 +154,10 @@
 // CHECK-SAME: ){{$}}
 
 // CHECK: !DISubprogram(name: "func",{{.*}} scope: [[D]]
-// CHECK-SAME:  DISPFlagDefinition
-// CHECK-SAME:  declaration: [[D_FUNC_DECL:![0-9]*]]
-// CHECK: [[D_FUNC_DECL]] = !DISubprogram(name: "func",{{.*}} scope: [[D]]
+// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-SAME:  declaration: [[D_FUNC_DECL]]
 
-// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "inner",{{.*}} line: 50
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "inner",{{.*}} line: 52
 // CHECK-NOT: DIFlagFwdDecl
 // CHECK-SAME: elements: 

[PATCH] D97094: [Driver] Print process statistics report on CC_PRINT_PROC_STAT env variable.

2021-02-22 Thread Vlad Vereschaka via Phabricator via cfe-commits
vvereschaka marked an inline comment as done.
vvereschaka added inline comments.



Comment at: clang/include/clang/Driver/Driver.h:210
 
+  /// Set CC_PRINT_PROC_STAT mode, which causes the frontend to dump
+  /// performance report to CC_PRINT_PROC_STAT_FILE or to stdout.

sepavloff wrote:
> Strictly speaking it is driver that dumps performance report, not frontend.
Thanks, I have updated the comment accordingly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97094

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


[clang] fe2dcd8 - DebugInfo: Emit "LocalToUnit" flag on local member function decls.

2021-02-22 Thread James Y Knight via cfe-commits

Author: James Y Knight
Date: 2021-02-22T17:55:25-05:00
New Revision: fe2dcd89acfd9301a230e38e9030734553baa8dc

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

LOG: DebugInfo: Emit "LocalToUnit" flag on local member function decls.

Previously, the definition was so-marked, but the declaration was
not. This resulted in LLVM's dwarf emission treating the function as
being external, and incorrectly emitting DW_AT_external.

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

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-class.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 54b7cceeb7b6..0aa8737b9f07 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1782,6 +1782,8 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction(
 Flags |= llvm::DINode::FlagLValueReference;
   if (Method->getRefQualifier() == RQ_RValue)
 Flags |= llvm::DINode::FlagRValueReference;
+  if (!Method->isExternallyVisible())
+SPFlags |= llvm::DISubprogram::SPFlagLocalToUnit;
   if (CGM.getLangOpts().Optimize)
 SPFlags |= llvm::DISubprogram::SPFlagOptimized;
 

diff  --git a/clang/test/CodeGenCXX/debug-info-class.cpp 
b/clang/test/CodeGenCXX/debug-info-class.cpp
index 33d3a074add1..1e271be94a9d 100644
--- a/clang/test/CodeGenCXX/debug-info-class.cpp
+++ b/clang/test/CodeGenCXX/debug-info-class.cpp
@@ -24,12 +24,14 @@ struct C {
 C::~C() {
 }
 
+namespace {
 struct D {
-  D();
-  virtual ~D();
+  D() {}
+  virtual ~D() {}
   void func() {
   }
 };
+} // namespace
 
 struct E {
   E();
@@ -135,11 +137,13 @@ int main(int argc, char **argv) {
 // CHECK-SAME: DIFlagStaticMember
 // CHECK: [[C_DTOR]] = !DISubprogram(name: "~C"
 
-// CHECK: [[D:![0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: 
"D"
+// CHECK: [[D:![0-9]+]] = distinct !DICompositeType(tag: 
DW_TAG_structure_type, name: "D"
 // CHECK-SAME: size:
-// CHECK-SAME: DIFlagFwdDecl
 // CHECK-NOT:  identifier:
 // CHECK-SAME: ){{$}}
+// CHECK: [[D_FUNC_DECL:![0-9]*]] = !DISubprogram(name: "func",{{.*}} scope: 
[[D]]
+// CHECK-SAME: DISPFlagLocalToUnit
+
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "E"
 // CHECK-SAME: DIFlagFwdDecl
 // CHECK-NOT:  identifier:
@@ -150,11 +154,10 @@ int main(int argc, char **argv) {
 // CHECK-SAME: ){{$}}
 
 // CHECK: !DISubprogram(name: "func",{{.*}} scope: [[D]]
-// CHECK-SAME:  DISPFlagDefinition
-// CHECK-SAME:  declaration: [[D_FUNC_DECL:![0-9]*]]
-// CHECK: [[D_FUNC_DECL]] = !DISubprogram(name: "func",{{.*}} scope: [[D]]
+// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-SAME:  declaration: [[D_FUNC_DECL]]
 
-// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "inner",{{.*}} 
line: 50
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "inner",{{.*}} 
line: 52
 // CHECK-NOT: DIFlagFwdDecl
 // CHECK-SAME: elements: [[G_INNER_MEM:![0-9]*]]
 // CHECK-SAME: identifier: "_ZTSN1G5innerE"
@@ -170,5 +173,5 @@ int main(int argc, char **argv) {
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "A"
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "HdrSize"
 //
-// CHECK: ![[EXCEPTLOC]] = !DILocation(line: 91,
-// CHECK: ![[RETLOC]] = !DILocation(line: 90,
+// CHECK: ![[EXCEPTLOC]] = !DILocation(line: 93,
+// CHECK: ![[RETLOC]] = !DILocation(line: 92,



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


[PATCH] D97094: [Driver] Print process statistics report on CC_PRINT_PROC_STAT env variable.

2021-02-22 Thread Vlad Vereschaka via Phabricator via cfe-commits
vvereschaka updated this revision to Diff 325579.
vvereschaka added a comment.

Fixed comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97094

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/cc-print-proc-stat.c
  clang/test/Driver/lit.local.cfg
  clang/tools/driver/driver.cpp

Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -258,6 +258,11 @@
   TheDriver.CCLogDiagnostics = !!::getenv("CC_LOG_DIAGNOSTICS");
   if (TheDriver.CCLogDiagnostics)
 TheDriver.CCLogDiagnosticsFilename = ::getenv("CC_LOG_DIAGNOSTICS_FILE");
+
+  // Handle CC_PRINT_PROC_STAT and CC_PRINT_PROC_STAT_FILE.
+  TheDriver.CCPrintProcessStats = !!::getenv("CC_PRINT_PROC_STAT");
+  if (TheDriver.CCPrintProcessStats)
+TheDriver.CCPrintStatReportFilename = ::getenv("CC_PRINT_PROC_STAT_FILE");
 }
 
 static void FixupDiagPrefixExeName(TextDiagnosticPrinter *DiagClient,
Index: clang/test/Driver/lit.local.cfg
===
--- clang/test/Driver/lit.local.cfg
+++ clang/test/Driver/lit.local.cfg
@@ -11,7 +11,7 @@
  'IPHONEOS_DEPLOYMENT_TARGET',
  'SDKROOT', 'CCC_OVERRIDE_OPTIONS',
  'CC_PRINT_OPTIONS', 'CC_PRINT_HEADERS',
- 'CC_LOG_DIAGNOSTICS']
+ 'CC_LOG_DIAGNOSTICS', 'CC_PRINT_PROC_STAT']
 
 for name in driver_overwrite_env_vars:
   if name in config.environment:
Index: clang/test/Driver/cc-print-proc-stat.c
===
--- /dev/null
+++ clang/test/Driver/cc-print-proc-stat.c
@@ -0,0 +1,6 @@
+// RUN: env CC_PRINT_PROC_STAT=1 \
+// RUN: CC_PRINT_PROC_STAT_FILE=%t.csv \
+// RUN: %clang -no-canonical-prefixes -S -o %t.s %s
+// RUN: FileCheck --check-prefix=CSV %s < %t.csv
+
+// CSV: clang{{.*}},"{{.*}}.s",{{[0-9]+}},{{[0-9]+}},{{[0-9]+}}
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -139,9 +139,9 @@
   CCPrintHeadersFilename(nullptr), CCLogDiagnosticsFilename(nullptr),
   CCCPrintBindings(false), CCPrintOptions(false), CCPrintHeaders(false),
   CCLogDiagnostics(false), CCGenDiagnostics(false),
-  TargetTriple(TargetTriple), CCCGenericGCCName(""), Saver(Alloc),
-  CheckInputsExist(true), GenReproducer(false),
-  SuppressMissingInputWarning(false) {
+  CCPrintProcessStats(false), TargetTriple(TargetTriple),
+  CCCGenericGCCName(""), Saver(Alloc), CheckInputsExist(true),
+  GenReproducer(false), SuppressMissingInputWarning(false) {
   // Provide a sane fallback if no VFS is specified.
   if (!this->VFS)
 this->VFS = llvm::vfs::getRealFileSystem();
@@ -1096,6 +1096,17 @@
   GenReproducer = Args.hasFlag(options::OPT_gen_reproducer,
options::OPT_fno_crash_diagnostics,
!!::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH"));
+
+  // Process -fproc-stat-report options.
+  if (const Arg *A = Args.getLastArg(options::OPT_fproc_stat_report_EQ)) {
+CCPrintProcessStats = true;
+CCPrintStatReportFilename = A->getValue();
+  }
+  if (Args.hasArg(options::OPT_fproc_stat_report))
+CCPrintProcessStats = true;
+  Args.ClaimAllArgs(options::OPT_fproc_stat_report);
+  Args.ClaimAllArgs(options::OPT_fproc_stat_report_EQ);
+
   // FIXME: TargetTriple is used by the target-prefixed calls to as/ld
   // and getToolChain is const.
   if (IsCLMode()) {
@@ -4004,62 +4015,59 @@
/*TargetDeviceOffloadKind*/ Action::OFK_None);
   }
 
-  StringRef StatReportFile;
-  bool PrintProcessStat = false;
-  if (const Arg *A = C.getArgs().getLastArg(options::OPT_fproc_stat_report_EQ))
-StatReportFile = A->getValue();
-  if (C.getArgs().hasArg(options::OPT_fproc_stat_report))
-PrintProcessStat = true;
-
   // If we have more than one job, then disable integrated-cc1 for now. Do this
   // also when we need to report process execution statistics.
-  if (C.getJobs().size() > 1 || !StatReportFile.empty() || PrintProcessStat)
+  if (C.getJobs().size() > 1 || CCPrintProcessStats)
 for (auto  : C.getJobs())
   J.InProcess = false;
 
-  if (!StatReportFile.empty() || PrintProcessStat) {
+  if (CCPrintProcessStats) {
 C.setPostCallback([=](const Command , int Res) {
   Optional ProcStat =
   Cmd.getProcessStatistics();
   if (!ProcStat)
 return;
-  if (PrintProcessStat) {
+
+  // Use FinalOutput variable to get the output file name.
+  const char *LinkingOutput = nullptr;
+  if (FinalOutput)
+LinkingOutput = FinalOutput->getValue();
+   

[PATCH] D96147: [SEMA] Added warn_decl_shadow support for structured bindings

2021-02-22 Thread David Crook via Phabricator via cfe-commits
Vexthil updated this revision to Diff 325578.
Vexthil added a comment.

Added unit tests for "shadows a structured binding"


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

https://reviews.llvm.org/D96147

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/warn-shadow.cpp

Index: clang/test/SemaCXX/warn-shadow.cpp
===
--- clang/test/SemaCXX/warn-shadow.cpp
+++ clang/test/SemaCXX/warn-shadow.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -std=c++11 -Wshadow-all %s
+// RUN: %clang_cc1 -verify -fsyntax-only -std=c++17 -Wshadow-all %s
 
 namespace {
   int i; // expected-note {{previous declaration is here}}
@@ -265,3 +265,44 @@
 PR24718_1 // Does not shadow a type.
   };
 };
+
+namespace structured_binding_tests {
+int x; // expected-note {{previous declaration is here}}
+int y; // expected-note {{previous declaration is here}}
+struct S {
+  int a, b;
+};
+
+void test1() {
+  const auto [x, y] = S(); // expected-warning 2 {{declaration shadows a variable in namespace 'structured_binding_tests'}}
+}
+
+void test2() {
+  int a; // expected-note {{previous declaration is here}}
+  bool b; // expected-note {{previous declaration is here}}
+  {
+auto [a, b] = S(); // expected-warning 2 {{declaration shadows a local variable}}
+  }
+}
+
+class A
+{
+  int m_a; // expected-note {{previous declaration is here}}
+  int m_b; // expected-note {{previous declaration is here}}
+
+  void test3() {
+auto [m_a, m_b] = S(); // expected-warning 2 {{declaration shadows a field of 'structured_binding_tests::A'}}
+  }
+};
+
+void test4() {
+  const auto [a, b] = S(); // expected-note 3 {{previous declaration is here}}
+  {
+int a = 4; // expected-warning {{declaration shadows a structured binding}}
+  }
+  {
+const auto [a, b] = S(); // expected-warning 2 {{declaration shadows a structured binding}}
+  }
+}
+
+}; // namespace structured_binding_tests
\ No newline at end of file
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -857,17 +857,25 @@
   Previous.clear();
 }
 
+auto *BD = BindingDecl::Create(Context, DC, B.NameLoc, B.Name);
+
+// Find the shadowed declaration before filtering for scope.
+NamedDecl *ShadowedDecl = D.getCXXScopeSpec().isEmpty()
+  ? getShadowedDeclaration(BD, Previous)
+  : nullptr;
+
 bool ConsiderLinkage = DC->isFunctionOrMethod() &&
DS.getStorageClassSpec() == DeclSpec::SCS_extern;
 FilterLookupForScope(Previous, DC, S, ConsiderLinkage,
  /*AllowInlineNamespace*/false);
+
 if (!Previous.empty()) {
   auto *Old = Previous.getRepresentativeDecl();
   Diag(B.NameLoc, diag::err_redefinition) << B.Name;
   Diag(Old->getLocation(), diag::note_previous_definition);
+} else if (ShadowedDecl && !D.isRedeclaration()) {
+  CheckShadow(BD, ShadowedDecl, Previous);
 }
-
-auto *BD = BindingDecl::Create(Context, DC, B.NameLoc, B.Name);
 PushOnScopeChains(BD, S, true);
 Bindings.push_back(BD);
 ParsingInitForAutoVars.insert(BD);
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -7491,7 +7491,8 @@
   SDK_StaticMember,
   SDK_Field,
   SDK_Typedef,
-  SDK_Using
+  SDK_Using,
+  SDK_StructuredBinding
 };
 
 /// Determine what kind of declaration we're shadowing.
@@ -7501,6 +7502,8 @@
 return SDK_Using;
   else if (isa(ShadowedDecl))
 return SDK_Typedef;
+  else if (isa(ShadowedDecl))
+return SDK_StructuredBinding;
   else if (isa(OldDC))
 return isa(ShadowedDecl) ? SDK_Field : SDK_StaticMember;
 
@@ -7540,9 +7543,8 @@
 return nullptr;
 
   NamedDecl *ShadowedDecl = R.getFoundDecl();
-  return isa(ShadowedDecl) || isa(ShadowedDecl)
- ? ShadowedDecl
- : nullptr;
+  return isa(ShadowedDecl) ? ShadowedDecl
+: nullptr;
 }
 
 /// Return the declaration shadowed by the given typedef \p D, or null
@@ -7560,6 +7562,18 @@
   return isa(ShadowedDecl) ? ShadowedDecl : nullptr;
 }
 
+/// Return the declaration shadowed by the given variable \p D, or null
+/// if it doesn't shadow any declaration or shadowing warnings are disabled.
+NamedDecl *Sema::getShadowedDeclaration(const BindingDecl *D,
+const LookupResult ) {
+  if (!shouldWarnIfShadowedDecl(Diags, R))
+return nullptr;
+
+  NamedDecl *ShadowedDecl = R.getFoundDecl();
+  return isa(ShadowedDecl) ? ShadowedDecl
+   

[clang-tools-extra] f0e6927 - [clangd] Shutdown sequence for modules, and doc threading requirements

2021-02-22 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-02-22T23:14:47+01:00
New Revision: f0e69272c62f2b7a39687748db60d21445010ac5

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

LOG: [clangd] Shutdown sequence for modules, and doc threading requirements

This allows modules to do work on non-TUScheduler background threads.

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/Module.h
clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 5ec0d816c95f..245a2d081f93 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -130,15 +130,13 @@ ClangdServer::ClangdServer(const 
GlobalCompilationDatabase ,
 : Modules(Opts.Modules), CDB(CDB), TFS(TFS),
   DynamicIdx(Opts.BuildDynamicSymbolIndex ? new FileIndex() : nullptr),
   ClangTidyProvider(Opts.ClangTidyProvider),
-  WorkspaceRoot(Opts.WorkspaceRoot),
-  // Pass a callback into `WorkScheduler` to extract symbols from a newly
-  // parsed file and rebuild the file index synchronously each time an AST
-  // is parsed.
-  // FIXME(ioeric): this can be slow and we may be able to index on less
-  // critical paths.
-  WorkScheduler(
-  CDB, TUScheduler::Options(Opts),
-  std::make_unique(DynamicIdx.get(), Callbacks)) 
{
+  WorkspaceRoot(Opts.WorkspaceRoot) {
+  // Pass a callback into `WorkScheduler` to extract symbols from a newly
+  // parsed file and rebuild the file index synchronously each time an AST
+  // is parsed.
+  WorkScheduler.emplace(
+  CDB, TUScheduler::Options(Opts),
+  std::make_unique(DynamicIdx.get(), Callbacks));
   // Adds an index to the stack, at higher priority than existing indexes.
   auto AddIndex = [&](SymbolIndex *Idx) {
 if (this->Index != nullptr) {
@@ -170,7 +168,7 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase 
,
 
   if (Opts.Modules) {
 Module::Facilities F{
-this->WorkScheduler,
+*this->WorkScheduler,
 this->Index,
 this->TFS,
 };
@@ -179,6 +177,20 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase 
,
   }
 }
 
+ClangdServer::~ClangdServer() {
+  // Destroying TUScheduler first shuts down request threads that might
+  // otherwise access members concurrently.
+  // (Nobody can be using TUScheduler because we're on the main thread).
+  WorkScheduler.reset();
+  // Now requests have stopped, we can shut down modules.
+  if (Modules) {
+for (auto  : *Modules)
+  Mod.stop();
+for (auto  : *Modules)
+  Mod.blockUntilIdle(Deadline::infinity());
+  }
+}
+
 void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents,
llvm::StringRef Version,
WantDiagnostics WantDiags, bool ForceRebuild) {
@@ -193,7 +205,7 @@ void ClangdServer::addDocument(PathRef File, 
llvm::StringRef Contents,
   Inputs.Opts = std::move(Opts);
   Inputs.Index = Index;
   Inputs.ClangTidyProvider = ClangTidyProvider;
-  bool NewFile = WorkScheduler.update(File, Inputs, WantDiags);
+  bool NewFile = WorkScheduler->update(File, Inputs, WantDiags);
   // If we loaded Foo.h, we want to make sure Foo.cpp is indexed.
   if (NewFile && BackgroundIdx)
 BackgroundIdx->boostRelated(File);
@@ -276,7 +288,7 @@ ClangdServer::createConfiguredContextProvider(const 
config::Provider *Provider,
   };
 }
 
-void ClangdServer::removeDocument(PathRef File) { WorkScheduler.remove(File); }
+void ClangdServer::removeDocument(PathRef File) { WorkScheduler->remove(File); 
}
 
 void ClangdServer::codeComplete(PathRef File, Position Pos,
 const clangd::CodeCompleteOptions ,
@@ -330,7 +342,7 @@ void ClangdServer::codeComplete(PathRef File, Position Pos,
   };
 
   // We use a potentially-stale preamble because latency is critical here.
-  WorkScheduler.runWithPreamble(
+  WorkScheduler->runWithPreamble(
   "CodeComplete", File,
   (Opts.RunParser == CodeCompleteOptions::AlwaysParse)
   ? TUScheduler::Stale
@@ -356,8 +368,8 @@ void ClangdServer::signatureHelp(PathRef File, Position Pos,
   };
 
   // Unlike code completion, we wait for a preamble here.
-  WorkScheduler.runWithPreamble("SignatureHelp", File, TUScheduler::Stale,
-std::move(Action));
+  WorkScheduler->runWithPreamble("SignatureHelp", File, TUScheduler::Stale,
+ std::move(Action));
 }
 
 void ClangdServer::formatRange(PathRef File, llvm::StringRef Code, Range Rng,
@@ -399,7 

[PATCH] D96755: [clangd] Shutdown sequence for modules, and doc threading requirements

2021-02-22 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf0e69272c62f: [clangd] Shutdown sequence for modules, and 
doc threading requirements (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D96755?vs=324262=325566#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96755

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Module.h
  clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp

Index: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -16,6 +16,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/JSON.h"
+#include "llvm/Testing/Support/Error.h"
 #include "llvm/Testing/Support/SupportHelpers.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -23,6 +24,7 @@
 namespace clang {
 namespace clangd {
 namespace {
+using llvm::Succeeded;
 using testing::ElementsAre;
 
 MATCHER_P(DiagMessage, M, "") {
@@ -40,6 +42,7 @@
 Base = ClangdServer::optsForTest();
 // This is needed to we can test index-based operations like call hierarchy.
 Base.BuildDynamicSymbolIndex = true;
+Base.Modules = 
   }
 
   LSPClient () {
@@ -67,6 +70,7 @@
 
   MockFS FS;
   ClangdLSPServer::Options Opts;
+  ModuleSet Modules;
 
 private:
   // Color logs so we can distinguish them from test output.
@@ -244,9 +248,7 @@
   [Reply(std::move(Reply)), Value(Value)]() mutable { Reply(Value); });
 }
   };
-  ModuleSet Mods;
-  Mods.add(std::make_unique());
-  Opts.Modules = 
+  Modules.add(std::make_unique());
 
   auto  = start();
   Client.notify("add", 2);
@@ -256,6 +258,104 @@
   ElementsAre(llvm::json::Value(2), llvm::json::Value(10)));
 }
 
+// Creates a Callback that writes its received value into an Optional.
+template 
+llvm::unique_function)>
+capture(llvm::Optional> ) {
+  Out.reset();
+  return [](llvm::Expected V) { Out.emplace(std::move(V)); };
+}
+
+TEST_F(LSPTest, ModulesThreadingTest) {
+  // A module that does its work on a background thread, and so exercises the
+  // block/shutdown protocol.
+  class AsyncCounter final : public Module {
+bool ShouldStop = false;
+int State = 0;
+std::deque> Queue; // null = increment, non-null = read.
+std::condition_variable CV;
+std::mutex Mu;
+std::thread Thread;
+
+void run() {
+  std::unique_lock Lock(Mu);
+  while (true) {
+CV.wait(Lock, [&] { return ShouldStop || !Queue.empty(); });
+if (ShouldStop) {
+  Queue.clear();
+  CV.notify_all();
+  return;
+}
+Callback  = Queue.front();
+if (Task)
+  Task(State);
+else
+  ++State;
+Queue.pop_front();
+CV.notify_all();
+  }
+}
+
+bool blockUntilIdle(Deadline D) override {
+  std::unique_lock Lock(Mu);
+  return clangd::wait(Lock, CV, D, [this] { return Queue.empty(); });
+}
+
+void stop() override {
+  {
+std::lock_guard Lock(Mu);
+ShouldStop = true;
+  }
+  CV.notify_all();
+}
+
+  public:
+AsyncCounter() : Thread([this] { run(); }) {}
+~AsyncCounter() {
+  // Verify shutdown sequence was performed.
+  // Real modules would not do this, to be robust to no ClangdServer.
+  EXPECT_TRUE(ShouldStop) << "ClangdServer should request shutdown";
+  EXPECT_EQ(Queue.size(), 0u) << "ClangdServer should block until idle";
+  Thread.join();
+}
+
+void initializeLSP(LSPBinder , const llvm::json::Object ,
+   llvm::json::Object ) override {
+  Bind.notification("increment", this, ::increment);
+}
+
+// Get the current value, bypassing the queue.
+// Used to verify that sync->blockUntilIdle avoids races in tests.
+int getSync() {
+  std::lock_guard Lock(Mu);
+  return State;
+}
+
+// Increment the current value asynchronously.
+void increment(const std::nullptr_t &) {
+  {
+std::lock_guard Lock(Mu);
+Queue.push_back(nullptr);
+  }
+  CV.notify_all();
+}
+  };
+
+  Modules.add(std::make_unique());
+  auto  = start();
+
+  Client.notify("increment", nullptr);
+  Client.notify("increment", nullptr);
+  Client.notify("increment", nullptr);
+  EXPECT_THAT_EXPECTED(Client.call("sync", nullptr).take(), Succeeded());
+  EXPECT_EQ(3, Modules.get()->getSync());
+  // Throw some work on the queue to make sure shutdown blocks on it.
+  Client.notify("increment", nullptr);
+  Client.notify("increment", nullptr);
+  Client.notify("increment", nullptr);
+  // And immediately shut down. Module destructor verifies that we blocked.
+}

[PATCH] D96856: [clangd] Narrow and document a loophole in blockUntilIdle

2021-02-22 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2d9cfcfef029: [clangd] Narrow and document a loophole in 
blockUntilIdle (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96856

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h


Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -335,6 +335,8 @@
 
   // Blocks the main thread until the server is idle. Only for use in tests.
   // Returns false if the timeout expires.
+  // FIXME: various subcomponents each get the full timeout, so it's more of
+  // an order of magnitude than a hard deadline.
   LLVM_NODISCARD bool
   blockUntilIdleForTest(llvm::Optional TimeoutSeconds = 10);
 
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -859,10 +859,34 @@
 
 LLVM_NODISCARD bool
 ClangdServer::blockUntilIdleForTest(llvm::Optional TimeoutSeconds) {
-  return WorkScheduler.blockUntilIdle(timeoutSeconds(TimeoutSeconds)) &&
- CDB.blockUntilIdle(timeoutSeconds(TimeoutSeconds)) &&
- (!BackgroundIdx ||
-  BackgroundIdx->blockUntilIdleForTest(TimeoutSeconds));
+  // Order is important here: we don't want to block on A and then B,
+  // if B might schedule work on A.
+
+  // Nothing else can schedule work on TUScheduler, because it's not threadsafe
+  // and we're blocking the main thread.
+  if (!WorkScheduler.blockUntilIdle(timeoutSeconds(TimeoutSeconds)))
+return false;
+
+  // Unfortunately we don't have strict topological order between the rest of
+  // the components. E.g. CDB broadcast triggers backrgound indexing.
+  // This queries the CDB which may discover new work if disk has changed.
+  //
+  // So try each one a few times in a loop.
+  // If there are no tricky interactions then all after the first are no-ops.
+  // Then on the last iteration, verify they're idle without waiting.
+  //
+  // There's a small chance they're juggling work and we didn't catch them :-(
+  for (llvm::Optional Timeout :
+   {TimeoutSeconds, TimeoutSeconds, llvm::Optional(0)}) {
+if (!CDB.blockUntilIdle(timeoutSeconds(Timeout)))
+  return false;
+if (BackgroundIdx && !BackgroundIdx->blockUntilIdleForTest(Timeout))
+  return false;
+  }
+
+  assert(WorkScheduler.blockUntilIdle(Deadline::zero()) &&
+ "Something scheduled work while we're blocking the main thread!");
+  return true;
 }
 
 void ClangdServer::profile(MemoryTree ) const {


Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -335,6 +335,8 @@
 
   // Blocks the main thread until the server is idle. Only for use in tests.
   // Returns false if the timeout expires.
+  // FIXME: various subcomponents each get the full timeout, so it's more of
+  // an order of magnitude than a hard deadline.
   LLVM_NODISCARD bool
   blockUntilIdleForTest(llvm::Optional TimeoutSeconds = 10);
 
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -859,10 +859,34 @@
 
 LLVM_NODISCARD bool
 ClangdServer::blockUntilIdleForTest(llvm::Optional TimeoutSeconds) {
-  return WorkScheduler.blockUntilIdle(timeoutSeconds(TimeoutSeconds)) &&
- CDB.blockUntilIdle(timeoutSeconds(TimeoutSeconds)) &&
- (!BackgroundIdx ||
-  BackgroundIdx->blockUntilIdleForTest(TimeoutSeconds));
+  // Order is important here: we don't want to block on A and then B,
+  // if B might schedule work on A.
+
+  // Nothing else can schedule work on TUScheduler, because it's not threadsafe
+  // and we're blocking the main thread.
+  if (!WorkScheduler.blockUntilIdle(timeoutSeconds(TimeoutSeconds)))
+return false;
+
+  // Unfortunately we don't have strict topological order between the rest of
+  // the components. E.g. CDB broadcast triggers backrgound indexing.
+  // This queries the CDB which may discover new work if disk has changed.
+  //
+  // So try each one a few times in a loop.
+  // If there are no tricky interactions then all after the first are no-ops.
+  // Then on the last iteration, verify they're idle without waiting.
+  //
+  // There's a small chance they're juggling work and we didn't catch them :-(
+  for (llvm::Optional Timeout :
+   {TimeoutSeconds, TimeoutSeconds, llvm::Optional(0)}) {
+if (!CDB.blockUntilIdle(timeoutSeconds(Timeout)))
+  return false;
+

[clang-tools-extra] 2d9cfcf - [clangd] Narrow and document a loophole in blockUntilIdle

2021-02-22 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-02-22T23:08:52+01:00
New Revision: 2d9cfcfef029952511462ee45c49c1bf223b9495

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

LOG: [clangd] Narrow and document a loophole in blockUntilIdle

blockUntilIdle of a parent can't always be correctly implemented as
  return ChildA.blockUntilIdle() && ChildB.blockUntilIdle()
The problem is that B can schedule work on A while we're waiting on it.

I believe this is theoretically possible today between CDB and background index.
Modules open more possibilities and it's hard to reason about all of them.

I don't have a perfect fix, and the abstraction is too good to lose. this patch:
 - calls out why we block on workscheduler first, and asserts correctness
 - documents the issue
 - reduces the practical possibility of spuriously returning true significantly

This function is ultimately only for testing, so we're driving down flake rate.

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 67aba1c3d92e..5ec0d816c95f 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -859,10 +859,34 @@ llvm::StringMap 
ClangdServer::fileStats() const {
 
 LLVM_NODISCARD bool
 ClangdServer::blockUntilIdleForTest(llvm::Optional TimeoutSeconds) {
-  return WorkScheduler.blockUntilIdle(timeoutSeconds(TimeoutSeconds)) &&
- CDB.blockUntilIdle(timeoutSeconds(TimeoutSeconds)) &&
- (!BackgroundIdx ||
-  BackgroundIdx->blockUntilIdleForTest(TimeoutSeconds));
+  // Order is important here: we don't want to block on A and then B,
+  // if B might schedule work on A.
+
+  // Nothing else can schedule work on TUScheduler, because it's not threadsafe
+  // and we're blocking the main thread.
+  if (!WorkScheduler.blockUntilIdle(timeoutSeconds(TimeoutSeconds)))
+return false;
+
+  // Unfortunately we don't have strict topological order between the rest of
+  // the components. E.g. CDB broadcast triggers backrgound indexing.
+  // This queries the CDB which may discover new work if disk has changed.
+  //
+  // So try each one a few times in a loop.
+  // If there are no tricky interactions then all after the first are no-ops.
+  // Then on the last iteration, verify they're idle without waiting.
+  //
+  // There's a small chance they're juggling work and we didn't catch them :-(
+  for (llvm::Optional Timeout :
+   {TimeoutSeconds, TimeoutSeconds, llvm::Optional(0)}) {
+if (!CDB.blockUntilIdle(timeoutSeconds(Timeout)))
+  return false;
+if (BackgroundIdx && !BackgroundIdx->blockUntilIdleForTest(Timeout))
+  return false;
+  }
+
+  assert(WorkScheduler.blockUntilIdle(Deadline::zero()) &&
+ "Something scheduled work while we're blocking the main thread!");
+  return true;
 }
 
 void ClangdServer::profile(MemoryTree ) const {

diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index 9581a558ea31..1c09c66e6406 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -335,6 +335,8 @@ class ClangdServer {
 
   // Blocks the main thread until the server is idle. Only for use in tests.
   // Returns false if the timeout expires.
+  // FIXME: various subcomponents each get the full timeout, so it's more of
+  // an order of magnitude than a hard deadline.
   LLVM_NODISCARD bool
   blockUntilIdleForTest(llvm::Optional TimeoutSeconds = 10);
 



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


[PATCH] D90972: [clang-tidy] Install run-clang-tidy.py in bin/ as run-clang-tidy

2021-02-22 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D90972#2446448 , @Flow wrote:

> In D90972#2394516 , @JonasToth wrote:
>
>> LGTM! thanks for fixing.
>
> I am unable to commit this myself. The latest version of this change 
> 
>  can be found in the install-run-clang-tidy-into-bin 
> 
>  on my LLVM fork .

Noticed this is a little stale, Do you still want this landing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90972

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


[PATCH] D97226: [clangd] Show hex value of numeric constants

2021-02-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

Don't show negative numbers
Don't show numbers <10 (hex is the same as decimal)
Show numeric enum values in hex too


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97226

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -513,7 +513,7 @@
  HI.Definition = "Color x = GREEN";
  HI.Kind = index::SymbolKind::Variable;
  HI.Type = "enum Color";
- HI.Value = "GREEN (1)"; // Symbolic when hovering on an expression.
+ HI.Value = "GREEN (0x1)"; // Symbolic when hovering on an expression.
}},
   {R"cpp(
 template struct Add {
@@ -543,7 +543,7 @@
  HI.ReturnType = "int";
  HI.Parameters.emplace();
  HI.NamespaceScope = "";
- HI.Value = "42";
+ HI.Value = "42 (0x2a)";
}},
   {R"cpp(
 const char *[[ba^r]] = "1234";
@@ -1468,7 +1468,7 @@
 HI.Definition = "static int hey = 10";
 HI.Documentation = "Global variable";
 // FIXME: Value shouldn't be set in this case
-HI.Value = "10";
+HI.Value = "10 (0xa)";
   }},
   {
   R"cpp(// Global variable in namespace
@@ -1485,7 +1485,7 @@
 HI.NamespaceScope = "ns1::";
 HI.Type = "int";
 HI.Definition = "static int hey = 10";
-HI.Value = "10";
+HI.Value = "10 (0xa)";
   }},
   {
   R"cpp(// Field in anonymous struct
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -381,8 +381,15 @@
 for (const EnumConstantDecl *ECD :
  T->castAs()->getDecl()->enumerators())
   if (ECD->getInitVal() == Val)
-return llvm::formatv("{0} ({1})", ECD->getNameAsString(), Val).str();
+return llvm::formatv("{0} ({1:x})", ECD->getNameAsString(), Val).str();
   }
+  // Show hex value of integers if they're at least 10 (not negative!)
+  if (T->isIntegralOrEnumerationType() &&
+  Constant.Val.getInt().getMinSignedBits() <= 64 &&
+  !Constant.Val.getInt().isNegative() && Constant.Val.getInt().uge(10))
+return llvm::formatv("{0} ({1:x})", Constant.Val.getAsString(Ctx, T),
+ Constant.Val.getInt().getExtValue())
+.str();
   return Constant.Val.getAsString(Ctx, T);
 }
 


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -513,7 +513,7 @@
  HI.Definition = "Color x = GREEN";
  HI.Kind = index::SymbolKind::Variable;
  HI.Type = "enum Color";
- HI.Value = "GREEN (1)"; // Symbolic when hovering on an expression.
+ HI.Value = "GREEN (0x1)"; // Symbolic when hovering on an expression.
}},
   {R"cpp(
 template struct Add {
@@ -543,7 +543,7 @@
  HI.ReturnType = "int";
  HI.Parameters.emplace();
  HI.NamespaceScope = "";
- HI.Value = "42";
+ HI.Value = "42 (0x2a)";
}},
   {R"cpp(
 const char *[[ba^r]] = "1234";
@@ -1468,7 +1468,7 @@
 HI.Definition = "static int hey = 10";
 HI.Documentation = "Global variable";
 // FIXME: Value shouldn't be set in this case
-HI.Value = "10";
+HI.Value = "10 (0xa)";
   }},
   {
   R"cpp(// Global variable in namespace
@@ -1485,7 +1485,7 @@
 HI.NamespaceScope = "ns1::";
 HI.Type = "int";
 HI.Definition = "static int hey = 10";
-HI.Value = "10";
+HI.Value = "10 (0xa)";
   }},
   {
   R"cpp(// Field in anonymous struct
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -381,8 +381,15 @@
 for (const EnumConstantDecl *ECD :
  T->castAs()->getDecl()->enumerators())
   if (ECD->getInitVal() == Val)
-return llvm::formatv("{0} ({1})", ECD->getNameAsString(), Val).str();
+return llvm::formatv("{0} ({1:x})", ECD->getNameAsString(), Val).str();
   }
+  // Show hex value of integers if they're at least 10 (not negative!)
+  if 

[PATCH] D94213: Clang: Remove support for 3DNow!, both intrinsics and builtins.

2021-02-22 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

In D94213#2579932 , @jyknight wrote:

> Ping.

Hi @jyknight - sorry for going quiet - 12.xx has brewed long enough that I 
think we can start looking at this again in trunk - I'll take a look in the 
next day or so.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94213

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


[PATCH] D86855: Convert __m64 intrinsics to unconditionally use SSE2 instead of MMX instructions.

2021-02-22 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86855

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


[PATCH] D94252: Delete (most) of the MMX builtin functions from Clang.

2021-02-22 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94252

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


[PATCH] D94213: Clang: Remove support for 3DNow!, both intrinsics and builtins.

2021-02-22 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.
Herald added a subscriber: jansvoboda11.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94213

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


[PATCH] D97224: Use Address for CGBuilder's CreateAtomicRMW and CreateAtomicCmpXchg.

2021-02-22 Thread James Y Knight via Phabricator via cfe-commits
jyknight created this revision.
jyknight added reviewers: gchatelet, jfb, rjmccall.
jyknight requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Following the LLVM change to add an alignment argument to the
IRBuilder calls, switch Clang's CGBuilder variants to take an Address
type. Then, update all callers to pass through the Address.

There is one interesting exception: Microsoft's
InterlockedCompareExchange128 family of functions are documented to
require (and assume) 16-byte alignment, despite the argument type
being only `long long*`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97224

Files:
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/CodeGen/atomic-ops.c
  clang/test/CodeGen/ms-intrinsics.c
  clang/test/OpenMP/parallel_reduction_codegen.cpp

Index: clang/test/OpenMP/parallel_reduction_codegen.cpp
===
--- clang/test/OpenMP/parallel_reduction_codegen.cpp
+++ clang/test/OpenMP/parallel_reduction_codegen.cpp
@@ -198,7 +198,7 @@
 // LAMBDA: br label %[[REDUCTION_DONE]]
 // LAMBDA: [[CASE2]]
 // LAMBDA: [[G_PRIV_VAL:%.+]] = load i32, i32* [[G_PRIVATE_ADDR]]
-// LAMBDA: atomicrmw add i32* [[G_REF]], i32 [[G_PRIV_VAL]] monotonic, align 4
+// LAMBDA: atomicrmw add i32* [[G_REF]], i32 [[G_PRIV_VAL]] monotonic, align 128
 // LAMBDA: br label %[[REDUCTION_DONE]]
 // LAMBDA: [[REDUCTION_DONE]]
 // LAMBDA: ret void
@@ -255,7 +255,7 @@
 // BLOCKS: br label %[[REDUCTION_DONE]]
 // BLOCKS: [[CASE2]]
 // BLOCKS: [[G_PRIV_VAL:%.+]] = load i32, i32* [[G_PRIVATE_ADDR]]
-// BLOCKS: atomicrmw add i32* [[G_REF]], i32 [[G_PRIV_VAL]] monotonic, align 4
+// BLOCKS: atomicrmw add i32* [[G_REF]], i32 [[G_PRIV_VAL]] monotonic, align 128
 // BLOCKS: br label %[[REDUCTION_DONE]]
 // BLOCKS: [[REDUCTION_DONE]]
 // BLOCKS: ret void
@@ -771,7 +771,7 @@
 // case 2:
 // t_var += t_var_reduction;
 // CHECK: [[T_VAR_PRIV_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR_PRIV]]
-// CHECK: atomicrmw add i32* [[T_VAR_REF]], i32 [[T_VAR_PRIV_VAL]] monotonic, align 4
+// CHECK: atomicrmw add i32* [[T_VAR_REF]], i32 [[T_VAR_PRIV_VAL]] monotonic, align 128
 
 // var = var.operator &(var_reduction);
 // CHECK: call void @__kmpc_critical(
@@ -801,7 +801,7 @@
 
 // t_var1 = min(t_var1, t_var1_reduction);
 // CHECK: [[T_VAR1_PRIV_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR1_PRIV]]
-// CHECK: atomicrmw min i32* [[T_VAR1_REF]], i32 [[T_VAR1_PRIV_VAL]] monotonic, align 4
+// CHECK: atomicrmw min i32* [[T_VAR1_REF]], i32 [[T_VAR1_PRIV_VAL]] monotonic, align 128
 
 // break;
 // CHECK: br label %[[RED_DONE]]
Index: clang/test/CodeGen/ms-intrinsics.c
===
--- clang/test/CodeGen/ms-intrinsics.c
+++ clang/test/CodeGen/ms-intrinsics.c
@@ -450,10 +450,10 @@
 // CHECK-64: [[EL:%[0-9]+]] = zext i64 %inc1 to i128
 // CHECK-64: [[EHS:%[0-9]+]] = shl nuw i128 [[EH]], 64
 // CHECK-64: [[EXP:%[0-9]+]] = or i128 [[EHS]], [[EL]]
-// CHECK-64: [[ORG:%[0-9]+]] = load i128, i128* [[CNR]], align 16
+// CHECK-64: [[ORG:%[0-9]+]] = load i128, i128* [[CNR]], align 8
 // CHECK-64: [[RES:%[0-9]+]] = cmpxchg volatile i128* [[DST]], i128 [[ORG]], i128 [[EXP]] seq_cst seq_cst, align 16
 // CHECK-64: [[OLD:%[0-9]+]] = extractvalue { i128, i1 } [[RES]], 0
-// CHECK-64: store i128 [[OLD]], i128* [[CNR]], align 16
+// CHECK-64: store i128 [[OLD]], i128* [[CNR]], align 8
 // CHECK-64: [[SUC1:%[0-9]+]] = extractvalue { i128, i1 } [[RES]], 1
 // CHECK-64: [[SUC8:%[0-9]+]] = zext i1 [[SUC1]] to i8
 // CHECK-64: ret i8 [[SUC8]]
Index: clang/test/CodeGen/atomic-ops.c
===
--- clang/test/CodeGen/atomic-ops.c
+++ clang/test/CodeGen/atomic-ops.c
@@ -655,9 +655,9 @@
   __atomic_load(_a, _b, memory_order_seq_cst);
   // CHECK: store atomic i64 {{.*}}, align 16
   __atomic_store(_a, _b, memory_order_seq_cst);
-  // CHECK: atomicrmw xchg i64* {{.*}}, align 8
+  // CHECK: atomicrmw xchg i64* {{.*}}, align 16
   __atomic_exchange(_a, _b, _c, memory_order_seq_cst);
-  // CHECK: cmpxchg weak i64* {{.*}}, align 8
+  // CHECK: cmpxchg weak i64* {{.*}}, align 16
   __atomic_compare_exchange(_a, _b, _c, 1, memory_order_seq_cst, memory_order_seq_cst);
 }
 
Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -5150,7 +5150,7 @@
 X.getType()->hasSignedIntegerRepresentation());
   }
   llvm::Value *Res =
-  CGF.Builder.CreateAtomicRMW(RMWOp, X.getPointer(CGF), UpdateVal, AO);
+  CGF.Builder.CreateAtomicRMW(RMWOp, X.getAddress(CGF), UpdateVal, AO);
   return std::make_pair(true, 

[PATCH] D97223: Add Alignment argument to IRBuilder CreateAtomicRMW and CreateAtomicCmpXchg.

2021-02-22 Thread James Y Knight via Phabricator via cfe-commits
jyknight created this revision.
jyknight added reviewers: gchatelet, jfb, rjmccall.
Herald added subscribers: teijeong, dexonsmith, rdzhabarov, tatianashp, 
msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, lucyrfox, 
mgester, arpith-jacob, antiagainst, shauheen, rriddle, mehdi_amini, hiraditya.
Herald added a reviewer: ftynse.
jyknight requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, stephenneuendorffer, 
nicolasvasilache.
Herald added projects: clang, MLIR, LLVM.

And then push those change throughout LLVM.

Keep the old signature in Clang's CGBuilder for now -- that will be
updated in a follow-on patch.

TODO: what about MLIR?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97223

Files:
  clang/lib/CodeGen/CGBuilder.h
  llvm/include/llvm/CodeGen/AtomicExpandUtils.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/CodeGen/AtomicExpandPass.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
  llvm/lib/Transforms/Instrumentation/InstrOrderFile.cpp
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td

Index: mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
===
--- mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -1526,6 +1526,7 @@
 
 def LLVM_AtomicRMWType : AnyTypeOf<[LLVM_AnyFloat, LLVM_AnyInteger]>;
 
+// FIXME: Need to add alignment attribute to MLIR atomicrmw operation.
 def LLVM_AtomicRMWOp : LLVM_Op<"atomicrmw"> {
   let arguments = (ins AtomicBinOp:$bin_op,
LLVM_PointerTo:$ptr,
@@ -1533,6 +1534,7 @@
   let results = (outs LLVM_AtomicRMWType:$res);
   let llvmBuilder = [{
 $res = builder.CreateAtomicRMW(getLLVMAtomicBinOp($bin_op), $ptr, $val,
+   llvm::MaybeAlign(),
getLLVMAtomicOrdering($ordering));
   }];
   let parser = [{ return parseAtomicRMWOp(parser, result); }];
@@ -1553,6 +1555,7 @@
  "an LLVM struct type with any integer or pointer followed by a single-bit "
  "integer">;
 
+// FIXME: Need to add alignment attribute to MLIR cmpxchg operation.
 def LLVM_AtomicCmpXchgOp : LLVM_Op<"cmpxchg"> {
   let arguments = (ins LLVM_PointerTo:$ptr,
LLVM_AtomicCmpXchgType:$cmp, LLVM_AtomicCmpXchgType:$val,
@@ -1560,7 +1563,7 @@
AtomicOrdering:$failure_ordering);
   let results = (outs LLVM_AtomicCmpXchgResultType:$res);
   let llvmBuilder = [{
-$res = builder.CreateAtomicCmpXchg($ptr, $cmp, $val,
+$res = builder.CreateAtomicCmpXchg($ptr, $cmp, $val, llvm::MaybeAlign(),
getLLVMAtomicOrdering($success_ordering),
getLLVMAtomicOrdering($failure_ordering));
   }];
Index: llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
===
--- llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -205,6 +205,7 @@
 // automic update currently can only be promoted across the current
 // loop, not the whole loop nest.
 Builder.CreateAtomicRMW(AtomicRMWInst::Add, Addr, LiveInValue,
+MaybeAlign(),
 AtomicOrdering::SequentiallyConsistent);
   else {
 LoadInst *OldVal = Builder.CreateLoad(Ty, Addr, "pgocount.promoted");
@@ -702,7 +703,7 @@
   if (Options.Atomic || AtomicCounterUpdateAll ||
   (Index == 0 && AtomicFirstCounter)) {
 Builder.CreateAtomicRMW(AtomicRMWInst::Add, Addr, Inc->getStep(),
-AtomicOrdering::Monotonic);
+MaybeAlign(), AtomicOrdering::Monotonic);
   } else {
 Value *IncStep = Inc->getStep();
 Value *Load = Builder.CreateLoad(IncStep->getType(), Addr, "pgocount");
Index: llvm/lib/Transforms/Instrumentation/InstrOrderFile.cpp
===
--- llvm/lib/Transforms/Instrumentation/InstrOrderFile.cpp
+++ llvm/lib/Transforms/Instrumentation/InstrOrderFile.cpp
@@ -144,7 +144,7 @@
 // Fill up UpdateOrderFileBB: grab the index, update the buffer!
 Value *IdxVal = updateB.CreateAtomicRMW(
 AtomicRMWInst::Add, BufferIdx, ConstantInt::get(Int32Ty, 1),
-AtomicOrdering::SequentiallyConsistent);
+MaybeAlign(), AtomicOrdering::SequentiallyConsistent);
 // We need to wrap around the index to fit it inside the buffer.
 Value *WrappedIdx = updateB.CreateAnd(
 IdxVal, ConstantInt::get(Int32Ty, INSTR_ORDER_FILE_BUFFER_MASK));
Index: llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
===
--- llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ 

[PATCH] D97043: [clang][DeclPrinter] Pass Context into StmtPrinter whenever possible

2021-02-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:526
  HI.Name = "result";
- HI.Definition = "static constexpr int result = 1 + 2";
+ HI.Definition = "static constexpr int result = a + b";
  HI.Kind = index::SymbolKind::StaticProperty;

kadircet wrote:
> not sure if this is a regression or not, as in theory we print the definition 
> as written.
this looks fine to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97043

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


[PATCH] D97098: [Utils] Add an option to specify number of cores to use in creduce-clang-crash.py

2021-02-22 Thread Zequan Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb380699416d8: [Utils] Add an option to specify number of 
cores to use in creduce-clang-crash. (authored by zequanwu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97098

Files:
  clang/utils/creduce-clang-crash.py


Index: clang/utils/creduce-clang-crash.py
===
--- clang/utils/creduce-clang-crash.py
+++ clang/utils/creduce-clang-crash.py
@@ -19,6 +19,7 @@
 import tempfile
 import shutil
 from distutils.spawn import find_executable
+import multiprocessing
 
 verbose = False
 creduce_cmd = None
@@ -64,7 +65,7 @@
   os.chmod(filename, os.stat(filename).st_mode | stat.S_IEXEC)
 
 class Reduce(object):
-  def __init__(self, crash_script, file_to_reduce):
+  def __init__(self, crash_script, file_to_reduce, core_number):
 crash_script_name, crash_script_ext = os.path.splitext(crash_script)
 file_reduce_name, file_reduce_ext = os.path.splitext(file_to_reduce)
 
@@ -78,6 +79,7 @@
 self.expected_output = []
 self.needs_stack_trace = False
 self.creduce_flags = ["--tidy"]
+self.creduce_flags = ["--n", str(core_number)]
 
 self.read_clang_args(crash_script, file_to_reduce)
 self.read_expected_output()
@@ -394,6 +396,9 @@
   parser.add_argument('--creduce', dest='creduce', type=str,
   help="The path to the `creduce` executable. "
   "Required if `creduce` is not in PATH environment.")
+  parser.add_argument('--n', dest='core_number', type=int, 
+  default=max(4, multiprocessing.cpu_count() / 2),
+  help="Number of cores to use.")
   parser.add_argument('-v', '--verbose', action='store_true')
   args = parser.parse_args()
 
@@ -401,11 +406,12 @@
   llvm_bin = os.path.abspath(args.llvm_bin) if args.llvm_bin else None
   creduce_cmd = check_cmd('creduce', None, args.creduce)
   clang_cmd = check_cmd('clang', llvm_bin, args.clang)
+  core_number = args.core_number
 
   crash_script = check_file(args.crash_script[0])
   file_to_reduce = check_file(args.file_to_reduce[0])
 
-  r = Reduce(crash_script, file_to_reduce)
+  r = Reduce(crash_script, file_to_reduce, core_number)
 
   r.simplify_clang_args()
   r.write_interestingness_test()


Index: clang/utils/creduce-clang-crash.py
===
--- clang/utils/creduce-clang-crash.py
+++ clang/utils/creduce-clang-crash.py
@@ -19,6 +19,7 @@
 import tempfile
 import shutil
 from distutils.spawn import find_executable
+import multiprocessing
 
 verbose = False
 creduce_cmd = None
@@ -64,7 +65,7 @@
   os.chmod(filename, os.stat(filename).st_mode | stat.S_IEXEC)
 
 class Reduce(object):
-  def __init__(self, crash_script, file_to_reduce):
+  def __init__(self, crash_script, file_to_reduce, core_number):
 crash_script_name, crash_script_ext = os.path.splitext(crash_script)
 file_reduce_name, file_reduce_ext = os.path.splitext(file_to_reduce)
 
@@ -78,6 +79,7 @@
 self.expected_output = []
 self.needs_stack_trace = False
 self.creduce_flags = ["--tidy"]
+self.creduce_flags = ["--n", str(core_number)]
 
 self.read_clang_args(crash_script, file_to_reduce)
 self.read_expected_output()
@@ -394,6 +396,9 @@
   parser.add_argument('--creduce', dest='creduce', type=str,
   help="The path to the `creduce` executable. "
   "Required if `creduce` is not in PATH environment.")
+  parser.add_argument('--n', dest='core_number', type=int, 
+  default=max(4, multiprocessing.cpu_count() / 2),
+  help="Number of cores to use.")
   parser.add_argument('-v', '--verbose', action='store_true')
   args = parser.parse_args()
 
@@ -401,11 +406,12 @@
   llvm_bin = os.path.abspath(args.llvm_bin) if args.llvm_bin else None
   creduce_cmd = check_cmd('creduce', None, args.creduce)
   clang_cmd = check_cmd('clang', llvm_bin, args.clang)
+  core_number = args.core_number
 
   crash_script = check_file(args.crash_script[0])
   file_to_reduce = check_file(args.file_to_reduce[0])
 
-  r = Reduce(crash_script, file_to_reduce)
+  r = Reduce(crash_script, file_to_reduce, core_number)
 
   r.simplify_clang_args()
   r.write_interestingness_test()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b380699 - [Utils] Add an option to specify number of cores to use in creduce-clang-crash.py

2021-02-22 Thread Zequan Wu via cfe-commits

Author: Zequan Wu
Date: 2021-02-22T12:43:09-08:00
New Revision: b380699416d8310f20c59928bf379129ec98e064

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

LOG: [Utils] Add an option to specify number of cores to use in 
creduce-clang-crash.py

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

Added: 


Modified: 
clang/utils/creduce-clang-crash.py

Removed: 




diff  --git a/clang/utils/creduce-clang-crash.py 
b/clang/utils/creduce-clang-crash.py
index 51f4d9d333bc..08056e52b826 100755
--- a/clang/utils/creduce-clang-crash.py
+++ b/clang/utils/creduce-clang-crash.py
@@ -19,6 +19,7 @@
 import tempfile
 import shutil
 from distutils.spawn import find_executable
+import multiprocessing
 
 verbose = False
 creduce_cmd = None
@@ -64,7 +65,7 @@ def write_to_script(text, filename):
   os.chmod(filename, os.stat(filename).st_mode | stat.S_IEXEC)
 
 class Reduce(object):
-  def __init__(self, crash_script, file_to_reduce):
+  def __init__(self, crash_script, file_to_reduce, core_number):
 crash_script_name, crash_script_ext = os.path.splitext(crash_script)
 file_reduce_name, file_reduce_ext = os.path.splitext(file_to_reduce)
 
@@ -78,6 +79,7 @@ def __init__(self, crash_script, file_to_reduce):
 self.expected_output = []
 self.needs_stack_trace = False
 self.creduce_flags = ["--tidy"]
+self.creduce_flags = ["--n", str(core_number)]
 
 self.read_clang_args(crash_script, file_to_reduce)
 self.read_expected_output()
@@ -394,6 +396,9 @@ def main():
   parser.add_argument('--creduce', dest='creduce', type=str,
   help="The path to the `creduce` executable. "
   "Required if `creduce` is not in PATH environment.")
+  parser.add_argument('--n', dest='core_number', type=int, 
+  default=max(4, multiprocessing.cpu_count() / 2),
+  help="Number of cores to use.")
   parser.add_argument('-v', '--verbose', action='store_true')
   args = parser.parse_args()
 
@@ -401,11 +406,12 @@ def main():
   llvm_bin = os.path.abspath(args.llvm_bin) if args.llvm_bin else None
   creduce_cmd = check_cmd('creduce', None, args.creduce)
   clang_cmd = check_cmd('clang', llvm_bin, args.clang)
+  core_number = args.core_number
 
   crash_script = check_file(args.crash_script[0])
   file_to_reduce = check_file(args.file_to_reduce[0])
 
-  r = Reduce(crash_script, file_to_reduce)
+  r = Reduce(crash_script, file_to_reduce, core_number)
 
   r.simplify_clang_args()
   r.write_interestingness_test()



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


[PATCH] D97098: [Utils] Add an option to specify number of cores to use in creduce-clang-crash.py

2021-02-22 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97098

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


[PATCH] D96838: Add GNU attribute 'retain'

2021-02-22 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Yeah, both COFF and Mach-O have longstanding ways to protect linker 
dead-stripping, and the compiler already has to manually trigger them on those 
targets for `used`, so it's certainly implementable to also trigger them for 
`retain`-without-`used`.  I just don't think it's a very good feature.  It 
seems to me that the use cases of `retain`-without-`used` all basically boil 
down to "Definition A relies on Definition B in some way that isn't just a 
symbol reference."  `retain`-without-`used` is at best a very rough way of 
achieving that underlying goal of forcing Definition B to be emitted if 
something requires Definition A, and what we really want is a way to express 
that dependence so that the compiler/linker can still strip Definition B if 
Definition A is also stripped.

Also in this space, I think we still don't have a way to express 
`llvm.compiler_used` in the source language, i.e. "feel free to dead-strip this 
if it's never referenced, but if it is referenced, there will be funny uses of 
it that the compiler can't reason about".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96838

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


[PATCH] D96838: Add GNU attribute 'retain'

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

LGTM aside from some minor improvements to the documentation.




Comment at: clang/include/clang/Basic/Attr.td:2655
+
+def Retain : InheritableAttr {
+  let Spellings = [GCC<"retain">];

MaskRay wrote:
> MaskRay wrote:
> > aaron.ballman wrote:
> > > rjmccall wrote:
> > > > MaskRay wrote:
> > > > > aaron.ballman wrote:
> > > > > > MaskRay wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > MaskRay wrote:
> > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > Should this be a target-specific attribute as it only has 
> > > > > > > > > > effects on ELF targets?
> > > > > > > > > As I understand it, GCC `retain` is not warned on unsupported 
> > > > > > > > > targets.
> > > > > > > > > 
> > > > > > > > > Regardless of GCC's choice, I think not having a `warning: 
> > > > > > > > > unknown attribute 'retain' ignored [-Wunknown-attributes]` 
> > > > > > > > > diagnostic makes sense. `retain` will be usually used 
> > > > > > > > > together with `used`. In Clang, `used` already has "retain" 
> > > > > > > > > semantics on macOS and Windows (I don't know what they do on 
> > > > > > > > > GCC; GCC folks want orthogonality for ELF and I agree). If 
> > > > > > > > > `retain` is silently ignored on macOS and Windows, then users 
> > > > > > > > > don't need to condition compile for different targets.
> > > > > > > > The other side of that is a user who writes only `retain` and 
> > > > > > > > expects it to do something when it's actually being silently 
> > > > > > > > ignored. While they may usually use it in conjunction with 
> > > > > > > > `used`, I'm more worried about the situation where the user is 
> > > > > > > > possibly confused.
> > > > > > > `retain` without `used` can be used on some external linkage 
> > > > > > > definitions, as well as internal linkage definitions which are 
> > > > > > > referenced by live sections. I agree there could be some 
> > > > > > > confusion, but hope with mccall's suggestion (thanks) the 
> > > > > > > documentation is clear.
> > > > > > If `retain` without `used` is an expected usage pattern, then I 
> > > > > > think we need a diagnostic when we ignore the `retain` attribute. I 
> > > > > > don't think it is reasonable to expect users to read the 
> > > > > > documentation because they won't know that they've misused the 
> > > > > > attribute when we silently ignore it.
> > > > > > 
> > > > > > Alternatively, would it be possible to make `retain` useful on all 
> > > > > > targets? e.g., when `retain` is used by itself on a declaration 
> > > > > > compiled for macOS or Windows, the backend does whatever it would 
> > > > > > normally do for `used`?
> > > > > There is the normal behavior: `__attribute__((retain)) static void 
> > > > > f1() {} // expected-warning {{unused function 'f1'}}`.
> > > > > 
> > > > > Sema.cpp:1227 has the unused diagnostics. There are already many 
> > > > > different versions of diagnostics. Do you suggest another diagnostic 
> > > > > line for `used is needed`? If you think so, I'll need to figure out 
> > > > > how to do that...
> > > > > 
> > > > > Added some tests leveraging the existing diagnostic code.
> > > > We could definitely support retain-without-used with the ELF semantics 
> > > > on all targets if we think they're useful.
> > > I was thinking more along the lines of:
> > > ```
> > > def Retain : InheritableAttr, TargetSpecificAttr {
> > >   ...
> > > }
> > > ```
> > > so that on targets where `retain` is ignored, the user gets an unknown 
> > > attribute diagnostic as with other target-specific attributes. However, I 
> > > see now that the attribute being passed along to the backend in all 
> > > situations and so it isn't really a target-specific attribute in the same 
> > > way as `MSNoVTable` (etc) is. It's not that `retain` isn't sensible on 
> > > those targets, it's that different backends will want to handle the 
> > > attribute differently and that might include it being a harmless noop. Is 
> > > that a correct understanding? If so, then I don't think we need to make 
> > > it target-specific or otherwise diagnose it.
> > This is the case where LangRef definition reflects the state on Mach-O but 
> > not on ELF (and not on PE-COFF before 2018-01).
> > 
> > https://reviews.llvm.org/rG99f479abcf2c9b36daad04eb91cd0aafa659bb1d (CC 
> > @compnerd) (2018-01) is the commit. We could let `!retain` (if we choose to 
> > use `!retain` as the representation) lower to similar `/INCLUDE:` 
> > directives in the `.drectve` section.
> > However, I see now that the attribute being passed along to the backend in 
> > all situations and so it isn't really a target-specific attribute in the 
> > same way as MSNoVTable (etc) is.
> 
> Yes. It depends on whether the backend can translate `!retain` into something 
> affecting linker garbage collection behavior.
> On ELF, it works via `SHF_GNU_RETAIN` (requires bleeding-edge 

[PATCH] D97098: [Utils] Add an option to specify number of cores to use in creduce-clang-crash.py

2021-02-22 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.

But lgtm either way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97098

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


[PATCH] D97098: [Utils] Add an option to specify number of cores to use in creduce-clang-crash.py

2021-02-22 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D97098#2579620 , @zequanwu wrote:

> Address comment, using `max(4, multiprocessing.cpu_count() / 2)` because 
> `os.cpu_count` is not available in python2.

We require py3 these days, so it's ok to assume it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97098

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


[PATCH] D77598: Integral template argument suffix and cast printing

2021-02-22 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/AST/TemplateBase.cpp:71-72
 
   if (T->isBooleanType() && !Policy.MSVCFormatting) {
 Out << (Val.getBoolValue() ? "true" : "false");
   } else if (T->isCharType()) {

rsmith wrote:
> rsmith wrote:
> > rnk wrote:
> > > rsmith wrote:
> > > > reikdas wrote:
> > > > > rsmith wrote:
> > > > > > rsmith wrote:
> > > > > > > It looks like `MSVCFormatting` wants `bool` values to be printed 
> > > > > > > as `0` and `1`, and this patch presumably changes that (along 
> > > > > > > with the printing of other builtin types). I wonder if this is a 
> > > > > > > problem in practice (eg, if such things are used as keys for 
> > > > > > > debug info or similar)...
> > > > > > Do we need to suppress printing the suffixes below in 
> > > > > > `MSVCFormatting` mode too?
> > > > > @rsmith The tests pass, so that is reassuring at least. Is there any 
> > > > > other way to find out whether we need to suppress printing the 
> > > > > suffixes for other types in MSVCFormatting mode?
> > > > @rnk Can you take a look at this? Per 
> > > > rG60103383f097b6580ecb4519eeb87defdb7c05c9 and PR21528 it seems like 
> > > > there might be specific requirements for how template arguments are 
> > > > formatted for CodeView support; we presumably need to make sure we 
> > > > still satisfy those requirements.
> > > Probably. This change looks like it preserves behavior from before when 
> > > `MSVCFormatting` is set, so I think this is OK. I checked, my version of 
> > > MSVC still uses 1/0 in debug info for boolean template args.
> > My concern is that we're changing the behavior for the other cases below in 
> > `MSVCFormatting` mode, not that we're changing the behavior for `bool`. If 
> > we have specific formatting requirements in `MSVCFormatting` mode, they 
> > presumably apply to all types, not only to `bool`, so we should be careful 
> > to not change the output in `MSVCFormatting` mode for any type.
> @rnk Ping.
I think we do need to suppress the suffixes for MSVCFormatting. Consider this 
visualizer I found in the stl.natvis file:
```
  
  {_MyRep} nanoseconds
  
  

  
  {_MyRep} microseconds
  
  
```

Adding L or ULL after 100 has the potential to break the visualizer.

However, in general, I don't think we need to freeze this code in amber. It's 
not like we put a lot of thought into making this code produce MSVC-idential 
names when we started using it in CodeView debug info. We just used it and 
debug issues as they come up.

I think a good rule of thumb for making changes is probably to ask if the main 
STL data structure names include this template argument feature. So, auto-typed 
non-type template parameters probably aren't an issue.

---

Separately, I wish the stl.natvis file was part of the github.com/microsoft/STL 
project so I could just link to it...


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

https://reviews.llvm.org/D77598

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


[PATCH] D96974: [clang][patch] Inclusive language, modify filename SanitizerBlacklist.h to NoSanitizeList.h

2021-02-22 Thread Melanie Blower via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe64fcdf8d53c: [clang][patch] Inclusive language, modify 
filename SanitizerBlacklist.h to… (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96974

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/NoSanitizeList.h
  clang/include/clang/Basic/SanitizerBlacklist.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/LangOptions.cpp
  clang/lib/Basic/NoSanitizeList.cpp
  clang/lib/Basic/SanitizerBlacklist.cpp
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/SanitizerMetadata.cpp
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3607,7 +3607,7 @@
 GenerateArg(Args, OPT_fsanitize_EQ, Sanitizer, SA);
 
   // Conflating '-fsanitize-system-blacklist' and '-fsanitize-blacklist'.
-  for (const std::string  : Opts.SanitizerBlacklistFiles)
+  for (const std::string  : Opts.NoSanitizeFiles)
 GenerateArg(Args, OPT_fsanitize_blacklist, F, SA);
 
   if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver3_8)
@@ -4006,12 +4006,11 @@
   // Parse -fsanitize= arguments.
   parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
   Diags, Opts.Sanitize);
-  Opts.SanitizerBlacklistFiles = Args.getAllArgValues(OPT_fsanitize_blacklist);
+  Opts.NoSanitizeFiles = Args.getAllArgValues(OPT_fsanitize_blacklist);
   std::vector systemBlacklists =
   Args.getAllArgValues(OPT_fsanitize_system_blacklist);
-  Opts.SanitizerBlacklistFiles.insert(Opts.SanitizerBlacklistFiles.end(),
-  systemBlacklists.begin(),
-  systemBlacklists.end());
+  Opts.NoSanitizeFiles.insert(Opts.NoSanitizeFiles.end(),
+  systemBlacklists.begin(), systemBlacklists.end());
 
   if (Arg *A = Args.getLastArg(OPT_fclang_abi_compat_EQ)) {
 Opts.setClangABICompat(LangOptions::ClangABI::Latest);
Index: clang/lib/CodeGen/SanitizerMetadata.cpp
===
--- clang/lib/CodeGen/SanitizerMetadata.cpp
+++ clang/lib/CodeGen/SanitizerMetadata.cpp
@@ -1,4 +1,4 @@
-//===--- SanitizerMetadata.cpp - Blacklist for sanitizers -===//
+//===--- SanitizerMetadata.cpp - Ignored entities for sanitizers --===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -34,15 +34,15 @@
bool IsExcluded) {
   if (!isAsanHwasanOrMemTag(CGM.getLangOpts().Sanitize))
 return;
-  IsDynInit &= !CGM.isInSanitizerBlacklist(GV, Loc, Ty, "init");
-  IsExcluded |= CGM.isInSanitizerBlacklist(GV, Loc, Ty);
+  IsDynInit &= !CGM.isInNoSanitizeList(GV, Loc, Ty, "init");
+  IsExcluded |= CGM.isInNoSanitizeList(GV, Loc, Ty);
 
   llvm::Metadata *LocDescr = nullptr;
   llvm::Metadata *GlobalName = nullptr;
   llvm::LLVMContext  = CGM.getLLVMContext();
   if (!IsExcluded) {
-// Don't generate source location and global name if it is blacklisted -
-// it won't be instrumented anyway.
+// Don't generate source location and global name if it is on
+// the NoSanitizeList - it won't be instrumented anyway.
 LocDescr = getLocationMetadata(Loc);
 if (!Name.empty())
   GlobalName = llvm::MDString::get(VMContext, Name);
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -25,7 +25,7 @@
 #include "clang/Basic/ABI.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/Module.h"
-#include "clang/Basic/SanitizerBlacklist.h"
+#include "clang/Basic/NoSanitizeList.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/XRayLists.h"
 #include "llvm/ADT/DenseMap.h"
@@ -1267,12 +1267,11 @@
   /// annotations are emitted during finalization of the LLVM code.
   void AddGlobalAnnotations(const ValueDecl *D, llvm::GlobalValue *GV);
 
-  bool isInSanitizerBlacklist(SanitizerMask Kind, llvm::Function *Fn,
-  SourceLocation Loc) const;
+  bool isInNoSanitizeList(SanitizerMask Kind, llvm::Function *Fn,
+  SourceLocation Loc) const;
 
-  bool isInSanitizerBlacklist(llvm::GlobalVariable *GV, SourceLocation 

[clang] e64fcdf - [clang][patch] Inclusive language, modify filename SanitizerBlacklist.h to NoSanitizeList.h

2021-02-22 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-02-22T15:11:37-05:00
New Revision: e64fcdf8d53c1d2ab709394c39743fa11d270181

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

LOG: [clang][patch] Inclusive language, modify filename SanitizerBlacklist.h to 
NoSanitizeList.h

This patch responds to a comment from @vitalybuka in D96203: suggestion to
do the change incrementally, and start by modifying this file name. I modified
the file name and made the other changes that follow from that rename.

Reviewers: vitalybuka, echristo, MaskRay, jansvoboda11, aaron.ballman

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

Added: 
clang/include/clang/Basic/NoSanitizeList.h
clang/lib/Basic/NoSanitizeList.cpp

Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/Basic/LangOptions.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/Decl.cpp
clang/lib/Basic/CMakeLists.txt
clang/lib/Basic/LangOptions.cpp
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CGClass.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/SanitizerMetadata.cpp
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 
clang/include/clang/Basic/SanitizerBlacklist.h
clang/lib/Basic/SanitizerBlacklist.cpp



diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index f256f9762b50..8ba4c41aac70 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -34,10 +34,10 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/Linkage.h"
+#include "clang/Basic/NoSanitizeList.h"
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/PartialDiagnostic.h"
 #include "clang/Basic/ProfileList.h"
-#include "clang/Basic/SanitizerBlacklist.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
 #include "clang/Basic/XRayLists.h"
@@ -562,9 +562,9 @@ class ASTContext : public RefCountedBase {
   ///  this ASTContext object.
   LangOptions 
 
-  /// Blacklist object that is used by sanitizers to decide which
+  /// NoSanitizeList object that is used by sanitizers to decide which
   /// entities should not be instrumented.
-  std::unique_ptr SanitizerBL;
+  std::unique_ptr NoSanitizeL;
 
   /// Function filtering mechanism to determine whether a given function
   /// should be imbued with the XRay "always" or "never" attributes.
@@ -691,9 +691,7 @@ class ASTContext : public RefCountedBase {
 return LangOpts.CPlusPlus || LangOpts.RecoveryAST;
   }
 
-  const SanitizerBlacklist () const {
-return *SanitizerBL;
-  }
+  const NoSanitizeList () const { return *NoSanitizeL; }
 
   const XRayFunctionFilter () const {
 return *XRayFilter;

diff  --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index 0d14121bac7a..c797167f8fd2 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -264,9 +264,9 @@ class LangOptions : public LangOptionsBase {
   /// Set of enabled sanitizers.
   SanitizerSet Sanitize;
 
-  /// Paths to blacklist files specifying which objects
+  /// Paths to files specifying which objects
   /// (files, functions, variables) should not be instrumented.
-  std::vector SanitizerBlacklistFiles;
+  std::vector NoSanitizeFiles;
 
   /// Paths to the XRay "always instrument" files specifying which
   /// objects (files, functions, variables) should be imbued with the XRay

diff  --git a/clang/include/clang/Basic/NoSanitizeList.h 
b/clang/include/clang/Basic/NoSanitizeList.h
new file mode 100644
index ..3f80e0fdedda
--- /dev/null
+++ b/clang/include/clang/Basic/NoSanitizeList.h
@@ -0,0 +1,50 @@
+//===--- NoSanitizeList.h - List of ignored entities for sanitizers --*- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// User-provided list of ignored entities used to disable/alter
+// instrumentation done in sanitizers.
+//
+//===--===//
+#ifndef LLVM_CLANG_BASIC_NOSANITIZELIST_H
+#define LLVM_CLANG_BASIC_NOSANITIZELIST_H
+
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+
+namespace clang {
+
+class SanitizerMask;
+class SourceManager;
+class SanitizerSpecialCaseList;
+
+class 

[PATCH] D96838: Add GNU attribute 'retain'

2021-02-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked an inline comment as done.
MaskRay added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:2655
+
+def Retain : InheritableAttr {
+  let Spellings = [GCC<"retain">];

MaskRay wrote:
> aaron.ballman wrote:
> > rjmccall wrote:
> > > MaskRay wrote:
> > > > aaron.ballman wrote:
> > > > > MaskRay wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > MaskRay wrote:
> > > > > > > > aaron.ballman wrote:
> > > > > > > > > Should this be a target-specific attribute as it only has 
> > > > > > > > > effects on ELF targets?
> > > > > > > > As I understand it, GCC `retain` is not warned on unsupported 
> > > > > > > > targets.
> > > > > > > > 
> > > > > > > > Regardless of GCC's choice, I think not having a `warning: 
> > > > > > > > unknown attribute 'retain' ignored [-Wunknown-attributes]` 
> > > > > > > > diagnostic makes sense. `retain` will be usually used together 
> > > > > > > > with `used`. In Clang, `used` already has "retain" semantics on 
> > > > > > > > macOS and Windows (I don't know what they do on GCC; GCC folks 
> > > > > > > > want orthogonality for ELF and I agree). If `retain` is 
> > > > > > > > silently ignored on macOS and Windows, then users don't need to 
> > > > > > > > condition compile for different targets.
> > > > > > > The other side of that is a user who writes only `retain` and 
> > > > > > > expects it to do something when it's actually being silently 
> > > > > > > ignored. While they may usually use it in conjunction with 
> > > > > > > `used`, I'm more worried about the situation where the user is 
> > > > > > > possibly confused.
> > > > > > `retain` without `used` can be used on some external linkage 
> > > > > > definitions, as well as internal linkage definitions which are 
> > > > > > referenced by live sections. I agree there could be some confusion, 
> > > > > > but hope with mccall's suggestion (thanks) the documentation is 
> > > > > > clear.
> > > > > If `retain` without `used` is an expected usage pattern, then I think 
> > > > > we need a diagnostic when we ignore the `retain` attribute. I don't 
> > > > > think it is reasonable to expect users to read the documentation 
> > > > > because they won't know that they've misused the attribute when we 
> > > > > silently ignore it.
> > > > > 
> > > > > Alternatively, would it be possible to make `retain` useful on all 
> > > > > targets? e.g., when `retain` is used by itself on a declaration 
> > > > > compiled for macOS or Windows, the backend does whatever it would 
> > > > > normally do for `used`?
> > > > There is the normal behavior: `__attribute__((retain)) static void f1() 
> > > > {} // expected-warning {{unused function 'f1'}}`.
> > > > 
> > > > Sema.cpp:1227 has the unused diagnostics. There are already many 
> > > > different versions of diagnostics. Do you suggest another diagnostic 
> > > > line for `used is needed`? If you think so, I'll need to figure out how 
> > > > to do that...
> > > > 
> > > > Added some tests leveraging the existing diagnostic code.
> > > We could definitely support retain-without-used with the ELF semantics on 
> > > all targets if we think they're useful.
> > I was thinking more along the lines of:
> > ```
> > def Retain : InheritableAttr, TargetSpecificAttr {
> >   ...
> > }
> > ```
> > so that on targets where `retain` is ignored, the user gets an unknown 
> > attribute diagnostic as with other target-specific attributes. However, I 
> > see now that the attribute being passed along to the backend in all 
> > situations and so it isn't really a target-specific attribute in the same 
> > way as `MSNoVTable` (etc) is. It's not that `retain` isn't sensible on 
> > those targets, it's that different backends will want to handle the 
> > attribute differently and that might include it being a harmless noop. Is 
> > that a correct understanding? If so, then I don't think we need to make it 
> > target-specific or otherwise diagnose it.
> This is the case where LangRef definition reflects the state on Mach-O but 
> not on ELF (and not on PE-COFF before 2018-01).
> 
> https://reviews.llvm.org/rG99f479abcf2c9b36daad04eb91cd0aafa659bb1d (CC 
> @compnerd) (2018-01) is the commit. We could let `!retain` (if we choose to 
> use `!retain` as the representation) lower to similar `/INCLUDE:` directives 
> in the `.drectve` section.
> However, I see now that the attribute being passed along to the backend in 
> all situations and so it isn't really a target-specific attribute in the same 
> way as MSNoVTable (etc) is.

Yes. It depends on whether the backend can translate `!retain` into something 
affecting linker garbage collection behavior.
On ELF, it works via `SHF_GNU_RETAIN` (requires bleeding-edge toolchain).
On other binary formats, it is currently a no-op. Further notes:

On COFF, I can make `!retain` work by using `/INCLUDE:` for 
non-local-LLVM-linkage definitions.
On macOS, the maintainer can decide whether it is useful to set 

[PATCH] D97137: Bug fix of clang-format, the AlignConsecutiveDeclarations option doesn't handle pointer properly

2021-02-22 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

You should mark comments as done, if they are.

Does your modification maybe add something to the alignment which is not a 
declaration?

  int a;
  double b;
  a * b;

How is that formatted? Yeah unlikely that something like that is in code, but 
it could be if `operator*` has side effects and one does not need the result.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97137

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


[PATCH] D50106: [libc++] Fix tuple assignment from types derived from a tuple-like

2021-02-22 Thread Louis Dionne via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa0839b14df6d: [libc++] Fix tuple assignment from types 
derived from a tuple-like (authored by ldionne).

Changed prior to commit:
  https://reviews.llvm.org/D50106?vs=325449=325524#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D50106

Files:
  libcxx/include/tuple
  
libcxx/test/libcxx/utilities/tuple/tuple.tuple/tuple.assign/array.extension.pass.cpp
  
libcxx/test/libcxx/utilities/tuple/tuple.tuple/tuple.assign/tuple_array_template_depth.pass.cpp
  libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp
  libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp
  libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
  libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp
  
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/derived_from_tuple_like.pass.cpp
  libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/laziness.pass.cpp
  libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp
  libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp
  
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/tuple_array_template_depth.pass.cpp
  libcxx/test/support/propagate_value_category.hpp

Index: libcxx/test/support/propagate_value_category.hpp
===
--- /dev/null
+++ libcxx/test/support/propagate_value_category.hpp
@@ -0,0 +1,153 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef TEST_SUPPORT_PROPAGATE_VALUE_CATEGORY
+#define TEST_SUPPORT_PROPAGATE_VALUE_CATEGORY
+
+#include "test_macros.h"
+#include 
+
+#if TEST_STD_VER < 11
+#error this header may only be used in C++11
+#endif
+
+using UnderlyingVCType = unsigned;
+enum ValueCategory : UnderlyingVCType {
+  VC_None = 0,
+  VC_LVal = 1 << 0,
+  VC_RVal = 1 << 1,
+  VC_Const = 1 << 2,
+  VC_Volatile = 1 << 3,
+  VC_ConstVolatile = VC_Const | VC_Volatile
+};
+
+inline constexpr ValueCategory operator&(ValueCategory LHS, ValueCategory RHS) {
+  return ValueCategory(LHS & (UnderlyingVCType)RHS);
+}
+
+inline constexpr ValueCategory operator|(ValueCategory LHS, ValueCategory RHS) {
+  return ValueCategory(LHS | (UnderlyingVCType)RHS);
+}
+
+inline constexpr ValueCategory operator^(ValueCategory LHS, ValueCategory RHS) {
+  return ValueCategory(LHS ^ (UnderlyingVCType)RHS);
+}
+
+inline constexpr bool isValidValueCategory(ValueCategory VC) {
+  return (VC & (VC_LVal | VC_RVal)) != (VC_LVal | VC_RVal);
+}
+
+inline constexpr bool hasValueCategory(ValueCategory Arg, ValueCategory Key) {
+  return Arg == Key || ((Arg & Key) == Key);
+}
+
+template 
+using UnCVRef =
+typename std::remove_cv::type>::type;
+
+template 
+constexpr ValueCategory getReferenceQuals() {
+  return std::is_lvalue_reference::value
+ ? VC_LVal
+ : (std::is_rvalue_reference::value ? VC_RVal : VC_None);
+}
+static_assert(getReferenceQuals() == VC_None, "");
+static_assert(getReferenceQuals() == VC_LVal, "");
+static_assert(getReferenceQuals() == VC_RVal, "");
+
+template 
+constexpr ValueCategory getCVQuals() {
+  using Vp = typename std::remove_reference::type;
+  return std::is_const::value && std::is_volatile::value
+ ? VC_ConstVolatile
+ : (std::is_const::value
+? VC_Const
+: (std::is_volatile::value ? VC_Volatile : VC_None));
+}
+static_assert(getCVQuals() == VC_None, "");
+static_assert(getCVQuals() == VC_Const, "");
+static_assert(getCVQuals() == VC_Volatile, "");
+static_assert(getCVQuals() == VC_ConstVolatile, "");
+static_assert(getCVQuals() == VC_None, "");
+static_assert(getCVQuals() == VC_Const, "");
+
+template 
+inline constexpr ValueCategory getValueCategory() {
+  return getReferenceQuals() | getCVQuals();
+}
+static_assert(getValueCategory() == VC_None, "");
+static_assert(getValueCategory() == (VC_LVal | VC_Const), "");
+static_assert(getValueCategory() ==
+  (VC_RVal | VC_ConstVolatile),
+  "");
+
+template 
+struct ApplyValueCategory {
+private:
+  static_assert(isValidValueCategory(VC), "");
+
+  template 
+  using CondT = typename std::conditional::type;
+
+public:
+  template >
+  using ApplyCVQuals = CondT<
+  hasValueCategory(VC, VC_ConstVolatile), typename std::add_cv::type,
+  CondT::type,
+CondT::type, Tp>>>;
+
+  template ::type>
+  using 

[PATCH] D96838: Add GNU attribute 'retain'

2021-02-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:2655
+
+def Retain : InheritableAttr {
+  let Spellings = [GCC<"retain">];

rjmccall wrote:
> MaskRay wrote:
> > aaron.ballman wrote:
> > > MaskRay wrote:
> > > > aaron.ballman wrote:
> > > > > MaskRay wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > Should this be a target-specific attribute as it only has effects 
> > > > > > > on ELF targets?
> > > > > > As I understand it, GCC `retain` is not warned on unsupported 
> > > > > > targets.
> > > > > > 
> > > > > > Regardless of GCC's choice, I think not having a `warning: unknown 
> > > > > > attribute 'retain' ignored [-Wunknown-attributes]` diagnostic makes 
> > > > > > sense. `retain` will be usually used together with `used`. In 
> > > > > > Clang, `used` already has "retain" semantics on macOS and Windows 
> > > > > > (I don't know what they do on GCC; GCC folks want orthogonality for 
> > > > > > ELF and I agree). If `retain` is silently ignored on macOS and 
> > > > > > Windows, then users don't need to condition compile for different 
> > > > > > targets.
> > > > > The other side of that is a user who writes only `retain` and expects 
> > > > > it to do something when it's actually being silently ignored. While 
> > > > > they may usually use it in conjunction with `used`, I'm more worried 
> > > > > about the situation where the user is possibly confused.
> > > > `retain` without `used` can be used on some external linkage 
> > > > definitions, as well as internal linkage definitions which are 
> > > > referenced by live sections. I agree there could be some confusion, but 
> > > > hope with mccall's suggestion (thanks) the documentation is clear.
> > > If `retain` without `used` is an expected usage pattern, then I think we 
> > > need a diagnostic when we ignore the `retain` attribute. I don't think it 
> > > is reasonable to expect users to read the documentation because they 
> > > won't know that they've misused the attribute when we silently ignore it.
> > > 
> > > Alternatively, would it be possible to make `retain` useful on all 
> > > targets? e.g., when `retain` is used by itself on a declaration compiled 
> > > for macOS or Windows, the backend does whatever it would normally do for 
> > > `used`?
> > There is the normal behavior: `__attribute__((retain)) static void f1() {} 
> > // expected-warning {{unused function 'f1'}}`.
> > 
> > Sema.cpp:1227 has the unused diagnostics. There are already many different 
> > versions of diagnostics. Do you suggest another diagnostic line for `used 
> > is needed`? If you think so, I'll need to figure out how to do that...
> > 
> > Added some tests leveraging the existing diagnostic code.
> We could definitely support retain-without-used with the ELF semantics on all 
> targets if we think they're useful.
I was thinking more along the lines of:
```
def Retain : InheritableAttr, TargetSpecificAttr {
  ...
}
```
so that on targets where `retain` is ignored, the user gets an unknown 
attribute diagnostic as with other target-specific attributes. However, I see 
now that the attribute being passed along to the backend in all situations and 
so it isn't really a target-specific attribute in the same way as `MSNoVTable` 
(etc) is. It's not that `retain` isn't sensible on those targets, it's that 
different backends will want to handle the attribute differently and that might 
include it being a harmless noop. Is that a correct understanding? If so, then 
I don't think we need to make it target-specific or otherwise diagnose it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96838

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


[PATCH] D97098: [Utils] Add an option to specify number of cores to use in creduce-clang-crash.py

2021-02-22 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 325520.
zequanwu added a comment.

Address comment, using `max(4, multiprocessing.cpu_count() / 2)` because 
`os.cpu_count` is not available in python2.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97098

Files:
  clang/utils/creduce-clang-crash.py


Index: clang/utils/creduce-clang-crash.py
===
--- clang/utils/creduce-clang-crash.py
+++ clang/utils/creduce-clang-crash.py
@@ -19,6 +19,7 @@
 import tempfile
 import shutil
 from distutils.spawn import find_executable
+import multiprocessing
 
 verbose = False
 creduce_cmd = None
@@ -64,7 +65,7 @@
   os.chmod(filename, os.stat(filename).st_mode | stat.S_IEXEC)
 
 class Reduce(object):
-  def __init__(self, crash_script, file_to_reduce):
+  def __init__(self, crash_script, file_to_reduce, core_number):
 crash_script_name, crash_script_ext = os.path.splitext(crash_script)
 file_reduce_name, file_reduce_ext = os.path.splitext(file_to_reduce)
 
@@ -78,6 +79,7 @@
 self.expected_output = []
 self.needs_stack_trace = False
 self.creduce_flags = ["--tidy"]
+self.creduce_flags = ["--n", str(core_number)]
 
 self.read_clang_args(crash_script, file_to_reduce)
 self.read_expected_output()
@@ -394,6 +396,9 @@
   parser.add_argument('--creduce', dest='creduce', type=str,
   help="The path to the `creduce` executable. "
   "Required if `creduce` is not in PATH environment.")
+  parser.add_argument('--n', dest='core_number', type=int, 
+  default=max(4, multiprocessing.cpu_count() / 2),
+  help="Number of cores to use.")
   parser.add_argument('-v', '--verbose', action='store_true')
   args = parser.parse_args()
 
@@ -401,11 +406,12 @@
   llvm_bin = os.path.abspath(args.llvm_bin) if args.llvm_bin else None
   creduce_cmd = check_cmd('creduce', None, args.creduce)
   clang_cmd = check_cmd('clang', llvm_bin, args.clang)
+  core_number = args.core_number
 
   crash_script = check_file(args.crash_script[0])
   file_to_reduce = check_file(args.file_to_reduce[0])
 
-  r = Reduce(crash_script, file_to_reduce)
+  r = Reduce(crash_script, file_to_reduce, core_number)
 
   r.simplify_clang_args()
   r.write_interestingness_test()


Index: clang/utils/creduce-clang-crash.py
===
--- clang/utils/creduce-clang-crash.py
+++ clang/utils/creduce-clang-crash.py
@@ -19,6 +19,7 @@
 import tempfile
 import shutil
 from distutils.spawn import find_executable
+import multiprocessing
 
 verbose = False
 creduce_cmd = None
@@ -64,7 +65,7 @@
   os.chmod(filename, os.stat(filename).st_mode | stat.S_IEXEC)
 
 class Reduce(object):
-  def __init__(self, crash_script, file_to_reduce):
+  def __init__(self, crash_script, file_to_reduce, core_number):
 crash_script_name, crash_script_ext = os.path.splitext(crash_script)
 file_reduce_name, file_reduce_ext = os.path.splitext(file_to_reduce)
 
@@ -78,6 +79,7 @@
 self.expected_output = []
 self.needs_stack_trace = False
 self.creduce_flags = ["--tidy"]
+self.creduce_flags = ["--n", str(core_number)]
 
 self.read_clang_args(crash_script, file_to_reduce)
 self.read_expected_output()
@@ -394,6 +396,9 @@
   parser.add_argument('--creduce', dest='creduce', type=str,
   help="The path to the `creduce` executable. "
   "Required if `creduce` is not in PATH environment.")
+  parser.add_argument('--n', dest='core_number', type=int, 
+  default=max(4, multiprocessing.cpu_count() / 2),
+  help="Number of cores to use.")
   parser.add_argument('-v', '--verbose', action='store_true')
   args = parser.parse_args()
 
@@ -401,11 +406,12 @@
   llvm_bin = os.path.abspath(args.llvm_bin) if args.llvm_bin else None
   creduce_cmd = check_cmd('creduce', None, args.creduce)
   clang_cmd = check_cmd('clang', llvm_bin, args.clang)
+  core_number = args.core_number
 
   crash_script = check_file(args.crash_script[0])
   file_to_reduce = check_file(args.file_to_reduce[0])
 
-  r = Reduce(crash_script, file_to_reduce)
+  r = Reduce(crash_script, file_to_reduce, core_number)
 
   r.simplify_clang_args()
   r.write_interestingness_test()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96838: Add GNU attribute 'retain'

2021-02-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a subscriber: compnerd.
MaskRay added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:2655
+
+def Retain : InheritableAttr {
+  let Spellings = [GCC<"retain">];

rjmccall wrote:
> MaskRay wrote:
> > aaron.ballman wrote:
> > > MaskRay wrote:
> > > > aaron.ballman wrote:
> > > > > MaskRay wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > Should this be a target-specific attribute as it only has effects 
> > > > > > > on ELF targets?
> > > > > > As I understand it, GCC `retain` is not warned on unsupported 
> > > > > > targets.
> > > > > > 
> > > > > > Regardless of GCC's choice, I think not having a `warning: unknown 
> > > > > > attribute 'retain' ignored [-Wunknown-attributes]` diagnostic makes 
> > > > > > sense. `retain` will be usually used together with `used`. In 
> > > > > > Clang, `used` already has "retain" semantics on macOS and Windows 
> > > > > > (I don't know what they do on GCC; GCC folks want orthogonality for 
> > > > > > ELF and I agree). If `retain` is silently ignored on macOS and 
> > > > > > Windows, then users don't need to condition compile for different 
> > > > > > targets.
> > > > > The other side of that is a user who writes only `retain` and expects 
> > > > > it to do something when it's actually being silently ignored. While 
> > > > > they may usually use it in conjunction with `used`, I'm more worried 
> > > > > about the situation where the user is possibly confused.
> > > > `retain` without `used` can be used on some external linkage 
> > > > definitions, as well as internal linkage definitions which are 
> > > > referenced by live sections. I agree there could be some confusion, but 
> > > > hope with mccall's suggestion (thanks) the documentation is clear.
> > > If `retain` without `used` is an expected usage pattern, then I think we 
> > > need a diagnostic when we ignore the `retain` attribute. I don't think it 
> > > is reasonable to expect users to read the documentation because they 
> > > won't know that they've misused the attribute when we silently ignore it.
> > > 
> > > Alternatively, would it be possible to make `retain` useful on all 
> > > targets? e.g., when `retain` is used by itself on a declaration compiled 
> > > for macOS or Windows, the backend does whatever it would normally do for 
> > > `used`?
> > There is the normal behavior: `__attribute__((retain)) static void f1() {} 
> > // expected-warning {{unused function 'f1'}}`.
> > 
> > Sema.cpp:1227 has the unused diagnostics. There are already many different 
> > versions of diagnostics. Do you suggest another diagnostic line for `used 
> > is needed`? If you think so, I'll need to figure out how to do that...
> > 
> > Added some tests leveraging the existing diagnostic code.
> We could definitely support retain-without-used with the ELF semantics on all 
> targets if we think they're useful.
This is the case where LangRef definition reflects the state on Mach-O but not 
on ELF (and not on PE-COFF before 2018-01).

https://reviews.llvm.org/rG99f479abcf2c9b36daad04eb91cd0aafa659bb1d (CC 
@compnerd) (2018-01) is the commit. We could let `!retain` (if we choose to use 
`!retain` as the representation) lower to similar `/INCLUDE:` directives in the 
`.drectve` section.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96838

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


[PATCH] D97132: [clang-tidy] Harden PreferMemberInitializerCheck

2021-02-22 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa2e15fa532f3: [clang-tidy] Harden 
PreferMemberInitializerCheck (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97132

Files:
  
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
@@ -488,3 +488,60 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'x' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
 // CHECK-FIXES: {{^\ *$}}
 }
+
+struct SafeDependancy {
+  int m;
+  int n;
+  SafeDependancy(int M) : m(M) {
+// CHECK-FIXES: SafeDependancy(int M) : m(M), n(m) {
+n = m;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor
+  }
+  // We match against direct field dependancy as well as descendant field
+  // dependancy, ensure both are accounted for.
+  SafeDependancy(short M) : m(M) {
+// CHECK-FIXES: SafeDependancy(short M) : m(M), n(m + 1) {
+n = m + 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor
+  }
+};
+
+struct BadDependancy {
+  int m;
+  int n;
+  BadDependancy(int N) : n(N) {
+m = n;
+  }
+  BadDependancy(short N) : n(N) {
+m = n + 1;
+  }
+};
+
+struct InitFromVarDecl {
+  int m;
+  InitFromVarDecl() {
+// Can't apply this fix as n is declared in the body of the constructor.
+int n = 3;
+m = n;
+  }
+};
+
+struct AlreadyHasInit {
+  int m = 4;
+  AlreadyHasInit() {
+m = 3;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'm' should be initialized in a member initializer of the constructor
+  }
+};
+
+#define ASSIGN_IN_MACRO(FIELD, VALUE) FIELD = (VALUE);
+
+struct MacroCantFix {
+  int n; // NoFix
+  // CHECK-FIXES: int n; // NoFix
+  MacroCantFix() {
+ASSIGN_IN_MACRO(n, 0)
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'n' should be initialized in a member initializer of the constructor
+// CHECK-FIXES: ASSIGN_IN_MACRO(n, 0)
+  }
+};
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
@@ -55,8 +55,37 @@
   return false;
 }
 
+namespace {
+AST_MATCHER_P(FieldDecl, indexNotLessThan, unsigned, Index) {
+  return Node.getFieldIndex() >= Index;
+}
+} // namespace
+
+// Checks if Field is initialised using a field that will be initialised after
+// it.
+// TODO: Probably should guard against function calls that could have side
+// effects or if they do reference another field that's initialized before this
+// field, but is modified before the assignment.
+static bool isSafeAssignment(const FieldDecl *Field, const Expr *Init,
+ const CXXConstructorDecl *Context) {
+
+  auto MemberMatcher =
+  memberExpr(hasObjectExpression(cxxThisExpr()),
+ member(fieldDecl(indexNotLessThan(Field->getFieldIndex();
+
+  auto DeclMatcher = declRefExpr(
+  to(varDecl(unless(parmVarDecl()), hasDeclContext(equalsNode(Context);
+
+  return match(expr(anyOf(MemberMatcher, DeclMatcher,
+  hasDescendant(MemberMatcher),
+  hasDescendant(DeclMatcher))),
+   *Init, Field->getASTContext())
+  .empty();
+}
+
 static const std::pair
-isAssignmentToMemberOf(const RecordDecl *Rec, const Stmt *S) {
+isAssignmentToMemberOf(const CXXRecordDecl *Rec, const Stmt *S,
+   const CXXConstructorDecl *Ctor) {
   if (const auto *BO = dyn_cast(S)) {
 if (BO->getOpcode() != BO_Assign)
   return std::make_pair(nullptr, nullptr);
@@ -69,8 +98,11 @@
 if (!Field)
   return std::make_pair(nullptr, nullptr);
 
-if (isa(ME->getBase()))
-  return std::make_pair(Field, BO->getRHS()->IgnoreParenImpCasts());
+if (!isa(ME->getBase()))
+  return std::make_pair(nullptr, nullptr);
+const Expr *Init = BO->getRHS()->IgnoreParenImpCasts();
+if (isSafeAssignment(Field, Init, Ctor))
+  return std::make_pair(Field, Init);
   } else if (const auto *COCE = dyn_cast(S)) {
 if (COCE->getOperator() != OO_Equal)
   return std::make_pair(nullptr, nullptr);
@@ -84,8 +116,11 @@
 if (!Field)
  

[clang-tools-extra] a2e15fa - [clang-tidy] Harden PreferMemberInitializerCheck

2021-02-22 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-02-22T19:41:11Z
New Revision: a2e15fa532f36db7080347fbae31470c8ceaffc4

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

LOG: [clang-tidy] Harden PreferMemberInitializerCheck

Prevent warning when the values are initialized using fields that will be 
initialized later or VarDecls defined in the constructors body.
Both of these cases can't be safely fixed.
Also improve logic of finding where to insert member initializers, previously 
it could be confused by in class member initializers.

Reviewed By: aaron.ballman

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

Added: 


Modified: 

clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
index 55d3576612d0..6f056e73ad5d 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
@@ -55,8 +55,37 @@ static bool shouldBeDefaultMemberInitializer(const Expr 
*Value) {
   return false;
 }
 
+namespace {
+AST_MATCHER_P(FieldDecl, indexNotLessThan, unsigned, Index) {
+  return Node.getFieldIndex() >= Index;
+}
+} // namespace
+
+// Checks if Field is initialised using a field that will be initialised after
+// it.
+// TODO: Probably should guard against function calls that could have side
+// effects or if they do reference another field that's initialized before this
+// field, but is modified before the assignment.
+static bool isSafeAssignment(const FieldDecl *Field, const Expr *Init,
+ const CXXConstructorDecl *Context) {
+
+  auto MemberMatcher =
+  memberExpr(hasObjectExpression(cxxThisExpr()),
+ member(fieldDecl(indexNotLessThan(Field->getFieldIndex();
+
+  auto DeclMatcher = declRefExpr(
+  to(varDecl(unless(parmVarDecl()), hasDeclContext(equalsNode(Context);
+
+  return match(expr(anyOf(MemberMatcher, DeclMatcher,
+  hasDescendant(MemberMatcher),
+  hasDescendant(DeclMatcher))),
+   *Init, Field->getASTContext())
+  .empty();
+}
+
 static const std::pair
-isAssignmentToMemberOf(const RecordDecl *Rec, const Stmt *S) {
+isAssignmentToMemberOf(const CXXRecordDecl *Rec, const Stmt *S,
+   const CXXConstructorDecl *Ctor) {
   if (const auto *BO = dyn_cast(S)) {
 if (BO->getOpcode() != BO_Assign)
   return std::make_pair(nullptr, nullptr);
@@ -69,8 +98,11 @@ isAssignmentToMemberOf(const RecordDecl *Rec, const Stmt *S) 
{
 if (!Field)
   return std::make_pair(nullptr, nullptr);
 
-if (isa(ME->getBase()))
-  return std::make_pair(Field, BO->getRHS()->IgnoreParenImpCasts());
+if (!isa(ME->getBase()))
+  return std::make_pair(nullptr, nullptr);
+const Expr *Init = BO->getRHS()->IgnoreParenImpCasts();
+if (isSafeAssignment(Field, Init, Ctor))
+  return std::make_pair(Field, Init);
   } else if (const auto *COCE = dyn_cast(S)) {
 if (COCE->getOperator() != OO_Equal)
   return std::make_pair(nullptr, nullptr);
@@ -84,8 +116,11 @@ isAssignmentToMemberOf(const RecordDecl *Rec, const Stmt 
*S) {
 if (!Field)
   return std::make_pair(nullptr, nullptr);
 
-if (isa(ME->getBase()))
-  return std::make_pair(Field, COCE->getArg(1)->IgnoreParenImpCasts());
+if (!isa(ME->getBase()))
+  return std::make_pair(nullptr, nullptr);
+const Expr *Init = COCE->getArg(1)->IgnoreParenImpCasts();
+if (isSafeAssignment(Field, Init, Ctor))
+  return std::make_pair(Field, Init);
   }
 
   return std::make_pair(nullptr, nullptr);
@@ -118,14 +153,12 @@ void PreferMemberInitializerCheck::check(
   const auto *Body = cast(Ctor->getBody());
 
   const CXXRecordDecl *Class = Ctor->getParent();
-  SourceLocation InsertPos;
   bool FirstToCtorInits = true;
 
   for (const Stmt *S : Body->body()) {
 if (S->getBeginLoc().isMacroID()) {
-  StringRef MacroName =
-Lexer::getImmediateMacroName(S->getBeginLoc(), *Result.SourceManager,
- getLangOpts());
+  StringRef MacroName = Lexer::getImmediateMacroName(
+  S->getBeginLoc(), *Result.SourceManager, getLangOpts());
   if (MacroName.contains_lower("assert"))
 return;
 }
@@ -143,97 +176,116 @@ void PreferMemberInitializerCheck::check(
 
 const FieldDecl *Field;
 const Expr *InitValue;
-std::tie(Field, InitValue) = isAssignmentToMemberOf(Class, S);

[PATCH] D97101: [Coverage] Emit zero count gap region between statements if first statements contains return, throw, goto, co_return

2021-02-22 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 325516.
zequanwu added a comment.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

Rebase and fix runtime-counter-relocation.c

> Do we have to revert D85036  in the same 
> patch in order to keep the integration tests green?

I didn't revert D85036 . I don't know why 
phabricator thinks I did.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97101

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CoverageMapping/classtemplate.cpp
  clang/test/CoverageMapping/coroutine.cpp
  clang/test/CoverageMapping/deferred-region.cpp
  clang/test/CoverageMapping/label.cpp
  clang/test/CoverageMapping/moremacros.c
  clang/test/CoverageMapping/return.c
  clang/test/CoverageMapping/switch.cpp
  clang/test/CoverageMapping/switchmacro.c
  clang/test/CoverageMapping/terminate-statements.cpp
  clang/test/CoverageMapping/trycatch.cpp
  clang/test/CoverageMapping/unreachable-macro.c
  compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c

Index: compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c
===
--- compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c
+++ compiler-rt/test/profile/ContinuousSyncMode/runtime-counter-relocation.c
@@ -21,9 +21,9 @@
 
 // CHECK-COVERAGE: Filename RegionsMissed Regions Cover   Functions  Missed Functions  Executed   Lines  Missed Lines Cover
 // CHECK-COVERAGE-NEXT: ---
-// CHECK-COVERAGE-NEXT: runtime-counter-relocation.c  4 175.00%   1 0   100.00%   5 260.00%
+// CHECK-COVERAGE-NEXT: runtime-counter-relocation.c  4 175.00%   1 0   100.00%   5 180.00%
 // CHECK-COVERAGE-NEXT: ---
-// CHECK-COVERAGE-NEXT: TOTAL 4 175.00%   1 0   100.00%   5 260.00%
+// CHECK-COVERAGE-NEXT: TOTAL 4 175.00%   1 0   100.00%   5 180.00%
 
 extern int __llvm_profile_is_continuous_mode_enabled(void);
 
Index: clang/test/CoverageMapping/unreachable-macro.c
===
--- clang/test/CoverageMapping/unreachable-macro.c
+++ clang/test/CoverageMapping/unreachable-macro.c
@@ -6,6 +6,7 @@
 void counters_in_macro_following_unreachable() {
   // CHECK-NEXT: File 0, [[@LINE-1]]:48 -> {{[0-9]+}}:2 = #0
   return;
+  // CHECK-NEXT: Gap,File 0, [[@LINE-1]]:10 -> [[@LINE+3]]:3 = 0
   // CHECK-NEXT: Expansion,File 0, [[@LINE+2]]:3 -> [[@LINE+2]]:8 = 0
   // CHECK-NEXT: File 0, [[@LINE+1]]:8 -> [[@LINE+2]]:2 = 0
   WHILE
Index: clang/test/CoverageMapping/trycatch.cpp
===
--- clang/test/CoverageMapping/trycatch.cpp
+++ clang/test/CoverageMapping/trycatch.cpp
@@ -13,7 +13,7 @@
 void func(int i) {// CHECK-NEXT: File 0, [[@LINE]]:18 -> {{[0-9]+}}:2 = #0
   // CHECK-NEXT: File 0, [[@LINE+1]]:6 -> [[@LINE+1]]:11 = #0
   if(i % 2) { // CHECK: File 0, [[@LINE]]:13 -> [[@LINE+4]]:4 = #1
-throw Error();
+throw Error();// CHECK-NEXT: Gap,File 0, [[@LINE]]:19 -> [[@LINE+1]]:5 = 0
 int j = 0;// CHECK-NEXT: File 0, [[@LINE]]:5 -> [[@LINE+2]]:4 = 0
   // CHECK: File 0, [[@LINE+1]]:10 -> [[@LINE+2]]:27 = (#0 - #1)
   } else if(i == 8)   // CHECK-NEXT: File 0, [[@LINE]]:13 -> [[@LINE]]:19 = (#0 - #1)
Index: clang/test/CoverageMapping/terminate-statements.cpp
===
--- /dev/null
+++ clang/test/CoverageMapping/terminate-statements.cpp
@@ -0,0 +1,130 @@
+// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name deferred-region.cpp -I %S/Inputs %s | FileCheck %s
+
+int f1() {
+  return 0;
+  return 0; // CHECK: Gap,File 0, [[@LINE-1]]:12 -> [[@LINE]]:3 = 0
+}
+
+int f2(int i) {
+  if (i)
+return 0;
+  else
+;
+  return 1; // CHECK: Gap,File 0, [[@LINE-1]]:6 -> [[@LINE]]:3 = 0
+}
+
+int f3() {
+  for (int a = 1; a < 9; a--)
+return a;
+  return 0; // CHECK: Gap,File 0, [[@LINE-1]]:14 -> [[@LINE]]:3 = 0
+}
+
+int f4(int i) {
+  while (i > 0) {
+i++;
+return i;
+  }
+  return 0; // CHECK: Gap,File 0, [[@LINE-1]]:4 -> [[@LINE]]:3 = 0
+}
+
+int f5(int i) {
+  do {
+return i;
+  } while (i > 0);
+  return 0; // CHECK: Gap,File 0, 

[PATCH] D97123: [clangd] Support FixIts that use InsertFromRange instead of inserting raw text

2021-02-22 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 325515.
njames93 added a comment.

Sort of added tests. Though they seem hacked in and I can't find a simple way 
to test the synthetic diagnostic messages.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97123

Files:
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/unittests/SourceCodeTests.cpp

Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -802,6 +802,61 @@
   EXPECT_FALSE(isKeyword("override", LangOpts));
 }
 
+Expected sourceRangeInMainFile(SourceManager , Range R) {
+  if (auto Beg = sourceLocationInMainFile(SM, R.start)) {
+if (auto End = sourceLocationInMainFile(SM, R.end)) {
+  return SourceRange(*Beg, *End);
+} else {
+  return End.takeError();
+}
+  } else {
+return Beg.takeError();
+  }
+}
+
+TEST(SourceCodeTests, FixItToTextEdit) {
+  Annotations Code(R"(
+int Var = $V1[[$V1^Value1]] + $V2[[$V2^Value2]];
+  )");
+  SourceManagerForFile SMFF("File", Code.code());
+  SourceManager  = SMFF.get();
+  LangOptions LangOpts;
+  Expected V1Char = sourceRangeInMainFile(SM, Code.range("V1"));
+  Expected V2Char = sourceRangeInMainFile(SM, Code.range("V2"));
+  auto V1Tok = sourceLocationInMainFile(SM, Code.point("V1"));
+  auto V2Tok = sourceLocationInMainFile(SM, Code.point("V2"));
+  ASSERT_TRUE(V1Char && V1Char->isValid());
+  ASSERT_TRUE(V2Char && V2Char->isValid());
+  ASSERT_TRUE(V1Tok && V1Tok->isValid());
+  ASSERT_TRUE(V2Tok && V2Tok->isValid());
+  auto RemoveCharRange = CharSourceRange::getCharRange(*V1Char);
+  auto RemoveTokRange = CharSourceRange::getTokenRange(*V1Tok, *V1Tok);
+  {
+FixItHint Hint;
+Hint.RemoveRange = RemoveCharRange;
+Hint.InsertFromRange = CharSourceRange::getCharRange(*V2Char);
+TextEdit E = toTextEdit(Hint, SM, LangOpts);
+EXPECT_EQ(E.range, Code.range("V1"));
+EXPECT_EQ(E.newText, "Value2");
+  }
+  {
+FixItHint Hint;
+Hint.RemoveRange = RemoveCharRange;
+Hint.InsertFromRange = CharSourceRange::getTokenRange(*V2Tok);
+TextEdit E = toTextEdit(Hint, SM, LangOpts);
+EXPECT_EQ(E.range, Code.range("V1"));
+EXPECT_EQ(E.newText, "Value2");
+  }
+  {
+FixItHint Hint;
+Hint.RemoveRange = RemoveTokRange;
+Hint.CodeToInsert = "Value2";
+TextEdit E = toTextEdit(Hint, SM, LangOpts);
+EXPECT_EQ(E.range, Code.range("V1"));
+EXPECT_EQ(E.newText, "Value2");
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -548,7 +548,15 @@
   TextEdit Result;
   Result.range =
   halfOpenToRange(M, Lexer::makeFileCharRange(FixIt.RemoveRange, M, L));
-  Result.newText = FixIt.CodeToInsert;
+
+  if (FixIt.InsertFromRange.isValid()) {
+assert(FixIt.CodeToInsert.empty() &&
+   "Cannot insert text when range is specified");
+// FIXME: Propagate errors from getSourceText
+Result.newText = Lexer::getSourceText(FixIt.InsertFromRange, M, L).str();
+  } else {
+Result.newText = FixIt.CodeToInsert;
+  }
   return Result;
 }
 
Index: clang-tools-extra/clangd/Diagnostics.cpp
===
--- clang-tools-extra/clangd/Diagnostics.cpp
+++ clang-tools-extra/clangd/Diagnostics.cpp
@@ -691,6 +691,13 @@
   llvm::StringRef Remove =
   Lexer::getSourceText(FixIt.RemoveRange, SM, *LangOpts, );
   llvm::StringRef Insert = FixIt.CodeToInsert;
+  if (FixIt.InsertFromRange.isValid()) {
+assert(FixIt.CodeToInsert.empty() &&
+   "Cannot insert text when range is specified");
+if (!Invalid)
+  Insert = Lexer::getSourceText(FixIt.InsertFromRange, SM, *LangOpts,
+);
+  }
   if (!Invalid) {
 llvm::raw_svector_ostream M(Message);
 if (!Remove.empty() && !Insert.empty()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96838: Add GNU attribute 'retain'

2021-02-22 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:2655
+
+def Retain : InheritableAttr {
+  let Spellings = [GCC<"retain">];

MaskRay wrote:
> aaron.ballman wrote:
> > MaskRay wrote:
> > > aaron.ballman wrote:
> > > > MaskRay wrote:
> > > > > aaron.ballman wrote:
> > > > > > Should this be a target-specific attribute as it only has effects 
> > > > > > on ELF targets?
> > > > > As I understand it, GCC `retain` is not warned on unsupported targets.
> > > > > 
> > > > > Regardless of GCC's choice, I think not having a `warning: unknown 
> > > > > attribute 'retain' ignored [-Wunknown-attributes]` diagnostic makes 
> > > > > sense. `retain` will be usually used together with `used`. In Clang, 
> > > > > `used` already has "retain" semantics on macOS and Windows (I don't 
> > > > > know what they do on GCC; GCC folks want orthogonality for ELF and I 
> > > > > agree). If `retain` is silently ignored on macOS and Windows, then 
> > > > > users don't need to condition compile for different targets.
> > > > The other side of that is a user who writes only `retain` and expects 
> > > > it to do something when it's actually being silently ignored. While 
> > > > they may usually use it in conjunction with `used`, I'm more worried 
> > > > about the situation where the user is possibly confused.
> > > `retain` without `used` can be used on some external linkage definitions, 
> > > as well as internal linkage definitions which are referenced by live 
> > > sections. I agree there could be some confusion, but hope with mccall's 
> > > suggestion (thanks) the documentation is clear.
> > If `retain` without `used` is an expected usage pattern, then I think we 
> > need a diagnostic when we ignore the `retain` attribute. I don't think it 
> > is reasonable to expect users to read the documentation because they won't 
> > know that they've misused the attribute when we silently ignore it.
> > 
> > Alternatively, would it be possible to make `retain` useful on all targets? 
> > e.g., when `retain` is used by itself on a declaration compiled for macOS 
> > or Windows, the backend does whatever it would normally do for `used`?
> There is the normal behavior: `__attribute__((retain)) static void f1() {} // 
> expected-warning {{unused function 'f1'}}`.
> 
> Sema.cpp:1227 has the unused diagnostics. There are already many different 
> versions of diagnostics. Do you suggest another diagnostic line for `used is 
> needed`? If you think so, I'll need to figure out how to do that...
> 
> Added some tests leveraging the existing diagnostic code.
We could definitely support retain-without-used with the ELF semantics on all 
targets if we think they're useful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96838

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


[PATCH] D97132: [clang-tidy] Harden PreferMemberInitializerCheck

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

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97132

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


[PATCH] D97098: [Utils] Add an option to specify number of cores to use in creduce-clang-crash.py

2021-02-22 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/utils/creduce-clang-crash.py:81
 self.creduce_flags = ["--tidy"]
+if core_number > 0:
+  self.creduce_flags = ["--n", str(core_number)]

I think we should try to pick a good default here. I think we can do better 
than creduce's default of 4 or whatever it is. I think `max(4, os.cpu_count() / 
2)` might be a good guess.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97098

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


[PATCH] D96838: Add GNU attribute 'retain'

2021-02-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:2655
+
+def Retain : InheritableAttr {
+  let Spellings = [GCC<"retain">];

aaron.ballman wrote:
> MaskRay wrote:
> > aaron.ballman wrote:
> > > MaskRay wrote:
> > > > aaron.ballman wrote:
> > > > > Should this be a target-specific attribute as it only has effects on 
> > > > > ELF targets?
> > > > As I understand it, GCC `retain` is not warned on unsupported targets.
> > > > 
> > > > Regardless of GCC's choice, I think not having a `warning: unknown 
> > > > attribute 'retain' ignored [-Wunknown-attributes]` diagnostic makes 
> > > > sense. `retain` will be usually used together with `used`. In Clang, 
> > > > `used` already has "retain" semantics on macOS and Windows (I don't 
> > > > know what they do on GCC; GCC folks want orthogonality for ELF and I 
> > > > agree). If `retain` is silently ignored on macOS and Windows, then 
> > > > users don't need to condition compile for different targets.
> > > The other side of that is a user who writes only `retain` and expects it 
> > > to do something when it's actually being silently ignored. While they may 
> > > usually use it in conjunction with `used`, I'm more worried about the 
> > > situation where the user is possibly confused.
> > `retain` without `used` can be used on some external linkage definitions, 
> > as well as internal linkage definitions which are referenced by live 
> > sections. I agree there could be some confusion, but hope with mccall's 
> > suggestion (thanks) the documentation is clear.
> If `retain` without `used` is an expected usage pattern, then I think we need 
> a diagnostic when we ignore the `retain` attribute. I don't think it is 
> reasonable to expect users to read the documentation because they won't know 
> that they've misused the attribute when we silently ignore it.
> 
> Alternatively, would it be possible to make `retain` useful on all targets? 
> e.g., when `retain` is used by itself on a declaration compiled for macOS or 
> Windows, the backend does whatever it would normally do for `used`?
There is the normal behavior: `__attribute__((retain)) static void f1() {} // 
expected-warning {{unused function 'f1'}}`.

Sema.cpp:1227 has the unused diagnostics. There are already many different 
versions of diagnostics. Do you suggest another diagnostic line for `used is 
needed`? If you think so, I'll need to figure out how to do that...

Added some tests leveraging the existing diagnostic code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96838

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


[PATCH] D94640: adds more checks to -Wfree-nonheap-object

2021-02-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: NoQ, Szelethus, rsmith.
aaron.ballman added a comment.
Herald added a subscriber: Charusso.

In D94640#2560647 , @cjdb wrote:

> fixes block expressions
>
> @aaron.ballman I'm not sure I follow what you're after re lambdas. Could you 
> please provide a test case that I can work with?

Sorry about missing your question -- this fell off my radar. I was thinking 
it'd be roughly the same as blocks, but I now think this'll create compile 
errors anyway: `free([]{ return nullptr; });` (where the lambda is accidentally 
not being called). So not nearly as important as I was thinking (sorry for 
that, but thank you for adding the support and test cases just the same!).

One worry I have is the number of effectively duplicated diagnostics we're now 
getting in conjunction with the static analyzer. It's not quite perfect overlap 
and so we can't get rid of the static analyzer check, but is there a long-term 
plan for how to resolve this?




Comment at: clang/lib/Sema/SemaChecking.cpp:10252
 namespace {
-void CheckFreeArgumentsOnLvalue(Sema , const std::string ,
-const UnaryOperator *UnaryExpr,
-const VarDecl *Var) {
-  StorageClass Class = Var->getStorageClass();
-  if (Class == StorageClass::SC_Extern ||
-  Class == StorageClass::SC_PrivateExtern ||
-  Var->getType()->isReferenceType())
-return;
-
-  S.Diag(UnaryExpr->getBeginLoc(), diag::warn_free_nonheap_object)
-  << CalleeName << Var;
-}
+constexpr int Placeholder = 0;
 

After seeing my suggested workaround in practice, I'm hopeful we can figure out 
how to get the diagnostics engine to not require us to jump through these 
hoops. I wouldn't block the patch over this approach, but it's not very obvious 
what's happening from reading the code either.



Comment at: clang/lib/Sema/SemaChecking.cpp:10342
+  static constexpr int NoPlaceholder = 1;
+  Diag(Arg->getBeginLoc(), diag::warn_free_nonheap_object)
+  << CalleeName << NoPlaceholder;

FWIW, this diagnostic will be awkward for lambdas because it mentions blocks 
explicitly. It's not critical thing given how hard it would be to hit the 
lambda case, but if you think of an easy way to solve it, I won't complain.



Comment at: clang/test/Analysis/free.c:66
 void t10 () {
-  free((void*)); // expected-warning {{Argument to free() is the address 
of the function 't10', which is not memory allocated by malloc()}}
+  free((void*));
+  // expected-warning@-1{{Argument to free() is the address of the function 
't10', which is not memory allocated by malloc()}}

This is another variant of the test that's slightly different (and only valid 
in C):
```
int *ptr(void);
void func(void) {
  free(ptr); // Oops, forgot to call ptr().
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94640

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


[PATCH] D96665: Revert "Implement nullPointerConstant() using a better API."

2021-02-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In D96665#2579422 , @steveire wrote:

> In D96665#2578635 , @goncharov wrote:
>
>> Hi @steveire! Sorry but I reverted this revert. Could you please give some 
>> context of "discussed elsewhere" and "pre-existing unit test for the 
>> matcher"? @aaron.ballman for cc
>
> @njames93 didn't realize that the offending commits were from 2019, as I 
> wrote in the comment. That's what I told him "elsewhere".
>
> I plan to re-apply this revert. If you have a reason I shouldn't do that, 
> please say what it is.

@goncharov I see you already re-landed it. In future please open review 
requests for things like this to avoid confusion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96665

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


[PATCH] D97101: [Coverage] Emit zero count gap region between statements if first statements contains return, throw, goto, co_return

2021-02-22 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Are the check-profile presubmit test failures related to this patch? Do we have 
to revert D85036  in the same patch in order 
to keep the integration tests green?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97101

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


[PATCH] D96838: Add GNU attribute 'retain'

2021-02-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 325499.
MaskRay added a comment.

Add tests that   Sema discarded unused functions are warned (nor different from 
the case without 'retain')


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96838

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGen/attr-retain.c
  clang/test/CodeGenCXX/attr-retain.cpp
  clang/test/CodeGenCXX/extern-c.cpp
  clang/test/Sema/attr-retain.c

Index: clang/test/Sema/attr-retain.c
===
--- /dev/null
+++ clang/test/Sema/attr-retain.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wunused-function
+
+/// We allow 'retain' on non-ELF targets because 'retain' is often used together
+/// with 'used'. 'used' has GC root semantics on macOS and Windows. We want
+/// users to just write retain,used and don't need to dispatch on binary formats.
+
+extern char test1[] __attribute__((retain));   // expected-warning {{'retain' attribute ignored on a non-definition declaration}}
+extern const char test2[] __attribute__((retain)); // expected-warning {{'retain' attribute ignored on a non-definition declaration}}
+const char test3[] __attribute__((retain)) = "";
+
+struct __attribute__((retain)) s { // expected-warning {{'retain' attribute only applies to variables with non-local storage, functions, and Objective-C methods}}
+};
+
+void foo() {
+  static int a __attribute__((retain));
+  int b __attribute__((retain)); // expected-warning {{'retain' attribute only applies to variables with non-local storage, functions, and Objective-C methods}}
+  (void)a;
+  (void)b;
+}
+
+__attribute__((retain,used)) static void f0() {}
+__attribute__((retain)) static void f1() {} // expected-warning {{unused function 'f1'}}
+__attribute__((retain)) void f2() {}
+
+/// Test attribute merging.
+int tentative;
+int tentative __attribute__((retain));
+extern int tentative;
+int tentative = 0;
Index: clang/test/CodeGenCXX/extern-c.cpp
===
--- clang/test/CodeGenCXX/extern-c.cpp
+++ clang/test/CodeGenCXX/extern-c.cpp
@@ -70,16 +70,19 @@
 __attribute__((used)) static int duplicate_internal_fn() { return 0; }
   }
 
-  // CHECK: @llvm.used = appending global {{.*}} @internal_var {{.*}} @internal_fn 
+  // CHECK: @llvm.used = appending global {{.*}} @internal_var {{.*}} @internal_fn
 
   // CHECK-NOT: @unused
   // CHECK-NOT: @duplicate_internal
   // CHECK: @internal_var = internal alias i32, i32* @_ZL12internal_var
+  // CHECK-NOT: !retain
   // CHECK-NOT: @unused
   // CHECK-NOT: @duplicate_internal
   // CHECK: @internal_fn = internal alias i32 (), i32 ()* @_ZL11internal_fnv
+  // CHECK-NOT: !retain
   // CHECK-NOT: @unused
   // CHECK-NOT: @duplicate_internal
+  // CHECK: define internal i32 @_ZL11internal_fnv()
 }
 
 namespace PR19411 {
Index: clang/test/CodeGenCXX/attr-retain.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/attr-retain.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -Werror %s -o - | FileCheck %s
+
+struct X0 {
+  // RETAIN: define linkonce_odr{{.*}} @_ZN2X0C1Ev({{.*}} !retain
+  __attribute__((used, retain)) X0() {}
+  // RETAIN: define linkonce_odr{{.*}} @_ZN2X0D1Ev({{.*}} !retain
+  __attribute__((used, retain)) ~X0() {}
+};
+
+struct X1 {
+  struct Nested {
+// RETAIN-NOT: 2f0Ev
+// RETAIN: define linkonce_odr{{.*}} @_ZN2X16Nested2f1Ev({{.*}} !retain
+void __attribute__((retain)) f0() {}
+void __attribute__((used, retain)) f1() {}
+  };
+};
+
+// CHECK: define internal void @_ZN10merge_declL4funcEv(){{.*}} !retain
+namespace merge_decl {
+static void func();
+void bar() { void func() __attribute__((used, retain)); }
+static void func() {}
+} // namespace merge_decl
+
+namespace instantiate_member {
+template 
+struct S {
+  void __attribute__((used, retain)) f() {}
+};
+
+void test() {
+  // CHECK: define linkonce_odr{{.*}} void @_ZN18instantiate_member1SIiE1fEv({{.*}} !retain
+  S a;
+}
+} // namespace instantiate_member
Index: clang/test/CodeGen/attr-retain.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-retain.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+/// Set !retain regardless of the target. The backend will lower !retain to
+/// SHF_GNU_RETAIN on ELF and ignore the metadata for other binary formats.
+// CHECK:  @c0 ={{.*}} constant i32 {{.*}} !retain ![[#EMPTY:]]
+// CHECK:  @foo.l0 = internal global i32 {{.*}} !retain ![[#EMPTY]]
+// CHECK:  @g0 ={{.*}} global i32 {{.*}} !retain ![[#EMPTY]]
+// CHECK-NEXT: @g1 ={{.*}} 

[PATCH] D96665: Revert "Implement nullPointerConstant() using a better API."

2021-02-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In D96665#2578635 , @goncharov wrote:

> Hi @steveire! Sorry but I reverted this revert. Could you please give some 
> context of "discussed elsewhere" and "pre-existing unit test for the 
> matcher"? @aaron.ballman for cc

@njames93 didn't realize that the offending commits were from 2019, as I wrote 
in the comment. That's what I told him "elsewhere".

I plan to re-apply this revert. If you have a reason I shouldn't do that, 
please say what it is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96665

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


[PATCH] D96665: Revert "Implement nullPointerConstant() using a better API."

2021-02-22 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In D96665#2578718 , @goncharov wrote:

> I have relanded this in 
> https://github.com/llvm/llvm-project/commit/3b148d6f991181a1b8f089c4bc2126e1a6c1212d
>  . My apologies

@goncharov Why did you revert this change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96665

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


[PATCH] D95396: Improve static_assert/_Static_assert diagnostics

2021-02-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 325487.
aaron.ballman added a comment.

Rebasing on ToT.


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

https://reviews.llvm.org/D95396

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/Parser/static_assert.c
  clang/test/Preprocessor/static_assert.c
  clang/test/Sema/static-assert.c
  clang/test/SemaCXX/static-assert.cpp

Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -triple=x86_64-linux-gnu
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -pedantic -triple=x86_64-linux-gnu
 
 int f(); // expected-note {{declared here}}
 
Index: clang/test/Sema/static-assert.c
===
--- clang/test/Sema/static-assert.c
+++ clang/test/Sema/static-assert.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -std=c11 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fms-compatibility -DMS -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fms-compatibility -DMS -fsyntax-only -verify=expected,ms %s
 // RUN: %clang_cc1 -std=c99 -pedantic -fsyntax-only -verify=expected,ext %s
 // RUN: %clang_cc1 -xc++ -std=c++11 -pedantic -fsyntax-only -verify=expected,ext,cxx %s
 
@@ -13,7 +13,7 @@
// ext-warning {{'_Static_assert' is a C11 extension}}
 
 #ifdef MS
-static_assert(1, "1 is nonzero");
+static_assert(1, "1 is nonzero"); // ms-warning {{use of 'static_assert' without inclusion of  is a Microsoft extension}}
 #endif
 
 void foo(void) {
@@ -21,7 +21,7 @@
   _Static_assert(0, "0 is nonzero"); // expected-error {{static_assert failed "0 is nonzero"}} \
  // ext-warning {{'_Static_assert' is a C11 extension}}
 #ifdef MS
-  static_assert(1, "1 is nonzero");
+  static_assert(1, "1 is nonzero"); // ms-warning {{use of 'static_assert' without}}
 #endif
 }
 
@@ -34,7 +34,7 @@
   _Static_assert(0, "0 is nonzero"); // expected-error {{static_assert failed "0 is nonzero"}} \
  // ext-warning {{'_Static_assert' is a C11 extension}}
 #ifdef MS
-  static_assert(1, "1 is nonzero");
+  static_assert(1, "1 is nonzero"); // ms-warning {{use of 'static_assert' without}}
 #endif
 };
 
@@ -58,3 +58,15 @@
// ext-warning 3 {{'_Static_assert' is a C11 extension}}
 typedef UNION(float, 0.5f) U4; // expected-error {{expected a type}} \
// ext-warning 3 {{'_Static_assert' is a C11 extension}}
+
+// After defining the assert macro in MS-compatibility mode, we should
+// no longer warn about including  under the assumption the
+// user already did that.
+#ifdef MS
+#define assert(expr)
+static_assert(1, "1 is nonzero"); // ok
+
+// But we should still warn if the user did something bonkers.
+#undef static_assert
+static_assert(1, "1 is nonzero"); // ms-warning {{use of 'static_assert' without}}
+#endif
Index: clang/test/Preprocessor/static_assert.c
===
--- /dev/null
+++ clang/test/Preprocessor/static_assert.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -E -dM %s | FileCheck --strict-whitespace --check-prefix=NOMS %s
+// RUN: %clang_cc1 -fms-compatibility -E -dM %s | FileCheck --strict-whitespace --check-prefix=MS %s
+
+// If the assert macro is defined in MS compatibility mode in C, we
+// automatically inject a macro definition for static_assert. Test that the
+// macro is properly added to the preprocessed output. This allows us to
+// diagonse use of the static_assert keyword when  has not been
+// included while still being able to compile preprocessed code.
+#define assert
+
+MS: #define static_assert _Static_assert
+NOMS-NOT: #define static_assert _Static_assert
Index: clang/test/Parser/static_assert.c
===
--- /dev/null
+++ clang/test/Parser/static_assert.c
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c2x -DTEST_SPELLING -verify=c2x %s
+// RUN: %clang_cc1 -fsyntax-only -std=c2x -DTEST_SPELLING -fms-compatibility -verify=c2x-ms %s
+// RUN: %clang_cc1 -fsyntax-only -std=c2x -Wpre-c2x-compat -verify=c2x-compat %s
+// RUN: %clang_cc1 -fsyntax-only -std=c99 -verify=c99 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c99 -pedantic -verify=c99-pedantic %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify=cxx17 -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -pedantic -verify=cxx17-pedantic -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify=cxx98 -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -pedantic -verify=cxx98-pedantic -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 

[PATCH] D97198: [OpenMP][Clang][NVPTX] Only build one bitcode library for each SM

2021-02-22 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 325492.
tianshilei1992 added a comment.

use `ptx61` instead


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97198

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-cuda_102-sm_35.bc
  clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_35.bc
  clang/test/Driver/openmp-offload-gpu.c
  openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
  openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu

Index: openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
===
--- openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
+++ openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
@@ -53,46 +53,28 @@
   return (double)nsecs * __kmpc_impl_get_wtick();
 }
 
-// In Cuda 9.0, __ballot(1) from Cuda 8.0 is replaced with __activemask().
 DEVICE __kmpc_impl_lanemask_t __kmpc_impl_activemask() {
-#if CUDA_VERSION < 9020
-  return __nvvm_vote_ballot(1);
-#else
   unsigned int Mask;
   asm volatile("activemask.b32 %0;" : "=r"(Mask));
   return Mask;
-#endif
 }
 
-// In Cuda 9.0, the *_sync() version takes an extra argument 'mask'.
 DEVICE int32_t __kmpc_impl_shfl_sync(__kmpc_impl_lanemask_t Mask, int32_t Var,
  int32_t SrcLane) {
-#if CUDA_VERSION >= 9000
   return __nvvm_shfl_sync_idx_i32(Mask, Var, SrcLane, 0x1f);
-#else
-  return __nvvm_shfl_idx_i32(Var, SrcLane, 0x1f);
-#endif // CUDA_VERSION
 }
 
 DEVICE int32_t __kmpc_impl_shfl_down_sync(__kmpc_impl_lanemask_t Mask,
   int32_t Var, uint32_t Delta,
   int32_t Width) {
   int32_t T = ((WARPSIZE - Width) << 8) | 0x1f;
-#if CUDA_VERSION >= 9000
   return __nvvm_shfl_sync_down_i32(Mask, Var, Delta, T);
-#else
-  return __nvvm_shfl_down_i32(Var, Delta, T);
-#endif // CUDA_VERSION
 }
 
 DEVICE void __kmpc_impl_syncthreads() { __syncthreads(); }
 
 DEVICE void __kmpc_impl_syncwarp(__kmpc_impl_lanemask_t Mask) {
-#if CUDA_VERSION >= 9000
   __nvvm_bar_warp_sync(Mask);
-#else
-  // In Cuda < 9.0 no need to sync threads in warps.
-#endif // CUDA_VERSION
 }
 
 // NVPTX specific kernel initialization
Index: openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
===
--- openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
+++ openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
@@ -137,6 +137,7 @@
  -Xclang -emit-llvm-bc
  -Xclang -aux-triple -Xclang ${aux_triple}
  -fopenmp -fopenmp-cuda-mode -Xclang -fopenmp-is-device
+ -Xclang -target-feature -Xclang +ptx61
  -D__CUDACC__
  -I${devicertl_base_directory}
  -I${devicertl_nvptx_directory}/src)
@@ -150,81 +151,51 @@
 # Create target to build all Bitcode libraries.
 add_custom_target(omptarget-nvptx-bc)
 
-# This map is from clang/lib/Driver/ToolChains/Cuda.cpp.
-# The last element is the default case.
-set(cuda_version_list 112 111 110 102 101 100 92 91 90 80)
-set(ptx_feature_list 71 71 70 65 64 63 61 61 60 42)
-# The following two lines of ugly code is not needed when the minimal CMake
-# version requirement is 3.17+.
-list(LENGTH cuda_version_list num_version_supported)
-math(EXPR loop_range "${num_version_supported} - 1")
-
-# Generate a Bitcode library for all the compute capabilities the user
-# requested and all PTX version we know for now.
+# Generate a Bitcode library for all the compute capabilities the user requested
 foreach(sm ${nvptx_sm_list})
-  set(sm_flags -Xclang -target-cpu -Xclang sm_${sm} "-D__CUDA_ARCH__=${sm}0")
-
-  # Uncomment the following code and remove those ugly part if the feature
-  # is available.
-  # foreach(cuda_version ptx_num IN ZIP_LISTS cuda_version_list ptx_feature_list)
-  foreach(itr RANGE ${loop_range})
-list(GET cuda_version_list ${itr} cuda_version)
-list(GET ptx_feature_list ${itr} ptx_num)
-set(cuda_flags ${sm_flags})
-list(APPEND cuda_flags -Xclang -target-feature -Xclang +ptx${ptx_num})
-if("${cuda_version}" MATCHES "^([0-9]+)([0-9])$")
-  set(cuda_version_major ${CMAKE_MATCH_1})
-  set(cuda_version_minor ${CMAKE_MATCH_2})
-else()
-  libomptarget_error_say(
-"Unrecognized CUDA version format: ${cuda_version}")
-endif()
-list(APPEND cuda_flags
-  "-DCUDA_VERSION=${cuda_version_major}0${cuda_version_minor}0")
-
-set(bc_files "")
-foreach(src ${cuda_src_files})
-  get_filename_component(infile ${src} ABSOLUTE)
-  get_filename_component(outfile ${src} NAME)
-  set(outfile "${outfile}-cuda_${cuda_version}-sm_${sm}.bc")
-
-  add_custom_command(OUTPUT ${outfile}
-COMMAND ${cuda_compiler} ${bc_flags}
-  ${cuda_flags} ${MAX_SM_DEFINITION} ${infile} -o ${outfile}
-DEPENDS 

[PATCH] D96838: Add GNU attribute 'retain'

2021-02-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:2655
+
+def Retain : InheritableAttr {
+  let Spellings = [GCC<"retain">];

MaskRay wrote:
> aaron.ballman wrote:
> > MaskRay wrote:
> > > aaron.ballman wrote:
> > > > Should this be a target-specific attribute as it only has effects on 
> > > > ELF targets?
> > > As I understand it, GCC `retain` is not warned on unsupported targets.
> > > 
> > > Regardless of GCC's choice, I think not having a `warning: unknown 
> > > attribute 'retain' ignored [-Wunknown-attributes]` diagnostic makes 
> > > sense. `retain` will be usually used together with `used`. In Clang, 
> > > `used` already has "retain" semantics on macOS and Windows (I don't know 
> > > what they do on GCC; GCC folks want orthogonality for ELF and I agree). 
> > > If `retain` is silently ignored on macOS and Windows, then users don't 
> > > need to condition compile for different targets.
> > The other side of that is a user who writes only `retain` and expects it to 
> > do something when it's actually being silently ignored. While they may 
> > usually use it in conjunction with `used`, I'm more worried about the 
> > situation where the user is possibly confused.
> `retain` without `used` can be used on some external linkage definitions, as 
> well as internal linkage definitions which are referenced by live sections. I 
> agree there could be some confusion, but hope with mccall's suggestion 
> (thanks) the documentation is clear.
If `retain` without `used` is an expected usage pattern, then I think we need a 
diagnostic when we ignore the `retain` attribute. I don't think it is 
reasonable to expect users to read the documentation because they won't know 
that they've misused the attribute when we silently ignore it.

Alternatively, would it be possible to make `retain` useful on all targets? 
e.g., when `retain` is used by itself on a declaration compiled for macOS or 
Windows, the backend does whatever it would normally do for `used`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96838

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


[PATCH] D94640: adds more checks to -Wfree-nonheap-object

2021-02-22 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb marked an inline comment as done.
cjdb added a comment.

Ping. @aaron.ballman any further requests? I think this is good to land 
otherwise?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94640

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


[PATCH] D96838: Add GNU attribute 'retain'

2021-02-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:2655
+
+def Retain : InheritableAttr {
+  let Spellings = [GCC<"retain">];

aaron.ballman wrote:
> MaskRay wrote:
> > aaron.ballman wrote:
> > > Should this be a target-specific attribute as it only has effects on ELF 
> > > targets?
> > As I understand it, GCC `retain` is not warned on unsupported targets.
> > 
> > Regardless of GCC's choice, I think not having a `warning: unknown 
> > attribute 'retain' ignored [-Wunknown-attributes]` diagnostic makes sense. 
> > `retain` will be usually used together with `used`. In Clang, `used` 
> > already has "retain" semantics on macOS and Windows (I don't know what they 
> > do on GCC; GCC folks want orthogonality for ELF and I agree). If `retain` 
> > is silently ignored on macOS and Windows, then users don't need to 
> > condition compile for different targets.
> The other side of that is a user who writes only `retain` and expects it to 
> do something when it's actually being silently ignored. While they may 
> usually use it in conjunction with `used`, I'm more worried about the 
> situation where the user is possibly confused.
`retain` without `used` can be used on some external linkage definitions, as 
well as internal linkage definitions which are referenced by live sections. I 
agree there could be some confusion, but hope with mccall's suggestion (thanks) 
the documentation is clear.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96838

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


[PATCH] D96838: Add GNU attribute 'retain'

2021-02-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 325486.
MaskRay marked 2 inline comments as done.
MaskRay added a comment.

incorporate rjmccall's doc suggestion


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96838

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGen/attr-retain.c
  clang/test/CodeGenCXX/attr-retain.cpp
  clang/test/CodeGenCXX/extern-c.cpp
  clang/test/Sema/attr-retain.c

Index: clang/test/Sema/attr-retain.c
===
--- /dev/null
+++ clang/test/Sema/attr-retain.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+/// We allow 'retain' on non-ELF targets because 'retain' is often used together
+/// with 'used'. 'used' has GC root semantics on macOS and Windows. We want
+/// users to just write retain,used and don't need to dispatch on binary formats.
+
+extern char test1[] __attribute__((retain));   // expected-warning {{'retain' attribute ignored on a non-definition declaration}}
+extern const char test2[] __attribute__((retain)); // expected-warning {{'retain' attribute ignored on a non-definition declaration}}
+const char test3[] __attribute__((retain)) = "";
+
+struct __attribute__((retain)) s { // expected-warning {{'retain' attribute only applies to variables with non-local storage, functions, and Objective-C methods}}
+};
+
+int g0 __attribute__((retain(0))); // expected-error {{'retain' attribute takes no arguments}}
+
+void foo() {
+  static int a __attribute__((retain));
+  int b __attribute__((retain)); // expected-warning {{'retain' attribute only applies to variables with non-local storage, functions, and Objective-C methods}}
+}
+
+__attribute__((used)) static void f0();
+
+/// Test attribute merging.
+int tentative;
+int tentative __attribute__((retain));
+extern int tentative;
+int tentative = 0;
Index: clang/test/CodeGenCXX/extern-c.cpp
===
--- clang/test/CodeGenCXX/extern-c.cpp
+++ clang/test/CodeGenCXX/extern-c.cpp
@@ -70,16 +70,19 @@
 __attribute__((used)) static int duplicate_internal_fn() { return 0; }
   }
 
-  // CHECK: @llvm.used = appending global {{.*}} @internal_var {{.*}} @internal_fn 
+  // CHECK: @llvm.used = appending global {{.*}} @internal_var {{.*}} @internal_fn
 
   // CHECK-NOT: @unused
   // CHECK-NOT: @duplicate_internal
   // CHECK: @internal_var = internal alias i32, i32* @_ZL12internal_var
+  // CHECK-NOT: !retain
   // CHECK-NOT: @unused
   // CHECK-NOT: @duplicate_internal
   // CHECK: @internal_fn = internal alias i32 (), i32 ()* @_ZL11internal_fnv
+  // CHECK-NOT: !retain
   // CHECK-NOT: @unused
   // CHECK-NOT: @duplicate_internal
+  // CHECK: define internal i32 @_ZL11internal_fnv()
 }
 
 namespace PR19411 {
Index: clang/test/CodeGenCXX/attr-retain.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/attr-retain.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -Werror %s -o - | FileCheck %s
+
+struct X0 {
+  // RETAIN: define linkonce_odr{{.*}} @_ZN2X0C1Ev({{.*}} !retain
+  __attribute__((used, retain)) X0() {}
+  // RETAIN: define linkonce_odr{{.*}} @_ZN2X0D1Ev({{.*}} !retain
+  __attribute__((used, retain)) ~X0() {}
+};
+
+struct X1 {
+  struct Nested {
+// RETAIN-NOT: 2f0Ev
+// RETAIN: define linkonce_odr{{.*}} @_ZN2X16Nested2f1Ev({{.*}} !retain
+void __attribute__((retain)) f0() {}
+void __attribute__((used, retain)) f1() {}
+  };
+};
+
+// CHECK: define internal void @_ZN10merge_declL4funcEv(){{.*}} !retain
+namespace merge_decl {
+static void func();
+void bar() { void func() __attribute__((used, retain)); }
+static void func() {}
+} // namespace merge_decl
+
+namespace instantiate_member {
+template 
+struct S {
+  void __attribute__((used, retain)) f() {}
+};
+
+void test() {
+  // CHECK: define linkonce_odr{{.*}} void @_ZN18instantiate_member1SIiE1fEv({{.*}} !retain
+  S a;
+}
+} // namespace instantiate_member
Index: clang/test/CodeGen/attr-retain.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-retain.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+/// Set !retain regardless of the target. The backend will lower !retain to
+/// SHF_GNU_RETAIN on ELF and ignore the metadata for other binary formats.
+// CHECK:  @c0 ={{.*}} constant i32 {{.*}} !retain ![[#EMPTY:]]
+// CHECK:  @foo.l0 = internal global i32 {{.*}} !retain ![[#EMPTY]]
+// CHECK:  @g0 ={{.*}} global i32 {{.*}} !retain ![[#EMPTY]]
+// CHECK-NEXT: @g1 ={{.*}} global i32 {{.*}} !retain ![[#EMPTY]]
+// CHECK-NEXT: @g3 = internal global i32 {{.*}} !retain ![[#EMPTY]]

[PATCH] D97132: [clang-tidy] Harden PreferMemberInitializerCheck

2021-02-22 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 325484.
njames93 marked 2 inline comments as done.
njames93 added a comment.

Address `auto` comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97132

Files:
  
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
@@ -488,3 +488,60 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'x' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
 // CHECK-FIXES: {{^\ *$}}
 }
+
+struct SafeDependancy {
+  int m;
+  int n;
+  SafeDependancy(int M) : m(M) {
+// CHECK-FIXES: SafeDependancy(int M) : m(M), n(m) {
+n = m;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor
+  }
+  // We match against direct field dependancy as well as descendant field
+  // dependancy, ensure both are accounted for.
+  SafeDependancy(short M) : m(M) {
+// CHECK-FIXES: SafeDependancy(short M) : m(M), n(m + 1) {
+n = m + 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor
+  }
+};
+
+struct BadDependancy {
+  int m;
+  int n;
+  BadDependancy(int N) : n(N) {
+m = n;
+  }
+  BadDependancy(short N) : n(N) {
+m = n + 1;
+  }
+};
+
+struct InitFromVarDecl {
+  int m;
+  InitFromVarDecl() {
+// Can't apply this fix as n is declared in the body of the constructor.
+int n = 3;
+m = n;
+  }
+};
+
+struct AlreadyHasInit {
+  int m = 4;
+  AlreadyHasInit() {
+m = 3;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'm' should be initialized in a member initializer of the constructor
+  }
+};
+
+#define ASSIGN_IN_MACRO(FIELD, VALUE) FIELD = (VALUE);
+
+struct MacroCantFix {
+  int n; // NoFix
+  // CHECK-FIXES: int n; // NoFix
+  MacroCantFix() {
+ASSIGN_IN_MACRO(n, 0)
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'n' should be initialized in a member initializer of the constructor
+// CHECK-FIXES: ASSIGN_IN_MACRO(n, 0)
+  }
+};
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
@@ -55,8 +55,37 @@
   return false;
 }
 
+namespace {
+AST_MATCHER_P(FieldDecl, indexNotLessThan, unsigned, Index) {
+  return Node.getFieldIndex() >= Index;
+}
+} // namespace
+
+// Checks if Field is initialised using a field that will be initialised after
+// it.
+// TODO: Probably should guard against function calls that could have side
+// effects or if they do reference another field that's initialized before this
+// field, but is modified before the assignment.
+static bool isSafeAssignment(const FieldDecl *Field, const Expr *Init,
+ const CXXConstructorDecl *Context) {
+
+  auto MemberMatcher =
+  memberExpr(hasObjectExpression(cxxThisExpr()),
+ member(fieldDecl(indexNotLessThan(Field->getFieldIndex();
+
+  auto DeclMatcher = declRefExpr(
+  to(varDecl(unless(parmVarDecl()), hasDeclContext(equalsNode(Context);
+
+  return match(expr(anyOf(MemberMatcher, DeclMatcher,
+  hasDescendant(MemberMatcher),
+  hasDescendant(DeclMatcher))),
+   *Init, Field->getASTContext())
+  .empty();
+}
+
 static const std::pair
-isAssignmentToMemberOf(const RecordDecl *Rec, const Stmt *S) {
+isAssignmentToMemberOf(const CXXRecordDecl *Rec, const Stmt *S,
+   const CXXConstructorDecl *Ctor) {
   if (const auto *BO = dyn_cast(S)) {
 if (BO->getOpcode() != BO_Assign)
   return std::make_pair(nullptr, nullptr);
@@ -69,8 +98,11 @@
 if (!Field)
   return std::make_pair(nullptr, nullptr);
 
-if (isa(ME->getBase()))
-  return std::make_pair(Field, BO->getRHS()->IgnoreParenImpCasts());
+if (!isa(ME->getBase()))
+  return std::make_pair(nullptr, nullptr);
+const Expr *Init = BO->getRHS()->IgnoreParenImpCasts();
+if (isSafeAssignment(Field, Init, Ctor))
+  return std::make_pair(Field, Init);
   } else if (const auto *COCE = dyn_cast(S)) {
 if (COCE->getOperator() != OO_Equal)
   return std::make_pair(nullptr, nullptr);
@@ -84,8 +116,11 @@
 if (!Field)
   return std::make_pair(nullptr, 

[PATCH] D97132: [clang-tidy] Harden PreferMemberInitializerCheck

2021-02-22 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 325482.
njames93 added a comment.

Add a test for the crash fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97132

Files:
  
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
@@ -488,3 +488,60 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'x' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
 // CHECK-FIXES: {{^\ *$}}
 }
+
+struct SafeDependancy {
+  int m;
+  int n;
+  SafeDependancy(int M) : m(M) {
+// CHECK-FIXES: SafeDependancy(int M) : m(M), n(m) {
+n = m;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor
+  }
+  // We match against direct field dependancy as well as descendant field
+  // dependancy, ensure both are accounted for.
+  SafeDependancy(short M) : m(M) {
+// CHECK-FIXES: SafeDependancy(short M) : m(M), n(m + 1) {
+n = m + 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor
+  }
+};
+
+struct BadDependancy {
+  int m;
+  int n;
+  BadDependancy(int N) : n(N) {
+m = n;
+  }
+  BadDependancy(short N) : n(N) {
+m = n + 1;
+  }
+};
+
+struct InitFromVarDecl {
+  int m;
+  InitFromVarDecl() {
+// Can't apply this fix as n is declared in the body of the constructor.
+int n = 3;
+m = n;
+  }
+};
+
+struct AlreadyHasInit {
+  int m = 4;
+  AlreadyHasInit() {
+m = 3;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'm' should be initialized in a member initializer of the constructor
+  }
+};
+
+#define ASSIGN_IN_MACRO(FIELD, VALUE) FIELD = (VALUE);
+
+struct MacroCantFix {
+  int n; // NoFix
+  // CHECK-FIXES: int n; // NoFix
+  MacroCantFix() {
+ASSIGN_IN_MACRO(n, 0)
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'n' should be initialized in a member initializer of the constructor
+// CHECK-FIXES: ASSIGN_IN_MACRO(n, 0)
+  }
+};
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
@@ -55,8 +55,37 @@
   return false;
 }
 
+namespace {
+AST_MATCHER_P(FieldDecl, indexNotLessThan, unsigned, Index) {
+  return Node.getFieldIndex() >= Index;
+}
+} // namespace
+
+// Checks if Field is initialised using a field that will be initialised after
+// it.
+// TODO: Probably should guard against function calls that could have side
+// effects or if they do reference another field that's initialized before this
+// field, but is modified before the assignment.
+static bool isSafeAssignment(const FieldDecl *Field, const Expr *Init,
+ const CXXConstructorDecl *Context) {
+
+  auto MemberMatcher =
+  memberExpr(hasObjectExpression(cxxThisExpr()),
+ member(fieldDecl(indexNotLessThan(Field->getFieldIndex();
+
+  auto DeclMatcher = declRefExpr(
+  to(varDecl(unless(parmVarDecl()), hasDeclContext(equalsNode(Context);
+
+  return match(expr(anyOf(MemberMatcher, DeclMatcher,
+  hasDescendant(MemberMatcher),
+  hasDescendant(DeclMatcher))),
+   *Init, Field->getASTContext())
+  .empty();
+}
+
 static const std::pair
-isAssignmentToMemberOf(const RecordDecl *Rec, const Stmt *S) {
+isAssignmentToMemberOf(const CXXRecordDecl *Rec, const Stmt *S,
+   const CXXConstructorDecl *Ctor) {
   if (const auto *BO = dyn_cast(S)) {
 if (BO->getOpcode() != BO_Assign)
   return std::make_pair(nullptr, nullptr);
@@ -69,8 +98,11 @@
 if (!Field)
   return std::make_pair(nullptr, nullptr);
 
-if (isa(ME->getBase()))
-  return std::make_pair(Field, BO->getRHS()->IgnoreParenImpCasts());
+if (!isa(ME->getBase()))
+  return std::make_pair(nullptr, nullptr);
+const auto *Init = BO->getRHS()->IgnoreParenImpCasts();
+if (isSafeAssignment(Field, Init, Ctor))
+  return std::make_pair(Field, Init);
   } else if (const auto *COCE = dyn_cast(S)) {
 if (COCE->getOperator() != OO_Equal)
   return std::make_pair(nullptr, nullptr);
@@ -84,8 +116,11 @@
 if (!Field)
   return std::make_pair(nullptr, nullptr);
 
-if (isa(ME->getBase()))
-  

[PATCH] D97053: [clang][SVE] Don't warn on vector to sizeless builtin implicit conversion

2021-02-22 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes accepted this revision.
c-rhodes added a comment.
This revision is now accepted and ready to land.

LGTM thanks




Comment at: clang/lib/Sema/SemaChecking.cpp:12054
   // Strip vector types.
-  if (isa(Source)) {
+  if (auto *SourceVT = dyn_cast(Source)) {
+if (Target->isVLSTBuiltinType()) {

nit: can this warning be fixed before landing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97053

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


  1   2   3   >