[PATCH] D81995: [xray] Option to omit the function index

2020-06-17 Thread Ian Levesque via Phabricator via cfe-commits
ianlevesque created this revision.
ianlevesque added reviewers: dberris, MaskRay, johnislarry.
Herald added subscribers: llvm-commits, Sanitizers, cfe-commits, arphaman, 
hiraditya.
Herald added projects: clang, Sanitizers, LLVM.

Add a flag to omit the xray_fn_idx to cut size overhead and relocations
roughly in half at the cost of reduced performance for single function
patching.  Minor additions to compiler-rt support per-function patching
without the index.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81995

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/XRayArgs.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/XRayArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/XRay/xray-function-index-flags.cpp
  compiler-rt/lib/xray/xray_init.cpp
  compiler-rt/lib/xray/xray_interface.cpp
  compiler-rt/test/xray/TestCases/Posix/coverage-sample.cpp
  compiler-rt/test/xray/TestCases/Posix/func-id-utils.cpp
  compiler-rt/test/xray/TestCases/Posix/patching-unpatching.cpp
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/test/CodeGen/AArch64/xray-omit-function-index.ll

Index: llvm/test/CodeGen/AArch64/xray-omit-function-index.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/xray-omit-function-index.ll
@@ -0,0 +1,33 @@
+; RUN: llc -filetype=asm -no-xray-index -o - -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s
+
+define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always" {
+; CHECK-LABEL: Lxray_sled_0:
+; CHECK-NEXT:  b  #32
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-LABEL: Ltmp0:
+  ret i32 0
+; CHECK-LABEL: Lxray_sled_1:
+; CHECK-NEXT:  b  #32
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-LABEL: Ltmp1:
+; CHECK-NEXT:  ret
+}
+; CHECK-LABEL: xray_instr_map
+; CHECK-LABEL: Lxray_sleds_start0
+; CHECK:   .xword .Lxray_sled_0
+; CHECK:   .xword .Lxray_sled_1
+; CHECK-LABEL: Lxray_sleds_end0
+
+; CHECK-NOT: xray_fn_idx
\ No newline at end of file
Index: llvm/lib/CodeGen/CommandFlags.cpp
===
--- llvm/lib/CodeGen/CommandFlags.cpp
+++ llvm/lib/CodeGen/CommandFlags.cpp
@@ -86,6 +86,7 @@
 CGOPT(bool, EmitCallSiteInfo)
 CGOPT(bool, EnableDebugEntryValues)
 CGOPT(bool, ForceDwarfFrameSection)
+CGOPT(bool, XRayOmitFunctionIndex)
 
 codegen::RegisterCodeGenFlags::RegisterCodeGenFlags() {
 #define CGBINDOPT(NAME)\
@@ -404,6 +405,11 @@
   cl::desc("Always emit a debug frame section."), cl::init(false));
   CGBINDOPT(ForceDwarfFrameSection);
 
+  static cl::opt XRayOmitFunctionIndex(
+  "no-xray-index", cl::desc("Don't emit xray_fn_idx section"),
+  cl::init(false));
+  CGBINDOPT(XRayOmitFunctionIndex);
+
 #undef CGBINDOPT
 
   mc::RegisterMCTargetOptionsFlags();
@@ -470,6 +476,7 @@
   Options.EmitCallSiteInfo = getEmitCallSiteInfo();
   Options.EnableDebugEntryValues = getEnableDebugEntryValues();
   Options.ForceDwarfFrameSection = getForceDwarfFrameSection();
+  Options.XRayOmitFunctionIndex = getXRayOmitFunctionIndex();
 
   Options.MCOptions = mc::InitMCTargetOptionsFromFlags();
 
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -3235,14 +3235,17 @@
 InstMap = OutContext.getELFSection("xray_instr_map", ELF::SHT_PROGBITS,
Flags, 0, GroupName,
MCSection::NonUniqueID, LinkedToSym);
-FnSledIndex = OutContext.getELFSection("xray_fn_idx", ELF::SHT_PROGBITS,
-   Flags | ELF::SHF_WRITE, 0, GroupName,
-   MCSection::NonUniqueID, LinkedToSym);
+
+if (!TM.Options.XRayOmitFunctionIndex)
+  FnSledIndex = OutContext.getELFSection(
+  "xray_fn_idx", ELF::SHT_PROGBITS, Flags | ELF::SHF_WRITE, 0,
+  GroupName, MCSection::NonUniqueID, LinkedToSym);
   } else if (MF->getSubtarget().getTargetTriple().isOSBinFormatMachO()) {
 InstMap = OutContext.getMachOSection("__DATA", "xray_instr_map", 0,
  SectionKind::getReadOnlyWithRel());
-FnSledIndex = OutContext.getMachOSection("__DATA", "xray_fn_idx", 0,
- SectionKind::getReadOnlyWithRel());
+if (!TM.Options.XRayOmitFunctionIndex)
+  FnSledIndex = OutContext.getMachOSection(

[PATCH] D81995: [xray] Option to omit the function index

2020-06-17 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris accepted this revision.
dberris 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/D81995/new/

https://reviews.llvm.org/D81995



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


[PATCH] D81407: [Analyzer][StreamChecker] Add note tags for file opening.

2020-06-17 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 271291.
balazske marked 2 inline comments as done.
balazske added a comment.

Corrected command line arguments in tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81407

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream-note.c
  clang/test/Analysis/stream.c

Index: clang/test/Analysis/stream.c
===
--- clang/test/Analysis/stream.c
+++ clang/test/Analysis/stream.c
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.unix.Stream -analyzer-store region -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.Stream -verify %s
 
 #include "Inputs/system-header-simulator.h"
 
@@ -139,7 +139,7 @@
   if (!p)
 return;
   if(c)
-return; // expected-warning {{Opened File never closed. Potential Resource leak}}
+return; // expected-warning {{Opened stream never closed. Potential resource leak}}
   fclose(p);
 }
 
@@ -240,3 +240,28 @@
   fwrite("1", 1, 1, F); // expected-warning {{might be 'indeterminate'}}
   fclose(F);
 }
+
+int Test;
+_Noreturn void handle_error();
+
+void check_leak_noreturn_1() {
+  FILE *F1 = tmpfile();
+  if (!F1)
+return;
+  if (Test == 1) {
+handle_error(); // no warning
+  }
+  rewind(F1);
+} // expected-warning {{Opened stream never closed. Potential resource leak}}
+
+// Check that "location uniqueing" works.
+// This results in reporting only one occurence of resource leak for a stream.
+void check_leak_noreturn_2() {
+  FILE *F1 = tmpfile();
+  if (!F1)
+return;
+  if (Test == 1) {
+return; // expected-warning {{Opened stream never closed. Potential resource leak}}
+  }
+  rewind(F1);
+} // no warning
Index: clang/test/Analysis/stream-note.c
===
--- /dev/null
+++ clang/test/Analysis/stream-note.c
@@ -0,0 +1,48 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.Stream -analyzer-output text -verify %s
+
+#include "Inputs/system-header-simulator.h"
+
+void check_note_at_correct_open() {
+  FILE *F1 = tmpfile(); // expected-note {{Stream opened here}}
+  if (!F1)
+// expected-note@-1 {{'F1' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+return;
+  FILE *F2 = tmpfile();
+  if (!F2) {
+// expected-note@-1 {{'F2' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+fclose(F1);
+return;
+  }
+  rewind(F2);
+  fclose(F2);
+  rewind(F1);
+}
+// expected-warning@-1 {{Opened stream never closed. Potential resource leak}}
+// expected-note@-2 {{Opened stream never closed. Potential resource leak}}
+
+void check_note_fopen() {
+  FILE *F = fopen("file", "r"); // expected-note {{Stream opened here}}
+  if (!F)
+// expected-note@-1 {{'F' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+return;
+}
+// expected-warning@-1 {{Opened stream never closed. Potential resource leak}}
+// expected-note@-2 {{Opened stream never closed. Potential resource leak}}
+
+void check_note_freopen() {
+  FILE *F = fopen("file", "r"); // expected-note {{Stream opened here}}
+  if (!F)
+// expected-note@-1 {{'F' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+return;
+  F = freopen(0, "w", F); // expected-note {{Stream reopened here}}
+  if (!F)
+// expected-note@-1 {{'F' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+return;
+}
+// expected-warning@-1 {{Opened stream never closed. Potential resource leak}}
+// expected-note@-2 {{Opened stream never closed. Potential resource leak}}
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -216,8 +216,8 @@
   "Read function called when stream is in EOF state. "
   "Function has no effect."};
   BuiltinBug BT_ResourceLeak{
-  this, "Resource Leak",
-  "Opened File never closed. Potential Resource leak."};
+  this, "Resource leak",
+  "Opened stream never closed. Potential resource leak."};
 
 public:
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
@@ -365,6 +365,33 @@
 
 return FnDescriptions.lookup(Call);
   }
+
+  /// Generate a message for BugReporterVisitor if the stored symbol is
+  /// marked as interesting by the actual bug report.
+  struct NoteFn {
+const CheckerNameRef CheckerName;
+SymbolRef StreamSym;
+std::string Message;
+
+std::string operator()(PathSensitiveBugReport &BR) const {
+  if (BR.isInteresting(StreamSym) &&
+  CheckerName == BR.getBugType().getCheckerName())
+return Message;
+
+  return "";
+}
+  };
+
+  const NoteTag *constructNoteTag(CheckerContext &C, Symb

[PATCH] D81761: [analyzer] Force dependency checkers to be hidden

2020-06-17 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

My observation is, if there is an example checker, it should be really 
"example" and not "test". (The "custom" is probably good to rename to "test" 
but not the "example".) (The names of these files look not good too: A 
**CheckerOptionHandling.cpp** contains an example checker, should be probably 
**CheckerOptionHandlingExample.cpp**).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81761



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


[clang-tools-extra] af3d824 - [clangd] Depend on llvm-config for lit tests

2020-06-17 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-06-17T10:40:16+02:00
New Revision: af3d82453410ff80fab71f1dd9e222ffb6cd5925

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

LOG: [clangd] Depend on llvm-config for lit tests

Added: 


Modified: 
clang-tools-extra/clangd/test/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/test/CMakeLists.txt 
b/clang-tools-extra/clangd/test/CMakeLists.txt
index c5cc7e3ec097..878408cc5483 100644
--- a/clang-tools-extra/clangd/test/CMakeLists.txt
+++ b/clang-tools-extra/clangd/test/CMakeLists.txt
@@ -21,7 +21,7 @@ if(CLANGD_BUILD_XPC)
   list(APPEND CLANGD_TEST_DEPS ClangdXpcUnitTests)
 endif()
 
-foreach(dep FileCheck count not)
+foreach(dep FileCheck count not llvm-config)
   if(TARGET ${dep})
 list(APPEND CLANGD_TEST_DEPS ${dep})
   endif()



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


[clang] e51c1d0 - [SveEmitter] Add builtins for svtbl2

2020-06-17 Thread Sander de Smalen via cfe-commits

Author: Sander de Smalen
Date: 2020-06-17T09:41:38+01:00
New Revision: e51c1d06a9922c3b6ce4b8b2e74126870ade1491

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

LOG: [SveEmitter] Add builtins for svtbl2

Reviewers: david-arm, efriedma, c-rhodes

Reviewed By: c-rhodes

Tags: #clang

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

Added: 
clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_tbl2.c

Modified: 
clang/include/clang/Basic/arm_sve.td
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index 8c6abb1c3f4f..a7223f770455 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -1838,6 +1838,7 @@ def SVWHILEWR_D : SInst<"svwhilewr[_{1}]", "Pcc", "lUld", 
MergeNone, "aarch64_sv
 

 // SVE2 - Extended table lookup/permute
 let ArchGuard = "defined(__ARM_FEATURE_SVE2)" in {
+def SVTBL2 : SInst<"svtbl2[_{d}]", "d2u",  "csilUcUsUiUlhfd", MergeNone>;
 def SVTBX  : SInst<"svtbx[_{d}]",  "dddu", "csilUcUsUiUlhfd", MergeNone, 
"aarch64_sve_tbx">;
 }
 

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 3b3ea5e95705..b81b2a449425 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -8265,6 +8265,29 @@ Value 
*CodeGenFunction::EmitAArch64SVEBuiltinExpr(unsigned BuiltinID,
 Function *F = CGM.getIntrinsic(Intrinsic::vscale, Ty);
 return Builder.CreateMul(NumEls, Builder.CreateCall(F));
   }
+
+  case SVE::BI__builtin_sve_svtbl2_u8:
+  case SVE::BI__builtin_sve_svtbl2_s8:
+  case SVE::BI__builtin_sve_svtbl2_u16:
+  case SVE::BI__builtin_sve_svtbl2_s16:
+  case SVE::BI__builtin_sve_svtbl2_u32:
+  case SVE::BI__builtin_sve_svtbl2_s32:
+  case SVE::BI__builtin_sve_svtbl2_u64:
+  case SVE::BI__builtin_sve_svtbl2_s64:
+  case SVE::BI__builtin_sve_svtbl2_f16:
+  case SVE::BI__builtin_sve_svtbl2_f32:
+  case SVE::BI__builtin_sve_svtbl2_f64: {
+SVETypeFlags TF(Builtin->TypeModifier);
+auto VTy = cast(getSVEType(TF));
+auto TupleTy = llvm::VectorType::get(VTy->getElementType(),
+ VTy->getElementCount() * 2);
+Function *FExtr =
+CGM.getIntrinsic(Intrinsic::aarch64_sve_tuple_get, {VTy, TupleTy});
+Value *V0 = Builder.CreateCall(FExtr, {Ops[0], Builder.getInt32(0)});
+Value *V1 = Builder.CreateCall(FExtr, {Ops[0], Builder.getInt32(1)});
+Function *F = CGM.getIntrinsic(Intrinsic::aarch64_sve_tbl2, VTy);
+return Builder.CreateCall(F, {V0, V1, Ops[1]});
+  }
   }
 
   /// Should not happen

diff  --git a/clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_tbl2.c 
b/clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_tbl2.c
new file mode 100644
index ..d74b17f72663
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_tbl2.c
@@ -0,0 +1,145 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 -triple 
aarch64-none-linux-gnu -target-feature +sve2 -fallow-half-arguments-and-returns 
-S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 
-DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve2 
-fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu 
-target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify 
-verify-ignore-unexpected=error %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns 
-fsyntax-only -verify=overload -verify-ignore-unexpected=error %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+svint8_t test_svtbl2_s8(svint8x2_t data, svuint8_t indices)
+{
+  // CHECK-LABEL: test_svtbl2_s8
+  // CHECK-DAG: %[[V0:.*]] = call  
@llvm.aarch64.sve.tuple.get.nxv16i8.nxv32i8( %data, i32 0)
+  // CHECK-DAG: %[[V1:.*]] = call  
@llvm.aarch64.sve.tuple.get.nxv16i8.nxv32i8( %data, i32 1)
+  // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.tbl2.nxv16i8( %[[V0]],  
%[[V1]],  %indices)
+  // CHECK-NEXT: ret  %[[INTRINSIC]]
+  // overload-warning@+2 {{implicit declaration of function 'svtbl2'}}
+  // expected-warning@+1 {{implicit declaration of function 'svtbl2_s8'}}
+  return SVE_ACLE_FUNC(svtbl2,_s8,,)(data, indices);
+}
+
+svint16_t test_svtbl2_s16(svint16x2_t data, svuint16_t indices)
+{
+  /

[PATCH] D75229: [clang-tidy] Add signal-in-multithreaded-program check

2020-06-17 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/SignalInMultithreadedProgramCheck.h:23
+/// Finds ``signal`` function calls when the program is multithreaded. It
+/// founds a program multithreaded when it finds at least one function call
+/// of the following: ``thrd_create``, ``std::thread``, ``boost::thread``,

founds -> finds, but I would rather reword it like this:
The checker considers the analyzed program multithreaded if it finds 



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:107
+  Finds ``signal`` function calls when the program is multithreaded. It
+  founds a program multithreaded when it finds at least one function call
+  of the following: ``thrd_create``, ``std::thread``, ``boost::thread``,

Same as before.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D75229



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


[PATCH] D81462: [SveEmitter] Add builtins for svtbl2

2020-06-17 Thread Sander de Smalen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe51c1d06a992: [SveEmitter] Add builtins for svtbl2 (authored 
by sdesmalen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81462

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_tbl2.c

Index: clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_tbl2.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_tbl2.c
@@ -0,0 +1,145 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 -triple aarch64-none-linux-gnu -target-feature +sve2 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve2 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify -verify-ignore-unexpected=error %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify=overload -verify-ignore-unexpected=error %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+svint8_t test_svtbl2_s8(svint8x2_t data, svuint8_t indices)
+{
+  // CHECK-LABEL: test_svtbl2_s8
+  // CHECK-DAG: %[[V0:.*]] = call  @llvm.aarch64.sve.tuple.get.nxv16i8.nxv32i8( %data, i32 0)
+  // CHECK-DAG: %[[V1:.*]] = call  @llvm.aarch64.sve.tuple.get.nxv16i8.nxv32i8( %data, i32 1)
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.tbl2.nxv16i8( %[[V0]],  %[[V1]],  %indices)
+  // CHECK-NEXT: ret  %[[INTRINSIC]]
+  // overload-warning@+2 {{implicit declaration of function 'svtbl2'}}
+  // expected-warning@+1 {{implicit declaration of function 'svtbl2_s8'}}
+  return SVE_ACLE_FUNC(svtbl2,_s8,,)(data, indices);
+}
+
+svint16_t test_svtbl2_s16(svint16x2_t data, svuint16_t indices)
+{
+  // CHECK-LABEL: test_svtbl2_s16
+  // CHECK-DAG: %[[V0:.*]] = call  @llvm.aarch64.sve.tuple.get.nxv8i16.nxv16i16( %data, i32 0)
+  // CHECK-DAG: %[[V1:.*]] = call  @llvm.aarch64.sve.tuple.get.nxv8i16.nxv16i16( %data, i32 1)
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.tbl2.nxv8i16( %[[V0]],  %[[V1]],  %indices)
+  // CHECK-NEXT: ret  %[[INTRINSIC]]
+  // overload-warning@+2 {{implicit declaration of function 'svtbl2'}}
+  // expected-warning@+1 {{implicit declaration of function 'svtbl2_s16'}}
+  return SVE_ACLE_FUNC(svtbl2,_s16,,)(data, indices);
+}
+
+svint32_t test_svtbl2_s32(svint32x2_t data, svuint32_t indices)
+{
+  // CHECK-LABEL: test_svtbl2_s32
+  // CHECK-DAG: %[[V0:.*]] = call  @llvm.aarch64.sve.tuple.get.nxv4i32.nxv8i32( %data, i32 0)
+  // CHECK-DAG: %[[V1:.*]] = call  @llvm.aarch64.sve.tuple.get.nxv4i32.nxv8i32( %data, i32 1)
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.tbl2.nxv4i32( %[[V0]],  %[[V1]],  %indices)
+  // CHECK-NEXT: ret  %[[INTRINSIC]]
+  // overload-warning@+2 {{implicit declaration of function 'svtbl2'}}
+  // expected-warning@+1 {{implicit declaration of function 'svtbl2_s32'}}
+  return SVE_ACLE_FUNC(svtbl2,_s32,,)(data, indices);
+}
+
+svint64_t test_svtbl2_s64(svint64x2_t data, svuint64_t indices)
+{
+  // CHECK-LABEL: test_svtbl2_s64
+  // CHECK-DAG: %[[V0:.*]] = call  @llvm.aarch64.sve.tuple.get.nxv2i64.nxv4i64( %data, i32 0)
+  // CHECK-DAG: %[[V1:.*]] = call  @llvm.aarch64.sve.tuple.get.nxv2i64.nxv4i64( %data, i32 1)
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.tbl2.nxv2i64( %[[V0]],  %[[V1]],  %indices)
+  // CHECK-NEXT: ret  %[[INTRINSIC]]
+  // overload-warning@+2 {{implicit declaration of function 'svtbl2'}}
+  // expected-warning@+1 {{implicit declaration of function 'svtbl2_s64'}}
+  return SVE_ACLE_FUNC(svtbl2,_s64,,)(data, indices);
+}
+
+svuint8_t test_svtbl2_u8(svuint8x2_t data, svuint8_t indices)
+{
+  // CHECK-LABEL: test_svtbl2_u8
+  // CHECK-DAG: %[[V0:.*]] = call  @llvm.aarch64.sve.tuple.get.nxv16i8.nxv32i8( %data, i32 0)
+  // CHECK-DAG: %[[V1:.*]] = call  @llvm.aarch64.sve.tuple.get.nxv16i8.nxv32i8( %data, i32 1)
+  // CHECK: %[[INTRINSIC:.*]] = call  @llvm.aarch64.sve.tbl2.nxv16i8( %[[V0]],  %[[V1]],  %indices)
+  // CHECK-NEXT: ret  %[[INTRINSIC]]
+  // overload-warning@+2 {{implicit declaration of function 'svtbl2'}}
+  // expected-warning@+1 {{implicit declaration of function 'svtbl2_u8'}}
+  return SVE_ACLE_FUNC(svtbl2,_u8,,)(data, indices);
+}
+
+svuint16_t test_svtbl2_u16(svuint16x2_t data, sv

[PATCH] D81787: [clang] Fix the serialization of LambdaExpr and the bogus mutation in LambdaExpr::getBody

2020-06-17 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno marked 4 inline comments as done.
riccibruno added inline comments.



Comment at: clang/include/clang/AST/ExprCXX.h:2012-2017
+  Stmt *getBody() const { return getStoredStmts()[capture_size()]; }
+
+  /// Retrieve the \p CompoundStmt representing the body of the lambda.
+  /// This is a convenience function for callers who do not need
+  /// to handle node(s) which may wrap a \p CompoundStmt.
+  CompoundStmt *getCompoundStmtBody() const {

aaron.ballman wrote:
> I wish we'd get the const correctness right when doing this (`const` methods 
> returning pointers to `const` objects, not mixing constness like this). I 
> don't insist, but if you put in overloads, I wouldn't be sad either.
I agree, these const-incorrect methods are a bad habit. The overloads even were 
in a previous version of this patch so I am not sure why I did not include them 
here. I will definitely include them in the commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81787



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


[PATCH] D80681: [clang][SourceManager] cache Macro Expansions

2020-06-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

In D80681#2096886 , @nickdesaulniers 
wrote:

> Heh, those were painstakingly written in markdown by hand, using 
> `CC="/usr/bin/time -v clang"` to test.  The weren't statistically significant 
> (N=1), nor were they autogenerated.  My claims about builds of LLVM are 
> similarly non-scientific in terms of statistical significance.


Thanks, I believe it would be still good to provide those numbers for LLVM too 
(even if they are non-scientific), for the sake of future travellers that want 
to play with caching logic here.

> I will break this up into 3 patches, and ask you kindly to review once I have 
> them ready.  I will post them here, too, in case other reviewers or 
> subscribers would like to follow along, then I'll Abandon this revision.

thanks a lot, I've provided some details on your libclang interface comment 
below. but you might want to hold off on dead-code elimination patch, as it is 
in a quite fragile state and libclang stability is a concern I am not too 
familiar with.




Comment at: clang/include/clang/Basic/SourceManager.h:1747
   return getLoadedSLocEntryByID(ID, Invalid);
-return getLocalSLocEntry(static_cast(ID), Invalid);
+return getLocalSLocEntry(static_cast(ID));
   }

nickdesaulniers wrote:
> kadircet wrote:
> > i think this deserves its separate patch.
> > 
> > We still can satisfy the interface requirements of libclang by introducing 
> > another member `getLocalSLocEntryWithInvalid` and change the assertion into 
> > an if check, populating `Invalid` in case of failure, what to return is 
> > more tricky though it is a const ref, I suppose we can return a dummy entry.
> > 
> > Feel free to keep the newly added calls without an `Invalid` argument, but 
> > I wouldn't modify the already existing ones in this patch.
> > the interface requirements of libclang 
> 
> Oh? I must have missed that. Can you tell me more about that interface?  I 
> would have thought this would fail to build if I messed up an interface?
signature requirement is specified in 
https://github.com/llvm/llvm-project/blob/master/clang/tools/libclang/CIndexInclusionStack.cpp#L21,
 but that's actually an implementation file. So one could change the details 
instead and keep libclang API the same (or as mentioned above, you can just 
introduce a new SourceManager member that will fill in Invalid)

But the more I looked at this code, it started looking more iffy. It's 
`getLoadedSLocEntry` sibling is operating on a vector, asserting in a couple 
places and as a fallback just creating a new entry at given index via 
`lodadedentriesvector[index] = something`without caring about OOB access as it 
asserted previously. So this whole `Invalid` shenanigan looks ... weird.

Satisfying a const ref return type with an optional `Invalid` flag seems 
implausible to me :/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80681



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


[PATCH] D75229: [clang-tidy] Add signal-in-multithreaded-program check

2020-06-17 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 added a comment.

Minor nits inline. Good job, I am not entitled to accept it, but LGTM!




Comment at: 
clang-tools-extra/clang-tidy/bugprone/SignalInMultithreadedProgramCheck.h:23
+/// Finds ``signal`` function calls when the program is multithreaded. It
+/// founds a program multithreaded when it finds at least one function call
+/// of the following: ``thrd_create``, ``std::thread``, ``boost::thread``,

gamesh411 wrote:
> founds -> finds, but I would rather reword it like this:
> The checker considers the analyzed program multithreaded if it finds 
Or better:
The **check** considers ...
as the term `checker` is used more in ClangSA, and `check` in clang-tidy.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D75229



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


[PATCH] D80981: [AST] Fix a crash on accessing a class without definition in constexpr function context.

2020-06-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked an inline comment as done.
hokein added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:4320
+if (!RD->hasDefinition())
+  return APValue();
 APValue Struct(APValue::UninitStruct(), RD->getNumBases(),

rsmith wrote:
> hokein wrote:
> > sammccall wrote:
> > > This doesn't look all that safe - you're using a `None` value to indicate 
> > > failure, but no current code path does that and none of the callers seem 
> > > to check for failure.
> > > (e.g. `evaluateVarDecl` returns true instead of false).
> > > Presumably we're going to get a diagnostic somewhere (though it's not 
> > > completely obvious to me) but can we be sure we won't assume this value 
> > > has the right type somewhere down the line?
> > > 
> > > I get the feeling this is correct and I don't have enough context to 
> > > understand why... how about you :-)
> > I don't have a promising explanation neither. 
> > 
> > I didn't find a better way to model failures in `getDefaultInitValue`. This 
> > function is used in multiple places of this file (and I'm not sure whether 
> > we should change it).
> > 
> > @rsmith any thoughts?
> `APValue()` is a valid representation for an object of class type, 
> representing a class object that is outside its lifetime, so I think it's OK 
> to use this representation, if we can be sure that this only happens along 
> error paths. (It's not ideal, though.)
> 
> If we can't be sure this happens only along error paths, then we should 
> produce a diagnostic here. Perhaps feed an `EvalInfo&` and a source location 
> into every caller of this function and produce a diagnostic if we end up 
> querying the default-initialized value of an incomplete-but-valid class type. 
> Or perhaps we could check that the class is complete and valid from every 
> caller of this function instead. (I think that we guarantee that, for a valid 
> complete class type, all transitive subobjects are of valid complete types, 
> so checking this only once at the top level before calling into 
> `getDefaultInitValue` should be enough.)
Thanks for the suggestions.

oh, yeah, I missed that the `Foo` Decl is invalid, so checking the class decl 
is valid at every caller of `getDefaultInitValue` should work -- it would also 
fix other potential issues, looks like here we guarantee that the VarDecl is 
valid, but don't verify the decl which the VarDecl's type refers to is valid in 
all callers.  

Given the fact that the `VarDecl` e is valid and class `Foo` Decl is invalid, 
another option to fix the crash is to invalidate this `VarDecl`. Should we 
invalidate the VarDecl if the type of the VarDecl refers to an invalid decl? My 
gut feeling is that it is worth keeping the VarDecl valid, so that more related 
AST nodes will be built (for better recovery and diagnostics), though it seems 
unsafe. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80981



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


[PATCH] D81718: [Analyzer][NFC] Add methods `getReturnObject()` and `getArgObject()` to `CallEvent`

2020-06-17 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

I am really sorry to tell that, but now I began adding support for raw pointers 
as iterators (I will upload them in a separate patch when fully ready) and then 
tried your test. It passes, the error is found using this particular patch. So 
please tell me what is wrong with it, because the test you suggested does not 
prove it incorrect once support for pointers as iterators are there. If you 
feel it too iterator-specific, then I can abandon this patch and move this 
functions into the iterator library (`Iterator.h` and `Iterator.cpp`) in D77229 
.


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

https://reviews.llvm.org/D81718



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


[clang] 93cd411 - [NFC] Run clang-format on clang/test/OpenMP/nvptx_target_codegen.cpp

2020-06-17 Thread Alexey Bader via cfe-commits

Author: Alexey Bader
Date: 2020-06-17T13:04:01+03:00
New Revision: 93cd4115799cefa698833ca7a2f1899243d94c77

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

LOG: [NFC] Run clang-format on clang/test/OpenMP/nvptx_target_codegen.cpp

Added: 


Modified: 
clang/test/OpenMP/nvptx_target_codegen.cpp

Removed: 




diff  --git a/clang/test/OpenMP/nvptx_target_codegen.cpp 
b/clang/test/OpenMP/nvptx_target_codegen.cpp
index 20415c0dc1b6..d615b8536c48 100644
--- a/clang/test/OpenMP/nvptx_target_codegen.cpp
+++ b/clang/test/OpenMP/nvptx_target_codegen.cpp
@@ -16,16 +16,16 @@
 // CHECK-DAG: {{@__omp_offloading_.+l123}}_exec_mode = weak constant i8 1
 // CHECK-DAG: {{@__omp_offloading_.+l200}}_exec_mode = weak constant i8 1
 // CHECK-DAG: {{@__omp_offloading_.+l310}}_exec_mode = weak constant i8 1
-// CHECK-DAG: {{@__omp_offloading_.+l348}}_exec_mode = weak constant i8 1
-// CHECK-DAG: {{@__omp_offloading_.+l366}}_exec_mode = weak constant i8 1
+// CHECK-DAG: {{@__omp_offloading_.+l347}}_exec_mode = weak constant i8 1
+// CHECK-DAG: {{@__omp_offloading_.+l365}}_exec_mode = weak constant i8 1
 // CHECK-DAG: {{@__omp_offloading_.+l331}}_exec_mode = weak constant i8 1
 
 __thread int id;
 
 int baz(int f, double &a);
 
-template
-struct TT{
+template 
+struct TT {
   tx X;
   ty Y;
   tx &operator[](int i) { return X; }
@@ -56,258 +56,258 @@ int foo(int n) {
   double cn[5][n];
   TT d;
 
-  // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+foo.+l123}}_worker()
-  // CHECK-DAG: [[OMP_EXEC_STATUS:%.+]] = alloca i8,
-  // CHECK-DAG: [[OMP_WORK_FN:%.+]] = alloca i8*,
-  // CHECK: store i8* null, i8** [[OMP_WORK_FN]],
-  // CHECK: store i8 0, i8* [[OMP_EXEC_STATUS]],
-  // CHECK: br label {{%?}}[[AWAIT_WORK:.+]]
-  //
-  // CHECK: [[AWAIT_WORK]]
-  // CHECK: call void @__kmpc_barrier_simple_spmd(%struct.ident_t* null, i32 0)
-  // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
-  // CHECK: [[SHOULD_EXIT:%.+]] = icmp eq i8* [[WORK]], null
-  // CHECK: br i1 [[SHOULD_EXIT]], label {{%?}}[[EXIT:.+]], label 
{{%?}}[[SEL_WORKERS:.+]]
-  //
-  // CHECK: [[SEL_WORKERS]]
-  // CHECK: [[ST:%.+]] = load i8, i8* [[OMP_EXEC_STATUS]],
-  // CHECK: [[IS_ACTIVE:%.+]] = icmp ne i8 [[ST]], 0
-  // CHECK: br i1 [[IS_ACTIVE]], label {{%?}}[[EXEC_PARALLEL:.+]], label 
{{%?}}[[BAR_PARALLEL:.+]]
-  //
-  // CHECK: [[EXEC_PARALLEL]]
-  // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
-  //
-  // CHECK: [[TERM_PARALLEL]]
-  // CHECK: br label {{%?}}[[BAR_PARALLEL]]
-  //
-  // CHECK: [[BAR_PARALLEL]]
-  // CHECK: call void @__kmpc_barrier_simple_spmd(%struct.ident_t* null, i32 0)
-  // CHECK: br label {{%?}}[[AWAIT_WORK]]
-  //
-  // CHECK: [[EXIT]]
-  // CHECK: ret void
-
-  // CHECK: define {{.*}}void [[T1:@__omp_offloading_.+foo.+l123]]()
-  // CHECK-DAG: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
-  // CHECK-DAG: [[NTH:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
-  // CHECK-DAG: [[WS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
-  // CHECK-DAG: [[TH_LIMIT:%.+]] = sub nuw i32 [[NTH]], [[WS]]
-  // CHECK: [[IS_WORKER:%.+]] = icmp ult i32 [[TID]], [[TH_LIMIT]]
-  // CHECK: br i1 [[IS_WORKER]], label {{%?}}[[WORKER:.+]], label 
{{%?}}[[CHECK_MASTER:.+]]
-  //
-  // CHECK: [[WORKER]]
-  // CHECK: {{call|invoke}} void [[T1]]_worker()
-  // CHECK: br label {{%?}}[[EXIT:.+]]
-  //
-  // CHECK: [[CHECK_MASTER]]
-  // CHECK-DAG: [[CMTID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
-  // CHECK-DAG: [[CMNTH:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
-  // CHECK-DAG: [[CMWS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
-  // CHECK: [[IS_MASTER:%.+]] = icmp eq i32 [[CMTID]],
-  // CHECK: br i1 [[IS_MASTER]], label {{%?}}[[MASTER:.+]], label 
{{%?}}[[EXIT]]
-  //
-  // CHECK: [[MASTER]]
-  // CHECK-DAG: [[MNTH:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
-  // CHECK-DAG: [[MWS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
-  // CHECK: [[MTMP1:%.+]] = sub nuw i32 [[MNTH]], [[MWS]]
-  // CHECK: call void @__kmpc_kernel_init(i32 [[MTMP1]]
-  // CHECK: br label {{%?}}[[TERMINATE:.+]]
-  //
-  // CHECK: [[TERMINATE]]
-  // CHECK: call void @__kmpc_kernel_deinit(
-  // CHECK: call void @__kmpc_barrier_simple_spmd(%struct.ident_t* null, i32 0)
-  // CHECK: br label {{%?}}[[EXIT]]
-  //
-  // CHECK: [[EXIT]]
-  // CHECK: ret void
-  #pragma omp target
+// CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+foo.+l123}}_worker()
+// CHECK-DAG: [[OMP_EXEC_STATUS:%.+]] = alloca i8,
+// CHECK-DAG: [[OMP_WORK_FN:%.+]] = alloca i8*,
+// CHECK: store i8* null, i8** [[OMP_WORK_FN]],
+// CHECK: store i8 0, i8* [[OMP_EXEC_STATUS]],
+// CHECK: br label {{%?}}[[AWAIT_WORK:.+]]
+//
+// CHECK: [[AWAIT_WORK]]
+// CHECK: call void @__kmpc_barrier_simple_spmd(%struct.ident_t* null, i3

[PATCH] D81920: [clangd] Change FSProvider::getFileSystem to take CurrentWorkingDirectory

2020-06-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 271312.
kadircet marked 2 inline comments as done.
kadircet added a comment.

- Change signature to llvm::Optional to accomodate call sites that 
don't want to cd


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81920

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/support/FSProvider.cpp
  clang-tools-extra/clangd/support/FSProvider.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/FSTests.cpp
  clang-tools-extra/clangd/unittests/HeadersTests.cpp
  clang-tools-extra/clangd/unittests/PreambleTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.h

Index: clang-tools-extra/clangd/unittests/TestFS.h
===
--- clang-tools-extra/clangd/unittests/TestFS.h
+++ clang-tools-extra/clangd/unittests/TestFS.h
@@ -15,6 +15,7 @@
 #include "GlobalCompilationDatabase.h"
 #include "support/Path.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/VirtualFileSystem.h"
 
@@ -30,10 +31,18 @@
 // A VFS provider that returns TestFSes containing a provided set of files.
 class MockFSProvider : public FileSystemProvider {
 public:
-  IntrusiveRefCntPtr getFileSystem() const override {
+  IntrusiveRefCntPtr getFileSystem() const {
 return buildTestFS(Files, Timestamps);
   }
 
+  IntrusiveRefCntPtr
+  getFileSystem(llvm::Optional CWD) const override {
+auto FS = getFileSystem();
+if (CWD)
+  FS->setCurrentWorkingDirectory(*CWD);
+return FS;
+  }
+
   // If relative paths are used, they are resolved with testPath().
   llvm::StringMap Files;
   llvm::StringMap Timestamps;
Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -74,7 +74,9 @@
   prepareCompilerInstance(std::move(CI), &BaselinePreamble->Preamble,
   llvm::MemoryBuffer::getMemBufferCopy(
   ModifiedContents.slice(0, Bounds.Size).str()),
-  PI.FSProvider->getFileSystem(), Diags);
+  PI.FSProvider->getFileSystem(
+  llvm::StringRef(PI.CompileCommand.Directory)),
+  Diags);
   PreprocessOnlyAction Action;
   if (!Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0])) {
 ADD_FAILURE() << "failed begin source file";
Index: clang-tools-extra/clangd/unittests/HeadersTests.cpp
===
--- clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -16,6 +16,7 @@
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Lex/PreprocessorOptions.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "gmock/gmock.h"
@@ -52,8 +53,7 @@
 EXPECT_TRUE(static_cast(CI));
 // The diagnostic options must be set before creating a CompilerInstance.
 CI->getDiagnosticOpts().IgnoreWarnings = true;
-auto VFS = FS.getFileSystem();
-VFS->setCurrentWorkingDirectory(Cmd->Directory);
+auto VFS = FS.getFileSystem(llvm::StringRef(Cmd->Directory));
 auto Clang = prepareCompilerInstance(
 std::move(CI), /*Preamble=*/nullptr,
 llvm::MemoryBuffer::getMemBuffer(FS.Files[MainFile], MainFile),
Index: clang-tools-extra/clangd/unittests/FSTests.cpp
===
--- clang-tools-extra/clangd/unittests/FSTests.cpp
+++ clang-tools-extra/clangd/unittests/FSTests.cpp
@@ -21,7 +21,6 @@
   Files["y"] = "";
   Files["main"] = "";
   auto FS = buildTestFS(Files);
-  FS->setCurrentWorkingDirectory(testRoot());
 
   PreambleFileStatusCache StatCache(testPath("main"));
   auto ProduceFS = StatCache.getProducingFS(FS);
Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -15,9 +15,11 @@
 #include "SyncAPI.h"
 #include "TestFS.h"
 #include "URI.h"
+#include "support/Path.h"
 #include "support/Threading.h"
 #include "clang/Config/config.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/Sm

[PATCH] D81998: [clangd][NFC] Rename FSProvider and getFileSystem

2020-06-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Clangd uses FSProvider to get threadsafe views into file systems. This
patch changes naming to make that more explicit.

Depends on D81920 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81998

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/support/FSProvider.cpp
  clang-tools-extra/clangd/support/FSProvider.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/HeadersTests.cpp
  clang-tools-extra/clangd/unittests/PreambleTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.h

Index: clang-tools-extra/clangd/unittests/TestFS.h
===
--- clang-tools-extra/clangd/unittests/TestFS.h
+++ clang-tools-extra/clangd/unittests/TestFS.h
@@ -29,14 +29,14 @@
 llvm::StringMap const &Timestamps = {});
 
 // A VFS provider that returns TestFSes containing a provided set of files.
-class MockFSProvider : public FileSystemProvider {
+class MockFSProvider : public ThreadSafeFS {
 public:
   IntrusiveRefCntPtr getFileSystem() const {
 return buildTestFS(Files, Timestamps);
   }
 
   IntrusiveRefCntPtr
-  getFileSystem(llvm::Optional CWD) const override {
+  view(llvm::Optional CWD) const override {
 auto FS = getFileSystem();
 if (CWD)
   FS->setCurrentWorkingDirectory(*CWD);
Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -70,13 +70,11 @@
   // We don't run PP directly over the patch cotents to test production
   // behaviour.
   auto Bounds = Lexer::ComputePreamble(ModifiedContents, *CI->getLangOpts());
-  auto Clang =
-  prepareCompilerInstance(std::move(CI), &BaselinePreamble->Preamble,
-  llvm::MemoryBuffer::getMemBufferCopy(
-  ModifiedContents.slice(0, Bounds.Size).str()),
-  PI.FSProvider->getFileSystem(
-  llvm::StringRef(PI.CompileCommand.Directory)),
-  Diags);
+  auto Clang = prepareCompilerInstance(
+  std::move(CI), &BaselinePreamble->Preamble,
+  llvm::MemoryBuffer::getMemBufferCopy(
+  ModifiedContents.slice(0, Bounds.Size).str()),
+  PI.FSProvider->view(llvm::StringRef(PI.CompileCommand.Directory)), Diags);
   PreprocessOnlyAction Action;
   if (!Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0])) {
 ADD_FAILURE() << "failed begin source file";
Index: clang-tools-extra/clangd/unittests/HeadersTests.cpp
===
--- clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -53,7 +53,7 @@
 EXPECT_TRUE(static_cast(CI));
 // The diagnostic options must be set before creating a CompilerInstance.
 CI->getDiagnosticOpts().IgnoreWarnings = true;
-auto VFS = FS.getFileSystem(llvm::StringRef(Cmd->Directory));
+auto VFS = FS.view(llvm::StringRef(Cmd->Directory));
 auto Clang = prepareCompilerInstance(
 std::move(CI), /*Preamble=*/nullptr,
 llvm::MemoryBuffer::getMemBuffer(FS.Files[MainFile], MainFile),
Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -271,9 +271,9 @@
 
 TEST_F(ClangdVFSTest, PropagatesContexts) {
   static Key Secret;
-  struct FSProvider : public FileSystemProvider {
+  struct FSProvider : public ThreadSafeFS {
 IntrusiveRefCntPtr
-getFileSystem(llvm::Optional) const override {
+view(llvm::Optional) const override {
   Got = Context::current().getExisting(Secret);
   return buildTestFS({});
 }
@@ -923,13 +923,13 @@
 // Check that running code completion doesn't stat() a bunch of files from the
 // preamble again. (They should be using the preamble's stat-cache)
 TEST(ClangdTests, PreambleVFSStatCache) {
-  class ListenStatsFSProvider : public FileSystemProvider {
+  class ListenStatsFSProvid

[PATCH] D81641: [SYCL][OpenMP] Implement thread-local storage restriction

2020-06-17 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

In D81641#2097433 , @Fznamznon wrote:

> Seems that `test/OpenMP/nvptx_target_codegen.cpp` is completely not 
> formatted. If I apply suggestion from pre-merge checks, this will look like a 
> big unrelated to this patch change and it will contradict with the whole file 
> style.


I formatted this file here: 
https://github.com/llvm/llvm-project/commit/93cd4115799cefa698833ca7a2f1899243d94c77.
Could you rebase your patch, please?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81641



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


[clang] 5bf0858 - Return "[InstCombine] Simplify compare of Phi with constant inputs against a constant"

2020-06-17 Thread Sam Parker via cfe-commits

Author: Sam Parker
Date: 2020-06-17T11:38:59+01:00
New Revision: 5bf0858c0b4cb5237fa4bf0cf58a76ec5076ef5a

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

LOG: Return "[InstCombine] Simplify compare of Phi with constant inputs against 
a constant"

I originally reverted the patch because it was causing performance
issues, but now I think it's just enabling simplify-cfg to do
something that I don't want instead :)

Sorry for the noise.

This reverts commit 3e39760f8eaad4770efa05824768e67237915cf5.

Added: 


Modified: 
clang/test/CodeGenObjC/exceptions.m
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/icmp-constant-phi.ll
llvm/test/Transforms/InstCombine/indexed-gep-compares.ll
llvm/test/Transforms/InstCombine/zext-or-icmp.ll

Removed: 




diff  --git a/clang/test/CodeGenObjC/exceptions.m 
b/clang/test/CodeGenObjC/exceptions.m
index 741f8a819158..3bb4f86cf025 100644
--- a/clang/test/CodeGenObjC/exceptions.m
+++ b/clang/test/CodeGenObjC/exceptions.m
@@ -97,7 +97,7 @@ void f3() {
 // CHECK:call void @objc_exception_try_exit(
 f3_helper(0, &x);
   } @finally {
-// CHECK:[[DEST1:%.*]] = phi i32 [ 0, {{%.*}} ], [ 3, {{%.*}} ]
+// CHECK:[[DEST1:%.*]] = phi i1 [ true, {{%.*}} ], [ false, {{%.*}} ]
 // CHECK:call void @objc_exception_try_enter
 // CHECK:call i32 @_setjmp
 @try {
@@ -105,7 +105,7 @@ void f3() {
   // CHECK:  call void @objc_exception_try_exit(
   f3_helper(1, &x);
 } @finally {
-  // CHECK:  [[DEST2:%.*]] = phi i32 [ 0, {{%.*}} ], [ 5, {{%.*}} ]
+  // CHECK:  [[DEST2:%.*]] = phi i1 [ true, {{%.*}} ], [ false, {{%.*}} ]
   // CHECK:  call void @f3_helper(i32 2, i32* nonnull [[X]])
   f3_helper(2, &x);
 

diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 48375a1a323f..a7b9ecb9bf3b 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -1452,6 +1452,27 @@ Instruction *InstCombiner::foldICmpWithConstant(ICmpInst 
&Cmp) {
 if (Instruction *Res = processUGT_ADDCST_ADD(Cmp, A, B, CI2, CI, *this))
   return Res;
 
+  // icmp(phi(C1, C2, ...), C) -> phi(icmp(C1, C), icmp(C2, C), ...).
+  Constant *C = dyn_cast(Op1);
+  if (!C)
+return nullptr;
+
+  if (auto *Phi = dyn_cast(Op0))
+if (all_of(Phi->operands(), [](Value *V) { return isa(V); })) {
+  Type *Ty = Cmp.getType();
+  Builder.SetInsertPoint(Phi);
+  PHINode *NewPhi =
+  Builder.CreatePHI(Ty, Phi->getNumOperands());
+  for (BasicBlock *Predecessor : predecessors(Phi->getParent())) {
+auto *Input =
+cast(Phi->getIncomingValueForBlock(Predecessor));
+auto *BoolInput = ConstantExpr::getCompare(Pred, Input, C);
+NewPhi->addIncoming(BoolInput, Predecessor);
+  }
+  NewPhi->takeName(&Cmp);
+  return replaceInstUsesWith(Cmp, NewPhi);
+}
+
   return nullptr;
 }
 

diff  --git a/llvm/test/Transforms/InstCombine/icmp-constant-phi.ll 
b/llvm/test/Transforms/InstCombine/icmp-constant-phi.ll
index 9753149f8012..7d4b9294143f 100644
--- a/llvm/test/Transforms/InstCombine/icmp-constant-phi.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-constant-phi.ll
@@ -2,8 +2,6 @@
 ; RUN: opt < %s -instcombine -S | FileCheck %s
 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
 
-; TODO: Replace with boolean Phi.
-
 define i1 @test_eq(i1 %cond) {
 ; CHECK-LABEL: @test_eq(
 ; CHECK-NEXT:  entry:
@@ -13,10 +11,9 @@ define i1 @test_eq(i1 %cond) {
 ; CHECK:   if.false:
 ; CHECK-NEXT:br label [[MERGE]]
 ; CHECK:   merge:
-; CHECK-NEXT:[[PHI:%.*]] = phi i32 [ 123, [[IF_TRUE]] ], [ 456, 
[[IF_FALSE]] ]
+; CHECK-NEXT:[[COMPARE:%.*]] = phi i1 [ true, [[IF_FALSE]] ], [ false, 
[[IF_TRUE]] ]
 ; CHECK-NEXT:br label [[EXIT:%.*]]
 ; CHECK:   exit:
-; CHECK-NEXT:[[COMPARE:%.*]] = icmp eq i32 [[PHI]], 456
 ; CHECK-NEXT:ret i1 [[COMPARE]]
 ;
 entry:
@@ -46,10 +43,9 @@ define i1 @test_slt(i1 %cond) {
 ; CHECK:   if.false:
 ; CHECK-NEXT:br label [[MERGE]]
 ; CHECK:   merge:
-; CHECK-NEXT:[[PHI:%.*]] = phi i32 [ 123, [[IF_TRUE]] ], [ 456, 
[[IF_FALSE]] ]
+; CHECK-NEXT:[[COMPARE:%.*]] = phi i1 [ false, [[IF_FALSE]] ], [ true, 
[[IF_TRUE]] ]
 ; CHECK-NEXT:br label [[EXIT:%.*]]
 ; CHECK:   exit:
-; CHECK-NEXT:[[COMPARE:%.*]] = icmp ult i32 [[PHI]], 456
 ; CHECK-NEXT:ret i1 [[COMPARE]]
 ;
 entry:
@@ -110,10 +106,9 @@ define i1 @test_ne(i1 %cond) {
 ; CHECK:   if.false:
 ; CHECK-NEXT:br label [[MERGE]]
 ; CHECK:   merge:
-; CHECK-NEXT:[[PHI:%.*]] = phi i32 [ 123, [[IF_TRUE]] ], [ 456, 
[[IF_FALSE]] ]
+; 

[PATCH] D81761: [analyzer] Force dependency checkers to be hidden

2020-06-17 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D81761#2097561 , @balazske wrote:

> My observation is, if there is an example checker, it should be really 
> "example" and not "test". (The "custom" is probably good to rename to "test" 
> but not the "example".) (The names of these files look not good too: A 
> **CheckerOptionHandling.cpp** contains an example checker, should be probably 
> **CheckerOptionHandlingExample.cpp**).


That is indeed a very fair point. My rationale was that these examples are in 
fact tested in the lit files, and my intention when writing them was to test 
checker registration from plugins.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81761



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


[PATCH] D81407: [Analyzer][StreamChecker] Add note tags for file opening.

2020-06-17 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus marked 2 inline comments as done.
Szelethus added a comment.
This revision is now accepted and ready to land.

Yay! Getting so close to enabling this by default. I'm a big fan of your work 
on this checker.




Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:378
+  if (BR.isInteresting(StreamSym) &&
+  CheckerName == BR.getBugType().getCheckerName())
+return Message;

I think is is going to be good enough until we automate things.



Comment at: clang/test/Analysis/stream.c:1
-// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.unix.Stream -analyzer-store 
region -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.Stream -verify %s
 

Nice catch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81407



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


[PATCH] D82002: [clangd] Drop FS usage in ClangTidyOpts

2020-06-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Depends on D81998 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82002

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

Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -15,6 +15,7 @@
 #include "index/Background.h"
 #include "index/Serialization.h"
 #include "refactor/Rename.h"
+#include "support/FSProvider.h"
 #include "support/Path.h"
 #include "support/Shutdown.h"
 #include "support/Trace.h"
@@ -472,6 +473,51 @@
 const char TestScheme::TestDir[] = "/clangd-test";
 #endif
 
+// A thread-safe options provider suitable for use by ClangdServer. It also
+// provides some default checks if user has specified none.
+class ClangdTidyOptionsProvider : public clang::tidy::FileOptionsProvider {
+public:
+  ClangdTidyOptionsProvider(const tidy::ClangTidyOptions &OverrideOptions,
+const ThreadSafeFS &FSProvider)
+  : FileOptionsProvider(tidy::ClangTidyGlobalOptions(),
+tidy::ClangTidyOptions(), OverrideOptions,
+FSProvider.view(llvm::None)) {}
+
+  std::vector getRawOptions(llvm::StringRef FileName) override {
+std::vector Sources;
+{
+  std::lock_guard Lock(Mu);
+  Sources = tidy::FileOptionsProvider::getRawOptions(FileName);
+}
+// If the user hasn't configured clang-tidy checks at all, including via
+// .clang-tidy, give them a nice set of checks.
+// (This should be what the "default" options does, but it isn't...)
+bool HasChecks = false;
+for (const auto &Source : Sources)
+  HasChecks |= Source.first.Checks.hasValue();
+if (!HasChecks)
+  Sources.push_back(DefaultClangdSource);
+return Sources;
+  }
+
+private:
+  std::mutex Mu;
+  const OptionsSource DefaultClangdSource = []() -> OptionsSource {
+tidy::ClangTidyOptions Opts;
+// These default checks are chosen for:
+//  - low false-positive rate
+//  - providing a lot of value
+//  - being reasonably efficient
+Opts.Checks = llvm::join_items(
+",", "readability-misleading-indentation",
+"readability-deleted-default", "bugprone-integer-division",
+"bugprone-sizeof-expression", "bugprone-suspicious-missing-comma",
+"bugprone-unused-raii", "bugprone-unused-return-value",
+"misc-unused-using-decls", "misc-unused-alias-decls",
+"misc-definitions-in-headers");
+return {Opts, "-clangd-opts"};
+  }();
+};
 } // namespace
 } // namespace clangd
 } // namespace clang
@@ -705,49 +751,15 @@
 TransportLayer = createPathMappingTransport(std::move(TransportLayer),
 std::move(*Mappings));
   }
-  // Create an empty clang-tidy option.
-  std::mutex ClangTidyOptMu;
-  std::unique_ptr
-  ClangTidyOptProvider; /*GUARDED_BY(ClangTidyOptMu)*/
+  std::unique_ptr ClangTidyOptProvider;
   if (EnableClangTidy) {
-auto EmptyDefaults = tidy::ClangTidyOptions::getDefaults();
-EmptyDefaults.Checks.reset(); // So we can tell if checks were ever set.
 tidy::ClangTidyOptions OverrideClangTidyOptions;
 if (!ClangTidyChecks.empty())
   OverrideClangTidyOptions.Checks = ClangTidyChecks;
-ClangTidyOptProvider = std::make_unique(
-tidy::ClangTidyGlobalOptions(),
-/* Default */ EmptyDefaults,
-/* Override */ OverrideClangTidyOptions, FSProvider.view(llvm::None));
-Opts.GetClangTidyOptions = [&](llvm::vfs::FileSystem &,
-   llvm::StringRef File) {
-  // This function must be thread-safe and tidy option providers are not.
-  tidy::ClangTidyOptions Opts;
-  {
-std::lock_guard Lock(ClangTidyOptMu);
-// FIXME: use the FS provided to the function.
-Opts = ClangTidyOptProvider->getOptions(File);
-  }
-  if (!Opts.Checks) {
-// If the user hasn't configured clang-tidy checks at all, including
-// via .clang-tidy, give them a nice set of checks.
-// (This should be what the "default" options does, but it isn't...)
-//
-// These default checks are chosen for:
-//  - low false-positive rate
-//  - providing a lot of value
-//  - being reasonably efficient
-Opts.Checks = llvm::join_items(
-",", "readability-misleading-indentation",
-"readability-deleted-default", "bugprone-integer-division",
-"bugprone-sizeof-expression", "bugprone-suspicious-missing-comma",
-"bugprone-unused-raii", "bugpr

[PATCH] D81422: Change filecheck default to dump input on failure

2020-06-17 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

I would also expect a simple command line flag to llvm-lit to be able to 
control this, rather than having to set an environment variable




Comment at: mlir/test/mlir-tblgen/op-format-spec.td:1
-// RUN: mlir-tblgen -gen-op-decls -asmformat-error-is-fatal=false -I 
%S/../../include %s -o=%t 2>&1 | FileCheck %s --dump-input-on-failure
+// RUN: mlir-tblgen -gen-op-decls -asmformat-error-is-fatal=false -I 
%S/../../include %s -o=%t 2>&1 | FileCheck %s
 

All of these MLIR tests are microscopic and I don't think this is a 
representative sample across all the projects. Most testcases are significantly 
larger, and have hundreds if not thousands of lines of output


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81422



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


[PATCH] D81678: Introduce partialinit attribute at call sites for stricter poison analysis

2020-06-17 Thread Juneyoung Lee via Phabricator via cfe-commits
aqjune added a comment.

In D81678#2091089 , @eugenis wrote:

> Positive attribute sounds good to me (frozen is not a bad name), but the 
> tests update change is going to be huge. Any concerns about IR size bloat? 
> The attribute will apply to the majority of function arguments, 8 bytes per 
> instance as far as I can see.


Hi,

The issue stems from the difference between whether passing poison/undef to fn 
arg is allowed in C and IR, so (to add a positive attribute) increase in diff 
and # of attributes will happen, the question is how we can make the increase 
as small as possible.
To minimize diff, what about additionally introducing a function-level 
attribute such as `args_frozen` stating that all arguments are frozen. (e.g 
`define void @f(i32 x, i32 y) args_frozen`)?
The attribute will appear at the end of the line, so many CHECK of function 
signatures will still pass. (e.g. clang/test/CodeGen/mips64-padding-arg.c )


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678



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


[PATCH] D81422: Change filecheck default to dump input on failure

2020-06-17 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini marked an inline comment as done.
mehdi_amini added a comment.

In D81422#2096643 , @arsenm wrote:

> I would also expect a simple command line flag to llvm-lit to be able to 
> control this, rather than having to set an environment variable


Would you like a lit command line flag that set the environment variable? I 
think that's easily doable




Comment at: mlir/test/mlir-tblgen/op-format-spec.td:1
-// RUN: mlir-tblgen -gen-op-decls -asmformat-error-is-fatal=false -I 
%S/../../include %s -o=%t 2>&1 | FileCheck %s --dump-input-on-failure
+// RUN: mlir-tblgen -gen-op-decls -asmformat-error-is-fatal=false -I 
%S/../../include %s -o=%t 2>&1 | FileCheck %s
 

arsenm wrote:
> All of these MLIR tests are microscopic and I don't think this is a 
> representative sample across all the projects. Most testcases are 
> significantly larger, and have hundreds if not thousands of lines of output
Well, if this can act as an extra incentive to break-up such large tests, it 
see it as a win: debugging failing patterns in the middle of such a large test 
output is not nice regardless.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81422



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


[PATCH] D81886: [AMDGPU] Add gfx1030 target

2020-06-17 Thread Jay Foad via Phabricator via cfe-commits
foad added inline comments.



Comment at: llvm/docs/AMDGPUUsage.rst:266-267

  names.
+ ``gfx1030`` ``amdgcn``   dGPU  - xnack   
*TBA*
+  [off]
+- wavefrontsize64

Seems odd to list xnack as a "supported fetaure" when the hardware doesn't 
support it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81886



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


[PATCH] D81678: Introduce partialinit attribute at call sites for stricter poison analysis

2020-06-17 Thread Gui Andrade via Phabricator via cfe-commits
guiand added a comment.

In D81678#2097081 , @aqjune wrote:

> To minimize diff, what about additionally introducing a function-level 
> attribute such as `args_frozen` stating that all arguments are frozen. (e.g 
> `define void @f(i32 x, i32 y) args_frozen`)?


I like this idea, and I think it will vastly reduce the tests diff. I'll try to 
update this patch with a positive `frozen` arg attribute and `args_frozen` 
function attribute ASAP.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678



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


[PATCH] D81678: Introduce partialinit attribute at call sites for stricter poison analysis

2020-06-17 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

In terms of the C++ API, we definitely want to provide an API phrased 
positively in terms of individual arguments, so transforms don't have to deal 
with inverted logic.

In terms of the actual internal memory representation, or textual IR, maybe we 
can be a bit more flexible.  `args_frozen` might be a reasonable compromise; 
the memory overhead should be pretty minimal even if we're attaching it to a 
bunch of functions, and it should be mostly readable.  But maybe a little 
awkward to explain the textual IR if it has both `arg_frozen` and `args_frozen`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678



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


[PATCH] D81967: [clang-tools-extra] Prevent linking to duplicate .a libs and dylib

2020-06-17 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Ok, I don't think this failure is due to my changes but I've proposed a 
solution as D82001  anyway.


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

https://reviews.llvm.org/D81967



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


[PATCH] D81641: [SYCL][OpenMP] Implement thread-local storage restriction

2020-06-17 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 271327.
Fznamznon edited the summary of this revision.
Fznamznon added a comment.

Rebased.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81641

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/OpenMP/nvptx_prohibit_thread_local.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/SemaSYCL/prohibit-thread-local.cpp

Index: clang/test/SemaSYCL/prohibit-thread-local.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/prohibit-thread-local.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64 -verify -fsyntax-only %s
+
+thread_local const int prohobit_ns_scope = 0;
+thread_local int prohobit_ns_scope2 = 0;
+thread_local const int allow_ns_scope = 0;
+
+struct S {
+  static const thread_local int prohibit_static_member;
+  static thread_local int prohibit_static_member2;
+};
+
+struct T {
+  static const thread_local int allow_static_member;
+};
+
+void foo() {
+  // expected-error@+1{{thread-local storage is not supported for the current target}}
+  thread_local const int prohibit_local = 0;
+  // expected-error@+1{{thread-local storage is not supported for the current target}}
+  thread_local int prohibit_local2;
+}
+
+void bar() { thread_local int allow_local; }
+
+void usage() {
+  // expected-note@+1 {{called by}}
+  foo();
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)prohobit_ns_scope;
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)prohobit_ns_scope2;
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)S::prohibit_static_member;
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)S::prohibit_static_member2;
+}
+
+template 
+__attribute__((sycl_kernel))
+// expected-note@+2 2{{called by}}
+void
+kernel_single_task(Func kernelFunc) { kernelFunc(); }
+
+int main() {
+  // expected-note@+1 2{{called by}}
+  kernel_single_task([]() { usage(); });
+  return 0;
+}
Index: clang/test/OpenMP/nvptx_target_codegen.cpp
===
--- clang/test/OpenMP/nvptx_target_codegen.cpp
+++ clang/test/OpenMP/nvptx_target_codegen.cpp
@@ -160,7 +160,7 @@
 // CHECK: [[EXIT]]
 // CHECK: ret void
 
-// CHECK: define {{.*}}void [[T2:@__omp_offloading_.+foo.+l200]](i[[SZ:32|64]] [[ARG1:%[a-zA-Z_]+]], i[[SZ:32|64]] [[ID:%[a-zA-Z_]+]])
+// CHECK: define {{.*}}void [[T2:@__omp_offloading_.+foo.+l200]](i[[SZ:32|64]] [[ARG1:%[a-zA-Z_]+]])
 // CHECK: [[AA_ADDR:%.+]] = alloca i[[SZ]],
 // CHECK: store i[[SZ]] [[ARG1]], i[[SZ]]* [[AA_ADDR]],
 // CHECK: [[AA_CADDR:%.+]] = bitcast i[[SZ]]* [[AA_ADDR]] to i16*
@@ -200,7 +200,7 @@
 #pragma omp target if (1)
   {
 aa += 1;
-id = aa;
+aa += 2;
   }
 
 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+foo.+l310}}_worker()
Index: clang/test/OpenMP/nvptx_prohibit_thread_local.cpp
===
--- /dev/null
+++ clang/test/OpenMP/nvptx_prohibit_thread_local.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-linux -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -aux-triple x86_64-unknown-linux -fopenmp-targets=nvptx64-nvidia-cuda %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -fsyntax-only
+
+thread_local const int prohobit_ns_scope = 0;
+thread_local int prohobit_ns_scope2 = 0;
+thread_local const int allow_ns_scope = 0;
+
+struct S {
+  static const thread_local int prohibit_static_member;
+  static thread_local int prohibit_static_member2;
+};
+
+struct T {
+  static const thread_local int allow_static_member;
+};
+
+void foo() {
+  // expected-error@+1{{thread-local storage is not supported for the current target}}
+  thread_local const int prohibit_local = 0;
+  // expected-error@+1{{thread-local storage is not supported for the current target}}
+  thread_local int prohibit_local2;
+}
+
+void bar() { thread_local int allow_local; }
+
+void usage() {
+  // expected-note@+1 {{called by}}
+  foo();
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)prohobit_ns_scope;
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)prohobit_ns_scope2;
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)S::prohibit_static_member;
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)S::prohibit_static_member2;
+}
+
+int main() {
+  // expected-note@+2 2{{called by}}
+#pragma omp target
+  usage();
+  return 0;
+}
Index: clang/lib/Sema/S

[PATCH] D81998: [clangd][NFC] Rename FSProvider and getFileSystem

2020-06-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 271330.
kadircet added a comment.

- Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81998

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/support/FSProvider.cpp
  clang-tools-extra/clangd/support/FSProvider.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/HeadersTests.cpp
  clang-tools-extra/clangd/unittests/PreambleTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.h

Index: clang-tools-extra/clangd/unittests/TestFS.h
===
--- clang-tools-extra/clangd/unittests/TestFS.h
+++ clang-tools-extra/clangd/unittests/TestFS.h
@@ -30,14 +30,14 @@
 llvm::StringMap const &Timestamps = {});
 
 // A VFS provider that returns TestFSes containing a provided set of files.
-class MockFSProvider : public FileSystemProvider {
+class MockFSProvider : public ThreadSafeFS {
 public:
   IntrusiveRefCntPtr getFileSystem() const {
 return buildTestFS(Files, Timestamps);
   }
 
   IntrusiveRefCntPtr
-  getFileSystem(llvm::NoneType) const override {
+  view(llvm::NoneType) const override {
 return getFileSystem();
   }
 
Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -74,7 +74,7 @@
   std::move(CI), &BaselinePreamble->Preamble,
   llvm::MemoryBuffer::getMemBufferCopy(
   ModifiedContents.slice(0, Bounds.Size).str()),
-  PI.FSProvider->getFileSystem(PI.CompileCommand.Directory), Diags);
+  PI.FSProvider->view(PI.CompileCommand.Directory), Diags);
   PreprocessOnlyAction Action;
   if (!Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0])) {
 ADD_FAILURE() << "failed begin source file";
Index: clang-tools-extra/clangd/unittests/HeadersTests.cpp
===
--- clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -53,7 +53,7 @@
 EXPECT_TRUE(static_cast(CI));
 // The diagnostic options must be set before creating a CompilerInstance.
 CI->getDiagnosticOpts().IgnoreWarnings = true;
-auto VFS = PI.FSProvider->getFileSystem(Cmd->Directory);
+auto VFS = PI.FSProvider->view(Cmd->Directory);
 auto Clang = prepareCompilerInstance(
 std::move(CI), /*Preamble=*/nullptr,
 llvm::MemoryBuffer::getMemBuffer(FS.Files[MainFile], MainFile),
Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -272,9 +272,9 @@
 
 TEST_F(ClangdVFSTest, PropagatesContexts) {
   static Key Secret;
-  struct FSProvider : public FileSystemProvider {
+  struct FSProvider : public ThreadSafeFS {
 IntrusiveRefCntPtr
-getFileSystem(llvm::NoneType) const override {
+view(llvm::NoneType) const override {
   Got = Context::current().getExisting(Secret);
   return buildTestFS({});
 }
@@ -924,13 +924,13 @@
 // Check that running code completion doesn't stat() a bunch of files from the
 // preamble again. (They should be using the preamble's stat-cache)
 TEST(ClangdTests, PreambleVFSStatCache) {
-  class ListenStatsFSProvider : public FileSystemProvider {
+  class ListenStatsFSProvider : public ThreadSafeFS {
   public:
 ListenStatsFSProvider(llvm::StringMap &CountStats)
 : CountStats(CountStats) {}
 
 IntrusiveRefCntPtr
-getFileSystem(llvm::NoneType) const override {
+view(llvm::NoneType) const override {
   class ListenStatVFS : public llvm::vfs::ProxyFileSystem {
   public:
 ListenStatVFS(IntrusiveRefCntPtr FS,
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -718,8 +718,7 @@
 ClangTidyOptProvider = std::make_unique(
 tidy::ClangTidyGlobalOptions(),
 /* Default */ EmptyDefaults,
-/* Override */ OverrideClangTidyOptions,
-FSProvider.getFileSystem(llvm::None));
+/* Override */ OverrideC

[PATCH] D81920: [clangd] Change FSProvider::getFileSystem to take CurrentWorkingDirectory

2020-06-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:187
+Opts.ClangTidyOpts =
+GetClangTidyOptions(*FSProvider.getFileSystem("."), File);
   Opts.SuggestMissingIncludes = SuggestMissingIncludes;

sammccall wrote:
> Not sure what to do in this patch, but ultimately I don't think we 
> must/should pass an FS of any form into this callback.
> (Doesn't make sense to assume getting options needs the FS, embedders can use 
> the context to know what version of the FS to use if needed)
sounds good, will delete in a follow-up patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81920



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


[PATCH] D81920: [clangd] Change FSProvider::getFileSystem to take CurrentWorkingDirectory

2020-06-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 271328.
kadircet added a comment.

- Provide two overloads to make implicit string -> StringRef conversion 
possible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81920

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/support/FSProvider.cpp
  clang-tools-extra/clangd/support/FSProvider.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/FSTests.cpp
  clang-tools-extra/clangd/unittests/HeadersTests.cpp
  clang-tools-extra/clangd/unittests/PreambleTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.h

Index: clang-tools-extra/clangd/unittests/TestFS.h
===
--- clang-tools-extra/clangd/unittests/TestFS.h
+++ clang-tools-extra/clangd/unittests/TestFS.h
@@ -15,6 +15,8 @@
 #include "GlobalCompilationDatabase.h"
 #include "support/Path.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/VirtualFileSystem.h"
 
@@ -30,10 +32,15 @@
 // A VFS provider that returns TestFSes containing a provided set of files.
 class MockFSProvider : public FileSystemProvider {
 public:
-  IntrusiveRefCntPtr getFileSystem() const override {
+  IntrusiveRefCntPtr getFileSystem() const {
 return buildTestFS(Files, Timestamps);
   }
 
+  IntrusiveRefCntPtr
+  getFileSystem(llvm::NoneType) const override {
+return getFileSystem();
+  }
+
   // If relative paths are used, they are resolved with testPath().
   llvm::StringMap Files;
   llvm::StringMap Timestamps;
Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -70,11 +70,11 @@
   // We don't run PP directly over the patch cotents to test production
   // behaviour.
   auto Bounds = Lexer::ComputePreamble(ModifiedContents, *CI->getLangOpts());
-  auto Clang =
-  prepareCompilerInstance(std::move(CI), &BaselinePreamble->Preamble,
-  llvm::MemoryBuffer::getMemBufferCopy(
-  ModifiedContents.slice(0, Bounds.Size).str()),
-  PI.FSProvider->getFileSystem(), Diags);
+  auto Clang = prepareCompilerInstance(
+  std::move(CI), &BaselinePreamble->Preamble,
+  llvm::MemoryBuffer::getMemBufferCopy(
+  ModifiedContents.slice(0, Bounds.Size).str()),
+  PI.FSProvider->getFileSystem(PI.CompileCommand.Directory), Diags);
   PreprocessOnlyAction Action;
   if (!Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0])) {
 ADD_FAILURE() << "failed begin source file";
Index: clang-tools-extra/clangd/unittests/HeadersTests.cpp
===
--- clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -16,6 +16,7 @@
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Lex/PreprocessorOptions.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "gmock/gmock.h"
@@ -52,8 +53,7 @@
 EXPECT_TRUE(static_cast(CI));
 // The diagnostic options must be set before creating a CompilerInstance.
 CI->getDiagnosticOpts().IgnoreWarnings = true;
-auto VFS = FS.getFileSystem();
-VFS->setCurrentWorkingDirectory(Cmd->Directory);
+auto VFS = PI.FSProvider->getFileSystem(Cmd->Directory);
 auto Clang = prepareCompilerInstance(
 std::move(CI), /*Preamble=*/nullptr,
 llvm::MemoryBuffer::getMemBuffer(FS.Files[MainFile], MainFile),
Index: clang-tools-extra/clangd/unittests/FSTests.cpp
===
--- clang-tools-extra/clangd/unittests/FSTests.cpp
+++ clang-tools-extra/clangd/unittests/FSTests.cpp
@@ -21,7 +21,6 @@
   Files["y"] = "";
   Files["main"] = "";
   auto FS = buildTestFS(Files);
-  FS->setCurrentWorkingDirectory(testRoot());
 
   PreambleFileStatusCache StatCache(testPath("main"));
   auto ProduceFS = StatCache.getProducingFS(FS);
Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -15,9 +15,12 @@
 #include "SyncAPI.h"
 #include "TestFS.h"
 #include "URI.h"
+#include "support/Path

[PATCH] D81975: [clangd] Add command line option for ClangTidyConfig

2020-06-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Good/bad news on timing here...

I'd like to introduce a config system (user config file, but also eventually 
in-project `.clangd` files, extensible over LSP etc).
It'll provide a generic way to apply different config to different files.
And it'll be YAML files on disk so it'll be simpler to supply such structured 
config (and still possible to provide config on the command-line).
I was literally going to send the design doc out today: 
http://tinyurl.com/clangd-config

This would replace most of our separate "user-pref"-like command-line flags 
(deprecate and maybe eventually remove).
As such I'm not sure introducing another one for fairly deep config is a good 
idea.

On the other hand, the scope for the config would be deliberately small for the 
LLVM 11 release, so we'd probably want to add clang-tidy config after the 
branch in a month, delaying it for one release cycle. How pressing is this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81975



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


[PATCH] D81953: [clang-tidy] warnings-as-error no longer exits with ErrorCount

2020-06-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D81953#2096635 , @njames93 wrote:

> In D81953#2096388 , @aaron.ballman 
> wrote:
>
> > LGTM unless @jroelofs has a reason why the code was originally written that 
> > way, but can you add test coverage for it?
>
>
> How would you suggest I add test coverage for this, afaik llvm-lit doesn't 
> seem to handle checking specific exit codes, only whether is was 0 or not. 
>  There are already test cases for a non-zero exit code with 
> `-warnings-as-errors`.


If lit doesn't provide a way to do this, I don't insist. I was thinking you'd 
have a way to use the lit shell to compare against the return value since it 
had the ability to test against nonzero or not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81953



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


[clang] 0bdcd95 - [SYCL][OpenMP] Implement thread-local storage restriction

2020-06-17 Thread Alexey Bader via cfe-commits

Author: Mariya Podchishchaeva
Date: 2020-06-17T14:36:00+03:00
New Revision: 0bdcd95bf20f159a2512aff1ef032bec52039bf6

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

LOG: [SYCL][OpenMP] Implement thread-local storage restriction

Summary:
SYCL and OpenMP prohibits thread local storage in device code,
so this commit ensures that error is emitted for device code and not
emitted for host code when host target supports it.

Reviewers: jdoerfert, erichkeane, bader

Reviewed By: jdoerfert, erichkeane

Subscribers: guansong, riccibruno, ABataev, yaxunl, ebevhan, Anastasia, 
sstefan1, cfe-commits

Tags: #clang

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

Added: 
clang/test/OpenMP/nvptx_prohibit_thread_local.cpp
clang/test/SemaSYCL/prohibit-thread-local.cpp

Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/OpenMP/nvptx_target_codegen.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 2bf16d138d5a..80469e3bedbe 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -7077,7 +7077,8 @@ NamedDecl *Sema::ActOnVariableDeclarator(
diag::err_thread_non_global)
 << DeclSpec::getSpecifierName(TSCS);
 else if (!Context.getTargetInfo().isTLSSupported()) {
-  if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) {
+  if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice ||
+  getLangOpts().SYCLIsDevice) {
 // Postpone error emission until we've collected attributes required to
 // figure out whether it's a host or device variable and whether the
 // error should be ignored.
@@ -7179,13 +7180,18 @@ NamedDecl *Sema::ActOnVariableDeclarator(
   // Handle attributes prior to checking for duplicates in MergeVarDecl
   ProcessDeclAttributes(S, NewVD, D);
 
-  if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) {
+  if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice ||
+  getLangOpts().SYCLIsDevice) {
 if (EmitTLSUnsupportedError &&
 ((getLangOpts().CUDA && DeclAttrsMatchCUDAMode(getLangOpts(), NewVD)) 
||
  (getLangOpts().OpenMPIsDevice &&
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(NewVD
   Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(),
diag::err_thread_unsupported);
+
+if (EmitTLSUnsupportedError &&
+(LangOpts.SYCLIsDevice || (LangOpts.OpenMP && 
LangOpts.OpenMPIsDevice)))
+  targetDiag(D.getIdentifierLoc(), diag::err_thread_unsupported);
 // CUDA B.2.5: "__shared__ and __constant__ variables have implied static
 // storage [duration]."
 if (SC == SC_None && S->getFnParent() != nullptr &&

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 66a2ec1fe9dc..ffc72140dcf4 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -355,10 +355,16 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, 
ArrayRef Locs,
 
   diagnoseUseOfInternalDeclInInlineFunction(*this, D, Loc);
 
-  if (LangOpts.SYCLIsDevice || (LangOpts.OpenMP && LangOpts.OpenMPIsDevice))
+  if (LangOpts.SYCLIsDevice || (LangOpts.OpenMP && LangOpts.OpenMPIsDevice)) {
 if (const auto *VD = dyn_cast(D))
   checkDeviceDecl(VD, Loc);
 
+if (!Context.getTargetInfo().isTLSSupported())
+  if (const auto *VD = dyn_cast(D))
+if (VD->getTLSKind() != VarDecl::TLS_None)
+  targetDiag(*Locs.begin(), diag::err_thread_unsupported);
+  }
+
   if (isa(D) && isa(D->getDeclContext()) &&
   !isUnevaluatedContext()) {
 // C++ [expr.prim.req.nested] p3

diff  --git a/clang/test/OpenMP/nvptx_prohibit_thread_local.cpp 
b/clang/test/OpenMP/nvptx_prohibit_thread_local.cpp
new file mode 100644
index ..b84918e528cb
--- /dev/null
+++ b/clang/test/OpenMP/nvptx_prohibit_thread_local.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-linux 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-aux-triple x86_64-unknown-linux -fopenmp-targets=nvptx64-nvidia-cuda %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -fsyntax-only
+
+thread_local const int prohobit_ns_scope = 0;
+thread_local int prohobit_ns_scope2 = 0;
+thread_local const int allow_ns_scope = 0;
+
+struct S {
+  static const thread_local int prohibit_static_member;
+  static thread_local int prohibit_static_member2;
+};
+
+struct T {
+  static const thread_local int allow_static_member;
+};
+
+void foo() {
+  // expected-error@+1{{thread-local storage is not supported for the current 
target}}
+  thread_local const int prohibit_local = 0;
+  // expected-error@+1{{thread-local storage is not supported for t

[PATCH] D82004: [clang-tidy][NFC] Remove the double look-up on IncludeInserter

2020-06-17 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: klimek, gribozavr2, aaron.ballman, alexfh.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

Refactor out the double lookup in `IncludeInserter` when trying to get the 
`IncludeSorter` for a specified `FileID`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82004

Files:
  clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
  clang-tools-extra/clang-tidy/utils/IncludeInserter.h


Index: clang-tools-extra/clang-tidy/utils/IncludeInserter.h
===
--- clang-tools-extra/clang-tidy/utils/IncludeInserter.h
+++ clang-tools-extra/clang-tidy/utils/IncludeInserter.h
@@ -71,6 +71,8 @@
   void AddInclude(StringRef FileName, bool IsAngled,
   SourceLocation HashLocation, SourceLocation EndLocation);
 
+  IncludeSorter &getOrCreate(FileID File);
+
   llvm::DenseMap> IncludeSorterByFile;
   llvm::DenseMap> InsertedHeaders;
   const SourceManager &SourceMgr;
Index: clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
===
--- clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
+++ clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "IncludeInserter.h"
+#include "IncludeSorter.h"
 #include "clang/Lex/Token.h"
 
 namespace clang {
@@ -45,6 +46,19 @@
   return std::make_unique(this);
 }
 
+IncludeSorter &IncludeInserter::getOrCreate(FileID FileID) {
+  // std::unique_ptr is cheap to construct, so force a construction now to save
+  // the lookup needed if we were to insert into the map.
+  std::unique_ptr &Entry = IncludeSorterByFile[FileID];
+  if (!Entry) {
+// If it wasn't found, Entry will be default constructed to nullptr.
+Entry = std::make_unique(
+&SourceMgr, &LangOpts, FileID,
+SourceMgr.getFilename(SourceMgr.getLocForStartOfFile(FileID)), Style);
+  }
+  return *Entry;
+}
+
 llvm::Optional
 IncludeInserter::CreateIncludeInsertion(FileID FileID, StringRef Header,
 bool IsAngled) {
@@ -53,31 +67,14 @@
   if (!InsertedHeaders[FileID].insert(std::string(Header)).second)
 return llvm::None;
 
-  if (IncludeSorterByFile.find(FileID) == IncludeSorterByFile.end()) {
-// This may happen if there have been no preprocessor directives in this
-// file.
-IncludeSorterByFile.insert(std::make_pair(
-FileID,
-std::make_unique(
-&SourceMgr, &LangOpts, FileID,
-SourceMgr.getFilename(SourceMgr.getLocForStartOfFile(FileID)),
-Style)));
-  }
-  return IncludeSorterByFile[FileID]->CreateIncludeInsertion(Header, IsAngled);
+  return getOrCreate(FileID).CreateIncludeInsertion(Header, IsAngled);
 }
 
 void IncludeInserter::AddInclude(StringRef FileName, bool IsAngled,
  SourceLocation HashLocation,
  SourceLocation EndLocation) {
   FileID FileID = SourceMgr.getFileID(HashLocation);
-  if (IncludeSorterByFile.find(FileID) == IncludeSorterByFile.end()) {
-IncludeSorterByFile.insert(std::make_pair(
-FileID, std::make_unique(
-&SourceMgr, &LangOpts, FileID,
-SourceMgr.getFilename(HashLocation), Style)));
-  }
-  IncludeSorterByFile[FileID]->AddInclude(FileName, IsAngled, HashLocation,
-  EndLocation);
+  getOrCreate(FileID).AddInclude(FileName, IsAngled, HashLocation, 
EndLocation);
 }
 
 } // namespace utils


Index: clang-tools-extra/clang-tidy/utils/IncludeInserter.h
===
--- clang-tools-extra/clang-tidy/utils/IncludeInserter.h
+++ clang-tools-extra/clang-tidy/utils/IncludeInserter.h
@@ -71,6 +71,8 @@
   void AddInclude(StringRef FileName, bool IsAngled,
   SourceLocation HashLocation, SourceLocation EndLocation);
 
+  IncludeSorter &getOrCreate(FileID File);
+
   llvm::DenseMap> IncludeSorterByFile;
   llvm::DenseMap> InsertedHeaders;
   const SourceManager &SourceMgr;
Index: clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
===
--- clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
+++ clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "IncludeInserter.h"
+#include "IncludeSorter.h"
 #include "clang/Lex/Token.h"
 
 namespace clang {
@@ -45,6 +46,19 @@
   return std::make_unique(this);
 }
 
+IncludeSorter &IncludeInserter::getOrCreate(FileID FileID) {
+  // std::unique_ptr is cheap to construct, so force a construction now to save
+  // the lookup needed if we were to insert into the map.
+  std::unique_ptr &Entry = IncludeSorter

[PATCH] D81478: [OPENMP50]Codegen for scan directives in parallel for regions.

2020-06-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked an inline comment as done.
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:3627
+  emitScanBasedDirective(CGF, S, NumIteratorsGen, FirstGen, SecondGen);
+} else {
+  OMPCancelStackRAII CancelRegion(CGF, OMPD_parallel_for, S.hasCancel());

jdoerfert wrote:
> ABataev wrote:
> > jdoerfert wrote:
> > > This looks pretty much like D81658, right? Could we avoid the duplication 
> > > and maybe use a templated function (or something else)?
> > The duplication is quite small. Here we don't need to check for 
> > lastprivates update, we need to check for the cancellation region. I don't 
> > think that the outlined functions are going to be much simpler and easier 
> > to read.
> I mean, these ~25 lines will exist 3 times at least. 2 times tacking 
> lastprivate, which we can do for the third time at no extra cost, and 2 times 
> with the cancelation RAII. Any change will need to be duplicated 3 times as 
> well, etc.
> 
> If we do
> ```
> template
> void emitWorksharingHelper(..., bool &HasLastprivate)
> if (llvm::any_of(S.getClausesOfKind(),
>  [](const OMPReductionClause *C) {
>return C->getModifier() == OMPC_REDUCTION_inscan;
>  })) {
>   const auto &&NumIteratorsGen = [&S](CodeGenFunction &CGF) {
> OMPLocalDeclMapRAII Scope(CGF);
> OMPLoopScope LoopScope(CGF, S);
> return CGF.EmitScalarExpr(S.getNumIterations());
>   };
>   const auto &&FirstGen = [&S](CodeGenFunction &CGF) {
> RAII CancelRegion(CGF, OMPD_for, S.hasCancel());
> (void)CGF.EmitOMPWorksharingLoop(S, S.getEnsureUpperBound(),
>  emitForLoopBounds,
>  emitDispatchForLoopBounds);
> // Emit an implicit barrier at the end.
> CGF.CGM.getOpenMPRuntime().emitBarrierCall(CGF, S.getBeginLoc(),
>OMPD_for);
>   };
>   const auto &&SecondGen = [&S, &HasLastprivate](CodeGenFunction &CGF) {
> RAII CancelRegion(CGF, OMPD_for, S.hasCancel());
> HasLastprivate = CGF.EmitOMPWorksharingLoop(S, 
> S.getEnsureUpperBound(),
>  emitForLoopBounds,
>  emitDispatchForLoopBounds);
>   };
>   emitScanBasedDirective(CGF, S, NumIteratorsGen, FirstGen, SecondGen);
> } else {
>   OMPCancelStackRAII CancelRegion(CGF, OMPD_parallel_for, S.hasCancel());
> CGF.EmitOMPWorksharingLoop(S, S.getEnsureUpperBound(), 
> emitForLoopBounds,
>emitDispatchForLoopBounds);
> }
> ```
> We can call it three times:
> ```
> emitWorksharingHelper(...);
> emitWorksharingHelper(...);
> emitWorksharingHelper(...);
> ```
> 
> Wouldn't that be cleaner?
1. It requires the new `OMPDummyRAII` class.
2. Thу functionality under control of the `else` branch also must be affected.
3. We don't always need to check for `HasLastprivate`.
4. The `NumIteratorsGen` might be different.
5. We'll have a lot of trouble with adding new functionality to this function, 
especially if this functionality is unique for one construct and not required 
for others.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81478



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


[PATCH] D81718: [Analyzer][NFC] Add methods `getReturnObject()` and `getArgObject()` to `CallEvent`

2020-06-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> These functions are not called at all by your tests!

Of course they aren't. Because they're dead code. You just introduced them and 
haven't called them yet.

But that code is taken and re-used from the checker. And the code in the 
checker has the problem. And after you tweaked the code a bit they still have 
that problem. And i'm pointing out the problem. And you //don't// want me to 
stop pointing out problems.

>> zero test coverage to demonstrate correctness of your solution.
> 
> Zero test coverage? Then what are the unit tests?

Unittests do not demonstrate correctness of the overall solution; that's what 
integration tests do. Unittests only demonstrate that the specific API behaves 
as expected. I'm questioning the expected behavior.

> I am really sorry to tell that, but now I began adding support for raw 
> pointers as iterators (I will upload them in a separate patch when fully 
> ready) and then tried your test. It passes, the error is found using this 
> particular patch.

This particular patch is NFC. It could not have helped. Sigh.


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

https://reviews.llvm.org/D81718



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


[PATCH] D81641: [SYCL][OpenMP] Implement thread-local storage restriction

2020-06-17 Thread Alexey Bader via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0bdcd95bf20f: [SYCL][OpenMP] Implement thread-local storage 
restriction (authored by Fznamznon, committed by bader).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81641

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/OpenMP/nvptx_prohibit_thread_local.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/SemaSYCL/prohibit-thread-local.cpp

Index: clang/test/SemaSYCL/prohibit-thread-local.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/prohibit-thread-local.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64 -verify -fsyntax-only %s
+
+thread_local const int prohobit_ns_scope = 0;
+thread_local int prohobit_ns_scope2 = 0;
+thread_local const int allow_ns_scope = 0;
+
+struct S {
+  static const thread_local int prohibit_static_member;
+  static thread_local int prohibit_static_member2;
+};
+
+struct T {
+  static const thread_local int allow_static_member;
+};
+
+void foo() {
+  // expected-error@+1{{thread-local storage is not supported for the current target}}
+  thread_local const int prohibit_local = 0;
+  // expected-error@+1{{thread-local storage is not supported for the current target}}
+  thread_local int prohibit_local2;
+}
+
+void bar() { thread_local int allow_local; }
+
+void usage() {
+  // expected-note@+1 {{called by}}
+  foo();
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)prohobit_ns_scope;
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)prohobit_ns_scope2;
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)S::prohibit_static_member;
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)S::prohibit_static_member2;
+}
+
+template 
+__attribute__((sycl_kernel))
+// expected-note@+2 2{{called by}}
+void
+kernel_single_task(Func kernelFunc) { kernelFunc(); }
+
+int main() {
+  // expected-note@+1 2{{called by}}
+  kernel_single_task([]() { usage(); });
+  return 0;
+}
Index: clang/test/OpenMP/nvptx_target_codegen.cpp
===
--- clang/test/OpenMP/nvptx_target_codegen.cpp
+++ clang/test/OpenMP/nvptx_target_codegen.cpp
@@ -160,7 +160,7 @@
 // CHECK: [[EXIT]]
 // CHECK: ret void
 
-// CHECK: define {{.*}}void [[T2:@__omp_offloading_.+foo.+l200]](i[[SZ:32|64]] [[ARG1:%[a-zA-Z_]+]], i[[SZ:32|64]] [[ID:%[a-zA-Z_]+]])
+// CHECK: define {{.*}}void [[T2:@__omp_offloading_.+foo.+l200]](i[[SZ:32|64]] [[ARG1:%[a-zA-Z_]+]])
 // CHECK: [[AA_ADDR:%.+]] = alloca i[[SZ]],
 // CHECK: store i[[SZ]] [[ARG1]], i[[SZ]]* [[AA_ADDR]],
 // CHECK: [[AA_CADDR:%.+]] = bitcast i[[SZ]]* [[AA_ADDR]] to i16*
@@ -200,7 +200,7 @@
 #pragma omp target if (1)
   {
 aa += 1;
-id = aa;
+aa += 2;
   }
 
 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+foo.+l310}}_worker()
Index: clang/test/OpenMP/nvptx_prohibit_thread_local.cpp
===
--- /dev/null
+++ clang/test/OpenMP/nvptx_prohibit_thread_local.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-linux -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -aux-triple x86_64-unknown-linux -fopenmp-targets=nvptx64-nvidia-cuda %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -fsyntax-only
+
+thread_local const int prohobit_ns_scope = 0;
+thread_local int prohobit_ns_scope2 = 0;
+thread_local const int allow_ns_scope = 0;
+
+struct S {
+  static const thread_local int prohibit_static_member;
+  static thread_local int prohibit_static_member2;
+};
+
+struct T {
+  static const thread_local int allow_static_member;
+};
+
+void foo() {
+  // expected-error@+1{{thread-local storage is not supported for the current target}}
+  thread_local const int prohibit_local = 0;
+  // expected-error@+1{{thread-local storage is not supported for the current target}}
+  thread_local int prohibit_local2;
+}
+
+void bar() { thread_local int allow_local; }
+
+void usage() {
+  // expected-note@+1 {{called by}}
+  foo();
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)prohobit_ns_scope;
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)prohobit_ns_scope2;
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)S::prohibit_static_member;
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)S::prohibit_static_member2;
+}
+
+int main() {
+  // expected-note@+2 2{{calle

[PATCH] D81975: [clangd] Add command line option for ClangTidyConfig

2020-06-17 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Gotta say it's not hugely pressing.
The reason for it is clangd lets you specify some checks to run but it doesn't 
let you specify the options for those checks. Effectively forcing each project 
to require a .clang-tidy configuration file if you want to use checks where you 
require some configuration.
This isn't an issue on large scale established projects, but when starting out 
on small scale projects, it would be nice if clangd(tidy) was already set up 
how you like it without going through the need of setting up a `.clang-tidy` 
file.
Once D81949  lands it will also be useful on 
large scale projects that enforce certain tidy checks, but locally a developer 
may want extra configurable checks running in their editor.

Having said all of that your proposal does appear to do what this patch aims 
just in a much more user friendly way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81975



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


[clang-tools-extra] df9a51d - Remove global std::strings. NFCI.

2020-06-17 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2020-06-17T14:29:42+02:00
New Revision: df9a51dab3512f61d7f26c16fd1358bf99c266e1

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

LOG: Remove global std::strings. NFCI.

Added: 


Modified: 
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
clang-tools-extra/clangd/index/remote/server/Server.cpp
llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
llvm/lib/Target/BPF/BPFCORE.h
llvm/lib/Target/BPF/BPFPreserveDIType.cpp
llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp 
b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
index a784fe47ccb4..3e25da385d7a 100644
--- a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -32,7 +32,7 @@ llvm::cl::opt IndexLocation(
 llvm::cl::opt
 ExecCommand("c", llvm::cl::desc("Command to execute and then exit"));
 
-static const std::string Overview = R"(
+static constexpr char Overview[] = R"(
 This is an **experimental** interactive tool to process user-provided search
 queries over given symbol collection obtained via clangd-indexer. The
 tool can be used to evaluate search quality of existing index implementations

diff  --git a/clang-tools-extra/clangd/index/remote/server/Server.cpp 
b/clang-tools-extra/clangd/index/remote/server/Server.cpp
index 871affe6c47c..4d84eb17210e 100644
--- a/clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ b/clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -23,7 +23,7 @@ namespace clangd {
 namespace remote {
 namespace {
 
-static const std::string Overview = R"(
+static constexpr char Overview[] = R"(
 This is an experimental remote index implementation. The server opens Dex and
 awaits gRPC lookup requests from the client.
 )";

diff  --git a/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp 
b/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
index 0e943aa07a3b..b213b1579661 100644
--- a/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
+++ b/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
@@ -92,7 +92,7 @@
 #define DEBUG_TYPE "bpf-abstract-member-access"
 
 namespace llvm {
-const std::string BPFCoreSharedInfo::AmaAttr = "btf_ama";
+constexpr StringRef BPFCoreSharedInfo::AmaAttr;
 } // namespace llvm
 
 using namespace llvm;

diff  --git a/llvm/lib/Target/BPF/BPFCORE.h b/llvm/lib/Target/BPF/BPFCORE.h
index f29c879518ab..af6425b16fa0 100644
--- a/llvm/lib/Target/BPF/BPFCORE.h
+++ b/llvm/lib/Target/BPF/BPFCORE.h
@@ -9,6 +9,8 @@
 #ifndef LLVM_LIB_TARGET_BPF_BPFCORE_H
 #define LLVM_LIB_TARGET_BPF_BPFCORE_H
 
+#include "llvm/ADT/StringRef.h"
+
 namespace llvm {
 
 class BPFCoreSharedInfo {
@@ -34,9 +36,9 @@ class BPFCoreSharedInfo {
   };
 
   /// The attribute attached to globals representing a field access
-  static const std::string AmaAttr;
+  static constexpr StringRef AmaAttr = "btf_ama";
   /// The attribute attached to globals representing a type id
-  static const std::string TypeIdAttr;
+  static constexpr StringRef TypeIdAttr = "btf_type_id";
 };
 
 } // namespace llvm

diff  --git a/llvm/lib/Target/BPF/BPFPreserveDIType.cpp 
b/llvm/lib/Target/BPF/BPFPreserveDIType.cpp
index a3f30beda6cd..c3cb7647aa79 100644
--- a/llvm/lib/Target/BPF/BPFPreserveDIType.cpp
+++ b/llvm/lib/Target/BPF/BPFPreserveDIType.cpp
@@ -26,7 +26,7 @@
 #define DEBUG_TYPE "bpf-preserve-di-type"
 
 namespace llvm {
-const std::string BPFCoreSharedInfo::TypeIdAttr = "btf_type_id";
+constexpr StringRef BPFCoreSharedInfo::TypeIdAttr;
 } // namespace llvm
 
 using namespace llvm;

diff  --git a/llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp 
b/llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
index fe2706117453..a7546d2be5d8 100644
--- a/llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
+++ b/llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
@@ -244,10 +244,10 @@ INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
 INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass)
 INITIALIZE_PASS_END(PPCLoopInstrFormPrep, DEBUG_TYPE, name, false, false)
 
-static const std::string PHINodeNameSuffix= ".phi";
-static const std::string CastNodeNameSuffix   = ".cast";
-static const std::string GEPNodeIncNameSuffix = ".inc";
-static const std::string GEPNodeOffNameSuffix = ".off";
+static constexpr StringRef PHINodeNameSuffix= ".phi";
+static constexpr StringRef CastNodeNameSuffix   = ".cast";
+static constexpr StringRef GEPNodeIncNameSuffix = ".inc";
+static constexpr StringRef GEPNodeOffNameSuffix = ".off";
 
 FunctionPass *llvm::createPPCLoopInstrFormPrepPass(PPCTargetMachine &TM) {
   return new PPCLoopInstrFormPrep(TM);
@@ -263,7 +263,7 @@ static bool IsPtrInBounds(Value *BasePtr) {
   return false;
 }
 
-static std::string getInstrName(const Value *I, const 

[clang] 34ee254 - [OPENMP50]Codegen for scan directive in for simd regions.

2020-06-17 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-06-17T08:43:17-04:00
New Revision: 34ee2549a72c2947fb3f6677fbe8ad97da100011

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

LOG: [OPENMP50]Codegen for scan directive in for simd regions.

Summary:
Added codegen for scan directives in parallel for regions.

Emits the code for the directive with inscan reductions.
Original code:
```
 #pragma omp for simd reduction(inscan, op : ...)
for(...) {
  ;
  #pragma omp scan (in)exclusive(...)
  
}
```
is transformed to something:
```
size num_iters = ;
 buffer[num_iters];
 #pragma omp for simd
for (i: 0..) {
  ;
  buffer[i] = red;
}
 #pragma omp barrier
for (int k = 0; k != ceil(log2(num_iters)); ++k)
for (size cnt = last_iter; cnt >= pow(2, k); --k)
  buffer[i] op= buffer[i-pow(2,k)];
 #pragma omp for simd
for (0..) {
  red = InclusiveScan ? buffer[i] : buffer[i-1];
  ;
}
```

Reviewers: jdoerfert

Reviewed By: jdoerfert

Subscribers: yaxunl, guansong, sstefan1, cfe-commits, caomhin

Tags: #clang

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

Added: 
clang/test/OpenMP/for_simd_scan_codegen.cpp

Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 5b05577543fc..e17bc184c93a 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1732,11 +1732,8 @@ void CodeGenFunction::EmitOMPLoopBody(const 
OMPLoopDirective &D,
 OMPAfterScanBlock = createBasicBlock("omp.after.scan.bb");
 // No need to allocate inscan exit block, in simd mode it is selected in 
the
 // codegen for the scan directive.
-if (D.getDirectiveKind() != OMPD_simd &&
-(!getLangOpts().OpenMPSimd ||
- isOpenMPSimdDirective(D.getDirectiveKind( {
+if (D.getDirectiveKind() != OMPD_simd && !getLangOpts().OpenMPSimd)
   OMPScanExitBlock = createBasicBlock("omp.exit.inscan.bb");
-}
 OMPScanDispatch = createBasicBlock("omp.inscan.dispatch");
 EmitBranch(OMPScanDispatch);
 EmitBlock(OMPBeforeScanBlock);
@@ -3261,9 +3258,34 @@ void CodeGenFunction::EmitOMPForSimdDirective(const 
OMPForSimdDirective &S) {
   bool HasLastprivates = false;
   auto &&CodeGen = [&S, &HasLastprivates](CodeGenFunction &CGF,
   PrePostActionTy &) {
-HasLastprivates = CGF.EmitOMPWorksharingLoop(S, S.getEnsureUpperBound(),
- emitForLoopBounds,
- emitDispatchForLoopBounds);
+if (llvm::any_of(S.getClausesOfKind(),
+ [](const OMPReductionClause *C) {
+   return C->getModifier() == OMPC_REDUCTION_inscan;
+ })) {
+  const auto &&NumIteratorsGen = [&S](CodeGenFunction &CGF) {
+OMPLocalDeclMapRAII Scope(CGF);
+OMPLoopScope LoopScope(CGF, S);
+return CGF.EmitScalarExpr(S.getNumIterations());
+  };
+  const auto &&FirstGen = [&S](CodeGenFunction &CGF) {
+(void)CGF.EmitOMPWorksharingLoop(S, S.getEnsureUpperBound(),
+ emitForLoopBounds,
+ emitDispatchForLoopBounds);
+// Emit an implicit barrier at the end.
+CGF.CGM.getOpenMPRuntime().emitBarrierCall(CGF, S.getBeginLoc(),
+   OMPD_for);
+  };
+  const auto &&SecondGen = [&S, &HasLastprivates](CodeGenFunction &CGF) {
+HasLastprivates = CGF.EmitOMPWorksharingLoop(S, 
S.getEnsureUpperBound(),
+ emitForLoopBounds,
+ 
emitDispatchForLoopBounds);
+  };
+  emitScanBasedDirective(CGF, S, NumIteratorsGen, FirstGen, SecondGen);
+} else {
+  HasLastprivates = CGF.EmitOMPWorksharingLoop(S, S.getEnsureUpperBound(),
+   emitForLoopBounds,
+   emitDispatchForLoopBounds);
+}
   };
   {
 auto LPCRegion =

diff  --git a/clang/test/OpenMP/for_simd_scan_codegen.cpp 
b/clang/test/OpenMP/for_simd_scan_codegen.cpp
new file mode 100644
index ..2c7f53a0aa36
--- /dev/null
+++ b/clang/test/OpenMP/for_simd_scan_codegen.cpp
@@ -0,0 +1,312 @@
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -x c++ -triple 
x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -std=c++11 -triple 
x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple 
x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | 
FileCheck %

[PATCH] D82002: [clangd] Drop FS usage in ClangTidyOpts

2020-06-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 271342.
kadircet added a comment.

- Accept an inner opt provider instead to enable wrapping other types of 
providers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82002

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

Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -15,6 +15,7 @@
 #include "index/Background.h"
 #include "index/Serialization.h"
 #include "refactor/Rename.h"
+#include "support/FSProvider.h"
 #include "support/Path.h"
 #include "support/Shutdown.h"
 #include "support/Trace.h"
@@ -472,6 +473,57 @@
 const char TestScheme::TestDir[] = "/clangd-test";
 #endif
 
+// A thread-safe options provider suitable for use by ClangdServer. It also
+// provides some default checks if user has specified none.
+class ClangdTidyOptionsProvider : public clang::tidy::ClangTidyOptionsProvider {
+public:
+  ClangdTidyOptionsProvider(
+  std::unique_ptr Inner)
+  : Inner(std::move(Inner)) {
+assert(this->Inner);
+  }
+
+  std::vector getRawOptions(llvm::StringRef FileName) override {
+std::vector Sources;
+{
+  std::lock_guard Lock(Mu);
+  Sources = Inner->getRawOptions(FileName);
+}
+// If the user hasn't configured clang-tidy checks at all, including via
+// .clang-tidy, give them a nice set of checks.
+// (This should be what the "default" options does, but it isn't...)
+bool HasChecks = false;
+for (const auto &Source : Sources)
+  HasChecks |= Source.first.Checks.hasValue();
+if (!HasChecks)
+  Sources.push_back(DefaultClangdSource);
+return Sources;
+  }
+
+  const tidy::ClangTidyGlobalOptions &getGlobalOptions() override {
+std::lock_guard Lock(Mu);
+return Inner->getGlobalOptions();
+  }
+
+private:
+  std::mutex Mu;
+  std::unique_ptr Inner;
+  const OptionsSource DefaultClangdSource = []() -> OptionsSource {
+tidy::ClangTidyOptions Opts;
+// These default checks are chosen for:
+//  - low false-positive rate
+//  - providing a lot of value
+//  - being reasonably efficient
+Opts.Checks = llvm::join_items(
+",", "readability-misleading-indentation",
+"readability-deleted-default", "bugprone-integer-division",
+"bugprone-sizeof-expression", "bugprone-suspicious-missing-comma",
+"bugprone-unused-raii", "bugprone-unused-return-value",
+"misc-unused-using-decls", "misc-unused-alias-decls",
+"misc-definitions-in-headers");
+return {Opts, "-clangd-opts"};
+  }();
+};
 } // namespace
 } // namespace clangd
 } // namespace clang
@@ -705,49 +757,20 @@
 TransportLayer = createPathMappingTransport(std::move(TransportLayer),
 std::move(*Mappings));
   }
-  // Create an empty clang-tidy option.
-  std::mutex ClangTidyOptMu;
-  std::unique_ptr
-  ClangTidyOptProvider; /*GUARDED_BY(ClangTidyOptMu)*/
+  std::unique_ptr ClangTidyOptProvider;
   if (EnableClangTidy) {
 auto EmptyDefaults = tidy::ClangTidyOptions::getDefaults();
 EmptyDefaults.Checks.reset(); // So we can tell if checks were ever set.
 tidy::ClangTidyOptions OverrideClangTidyOptions;
 if (!ClangTidyChecks.empty())
   OverrideClangTidyOptions.Checks = ClangTidyChecks;
-ClangTidyOptProvider = std::make_unique(
-tidy::ClangTidyGlobalOptions(),
-/* Default */ EmptyDefaults,
-/* Override */ OverrideClangTidyOptions, FSProvider.view(llvm::None));
-Opts.GetClangTidyOptions = [&](llvm::vfs::FileSystem &,
-   llvm::StringRef File) {
-  // This function must be thread-safe and tidy option providers are not.
-  tidy::ClangTidyOptions Opts;
-  {
-std::lock_guard Lock(ClangTidyOptMu);
-// FIXME: use the FS provided to the function.
-Opts = ClangTidyOptProvider->getOptions(File);
-  }
-  if (!Opts.Checks) {
-// If the user hasn't configured clang-tidy checks at all, including
-// via .clang-tidy, give them a nice set of checks.
-// (This should be what the "default" options does, but it isn't...)
-//
-// These default checks are chosen for:
-//  - low false-positive rate
-//  - providing a lot of value
-//  - being reasonably efficient
-Opts.Checks = llvm::join_items(
-",", "readability-misleading-indentation",
-"readability-deleted-default", "bugprone-integer-division",
-"bugprone-sizeof-expression", "bugprone-suspicious-missing-comma",
-"bugprone-unused-raii", "bugprone-unused-return-value",
-"misc-unused-using-decls", "misc

[PATCH] D81920: [clangd] Change FSProvider::getFileSystem to take CurrentWorkingDirectory

2020-06-17 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/ClangdServer.cpp:323
+format::DefaultFallbackStyle, Code,
+FSProvider.getFileSystem(llvm::None).get());
   if (!Style)

nit: I think we should have /*CWD=*/ on the None (and elsewhere)



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:402
+  InpAST->Inputs.FSProvider
+  ->getFileSystem(InpAST->Inputs.CompileCommand.Directory)
+  .get());

seems weird that we provide a working directory sometimes but not other times 
when getting format style.
I think this is because not providing one is suspicious, it's not actually 
needed, but sometimes we have one around?

Maybe just make getFormatStyleForFile take a FSProvider instead?



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:555
   // different code layout.
   if (auto CorrespondingFile = getCorrespondingHeaderOrSource(
+  std::string(Path), FSProvider.getFileSystem(llvm::None)))

we could plumb in threadsafefs here too...



Comment at: clang-tools-extra/clangd/Preamble.cpp:424
+  auto VFS = Baseline.StatCache->getConsumingFS(
+  Modified.FSProvider->getFileSystem(Modified.CompileCommand.Directory));
   // First scan preprocessor directives in Baseline and Modified. These will be

I don't see a corresponding removed CD - is this a bugfix?



Comment at: clang-tools-extra/clangd/support/FSProvider.cpp:81
+  if (FS->setCurrentWorkingDirectory(CWD))
+elog("Failed to set CWD in RealFileSystemProvider");
+  return FS;

Nit: RealFileSystemProvider isn't the current class.

What about `elog("VFS: failed to set CWD to {0}: {1}", CWD, Err.message())`?



Comment at: clang-tools-extra/clangd/support/FSProvider.h:32
   virtual llvm::IntrusiveRefCntPtr
-  getFileSystem() const = 0;
+  getFileSystem(llvm::NoneType CWD) const = 0;
+

/// Initial working directory is arbitrary.



Comment at: clang-tools-extra/clangd/support/FSProvider.h:34
+
+  /// Similar to above one, except it will try to set curret working directory
+  /// to \p CWD.

"Similar to above one" seems a bit awkward, maybe "As above"?

curret -> current



Comment at: clang-tools-extra/clangd/support/FSProvider.h:38
+  /// StringRef conversion possible.
+  llvm::IntrusiveRefCntPtr
+  getFileSystem(PathRef CWD) const;

did you want this to be virtual so that a truly virtual FS e.g. where the 
working directory is just a variable can be constructed with it directly?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81920



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


[PATCH] D79842: [clang][Driver] Correct tool search path priority

2020-06-17 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett marked 2 inline comments as done.
DavidSpickett added inline comments.



Comment at: clang/test/Driver/program-path-priority.c:22
+/// No gccs at all, nothing is found
+// RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=NO_NOTREAL_GCC %s

MaskRay wrote:
> Nit: this may be the preference of some reviewers, but they tend to favor `| 
> \` in the end of the last line. `|` makes it clear that it has a continuation 
> line (and if you type the first line with `|`, your shell will wait for the 
> next line)
Ah now I understand. Yes that looks clearer so I've done that too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79842



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


[PATCH] D79842: [clang][Driver] Correct tool search path priority

2020-06-17 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett updated this revision to Diff 271345.
DavidSpickett added a comment.

Moved pipe (|) to end of the first lines to
make it clearer that there's a continuation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79842

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/program-path-priority.c
  clang/test/lit.cfg.py

Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -46,6 +46,8 @@
 config.substitutions.append(
 ('%src_include_dir', config.clang_src_dir + '/include'))
 
+config.substitutions.append(
+('%target_triple', config.target_triple))
 
 # Propagate path to symbolizer for ASan/MSan.
 llvm_config.with_system_environment(
Index: clang/test/Driver/program-path-priority.c
===
--- /dev/null
+++ clang/test/Driver/program-path-priority.c
@@ -0,0 +1,106 @@
+/// Don't create symlinks on Windows
+// UNSUPPORTED: system-windows
+
+/// Check the priority used when searching for tools
+/// Names and locations are usually in this order:
+/// -tool, tool, -tool
+/// program path, PATH
+/// (from highest to lowest priority)
+/// A higher priority name found in a lower priority
+/// location will win over a lower priority name in a
+/// higher priority location.
+/// Prefix dirs (added with -B) override the location,
+/// so only name priority is accounted for, unless we fail to find
+/// anything at all in the prefix.
+
+/// Copy clang to a new dir which will be its
+/// "program path" for these tests
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: ln -s %clang %t/clang
+
+/// No gccs at all, nothing is found
+// RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=NO_NOTREAL_GCC %s
+// NO_NOTREAL_GCC-NOT: notreal-none-elf-gcc
+// NO_NOTREAL_GCC-NOT: /gcc
+
+/// -gcc in program path is found
+// RUN: touch %t/notreal-none-elf-gcc && chmod +x %t/notreal-none-elf-gcc
+// RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=PROG_PATH_NOTREAL_GCC %s
+// PROG_PATH_NOTREAL_GCC: notreal-none-elf-gcc
+
+/// -gcc on the PATH is found
+// RUN: mkdir -p %t/env
+// RUN: rm %t/notreal-none-elf-gcc
+// RUN: touch %t/env/notreal-none-elf-gcc && chmod +x %t/env/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=ENV_PATH_NOTREAL_GCC %s
+// ENV_PATH_NOTREAL_GCC: env/notreal-none-elf-gcc
+
+/// -gcc in program path is preferred to one on the PATH
+// RUN: touch %t/notreal-none-elf-gcc && chmod +x %t/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=BOTH_NOTREAL_GCC %s
+// BOTH_NOTREAL_GCC: notreal-none-elf-gcc
+// BOTH_NOTREAL_GCC-NOT: env/notreal-none-elf-gcc
+
+/// On program path, -gcc is preferred to plain gcc
+// RUN: touch %t/gcc && chmod +x %t/gcc
+// RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=NOTREAL_GCC_PREFERRED %s
+// NOTREAL_GCC_PREFERRED: notreal-none-elf-gcc
+// NOTREAL_GCC_PREFERRED-NOT: /gcc
+
+/// -gcc on the PATH is preferred to gcc in program path
+// RUN: rm %t/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=NOTREAL_PATH_OVER_GCC_PROG %s
+// NOTREAL_PATH_OVER_GCC_PROG: env/notreal-none-elf-gcc
+// NOTREAL_PATH_OVER_GCC_PROG-NOT: /gcc
+
+/// -gcc on the PATH is preferred to gcc on the PATH
+// RUN: rm %t/gcc
+// RUN: touch %t/env/gcc && chmod +x %t/env/gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=NOTREAL_PATH_OVER_GCC_PATH %s
+// NOTREAL_PATH_OVER_GCC_PATH: env/notreal-none-elf-gcc
+// NOTREAL_PATH_OVER_GCC_PATH-NOT: /gcc
+
+/// -gcc has lowest priority so -gcc
+/// on PATH beats default triple in program path
+// RUN: touch %t/%target_triple-gcc && chmod +x %t/%target_triple-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=DEFAULT_TRIPLE_GCC %s
+// DEFAULT_TRIPLE_GCC: env/notreal-none-elf-gcc
+
+/// plain gcc on PATH beats default triple in program path
+// RUN: rm %t/env/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=DEFAULT_TRIPLE_NO_NOTREAL %s
+// DEFAULT_TRIPLE_NO_NOTREAL: env/gcc
+// DEFAULT_TRIPLE_NO_NOTREAL-NOT: -gcc
+
+/// default triple only chosen when no others are present
+// RUN: rm %t/env/gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=DEFAULT_TRIPLE_NO_OTHERS %s
+// DEFAULT_TRIPLE_NO_OTHERS: -gcc
+// DEFAULT_TRIPLE_NO_OTHERS

[PATCH] D81958: [clangd] Add library to semantically strip flags by name.

2020-06-17 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz added inline comments.



Comment at: clang-tools-extra/clangd/CompileCommands.cpp:256
+  case Option::RemainingArgsClass:
+return {1, 0};
+  case Option::RemainingArgsJoinedClass:

nit: could you replace 1 with some constant value with descriptive name?  
It's not immediately clear if this is some significant value (e.g. some flag 
number or something) or just, as it's the case, just a very large number.



Comment at: clang-tools-extra/clangd/CompileCommands.cpp:301
+
+// Collect sets of aliases, so we can treet -foo and -foo= as synonyms.
+// Conceptually a double-linked list: PrevAlias[I] -> I -> NextAlias[I].

typo: treet



Comment at: clang-tools-extra/clangd/CompileCommands.cpp:401
+
+  // Examine args list to determine if we're in GCC, CL-compatible, or cc1 
mode.
+  DriverMode MainMode = DM_GCC;

nit: this function is already quite long and this part seems like a re-usable 
and self-contained piece. Could we extra this into some GetDriverMode() helper?



Comment at: clang-tools-extra/clangd/CompileCommands.cpp:431
+continue; // current arg doesn't match the prefix string
+  bool PrefixMatch = Arg.size() > R.Text.size();
+  unsigned ArgCount = PrefixMatch ? R.PrefixArgs : R.ExactArgs;

Correct me if I'm wrong, but this is relying on the fact that Rules are sorted, 
right? Or, to be more specific, on the fact that -foo comes before -foobar.

Consider two rules in config file, one to remove -include, another to remove 
-include-pch, in that order. -include will do a prefix match on Arg == 
-include-pch and attempt to remove exactly one arg (-include is 
JoinedOrSeparate, which has 1 for PrefixArgs), when in reality that was 
"--include-pch foo.pch", an exact match on a different option.

So a config like:
Remove: [-include, -include-pch]
and command line:
[-include-pch, foo.pch]
should be [], but ends up being [foo.pch]

It looks like Options.inc is sorted in the correct way (include-pch will always 
be before -include). I don't know if that's guaranteed, but it looks to be the 
case. However, since you are adding these options to Rules on each strip() 
call, you end up depending on the order of strip() calls. That seems like a bug.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81958



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


[PATCH] D81967: [clang-tools-extra] Prevent linking to duplicate .a libs and dylib

2020-06-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

I'm afraid I don't really understand how this fix works, so my questions might 
be silly. Thanks for fixing things!




Comment at: clang-tools-extra/clangd/CMakeLists.txt:105
+
+clang_target_link_libraries(clangDaemon
+  PRIVATE

This has split our link dependencies in two, and I'm not really sure why (and 
so am likely to put future dependencies in the wrong place).

Can *all* the link dependencies be moved to the clang_target_link_libraries 
section?
((Even if this addresses a problem only seen with clang libs, I'd rather have 
everything in one place)



Comment at: clang-tools-extra/clangd/unittests/CMakeLists.txt:123
   clangTidy
-  LLVMSupport
   LLVMTestingSupport

why this change? We do depend directly on LLVMSupport, and I'd prefer that to 
remain explicit rather than pick it up transitively.


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

https://reviews.llvm.org/D81967



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


[PATCH] D75169: [ARM] Supporting lowering of half-precision FP arguments and returns in AArch32's backend

2020-06-17 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard accepted this revision.
ostannard added a comment.
This revision is now accepted and ready to land.

I don't think it makes sense to make `f16` legal for targets which don't have 
any arithmetic operations on it, since that would be contrary to the definition 
of "legal". I'd also expect doing so to introduce a lot more complexity than 
this patch.

I think all of the previous comments have been addressed now, and this LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75169



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


[clang-tools-extra] ccd1270 - [clang-tidy] warnings-as-error no longer exits with ErrorCount

2020-06-17 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-06-17T14:35:37+01:00
New Revision: ccd127008aa2aa0a303c9a0a48f4080a5bb7cd0b

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

LOG: [clang-tidy] warnings-as-error no longer exits with ErrorCount

When using `-warnings-as-errors`, If there are any warnings promoted to errors, 
clang-tidy exits with the number of warnings. This really isn't needed and can 
cause issues when the number of warnings doesn't fit into 8 bits as POSIX 
terminals aren't designed to handle more than that.
This addresses https://bugs.llvm.org/show_bug.cgi?id=46305.

Bug originally added in D15528

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp 
b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index aca16b0d6d81..7f668345bbb1 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -478,7 +478,7 @@ int clangTidyMain(int argc, const char **argv) {
   llvm::errs() << WErrorCount << " warning" << Plural << " treated as 
error"
<< Plural << "\n";
 }
-return WErrorCount;
+return 1;
   }
 
   if (FoundErrors) {



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


[PATCH] D81920: [clangd] Change FSProvider::getFileSystem to take CurrentWorkingDirectory

2020-06-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked 9 inline comments as done.
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:555
   // different code layout.
   if (auto CorrespondingFile = getCorrespondingHeaderOrSource(
+  std::string(Path), FSProvider.getFileSystem(llvm::None)))

sammccall wrote:
> we could plumb in threadsafefs here too...
this function is also used by tweaks (DefineOutline), and they don't have 
access to FSProvider. I would rather do that plumbing on a separate patch.



Comment at: clang-tools-extra/clangd/Preamble.cpp:424
+  auto VFS = Baseline.StatCache->getConsumingFS(
+  Modified.FSProvider->getFileSystem(Modified.CompileCommand.Directory));
   // First scan preprocessor directives in Baseline and Modified. These will be

sammccall wrote:
> I don't see a corresponding removed CD - is this a bugfix?
not really, CWD doesn't matter for preamble scanning as we only go over current 
file contents that are set explicitly.

It will actually be dropped by https://reviews.llvm.org/D81719, changing it to 
pass None here to not confuse.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81920



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


[PATCH] D81967: [clang-tools-extra] Prevent linking to duplicate .a libs and dylib

2020-06-17 Thread Michał Górny via Phabricator via cfe-commits
mgorny marked 2 inline comments as done.
mgorny added inline comments.



Comment at: clang-tools-extra/clangd/CMakeLists.txt:105
+
+clang_target_link_libraries(clangDaemon
+  PRIVATE

sammccall wrote:
> This has split our link dependencies in two, and I'm not really sure why (and 
> so am likely to put future dependencies in the wrong place).
> 
> Can *all* the link dependencies be moved to the clang_target_link_libraries 
> section?
> ((Even if this addresses a problem only seen with clang libs, I'd rather have 
> everything in one place)
No. `clang_target_link_libraries` is only for libraries that are included in 
`libclang-cpp.so`, so when the latter is built, they are replaced with it 
entirely. I'm all for improving this (e.g. to automatically replace only these 
libs that are included in clang-cpp) but I don't really have time to work on 
this beyond fixing immediate failures.



Comment at: clang-tools-extra/clangd/unittests/CMakeLists.txt:123
   clangTidy
-  LLVMSupport
   LLVMTestingSupport

sammccall wrote:
> why this change? We do depend directly on LLVMSupport, and I'd prefer that to 
> remain explicit rather than pick it up transitively.
It's already listed in `LLVM_LINK_COMPONENTS` which handles using libLLVM 
correctly. Listing it here results in another copy of LLVMSupport being linked 
in which caused the test to crash immediately on duplicate command-line options.


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

https://reviews.llvm.org/D81967



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


[PATCH] D81970: [Clang][Driver] Remove gold linker support for PS4 toolchain

2020-06-17 Thread Paul Robinson via Phabricator via cfe-commits
probinson accepted this revision.
probinson added a comment.
This revision is now accepted and ready to land.

LGTM with one inline comment.




Comment at: clang/lib/Driver/ToolChains/PS4CPU.cpp:154
   const char *Exec =
-#ifdef _WIN32
-  Args.MakeArgString(ToolChain.GetProgramPath("orbis-ld.gold"));
-#else
-  Args.MakeArgString(ToolChain.GetProgramPath("orbis-ld"));
-#endif
+  Args.MakeArgString(ToolChain.GetProgramPath(LdName.c_str()));
 

Seems like you shouldn't need a temp variable LdName here?  The old code just 
passes the literal string directly:
`Args.MakeArgString(ToolChain.GetProgramPath("orbis-ld"));`



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81970



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


[PATCH] D82002: [clangd] Drop FS usage in ClangTidyOpts

2020-06-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 271358.
kadircet added a comment.

- Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82002

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

Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -15,6 +15,7 @@
 #include "index/Background.h"
 #include "index/Serialization.h"
 #include "refactor/Rename.h"
+#include "support/FSProvider.h"
 #include "support/Path.h"
 #include "support/Shutdown.h"
 #include "support/Trace.h"
@@ -472,6 +473,57 @@
 const char TestScheme::TestDir[] = "/clangd-test";
 #endif
 
+// A thread-safe options provider suitable for use by ClangdServer. It also
+// provides some default checks if user has specified none.
+class ClangdTidyOptionsProvider : public clang::tidy::ClangTidyOptionsProvider {
+public:
+  ClangdTidyOptionsProvider(
+  std::unique_ptr Inner)
+  : Inner(std::move(Inner)) {
+assert(this->Inner);
+  }
+
+  std::vector getRawOptions(llvm::StringRef FileName) override {
+std::vector Sources;
+{
+  std::lock_guard Lock(Mu);
+  Sources = Inner->getRawOptions(FileName);
+}
+// If the user hasn't configured clang-tidy checks at all, including via
+// .clang-tidy, give them a nice set of checks.
+// (This should be what the "default" options does, but it isn't...)
+bool HasChecks = false;
+for (const auto &Source : Sources)
+  HasChecks |= Source.first.Checks.hasValue();
+if (!HasChecks)
+  Sources.push_back(DefaultClangdSource);
+return Sources;
+  }
+
+  const tidy::ClangTidyGlobalOptions &getGlobalOptions() override {
+std::lock_guard Lock(Mu);
+return Inner->getGlobalOptions();
+  }
+
+private:
+  std::mutex Mu;
+  std::unique_ptr Inner;
+  const OptionsSource DefaultClangdSource = []() -> OptionsSource {
+tidy::ClangTidyOptions Opts;
+// These default checks are chosen for:
+//  - low false-positive rate
+//  - providing a lot of value
+//  - being reasonably efficient
+Opts.Checks = llvm::join_items(
+",", "readability-misleading-indentation",
+"readability-deleted-default", "bugprone-integer-division",
+"bugprone-sizeof-expression", "bugprone-suspicious-missing-comma",
+"bugprone-unused-raii", "bugprone-unused-return-value",
+"misc-unused-using-decls", "misc-unused-alias-decls",
+"misc-definitions-in-headers");
+return {Opts, "-clangd-opts"};
+  }();
+};
 } // namespace
 } // namespace clangd
 } // namespace clang
@@ -705,50 +757,20 @@
 TransportLayer = createPathMappingTransport(std::move(TransportLayer),
 std::move(*Mappings));
   }
-  // Create an empty clang-tidy option.
-  std::mutex ClangTidyOptMu;
-  std::unique_ptr
-  ClangTidyOptProvider; /*GUARDED_BY(ClangTidyOptMu)*/
+  std::unique_ptr ClangTidyOptProvider;
   if (EnableClangTidy) {
 auto EmptyDefaults = tidy::ClangTidyOptions::getDefaults();
 EmptyDefaults.Checks.reset(); // So we can tell if checks were ever set.
 tidy::ClangTidyOptions OverrideClangTidyOptions;
 if (!ClangTidyChecks.empty())
   OverrideClangTidyOptions.Checks = ClangTidyChecks;
-ClangTidyOptProvider = std::make_unique(
-tidy::ClangTidyGlobalOptions(),
-/* Default */ EmptyDefaults,
-/* Override */ OverrideClangTidyOptions,
-FSProvider.view(/*CWD=*/llvm::None));
-Opts.GetClangTidyOptions = [&](llvm::vfs::FileSystem &,
-   llvm::StringRef File) {
-  // This function must be thread-safe and tidy option providers are not.
-  tidy::ClangTidyOptions Opts;
-  {
-std::lock_guard Lock(ClangTidyOptMu);
-// FIXME: use the FS provided to the function.
-Opts = ClangTidyOptProvider->getOptions(File);
-  }
-  if (!Opts.Checks) {
-// If the user hasn't configured clang-tidy checks at all, including
-// via .clang-tidy, give them a nice set of checks.
-// (This should be what the "default" options does, but it isn't...)
-//
-// These default checks are chosen for:
-//  - low false-positive rate
-//  - providing a lot of value
-//  - being reasonably efficient
-Opts.Checks = llvm::join_items(
-",", "readability-misleading-indentation",
-"readability-deleted-default", "bugprone-integer-division",
-"bugprone-sizeof-expression", "bugprone-suspicious-missing-comma",
-"bugprone-unused-raii", "bugprone-unused-return-value",
-"misc-unused-using-decls", "misc-unused-alias-decls",
-"misc-definitions-in-hea

[PATCH] D75229: [clang-tidy] Add signal-in-multithreaded-program check

2020-06-17 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/SignalInMultithreadedProgramCheck.h:23
+/// Finds ``signal`` function calls when the program is multithreaded. It
+/// founds a program multithreaded when it finds at least one function call
+/// of the following: ``thrd_create``, ``std::thread``, ``boost::thread``,

gamesh411 wrote:
> gamesh411 wrote:
> > founds -> finds, but I would rather reword it like this:
> > The checker considers the analyzed program multithreaded if it finds 
> Or better:
> The **check** considers ...
> as the term `checker` is used more in ClangSA, and `check` in clang-tidy.
Clang-tidy uses //check//.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D75229



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


[PATCH] D81998: [clangd][NFC] Rename FSProvider and getFileSystem

2020-06-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 271357.
kadircet added a comment.

- Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81998

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/support/FSProvider.cpp
  clang-tools-extra/clangd/support/FSProvider.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/HeadersTests.cpp
  clang-tools-extra/clangd/unittests/PreambleTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.h

Index: clang-tools-extra/clangd/unittests/TestFS.h
===
--- clang-tools-extra/clangd/unittests/TestFS.h
+++ clang-tools-extra/clangd/unittests/TestFS.h
@@ -31,17 +31,14 @@
 llvm::StringMap const &Timestamps = {});
 
 // A VFS provider that returns TestFSes containing a provided set of files.
-class MockFSProvider : public FileSystemProvider {
+class MockFSProvider : public ThreadSafeFS {
 public:
-  // Prevent name hiding caused by the overload below.
-  using FileSystemProvider::getFileSystem;
-
   IntrusiveRefCntPtr getFileSystem() const {
 return buildTestFS(Files, Timestamps);
   }
 
   IntrusiveRefCntPtr
-  getFileSystem(llvm::NoneType) const override {
+  view(llvm::NoneType) const override {
 return getFileSystem();
   }
 
Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -74,7 +74,7 @@
   std::move(CI), &BaselinePreamble->Preamble,
   llvm::MemoryBuffer::getMemBufferCopy(
   ModifiedContents.slice(0, Bounds.Size).str()),
-  PI.FSProvider->getFileSystem(PI.CompileCommand.Directory), Diags);
+  PI.FSProvider->view(PI.CompileCommand.Directory), Diags);
   PreprocessOnlyAction Action;
   if (!Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0])) {
 ADD_FAILURE() << "failed begin source file";
Index: clang-tools-extra/clangd/unittests/HeadersTests.cpp
===
--- clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -53,7 +53,7 @@
 EXPECT_TRUE(static_cast(CI));
 // The diagnostic options must be set before creating a CompilerInstance.
 CI->getDiagnosticOpts().IgnoreWarnings = true;
-auto VFS = PI.FSProvider->getFileSystem(Cmd->Directory);
+auto VFS = PI.FSProvider->view(Cmd->Directory);
 auto Clang = prepareCompilerInstance(
 std::move(CI), /*Preamble=*/nullptr,
 llvm::MemoryBuffer::getMemBuffer(FS.Files[MainFile], MainFile),
Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -272,9 +272,9 @@
 
 TEST_F(ClangdVFSTest, PropagatesContexts) {
   static Key Secret;
-  struct FSProvider : public FileSystemProvider {
+  struct FSProvider : public ThreadSafeFS {
 IntrusiveRefCntPtr
-getFileSystem(llvm::NoneType) const override {
+view(llvm::NoneType) const override {
   Got = Context::current().getExisting(Secret);
   return buildTestFS({});
 }
@@ -924,13 +924,13 @@
 // Check that running code completion doesn't stat() a bunch of files from the
 // preamble again. (They should be using the preamble's stat-cache)
 TEST(ClangdTests, PreambleVFSStatCache) {
-  class ListenStatsFSProvider : public FileSystemProvider {
+  class ListenStatsFSProvider : public ThreadSafeFS {
   public:
 ListenStatsFSProvider(llvm::StringMap &CountStats)
 : CountStats(CountStats) {}
 
 IntrusiveRefCntPtr
-getFileSystem(llvm::NoneType) const override {
+view(llvm::NoneType) const override {
   class ListenStatVFS : public llvm::vfs::ProxyFileSystem {
   public:
 ListenStatVFS(IntrusiveRefCntPtr FS,
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -719,7 +719,7 @@
 tidy::ClangTidyGlobalOptions(),
 /* Default */ EmptyDef

[PATCH] D81920: [clangd] Change FSProvider::getFileSystem to take CurrentWorkingDirectory

2020-06-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 271354.
kadircet marked an inline comment as done.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81920

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/support/FSProvider.cpp
  clang-tools-extra/clangd/support/FSProvider.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/FSTests.cpp
  clang-tools-extra/clangd/unittests/HeadersTests.cpp
  clang-tools-extra/clangd/unittests/PreambleTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.h

Index: clang-tools-extra/clangd/unittests/TestFS.h
===
--- clang-tools-extra/clangd/unittests/TestFS.h
+++ clang-tools-extra/clangd/unittests/TestFS.h
@@ -13,8 +13,11 @@
 #define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTFS_H
 #include "ClangdServer.h"
 #include "GlobalCompilationDatabase.h"
+#include "support/FSProvider.h"
 #include "support/Path.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/VirtualFileSystem.h"
 
@@ -30,10 +33,18 @@
 // A VFS provider that returns TestFSes containing a provided set of files.
 class MockFSProvider : public FileSystemProvider {
 public:
-  IntrusiveRefCntPtr getFileSystem() const override {
+  // Prevent name hiding caused by the overload below.
+  using FileSystemProvider::getFileSystem;
+
+  IntrusiveRefCntPtr getFileSystem() const {
 return buildTestFS(Files, Timestamps);
   }
 
+  IntrusiveRefCntPtr
+  getFileSystem(llvm::NoneType) const override {
+return getFileSystem();
+  }
+
   // If relative paths are used, they are resolved with testPath().
   llvm::StringMap Files;
   llvm::StringMap Timestamps;
Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -70,11 +70,11 @@
   // We don't run PP directly over the patch cotents to test production
   // behaviour.
   auto Bounds = Lexer::ComputePreamble(ModifiedContents, *CI->getLangOpts());
-  auto Clang =
-  prepareCompilerInstance(std::move(CI), &BaselinePreamble->Preamble,
-  llvm::MemoryBuffer::getMemBufferCopy(
-  ModifiedContents.slice(0, Bounds.Size).str()),
-  PI.FSProvider->getFileSystem(), Diags);
+  auto Clang = prepareCompilerInstance(
+  std::move(CI), &BaselinePreamble->Preamble,
+  llvm::MemoryBuffer::getMemBufferCopy(
+  ModifiedContents.slice(0, Bounds.Size).str()),
+  PI.FSProvider->getFileSystem(PI.CompileCommand.Directory), Diags);
   PreprocessOnlyAction Action;
   if (!Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0])) {
 ADD_FAILURE() << "failed begin source file";
Index: clang-tools-extra/clangd/unittests/HeadersTests.cpp
===
--- clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -16,6 +16,7 @@
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Lex/PreprocessorOptions.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "gmock/gmock.h"
@@ -52,8 +53,7 @@
 EXPECT_TRUE(static_cast(CI));
 // The diagnostic options must be set before creating a CompilerInstance.
 CI->getDiagnosticOpts().IgnoreWarnings = true;
-auto VFS = FS.getFileSystem();
-VFS->setCurrentWorkingDirectory(Cmd->Directory);
+auto VFS = PI.FSProvider->getFileSystem(Cmd->Directory);
 auto Clang = prepareCompilerInstance(
 std::move(CI), /*Preamble=*/nullptr,
 llvm::MemoryBuffer::getMemBuffer(FS.Files[MainFile], MainFile),
Index: clang-tools-extra/clangd/unittests/FSTests.cpp
===
--- clang-tools-extra/clangd/unittests/FSTests.cpp
+++ clang-tools-extra/clangd/unittests/FSTests.cpp
@@ -21,7 +21,6 @@
   Files["y"] = "";
   Files["main"] = "";
   auto FS = buildTestFS(Files);
-  FS->setCurrentWorkingDirectory(testRoot());
 
   PreambleFileStatusCache StatCache(testPath("main"));
   auto ProduceFS = StatCache.getProducingFS(F

[PATCH] D81098: [OpenMP] Upgrade default version of OpenMP to 5.0

2020-06-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Looks good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81098



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


[PATCH] D81958: [clangd] Add library to semantically strip flags by name.

2020-06-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/CompileCommands.cpp:263
+// Flag-parsing mode, which affects which flags are available.
+enum DriverMode : unsigned char {
+  DM_None = 0,

nit: put it into anonymous namespace to avoid potential ODR violation.



Comment at: clang-tools-extra/clangd/CompileCommands.cpp:294
+  // We compute a table containing strings to look for and #args to skip.
+  // e.g. "-x" => {-x 2 args, -x* 2 args, --language 2 args, --language=* 1 
arg}
+  using TableTy =

Is `-x* 2 args` right? it seems that `-xc++` is just 1 arg.



Comment at: clang-tools-extra/clangd/CompileCommands.cpp:329
+// Every spelling of this option will get the same set of rules.
+for (unsigned ID = 1; ID < DriverID::LastOption; ++ID) {
+  if (PrevAlias[ID] || ID == DriverID::OPT_Xclang)

nit: add a comment after 1 e.g `/*skip the OPT_INVALID*/`, explaining why not 
starting from 0.



Comment at: clang-tools-extra/clangd/CompileCommands.cpp:425
+llvm::StringRef Arg = Args[Read];
+for (const Rule &R : Rules) {
+  // Rule can fail to match if...

this loop is long and nested within a tricky while, maybe consider pulling it 
out a separate function like `getMatchedRule`.



Comment at: clang-tools-extra/clangd/CompileCommands.cpp:438
+  if (WasXclang) {
+--Write; // Drop previous -Xclang arg
+CurrentMode = MainMode;

nit: assert(Write > 0)?



Comment at: clang-tools-extra/clangd/CompileCommands.h:60
+// Args that are not recognized as flags are still removed as literal strings,
+// and strip("ABC*") will remove any arg with an ABC prefix.
+//

Is the glob `*` supported when the Arg (in `strip` API) is recognized as an 
option flag? My reading of the code implies it is not.

Maybe consider moving the above two lines to `strip` API comment, it is more 
discoverable.



Comment at: clang-tools-extra/clangd/CompileCommands.h:72
+  // Remove the targets from Args, in-place.
+  void process(std::vector &Args) const;
+

The `Args` is expected to be a standard compile command? if so, might be name 
it `CompileCommand`.



Comment at: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp:197
+}
+
+TEST(ArgStripperTest, Spellings) {

add tests for stripping the diagnostic flags, `-Wfoo` etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81958



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


[PATCH] D82011: [clangd] Don't mangle workdir-relevant driver path in compile commands

2020-06-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

We can't resolve this (if it's a symlink) without further refactoring, but the
current behaviour is just incorrect.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82011

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp


Index: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -115,7 +115,7 @@
 
   Cmd = {"foo/unknown-binary", "foo.cc"};
   Mangler.adjust(Cmd);
-  EXPECT_EQ(testPath("fake/unknown-binary"), Cmd.front());
+  EXPECT_EQ("foo/unknown-binary", Cmd.front());
 }
 
 // Only run the PATH/symlink resolving test on unix, we need to fiddle
Index: clang-tools-extra/clangd/CompileCommands.cpp
===
--- clang-tools-extra/clangd/CompileCommands.cpp
+++ clang-tools-extra/clangd/CompileCommands.cpp
@@ -135,6 +135,12 @@
   // First, eliminate relative paths.
   std::string Storage;
   if (!llvm::sys::path::is_absolute(Driver)) {
+// If it's working-dir relative like bin/clang, we can't resolve it.
+// FIXME: we could if we had the working directory here.
+// Let's hope it's not a symlink.
+if (llvm::any_of(Driver,
+ [](char C) { return llvm::sys::path::is_separator(C); }))
+  return Driver.str();
 // If the driver is a generic like "g++" with no path, add clang dir.
 if (ClangPath &&
 (Driver == "clang" || Driver == "clang++" || Driver == "gcc" ||


Index: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -115,7 +115,7 @@
 
   Cmd = {"foo/unknown-binary", "foo.cc"};
   Mangler.adjust(Cmd);
-  EXPECT_EQ(testPath("fake/unknown-binary"), Cmd.front());
+  EXPECT_EQ("foo/unknown-binary", Cmd.front());
 }
 
 // Only run the PATH/symlink resolving test on unix, we need to fiddle
Index: clang-tools-extra/clangd/CompileCommands.cpp
===
--- clang-tools-extra/clangd/CompileCommands.cpp
+++ clang-tools-extra/clangd/CompileCommands.cpp
@@ -135,6 +135,12 @@
   // First, eliminate relative paths.
   std::string Storage;
   if (!llvm::sys::path::is_absolute(Driver)) {
+// If it's working-dir relative like bin/clang, we can't resolve it.
+// FIXME: we could if we had the working directory here.
+// Let's hope it's not a symlink.
+if (llvm::any_of(Driver,
+ [](char C) { return llvm::sys::path::is_separator(C); }))
+  return Driver.str();
 // If the driver is a generic like "g++" with no path, add clang dir.
 if (ClangPath &&
 (Driver == "clang" || Driver == "clang++" || Driver == "gcc" ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81953: [clang-tidy] warnings-as-error no longer exits with ErrorCount

2020-06-17 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGccd127008aa2: [clang-tidy] warnings-as-error no longer exits 
with ErrorCount (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81953

Files:
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp


Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -478,7 +478,7 @@
   llvm::errs() << WErrorCount << " warning" << Plural << " treated as 
error"
<< Plural << "\n";
 }
-return WErrorCount;
+return 1;
   }
 
   if (FoundErrors) {


Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -478,7 +478,7 @@
   llvm::errs() << WErrorCount << " warning" << Plural << " treated as error"
<< Plural << "\n";
 }
-return WErrorCount;
+return 1;
   }
 
   if (FoundErrors) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82011: [clangd] Don't mangle workdir-relevant driver path in compile commands

2020-06-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!




Comment at: clang-tools-extra/clangd/CompileCommands.cpp:141
+// Let's hope it's not a symlink.
+if (llvm::any_of(Driver,
+ [](char C) { return llvm::sys::path::is_separator(C); }))

I believe it would be clearer if you put it below, into `else if (ClangPath)` 
part.

i.e.
```
if (Absolute ...)
  ..
// If we couldn't find program and driver is just a filename, use clang dir
// FIXME: Note that Driver can still be relative to workdir even if it doesn't 
have any path separators.
// We should pass WD into here and try to make Driver absolute.
else if(ClangPath && !hasPathSeparators(Driver))
 ...
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82011



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


[PATCH] D73543: [clang] Add support for __builtin_memcpy_inline

2020-06-17 Thread Marco Elver via Phabricator via cfe-commits
melver added inline comments.



Comment at: clang/test/Sema/builtins-memcpy-inline.c:7
+#warning defined as expected
+// expected-warning@-1 {{defined as expected}}
+#endif

It appears that the expected-warning check here is guarded by the #if as well. 
Moving it after the #endif results in a failing test.

I noticed this as I was trying to use __has_feature(__builtin_memcpy_inline), 
but it somehow does not work, even though the compiler clearly supports 
__builtin_memcpy_inline.

Any idea what's wrong with the __has_feature test?

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73543



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


[PATCH] D81720: [clangd] Change prepareCompilerInstance to take an FSProvider

2020-06-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Yay for getting rid of more VFSes passed around. Not sure about some of the 
other signature changes to prepareCompilerInstance. It seems a bit harder to 
call now.

In particular I'm not sure whether moving the preamble-stat-cache across setup 
from caller to callee is really an improvement once we modify that to wrap a 
ThreadsafeFS instead of a FS.
It's just... a reminder to use the cache, I guess? But the , nullptr, nullptr 
is annoying where we don't care about that.




Comment at: clang-tools-extra/clangd/Compiler.cpp:104
+const PreambleFileStatusCache *FSCache) {
+  assert(FSProvider && "FSProvider is null");
   assert(!CI->getPreprocessorOpts().RetainRemappedFileBuffers &&

why is this a reference if it can't be null?

(otherwise, remove the assert message - just repeats the assertion)



Comment at: clang-tools-extra/clangd/Compiler.h:78
 std::unique_ptr prepareCompilerInstance(
-std::unique_ptr, const PrecompiledPreamble *,
-std::unique_ptr MainFile,
-IntrusiveRefCntPtr, DiagnosticConsumer &);
+std::unique_ptr CI,
+std::unique_ptr Buffer, DiagnosticConsumer 
&DiagsClient,

none of the new parameter names say anything beyond repeating the types, can we 
drop them?



Comment at: clang-tools-extra/clangd/Compiler.h:79
+std::unique_ptr CI,
+std::unique_ptr Buffer, DiagnosticConsumer 
&DiagsClient,
+const tooling::CompileCommand &Cmd, const FileSystemProvider *FSProvider,

nit: grouping of parameters seems a bit confusing, preamble + mainfile together 
(in either order) was clearer I think. DiagnosticConsumer is logically an 
output param, nice to keep it at the end. Why split the FSProvider and the FS 
cache, etc.



Comment at: clang-tools-extra/clangd/Compiler.h:80
+std::unique_ptr Buffer, DiagnosticConsumer 
&DiagsClient,
+const tooling::CompileCommand &Cmd, const FileSystemProvider *FSProvider,
+const PrecompiledPreamble *Preamble,

It doesn't seem reasonable to require both CompilerInvocation and 
CompileCommand. We can pass working dir in if we must...

(CompilerInvocation actually has a working directory field, but it looks like 
it potentially changes behavior. We could consider setting it in 
buildCompilerInvocation() in future...)



Comment at: clang-tools-extra/clangd/ParsedAST.cpp:356
   llvm::Optional FixIncludes;
-  auto BuildDir = VFS->getCurrentWorkingDirectory();
-  if (Inputs.Opts.SuggestMissingIncludes && Inputs.Index &&
-  !BuildDir.getError()) {
-auto Style = getFormatStyleForFile(Filename, Inputs.Contents, VFS.get());
+  // FIXME: Why not use CompileCommand.Directory instead?
+  if (Inputs.Opts.SuggestMissingIncludes && Inputs.Index) {

you appear to have added the fixme and... also fixed it



Comment at: clang-tools-extra/clangd/index/Background.cpp:273
+  /*Preamble=*/nullptr,
+  /*FSCache=*/nullptr);
   if (!Clang)

hmm!



Comment at: clang-tools-extra/clangd/unittests/PreambleTests.cpp:78
+  Diags, PI.CompileCommand, PI.FSProvider, &BaselinePreamble->Preamble,
+  BaselinePreamble->StatCache.get());
   PreprocessOnlyAction Action;

why this change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81720



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


[PATCH] D81998: [clangd][NFC] Rename FSProvider and getFileSystem

2020-06-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/support/FSProvider.h:1
 //===--- FSProvider.h - VFS provider for ClangdServer *- 
C++-*-===//
 //

we should rename this file as well :-(



Comment at: clang-tools-extra/clangd/support/FSProvider.h:24
 // As FileSystem is not threadsafe, concurrent threads must each obtain one.
-class FileSystemProvider {
+class ThreadSafeFS {
 public:

nit: can we have ThreadsafeFS without the extra capital S? it's about as common 
(when you can't have hyphens) and easier to parse (since "safe" more clearly 
binds to "thread" rather than "fs")



Comment at: clang-tools-extra/clangd/support/FSProvider.h:27
+  virtual ~ThreadSafeFS() = default;
   /// Called by ClangdServer to obtain a vfs::FileSystem to be used for 
parsing.
   /// Context::current() will be the context passed to the clang entrypoint,

Now that we know what this abstraction is, the comment seems a bit out of place 
layering-wise.

Maybe we should say something about context-sensitivity at the **class level**, 
but probably shouldn't describe clangd's context-propagation here.

e.g.
```
Implementations may choose to depend on Context::current() e.g. to implement 
snapshot semantics. clangd will not create vfs::FileSystems for use in 
different contexts, so either ThreadsafeFS::view or the returned FS may contain 
this logic.
```

whereas here maybe just

```
Obtain a vfs::FileSystem with an arbitrary initial working directory.
```

and below

```
Obtain a vfs::FileSystem with a specified working directory.
If the working directory can't be set (e.g. doesn't exist), logs and returns 
the FS anyway.
```



Comment at: clang-tools-extra/clangd/support/FSProvider.h:42
 
-class RealFileSystemProvider : public FileSystemProvider {
+class RealFileSystemProvider : public ThreadSafeFS {
 public:

RealThreadsafeFS



Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:722
 /* Override */ OverrideClangTidyOptions,
-FSProvider.getFileSystem(/*CWD=*/llvm::None));
+FSProvider.view(/*CWD=*/llvm::None));
 Opts.GetClangTidyOptions = [&](llvm::vfs::FileSystem &,

we need a new conventional name for these variables.

Not sure if FS works, since we may have the vfs::FileSystem in the same scope. 
TFS?

Ultimately we should really get rid of any mention of FSProvider in the code, I 
don't think it's a good name for anything anymore.
Not sure if it's more/less painful to  do this in separate patches... the 
inconsistent naming will be confusing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81998



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


[PATCH] D81407: [Analyzer][StreamChecker] Add note tags for file opening.

2020-06-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:406
 
+const ExplodedNode *StreamChecker::getAcquisitionSite(const ExplodedNode *N,
+  SymbolRef StreamSym,

Ok, so this is a tiny auxiliary visitor.

I wish we could set uniqueing location post-factum from within the note tag. 
Unfortunately we can't because notes are generated after uniqueing :(

I'd like you to experiment with tracking this information as part of the state 
instead so that you didn't need to perform an additional scan. I'd be happy if 
it helps you avoid performing this additional pass.

I.e., when you're opening the file, add all the information you need for 
building your uniqueing location into the stream state (not the node though, 
just the program point or something like that). Then retrieve it in O(1) when 
you're emitting the report.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81407



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


[PATCH] D82016: [clang-format] [PR462254] fix indentation of default and break correctly in whitesmiths style

2020-06-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: krasimir, JakeMerdichAMD, curdeius, jbcoe, 
timwoj.
MyDeveloperDay added projects: clang, clang-format.

https://bugs.llvm.org/show_bug.cgi?id=46254

In ‘clang-format’, when using "BreakBeforeBraces: Whitesmiths".
In a ‘switch’ block, the ‘default’ case is always missing and indentation 
level. See below.

  switch(x)
 {
 case 0:
{
foo(x + 1);
}
 break;
  
 case 1:
{
goo(x % 42);
}
 break;
  
  default:
{
printf("the default case");
}
 break;
 }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82016

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12941,9 +12941,7 @@
"  }\n",
WhitesmithsBraceStyle);
 
-  // FIXME: the block and the break under case 2 in this test don't get indented
-  // correctly
-  /*
+  WhitesmithsBraceStyle.IndentCaseBlocks = true;
   verifyFormat("void switchTest1(int a)\n"
"  {\n"
"  switch (a)\n"
@@ -12951,35 +12949,101 @@
"case 2:\n"
"  {\n"
"  }\n"
-   "  break;\n"
+   "break;\n"
"}\n"
"  }\n",
WhitesmithsBraceStyle);
-  */
 
-  // FIXME: the block and the break under case 2 in this test don't get indented
-  // correctly
-  /*
   verifyFormat("void switchTest2(int a)\n"
"  {\n"
"  switch (a)\n"
"{\n"
-   "  case 0:\n"
+   "case 0:\n"
"break;\n"
-   "  case 1:\n"
+   "case 1:\n"
+   "  {\n"
+   "  break;\n"
+   "  }\n"
+   "case 2:\n"
+   "  {\n"
+   "  }\n"
+   "break;\n"
+   "default:\n"
+   "break;\n"
+   "}\n"
+   "  }\n",
+   WhitesmithsBraceStyle);
+
+  verifyFormat("void switchTest3(int a)\n"
+   "  {\n"
+   "  switch (a)\n"
"{\n"
+   "case 0:\n"
+   "  {\n"
+   "  foo(x);\n"
+   "  }\n"
+   "break;\n"
+   "default:\n"
+   "  {\n"
+   "  foo(1);\n"
+   "  }\n"
"break;\n"
"}\n"
-   "  case 2:\n"
+   "  }\n",
+   WhitesmithsBraceStyle);
+
+  WhitesmithsBraceStyle.IndentCaseBlocks = false;
+
+  verifyFormat("void switchTest4(int a)\n"
+   "  {\n"
+   "  switch (a)\n"
+   "{\n"
+   "case 2:\n"
"{\n"
"}\n"
"break;\n"
-   "  default:\n"
+   "}\n"
+   "  }\n",
+   WhitesmithsBraceStyle);
+
+  verifyFormat("void switchTest5(int a)\n"
+   "  {\n"
+   "  switch (a)\n"
+   "{\n"
+   "case 0:\n"
+   "break;\n"
+   "case 1:\n"
+   "{\n"
+   "foo();\n"
+   "break;\n"
+   "}\n"
+   "case 2:\n"
+   "{\n"
+   "}\n"
+   "break;\n"
+   "default:\n"
+   "break;\n"
+   "}\n"
+   "  }\n",
+   WhitesmithsBraceStyle);
+
+  verifyFormat("void switchTest6(int a)\n"
+   "  {\n"
+   "  switch (a)\n"
+   "{\n"
+   "case 0:\n"
+   "{\n"
+   "foo(x);\n"
+   "}\n"
+   "break;\n"
+   "default:\n"
+   "{\n"
+   "foo(1);\n"
+   "}\n"
"break;\n"
"}\n"
"  }\n",
WhitesmithsBraceStyle);
-  */
 
   verifyFormat("enum X\n"
"  {\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2214,8 +2214,13 @@
 parseBlock(/*MustBeDeclaration=*/false);
 if (FormatTok->Tok.is(tok::kw_break)) {
   if (Style.BraceWrapping.AfterControlStatement ==
-  FormatStyle::BWACS_Always)
+  FormatStyle::BW

[PATCH] D81407: [Analyzer][StreamChecker] Add note tags for file opening.

2020-06-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:406
 
+const ExplodedNode *StreamChecker::getAcquisitionSite(const ExplodedNode *N,
+  SymbolRef StreamSym,

NoQ wrote:
> Ok, so this is a tiny auxiliary visitor.
> 
> I wish we could set uniqueing location post-factum from within the note tag. 
> Unfortunately we can't because notes are generated after uniqueing :(
> 
> I'd like you to experiment with tracking this information as part of the 
> state instead so that you didn't need to perform an additional scan. I'd be 
> happy if it helps you avoid performing this additional pass.
> 
> I.e., when you're opening the file, add all the information you need for 
> building your uniqueing location into the stream state (not the node though, 
> just the program point or something like that). Then retrieve it in O(1) when 
> you're emitting the report.
Another thing we could try is to implement such post-processing pass globally 
for all checkers. I.e., instead of an optional uniqueing location accept an 
optional lambda that looks at a node and answers whether this node should be 
used as a uniqueing location. Then before report deduplication scan each report 
that supplies such lambda and update its uniqueing location. That'll probably 
require some work on BugReporter but that sounds like a nice way to avoid all 
the boilerplate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81407



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-17 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added inline comments.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:708
+" based on strong external symbols");
+  GlobalUniqueModuleId = GlobalUniqueModuleId.substr(1);
+}

Correct me if I'm wrong...
`GlobalUniqueModuleId` will always get “initialized" in 
`EmitCXXGlobalInitFunc`. And `EmitCXXGlobalInitFunc` will always run before 
`EmitCXXGlobalCleanUpFunc` in `CodeGenModule::Release()`. So in theory, we do 
not need to initialize it again in here. 
If we could not `assert (!GlobalUniqueModuleId.empty())` here, that tells me in 
`EmitCXXGlobalInitFunc` we effectively get an empty string after 
`GlobalUniqueModuleId = GlobalUniqueModuleId.substr(1);`. So something is not 
right?



Comment at: clang/lib/CodeGen/CodeGenModule.h:471
 
-  /// Global destructor functions and arguments that need to run on 
termination.
+  /// Global destructor functions and arguments that need to run on 
termination;
+  /// When UseSinitAndSterm is set, it instead contains sterm finalizer

Word after `;` should not be Capitalize. We should use small case, or change 
this to `.`.
I would prefer changing it to `.`.



Comment at: clang/test/CodeGen/static-init.cpp:142
+
+// CHECK: ; Function Attrs: noinline nounwind
+// CHECK: define internal void @__finalize__ZZN5test41fEvE11staticLocal() #0 {

Is checking this Attrs necessary?



Comment at: clang/test/CodeGen/static-init.cpp:157
+
+// CHECK: define void 
@__sinit8000_clang_1145401da454a7baad10bfe313c46638() #5 {
+// CHECK: entry:

I think we used to have dso_local marked on sinit and sterm function in 
previous diff. Now they are gone. What's the reason for removing them?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74166



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


[PATCH] D82002: [clangd] Drop FS usage in ClangTidyOpts

2020-06-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.h:46
-/// to allow reading tidy configs from the VFS used for parsing.
-using ClangTidyOptionsBuilder = std::function;

Hmm, I like the idea of avoiding a custom type and just reusing the standard 
one here, but:
- taking someone else's interface (which has existing implementations, some of 
the key ones being subtly non-threadsafe) and slapping "must be threadsafe" on 
it seems like a recipe for bugs
- ClangTidyOptionsProvider is a really horrible interface that exposes several 
things we don't need

anything wrong with just std::function?
It's reasonable to use a ClangTidyOptionsProvider to create them, though I'm 
not sure it actually saves anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82002



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


[PATCH] D82019: [OPENMP]Fix PR46357: Do not allow types declarations in pragmas.

2020-06-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: sstefan1, guansong, yaxunl.
Herald added a project: clang.

Compiler may erroneously treat current context in OpenMP pragmas as the
context where new type declaration/definition is allowed. But the
declartation/definition of the new types in OpenMP pragmas should not be
allowed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82019

Files:
  clang/include/clang/Parse/RAIIObjectsForParser.h
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/test/OpenMP/declare_reduction_ast_print.cpp


Index: clang/test/OpenMP/declare_reduction_ast_print.cpp
===
--- clang/test/OpenMP/declare_reduction_ast_print.cpp
+++ clang/test/OpenMP/declare_reduction_ast_print.cpp
@@ -17,7 +17,11 @@
 {
   struct A { int a; A() : a(0) {} };
   #pragma omp declare reduction(+: A : bar(omp_out, omp_in))
-};
+  #pragma omp declare reduction(-: struct A : bar(omp_out, omp_in))
+}
+// CHECK: namespace N1 {
+// CHECK: #pragma omp declare reduction (+ : N1::A : bar(omp_out, omp_in))
+// CHECK: #pragma omp declare reduction (- : struct A : bar(omp_out, omp_in))
 
 #pragma omp declare reduction(+ : int, char : omp_out *= omp_in)
 // CHECK: #pragma omp declare reduction (+ : int : omp_out *= omp_in){{$}}
Index: clang/lib/Parse/ParseOpenMP.cpp
===
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -1824,6 +1824,8 @@
 // Skip last tokens.
 skipUntilPragmaOpenMPEnd(OMPD_begin_declare_variant);
 
+ParsingOpenMPDirectiveRAII NormalScope(*this, /*Value=*/false);
+
 VariantMatchInfo VMI;
 ASTContext &ASTCtx = Actions.getASTContext();
 TI.getAsVariantMatchInfo(ASTCtx, VMI);
@@ -1921,6 +1923,7 @@
 if (!Actions.ActOnStartOpenMPDeclareTargetDirective(DTLoc))
   return DeclGroupPtrTy();
 
+ParsingOpenMPDirectiveRAII NormalScope(*this, /*Value=*/false);
 llvm::SmallVector  Decls;
 DKind = parseOpenMPDirectiveKind(*this);
 while (DKind != OMPD_end_declare_target && Tok.isNot(tok::eof) &&
@@ -2333,6 +2336,7 @@
   // FIXME: We create a bogus CompoundStmt scope to hold the contents of
   // the captured region. Code elsewhere assumes that any FunctionScopeInfo
   // should have at least one compound statement scope within it.
+  ParsingOpenMPDirectiveRAII NormalScope(*this, /*Value=*/false);
   AssociatedStmt = (Sema::CompoundScopeRAII(Actions), ParseStatement());
   AssociatedStmt = Actions.ActOnOpenMPRegionEnd(AssociatedStmt, Clauses);
 } else if (DKind == OMPD_target_update || DKind == OMPD_target_enter_data 
||
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1681,7 +1681,8 @@
 
   const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
   Sema::TagUseKind TUK;
-  if (isDefiningTypeSpecifierContext(DSC) == AllowDefiningTypeSpec::No)
+  if (isDefiningTypeSpecifierContext(DSC) == AllowDefiningTypeSpec::No ||
+  (getLangOpts().OpenMP && OpenMPDirectiveParsing))
 TUK = Sema::TUK_Reference;
   else if (Tok.is(tok::l_brace) ||
(getLangOpts().CPlusPlus && Tok.is(tok::colon)) ||
Index: clang/include/clang/Parse/RAIIObjectsForParser.h
===
--- clang/include/clang/Parse/RAIIObjectsForParser.h
+++ clang/include/clang/Parse/RAIIObjectsForParser.h
@@ -294,9 +294,9 @@
 bool OldVal;
 
   public:
-ParsingOpenMPDirectiveRAII(Parser &P)
+ParsingOpenMPDirectiveRAII(Parser &P, bool Value = true)
 : P(P), OldVal(P.OpenMPDirectiveParsing) {
-  P.OpenMPDirectiveParsing = true;
+  P.OpenMPDirectiveParsing = Value;
 }
 
 /// This can be used to restore the state early, before the dtor


Index: clang/test/OpenMP/declare_reduction_ast_print.cpp
===
--- clang/test/OpenMP/declare_reduction_ast_print.cpp
+++ clang/test/OpenMP/declare_reduction_ast_print.cpp
@@ -17,7 +17,11 @@
 {
   struct A { int a; A() : a(0) {} };
   #pragma omp declare reduction(+: A : bar(omp_out, omp_in))
-};
+  #pragma omp declare reduction(-: struct A : bar(omp_out, omp_in))
+}
+// CHECK: namespace N1 {
+// CHECK: #pragma omp declare reduction (+ : N1::A : bar(omp_out, omp_in))
+// CHECK: #pragma omp declare reduction (- : struct A : bar(omp_out, omp_in))
 
 #pragma omp declare reduction(+ : int, char : omp_out *= omp_in)
 // CHECK: #pragma omp declare reduction (+ : int : omp_out *= omp_in){{$}}
Index: clang/lib/Parse/ParseOpenMP.cpp
===
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -1824,6 +1824,8 @@
 // Skip last tokens.
   

[PATCH] D81964: [clangd] Make use of preamble bounds from the patch inside ReplayPreamble

2020-06-17 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/Preamble.cpp:220
   std::vector TextualDirectives;
+  PreambleBounds Bounds = {0, false};
 };

nit: = {} again



Comment at: clang-tools-extra/clangd/Preamble.cpp:288
   ScannedPreamble SP;
+  SP.Bounds = std::move(Bounds);
   PP.addPPCallbacks(

(we know these are trivial structs, could drop move)



Comment at: clang-tools-extra/clangd/Preamble.h:123
 
+  /// Returns preamble bounds for the current version of the file.
+  PreambleBounds preambleBounds() const { return PatchBounds; }

current -> Modified

I'd suggest calling this modifiedBounds()



Comment at: clang-tools-extra/clangd/Preamble.h:136
   std::vector PreambleIncludes;
+  PreambleBounds PatchBounds = {0, false};
 };

nit: = {} seems less confusing.

Call this ModifiedBounds (or ModifiedPreambleBounds) as well? Not obvious to me 
what it is at the moment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81964



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


[PATCH] D81395: [AST][RecoveryExpr] Preserve the invalid "undef_var" initializer.

2020-06-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

LG once the overload set is fixed




Comment at: clang/include/clang/Sema/Sema.h:3876
+llvm::function_ref Filter,
+bool RecoverUncorrectedTypos = false) {
+return CorrectDelayedTyposInExpr(ER, nullptr, RecoverUncorrectedTypos,

I think it's too confusing to have multiple overloads with different subsets of 
the parameters possible and also in different orders :-(

If there's nothing better, you could replace this with two overloads

CorrectDelayedTyposInExpr(ER, Filter)
CorrectDelayedTyposInExpr(ER, bool, Filter)



Comment at: clang/lib/Sema/SemaDecl.cpp:12014
   ExprResult Res = CorrectDelayedTyposInExpr(
-  Args[Idx], VDecl, [this, Entity, Kind](Expr *E) {
+  Args[Idx], VDecl, /*RecoverUncorrectedTypos=*/true,
+  [this, Entity, Kind](Expr *E) {

could consider splitting this change out of the refactoring (or vice versa), up 
to you



Comment at: clang/lib/Sema/SemaExprCXX.cpp:8318
+  FullExpr = CorrectDelayedTyposInExpr(FullExpr.get(), nullptr,
+   /*recoverUncorrectedTypos*/ true);
+  if (FullExpr.isInvalid())

/*RecoverUncorrectedTypos=*/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81395



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


[PATCH] D82016: [clang-format] [PR462254] fix indentation of default and break correctly in whitesmiths style

2020-06-17 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe accepted this revision.
jbcoe added a comment.
This revision is now accepted and ready to land.

Thanks for this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82016



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


[PATCH] D81912: [AST] Dump containsErrors bit for the Type.

2020-06-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/lib/AST/TextNodeDumper.cpp:205
 
+  if (T->containsErrors())
+OS << " contains-errors";

hokein wrote:
> sammccall wrote:
> > IIRC in the expr case we used a color, does that make sense here?
> yeah, in the expr we use a color, but here I don't have a strong opinion -- 
> the other dependence bits don't use color as well, so I'd keep consistent.
IMO it's at least as important to be consistent in how "contains-errors" is 
displayed, than it is that it's displayed in the same way as other bits.

I think this bit is special enough to warrant a color, but happy without... in 
that case we should drop it from exprs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81912



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


[PATCH] D81967: [clang-tools-extra] Prevent linking to duplicate .a libs and dylib

2020-06-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks! I understand the clangd stuff better now, and scanning through the 
other changes they seem to be the same pattern. LGTM




Comment at: clang-tools-extra/clangd/CMakeLists.txt:105
+
+clang_target_link_libraries(clangDaemon
+  PRIVATE

mgorny wrote:
> sammccall wrote:
> > This has split our link dependencies in two, and I'm not really sure why 
> > (and so am likely to put future dependencies in the wrong place).
> > 
> > Can *all* the link dependencies be moved to the clang_target_link_libraries 
> > section?
> > ((Even if this addresses a problem only seen with clang libs, I'd rather 
> > have everything in one place)
> No. `clang_target_link_libraries` is only for libraries that are included in 
> `libclang-cpp.so`, so when the latter is built, they are replaced with it 
> entirely. I'm all for improving this (e.g. to automatically replace only 
> these libs that are included in clang-cpp) but I don't really have time to 
> work on this beyond fixing immediate failures.
ah, thanks. Sounds like it should be `target_link_clang_libraries` then :-)



Comment at: clang-tools-extra/clangd/unittests/CMakeLists.txt:123
   clangTidy
-  LLVMSupport
   LLVMTestingSupport

mgorny wrote:
> sammccall wrote:
> > why this change? We do depend directly on LLVMSupport, and I'd prefer that 
> > to remain explicit rather than pick it up transitively.
> It's already listed in `LLVM_LINK_COMPONENTS` which handles using libLLVM 
> correctly. Listing it here results in another copy of LLVMSupport being 
> linked in which caused the test to crash immediately on duplicate 
> command-line options.
Thanks, sounds like we should move TestingSupport there too (but will do that 
separately).


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

https://reviews.llvm.org/D81967



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-17 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added inline comments.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:835
+
+  llvm::CallInst *CI = nullptr; 
+  if (Arg == nullptr) {

nit: trailing whitespace



Comment at: clang/test/CodeGen/static-init.cpp:31
+namespace test4 {
+  struct Test4 { 
+Test4();

nit: trailing whitespace in this line.
struct Test4 { 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74166



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


[PATCH] D82020: PowerPC-specific builtin constrained FP enablement

2020-06-17 Thread Andrew J Wock via Phabricator via cfe-commits
ajwock created this revision.
ajwock added reviewers: kpn, cameron.mcinally, spatel, hfinkel, nemanjai, 
kbarton.
Herald added subscribers: cfe-commits, steven.zhang, shchenz.
Herald added a project: clang.
ajwock added a reviewer: steven.zhang.

This change enables PowerPC compiler builtins to generate constrained floating 
point operations when clang is indicated to do so.

A couple of possibly unexpected backend divergences between constrained 
floating point and regular behavior are highlighted under the test tag 
FIXME-CHECK.  This may be something for those on the PPC backend to look at.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82020

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-fpconstrained.c

Index: clang/test/CodeGen/builtins-ppc-fpconstrained.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-ppc-fpconstrained.c
@@ -0,0 +1,166 @@
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
+// RUN: -disable-O0-optnone -Wall -Wno-unused -Werror -emit-llvm %s -o - | \
+// RUN: FileCheck --check-prefix=CHECK-UNCONSTRAINED -vv %s
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
+// RUN: -disable-O0-optnone -ffp-exception-behavior=strict -Wall \
+// RUN: -Wno-unused -Werror -emit-llvm %s -o - | FileCheck \
+// RUN: --check-prefix=CHECK-CONSTRAINED -vv %s
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
+// RUN: -disable-O0-optnone -fallow-half-arguments-and-returns -S -o - %s | \
+// RUN: FileCheck --check-prefix=CHECK-ASM --check-prefix=NOT-FIXME-CHECK  %s
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
+// RUN: -disable-O0-optnone -fallow-half-arguments-and-returns -S \
+// RUN: -ffp-exception-behavior=strict  -o - %s | FileCheck \
+// RUN: --check-prefix=CHECK-ASM --check-prefix=FIXME-CHECK  %s
+
+typedef __attribute__((vector_size(4 * sizeof(float float vec_float;
+typedef __attribute__((vector_size(2 * sizeof(double double vec_double;
+
+volatile vec_double vd;
+volatile vec_float vf;
+
+void test_float(void) {
+  vf = __builtin_vsx_xvsqrtsp(vf);
+  // CHECK-LABEL: try-xvsqrtsp
+  // CHECK-UNCONSTRAINED: @llvm.sqrt.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.sqrt.v4f32(<4 x float> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // CHECK-ASM: xvsqrtsp
+
+  vd = __builtin_vsx_xvsqrtdp(vd);
+  // CHECK-LABEL: try-xvsqrtdp
+  // CHECK-UNCONSTRAINED: @llvm.sqrt.v2f64(<2 x double> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.sqrt.v2f64(<2 x double> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // CHECK-ASM: xvsqrtdp
+
+  vf = __builtin_vsx_xvrspim(vf);
+  // CHECK-LABEL: try-xvrspim
+  // CHECK-UNCONSTRAINED: @llvm.floor.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.floor.v4f32(<4 x float> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrspim
+
+  vd = __builtin_vsx_xvrdpim(vd);
+  // CHECK-LABEL: try-xvrdpim
+  // CHECK-UNCONSTRAINED: @llvm.floor.v2f64(<2 x double> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.floor.v2f64(<2 x double> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrdpim
+
+  vf = __builtin_vsx_xvrspi(vf);
+  // CHECK-LABEL: try-xvrspi
+  // CHECK-UNCONSTRAINED: @llvm.round.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.round.v4f32(<4 x float> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrspi
+
+  vd = __builtin_vsx_xvrdpi(vd);
+  // CHECK-LABEL: try-xvrdpi
+  // CHECK-UNCONSTRAINED: @llvm.round.v2f64(<2 x double> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.round.v2f64(<2 x double> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrdpi
+
+  vf = __builtin_vsx_xvrspic(vf);
+  // CHECK-LABEL: try-xvrspic
+  // CHECK-UNCONSTRAINED: @llvm.nearbyint.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.nearbyint.v4f32(<4 x float> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // NO-FIXME-CHECK: xvrspic
+  // FIXME-CHECK: bl nearbyintf
+  // FIXME-CHECK: bl nearbyintf
+  // FIXME-CHECK: bl nearbyintf
+  // FIXME-CHECK: bl nearbyintf
+
+  vd = __builtin_vsx_xvrdpic(vd);
+  // CHECK-LABEL: try-xvrdpic
+  // CHECK-UNCONSTRAINED: @llvm.nearbyint.v2f64(<2 x double> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.nearbyint.v2f64(<2 x double> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // NO-FIXME-CHECK: xvrdpic
+  // FIXME-CHECK: bl nearbyint
+  // FIXME-CHECK: bl nearbyint
+
+  vf = __builtin_vsx_xvrspip(vf);
+  // CHECK-LABEL: try-xvrspip
+  // CHECK-UNCONSTRAINED: @llvm.ceil.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.ceil.v4f32(<4 x float> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrspi

[clang-tools-extra] 4317ee2 - [clangd] Make use of preamble bounds from the patch inside ReplayPreamble

2020-06-17 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-06-17T18:32:59+02:00
New Revision: 4317ee27bd64759b922438659f5b6883c0fbe404

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

LOG: [clangd] Make use of preamble bounds from the patch inside ReplayPreamble

Summary:
Clangd was using bounds from the stale preamble, which might result in
crashes. For example:
```
 #include "a.h"
 #include "b.h" // this line is newly inserted
 #include "c.h"
```

PreambleBounds for the baseline only contains first two lines, but
ReplayPreamble logic contains an include from the third line. This would
result in a crash as we only lex preamble part of the current file
during ReplayPreamble.

This patch adds a `preambleBounds` method to PreamblePatch, which can be
used to figure out preamble bounds for the current version of the file.
Then uses it when attaching ReplayPreamble, so that it can lex the
up-to-date preamble region.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/Preamble.cpp
clang-tools-extra/clangd/Preamble.h
clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
clang-tools-extra/clangd/unittests/PreambleTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ParsedAST.cpp 
b/clang-tools-extra/clangd/ParsedAST.cpp
index e85f1b30cd3a..f622ab298196 100644
--- a/clang-tools-extra/clangd/ParsedAST.cpp
+++ b/clang-tools-extra/clangd/ParsedAST.cpp
@@ -383,7 +383,7 @@ ParsedAST::build(llvm::StringRef Filename, const 
ParseInputs &Inputs,
 Includes.MainFileIncludes = Patch->preambleIncludes();
 // Replay the preamble includes so that clang-tidy checks can see them.
 ReplayPreamble::attach(Patch->preambleIncludes(), *Clang,
-   Preamble->Preamble.getBounds());
+   Patch->modifiedBounds());
   }
   // Important: collectIncludeStructure is registered *after* ReplayPreamble!
   // Otherwise we would collect the replayed includes again...

diff  --git a/clang-tools-extra/clangd/Preamble.cpp 
b/clang-tools-extra/clangd/Preamble.cpp
index c32dc8c66b2f..d7a15ff0a101 100644
--- a/clang-tools-extra/clangd/Preamble.cpp
+++ b/clang-tools-extra/clangd/Preamble.cpp
@@ -217,6 +217,7 @@ struct DirectiveCollector : public PPCallbacks {
 struct ScannedPreamble {
   std::vector Includes;
   std::vector TextualDirectives;
+  PreambleBounds Bounds = {0, false};
 };
 
 /// Scans the preprocessor directives in the preamble section of the file by
@@ -284,6 +285,7 @@ scanPreamble(llvm::StringRef Contents,
   IncludeStructure Includes;
   PP.addPPCallbacks(collectIncludeStructureCallback(SM, &Includes));
   ScannedPreamble SP;
+  SP.Bounds = Bounds;
   PP.addPPCallbacks(
   std::make_unique(PP, SP.TextualDirectives));
   if (llvm::Error Err = Action.Execute())
@@ -463,6 +465,7 @@ PreamblePatch PreamblePatch::create(llvm::StringRef 
FileName,
   llvm::sys::path::append(PatchName, llvm::sys::path::parent_path(FileName),
   PreamblePatchHeaderName);
   PP.PatchFileName = PatchName.str().str();
+  PP.ModifiedBounds = ModifiedScan->Bounds;
 
   llvm::raw_string_ostream Patch(PP.PatchContents);
   // Set default filename for subsequent #line directives
@@ -548,6 +551,7 @@ std::vector PreamblePatch::preambleIncludes() 
const {
 PreamblePatch PreamblePatch::unmodified(const PreambleData &Preamble) {
   PreamblePatch PP;
   PP.PreambleIncludes = Preamble.Includes.MainFileIncludes;
+  PP.ModifiedBounds = Preamble.Preamble.getBounds();
   return PP;
 }
 

diff  --git a/clang-tools-extra/clangd/Preamble.h 
b/clang-tools-extra/clangd/Preamble.h
index 35c168573b90..1de1d6cfe5fa 100644
--- a/clang-tools-extra/clangd/Preamble.h
+++ b/clang-tools-extra/clangd/Preamble.h
@@ -31,6 +31,7 @@
 #include "support/Path.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/PrecompiledPreamble.h"
+#include "clang/Lex/Lexer.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/StringRef.h"
 
@@ -119,6 +120,9 @@ class PreamblePatch {
   /// using the presumed-location mechanism.
   std::vector preambleIncludes() const;
 
+  /// Returns preamble bounds for the Modified.
+  PreambleBounds modifiedBounds() const { return ModifiedBounds; }
+
   /// Returns textual patch contents.
   llvm::StringRef text() const { return PatchContents; }
 
@@ -129,6 +133,7 @@ class PreamblePatch {
   /// Includes that are present in both \p Baseline and \p Modified. Used for
   /// patching includes of baseline preamble.
   std::vector PreambleIncludes;
+  PreambleBounds ModifiedBounds = {0, false};
 };
 
 /// Translates locations 

[PATCH] D82024: [clangd] Rename FSProvider to TFS in case of ThreadsafeFS

2020-06-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
javed.absar, ilya-biryukov.
Herald added a project: clang.

Depends on D81998 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82024

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/HeadersTests.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
  clang-tools-extra/clangd/unittests/PreambleTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp

Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -54,7 +54,7 @@
   Inputs.CompileCommand.Filename = FullFilename;
   Inputs.CompileCommand.Directory = testRoot();
   Inputs.Contents = Code;
-  Inputs.FSProvider = &FSProvider;
+  Inputs.TFS = &FSProvider;
   Inputs.Opts = ParseOptions();
   Inputs.Opts.BuildRecoveryAST = true;
   Inputs.Opts.PreserveRecoveryASTType = true;
Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -74,7 +74,7 @@
   ParseInputs getInputs(PathRef File, std::string Contents) {
 ParseInputs Inputs;
 Inputs.CompileCommand = *CDB.getCompileCommand(File);
-Inputs.FSProvider = &FSProvider;
+Inputs.TFS = &FSProvider;
 Inputs.Contents = std::move(Contents);
 Inputs.Opts = ParseOptions();
 return Inputs;
Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -70,11 +70,11 @@
   // We don't run PP directly over the patch cotents to test production
   // behaviour.
   auto Bounds = Lexer::ComputePreamble(ModifiedContents, *CI->getLangOpts());
-  auto Clang = prepareCompilerInstance(
-  std::move(CI), &BaselinePreamble->Preamble,
-  llvm::MemoryBuffer::getMemBufferCopy(
-  ModifiedContents.slice(0, Bounds.Size).str()),
-  PI.FSProvider->view(PI.CompileCommand.Directory), Diags);
+  auto Clang =
+  prepareCompilerInstance(std::move(CI), &BaselinePreamble->Preamble,
+  llvm::MemoryBuffer::getMemBufferCopy(
+  ModifiedContents.slice(0, Bounds.Size).str()),
+  PI.TFS->view(PI.CompileCommand.Directory), Diags);
   PreprocessOnlyAction Action;
   if (!Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0])) {
 ADD_FAILURE() << "failed begin source file";
Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -253,7 +253,7 @@
   FSProvider.Files = {{testPath("foo.cpp"), "void test() {}"}};
   // Unknown flags should not prevent a build of compiler invocation.
   ParseInputs Inputs;
-  Inputs.FSProvider = &FSProvider;
+  Inputs.TFS = &FSProvider;
   Inputs.CompileCommand.CommandLine = {"clang", "-fsome-unknown-flag",
testPath("foo.cpp")};
   IgnoreDiagnostics IgnoreDiags;
Index: clang-tools-extra/clangd/unittests/HeadersTests.cpp
===
--- clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -48,12 +48,12 @@
 
 ParseInputs PI;
 PI.CompileCommand = *Cmd;
-PI.FSProvider = &FS;
+PI.TFS = &FS;
 auto CI = buildCompilerInvocation(PI, IgnoreDiags);
 EXPECT_TRUE(static_cast(CI));
 // The diagnostic options must be set before creating a CompilerInstance.
 CI->getDiagnosticOpts().IgnoreWarnings = true;
-auto VFS = PI.FSProvider->view(Cmd->Directory);
+auto VFS = PI.TFS->view(Cmd->Directory);
 auto Clang = prepareCompilerInstance(
 std::move(CI), /*Preamble=*

[PATCH] D81998: [clangd][NFC] Rename FSProvider and getFileSystem

2020-06-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked 6 inline comments as done.
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:722
 /* Override */ OverrideClangTidyOptions,
-FSProvider.getFileSystem(/*CWD=*/llvm::None));
+FSProvider.view(/*CWD=*/llvm::None));
 Opts.GetClangTidyOptions = [&](llvm::vfs::FileSystem &,

sammccall wrote:
> we need a new conventional name for these variables.
> 
> Not sure if FS works, since we may have the vfs::FileSystem in the same 
> scope. TFS?
> 
> Ultimately we should really get rid of any mention of FSProvider in the code, 
> I don't think it's a good name for anything anymore.
> Not sure if it's more/less painful to  do this in separate patches... the 
> inconsistent naming will be confusing.
Sent out D82024


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81998



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


[PATCH] D81964: [clangd] Make use of preamble bounds from the patch inside ReplayPreamble

2020-06-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/Preamble.h:136
   std::vector PreambleIncludes;
+  PreambleBounds PatchBounds = {0, false};
 };

sammccall wrote:
> nit: = {} seems less confusing.
> 
> Call this ModifiedBounds (or ModifiedPreambleBounds) as well? Not obvious to 
> me what it is at the moment.
unfortunately `PreambleBounds` doesn't have a default constructor :/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81964



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


[PATCH] D81964: [clangd] Make use of preamble bounds from the patch inside ReplayPreamble

2020-06-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 271390.
kadircet marked 5 inline comments as done.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81964

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
  clang-tools-extra/clangd/unittests/PreambleTests.cpp

Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -488,6 +488,51 @@
   EXPECT_EQ(DecompLoc.first, SM.getMainFileID());
   EXPECT_EQ(SM.getLineNumber(DecompLoc.first, DecompLoc.second), 3U);
 }
+
+TEST(PreamblePatch, ModifiedBounds) {
+  struct {
+llvm::StringLiteral Baseline;
+llvm::StringLiteral Modified;
+  } Cases[] = {
+  // Size increased
+  {
+  "",
+  R"cpp(
+#define FOO
+FOO)cpp",
+  },
+  // Stayed same
+  {"#define FOO", "#define BAR"},
+  // Got smaller
+  {
+  R"cpp(
+#define FOO
+#undef FOO)cpp",
+  "#define FOO"},
+  };
+
+  for (const auto &Case : Cases) {
+auto TU = TestTU::withCode(Case.Baseline);
+auto BaselinePreamble = TU.preamble();
+ASSERT_TRUE(BaselinePreamble);
+
+Annotations Modified(Case.Modified);
+TU.Code = Modified.code().str();
+MockFSProvider FSProvider;
+auto PP = PreamblePatch::create(testPath(TU.Filename),
+TU.inputs(FSProvider), *BaselinePreamble);
+
+IgnoreDiagnostics Diags;
+auto CI = buildCompilerInvocation(TU.inputs(FSProvider), Diags);
+ASSERT_TRUE(CI);
+
+const auto ExpectedBounds =
+Lexer::ComputePreamble(Case.Modified, *CI->getLangOpts());
+EXPECT_EQ(PP.modifiedBounds().Size, ExpectedBounds.Size);
+EXPECT_EQ(PP.modifiedBounds().PreambleEndsAtStartOfLine,
+  ExpectedBounds.PreambleEndsAtStartOfLine);
+  }
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -444,24 +444,76 @@
 EXPECT_EQ(SkippedFiles[I].kind(), tok::header_name);
   }
 
+  TU.AdditionalFiles["a.h"] = "";
+  TU.AdditionalFiles["b.h"] = "";
+  TU.AdditionalFiles["c.h"] = "";
   // Make sure replay logic works with patched preambles.
-  TU.Code = "";
-  StoreDiags Diags;
+  llvm::StringLiteral Baseline = R"cpp(
+#include "a.h"
+#include "c.h")cpp";
   MockFSProvider FS;
+  TU.Code = Baseline.str();
   auto Inputs = TU.inputs(FS);
-  auto CI = buildCompilerInvocation(Inputs, Diags);
-  auto EmptyPreamble =
-  buildPreamble(testPath(TU.Filename), *CI, Inputs, true, nullptr);
-  ASSERT_TRUE(EmptyPreamble);
-  TU.Code = "#include ";
+  auto BaselinePreamble = TU.preamble();
+  ASSERT_TRUE(BaselinePreamble);
+
+  // First make sure we don't crash on various modifications to the preamble.
+  llvm::StringLiteral Cases[] = {
+  // clang-format off
+  // New include in middle.
+  R"cpp(
+#include "a.h"
+#include "b.h"
+#include "c.h")cpp",
+  // New include at top.
+  R"cpp(
+#include "b.h"
+#include "a.h"
+#include "c.h")cpp",
+  // New include at bottom.
+  R"cpp(
+#include "a.h"
+#include "c.h"
+#include "b.h")cpp",
+  // Same size with a missing include.
+  R"cpp(
+#include "a.h"
+#include "b.h")cpp",
+  // Smaller with no new includes.
+  R"cpp(
+#include "a.h")cpp",
+  // Smaller with a new includes.
+  R"cpp(
+#include "b.h")cpp",
+  // clang-format on
+  };
+  for (llvm::StringLiteral Case : Cases) {
+TU.Code = Case.str();
+
+IgnoreDiagnostics Diags;
+auto CI = buildCompilerInvocation(TU.inputs(FS), Diags);
+auto PatchedAST = ParsedAST::build(testPath(TU.Filename), TU.inputs(FS),
+   std::move(CI), {}, BaselinePreamble);
+ASSERT_TRUE(PatchedAST);
+EXPECT_TRUE(PatchedAST->getDiagnostics().empty());
+  }
+
+  // Then ensure correctness by making sure includes were seen only once.
+  // Note that we first see the includes from the patch, as preamble includes
+  // are replayed after exiting the built-in file.
   Includes.clear();
+  TU.Code = R"cpp(
+#include "a.h"
+#include "b.h")cpp";
+  IgnoreDiagnostics Diags;
+  auto CI = buildCompilerInvocation(TU.inputs(FS), Diags);
   auto PatchedAST = ParsedAST::build(testPath(TU.Filename), TU.inputs(FS),
- std::move(CI)

[PATCH] D81972: [NFC] Cleanup of EmitCXXGlobalInitFunc() and EmitCXXGlobalDtorFunc()

2020-06-17 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 271389.
Xiangling_L marked an inline comment as done.
Xiangling_L added a comment.

Minor change;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81972

Files:
  clang/lib/CodeGen/CGDeclCXX.cpp


Index: clang/lib/CodeGen/CGDeclCXX.cpp
===
--- clang/lib/CodeGen/CGDeclCXX.cpp
+++ clang/lib/CodeGen/CGDeclCXX.cpp
@@ -533,6 +533,23 @@
   CXXThreadLocals.clear();
 }
 
+static StringRef getTransformedFileName(llvm::Module &M,
+SmallString<128> &FileName) {
+  FileName = llvm::sys::path::filename(M.getName());
+
+  if (FileName.empty())
+FileName = "";
+
+  for (size_t i = 0; i < FileName.size(); ++i) {
+// Replace everything that's not [a-zA-Z0-9._] with a _. This set happens
+// to be the set of C preprocessing numbers.
+if (!isPreprocessingNumberBody(FileName[i]))
+  FileName[i] = '_';
+  }
+
+  return FileName;
+}
+
 void
 CodeGenModule::EmitCXXGlobalInitFunc() {
   while (!CXXGlobalInits.empty() && !CXXGlobalInits.back())
@@ -577,22 +594,18 @@
 PrioritizedCXXGlobalInits.clear();
   }
 
-  // Include the filename in the symbol name. Including "sub_" matches gcc and
-  // makes sure these symbols appear lexicographically behind the symbols with
-  // priority emitted above.
-  SmallString<128> FileName = llvm::sys::path::filename(getModule().getName());
-  if (FileName.empty())
-FileName = "";
-
-  for (size_t i = 0; i < FileName.size(); ++i) {
-// Replace everything that's not [a-zA-Z0-9._] with a _. This set happens
-// to be the set of C preprocessing numbers.
-if (!isPreprocessingNumberBody(FileName[i]))
-  FileName[i] = '_';
-  }
+  if (CXXGlobalInits.empty())
+return;
 
+  // Include the filename in the symbol name. Including "sub_" matches gcc
+  // and makes sure these symbols appear lexicographically behind the symbols
+  // with priority emitted above.
+  SmallString<128> FileName;
   llvm::Function *Fn = CreateGlobalInitOrDestructFunction(
-  FTy, llvm::Twine("_GLOBAL__sub_I_", FileName), FI);
+  FTy,
+  llvm::Twine("_GLOBAL__sub_I_",
+  getTransformedFileName(getModule(), FileName)),
+  FI);
 
   CodeGenFunction(*this).GenerateCXXGlobalInitFunc(Fn, CXXGlobalInits);
   AddGlobalCtor(Fn);
@@ -631,6 +644,7 @@
 
   CodeGenFunction(*this).GenerateCXXGlobalDtorsFunc(Fn, CXXGlobalDtors);
   AddGlobalDtor(Fn);
+  CXXGlobalDtors.clear();
 }
 
 /// Emit the code necessary to initialize the given global variable.


Index: clang/lib/CodeGen/CGDeclCXX.cpp
===
--- clang/lib/CodeGen/CGDeclCXX.cpp
+++ clang/lib/CodeGen/CGDeclCXX.cpp
@@ -533,6 +533,23 @@
   CXXThreadLocals.clear();
 }
 
+static StringRef getTransformedFileName(llvm::Module &M,
+SmallString<128> &FileName) {
+  FileName = llvm::sys::path::filename(M.getName());
+
+  if (FileName.empty())
+FileName = "";
+
+  for (size_t i = 0; i < FileName.size(); ++i) {
+// Replace everything that's not [a-zA-Z0-9._] with a _. This set happens
+// to be the set of C preprocessing numbers.
+if (!isPreprocessingNumberBody(FileName[i]))
+  FileName[i] = '_';
+  }
+
+  return FileName;
+}
+
 void
 CodeGenModule::EmitCXXGlobalInitFunc() {
   while (!CXXGlobalInits.empty() && !CXXGlobalInits.back())
@@ -577,22 +594,18 @@
 PrioritizedCXXGlobalInits.clear();
   }
 
-  // Include the filename in the symbol name. Including "sub_" matches gcc and
-  // makes sure these symbols appear lexicographically behind the symbols with
-  // priority emitted above.
-  SmallString<128> FileName = llvm::sys::path::filename(getModule().getName());
-  if (FileName.empty())
-FileName = "";
-
-  for (size_t i = 0; i < FileName.size(); ++i) {
-// Replace everything that's not [a-zA-Z0-9._] with a _. This set happens
-// to be the set of C preprocessing numbers.
-if (!isPreprocessingNumberBody(FileName[i]))
-  FileName[i] = '_';
-  }
+  if (CXXGlobalInits.empty())
+return;
 
+  // Include the filename in the symbol name. Including "sub_" matches gcc
+  // and makes sure these symbols appear lexicographically behind the symbols
+  // with priority emitted above.
+  SmallString<128> FileName;
   llvm::Function *Fn = CreateGlobalInitOrDestructFunction(
-  FTy, llvm::Twine("_GLOBAL__sub_I_", FileName), FI);
+  FTy,
+  llvm::Twine("_GLOBAL__sub_I_",
+  getTransformedFileName(getModule(), FileName)),
+  FI);
 
   CodeGenFunction(*this).GenerateCXXGlobalInitFunc(Fn, CXXGlobalInits);
   AddGlobalCtor(Fn);
@@ -631,6 +644,7 @@
 
   CodeGenFunction(*this).GenerateCXXGlobalDtorsFunc(Fn, CXXGlobalDtors);
   AddGlobalDtor(Fn);
+  CXXGlobalDtors.clear();
 }
 
 /// Emit the code necessary to initialize the given global variab

[PATCH] D81998: [clangd][NFC] Rename FSProvider and getFileSystem

2020-06-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 271386.
kadircet marked an inline comment as done.
kadircet added a comment.
Herald added subscribers: javed.absar, mgorny.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81998

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/fuzzer/clangd-fuzzer.cpp
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/support/CMakeLists.txt
  clang-tools-extra/clangd/support/FSProvider.cpp
  clang-tools-extra/clangd/support/FSProvider.h
  clang-tools-extra/clangd/support/ThreadsafeFS.cpp
  clang-tools-extra/clangd/support/ThreadsafeFS.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/HeadersTests.cpp
  clang-tools-extra/clangd/unittests/PreambleTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.h

Index: clang-tools-extra/clangd/unittests/TestFS.h
===
--- clang-tools-extra/clangd/unittests/TestFS.h
+++ clang-tools-extra/clangd/unittests/TestFS.h
@@ -13,8 +13,8 @@
 #define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTFS_H
 #include "ClangdServer.h"
 #include "GlobalCompilationDatabase.h"
-#include "support/FSProvider.h"
 #include "support/Path.h"
+#include "support/ThreadsafeFS.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
@@ -31,17 +31,14 @@
 llvm::StringMap const &Timestamps = {});
 
 // A VFS provider that returns TestFSes containing a provided set of files.
-class MockFSProvider : public FileSystemProvider {
+class MockFSProvider : public ThreadsafeFS {
 public:
-  // Prevent name hiding caused by the overload below.
-  using FileSystemProvider::getFileSystem;
-
   IntrusiveRefCntPtr getFileSystem() const {
 return buildTestFS(Files, Timestamps);
   }
 
   IntrusiveRefCntPtr
-  getFileSystem(llvm::NoneType) const override {
+  view(llvm::NoneType) const override {
 return getFileSystem();
   }
 
Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -16,10 +16,10 @@
 #include "TestFS.h"
 #include "support/Cancellation.h"
 #include "support/Context.h"
-#include "support/FSProvider.h"
 #include "support/Path.h"
 #include "support/TestTracer.h"
 #include "support/Threading.h"
+#include "support/ThreadsafeFS.h"
 #include "clang/Basic/DiagnosticDriver.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/FunctionExtras.h"
@@ -775,12 +775,11 @@
   FSProvider.Timestamps[HeaderB] = time_t(1);
 
   // The addition of the missing header file triggers a rebuild, no errors.
-  updateWithDiags(
-  S, Source, Inputs, WantDiagnostics::Yes,
-  [&DiagCount](std::vector Diags) {
-++DiagCount;
-EXPECT_THAT(Diags, IsEmpty());
-  });
+  updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes,
+  [&DiagCount](std::vector Diags) {
+++DiagCount;
+EXPECT_THAT(Diags, IsEmpty());
+  });
 
   // Ensure previous assertions are done before we touch the FS again.
   ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
@@ -798,12 +797,12 @@
 
   // Forcing the reload should should cause a rebuild.
   Inputs.ForceRebuild = true;
-  updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes,
-  [&DiagCount](std::vector Diags) {
-++DiagCount;
-ElementsAre(Field(&Diag::Message,
-  "use of undeclared identifier 'b'"));
-  });
+  updateWithDiags(
+  S, Source, Inputs, WantDiagnostics::Yes,
+  [&DiagCount](std::vector Diags) {
+++DiagCount;
+ElementsAre(Field(&Diag::Message, "use of undeclared identifier 'b'"));
+  });
 
   ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   EXPECT_EQ(DiagCount, 3U);
Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -74,7 +74,7 @@
   std::move(CI), &BaselinePreamble->P

[PATCH] D81478: [OPENMP50]Codegen for scan directives in parallel for regions.

2020-06-17 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:3627
+  emitScanBasedDirective(CGF, S, NumIteratorsGen, FirstGen, SecondGen);
+} else {
+  OMPCancelStackRAII CancelRegion(CGF, OMPD_parallel_for, S.hasCancel());

ABataev wrote:
> jdoerfert wrote:
> > ABataev wrote:
> > > jdoerfert wrote:
> > > > This looks pretty much like D81658, right? Could we avoid the 
> > > > duplication and maybe use a templated function (or something else)?
> > > The duplication is quite small. Here we don't need to check for 
> > > lastprivates update, we need to check for the cancellation region. I 
> > > don't think that the outlined functions are going to be much simpler and 
> > > easier to read.
> > I mean, these ~25 lines will exist 3 times at least. 2 times tacking 
> > lastprivate, which we can do for the third time at no extra cost, and 2 
> > times with the cancelation RAII. Any change will need to be duplicated 3 
> > times as well, etc.
> > 
> > If we do
> > ```
> > template
> > void emitWorksharingHelper(..., bool &HasLastprivate)
> > if (llvm::any_of(S.getClausesOfKind(),
> >  [](const OMPReductionClause *C) {
> >return C->getModifier() == OMPC_REDUCTION_inscan;
> >  })) {
> >   const auto &&NumIteratorsGen = [&S](CodeGenFunction &CGF) {
> > OMPLocalDeclMapRAII Scope(CGF);
> > OMPLoopScope LoopScope(CGF, S);
> > return CGF.EmitScalarExpr(S.getNumIterations());
> >   };
> >   const auto &&FirstGen = [&S](CodeGenFunction &CGF) {
> > RAII CancelRegion(CGF, OMPD_for, S.hasCancel());
> > (void)CGF.EmitOMPWorksharingLoop(S, S.getEnsureUpperBound(),
> >  emitForLoopBounds,
> >  emitDispatchForLoopBounds);
> > // Emit an implicit barrier at the end.
> > CGF.CGM.getOpenMPRuntime().emitBarrierCall(CGF, S.getBeginLoc(),
> >OMPD_for);
> >   };
> >   const auto &&SecondGen = [&S, &HasLastprivate](CodeGenFunction &CGF) {
> > RAII CancelRegion(CGF, OMPD_for, S.hasCancel());
> > HasLastprivate = CGF.EmitOMPWorksharingLoop(S, 
> > S.getEnsureUpperBound(),
> >  emitForLoopBounds,
> >  emitDispatchForLoopBounds);
> >   };
> >   emitScanBasedDirective(CGF, S, NumIteratorsGen, FirstGen, SecondGen);
> > } else {
> >   OMPCancelStackRAII CancelRegion(CGF, OMPD_parallel_for, 
> > S.hasCancel());
> > CGF.EmitOMPWorksharingLoop(S, S.getEnsureUpperBound(), 
> > emitForLoopBounds,
> >emitDispatchForLoopBounds);
> > }
> > ```
> > We can call it three times:
> > ```
> > emitWorksharingHelper(...);
> > emitWorksharingHelper(...);
> > emitWorksharingHelper(...);
> > ```
> > 
> > Wouldn't that be cleaner?
> 1. It requires the new `OMPDummyRAII` class.
> 2. Thу functionality under control of the `else` branch also must be affected.
> 3. We don't always need to check for `HasLastprivate`.
> 4. The `NumIteratorsGen` might be different.
> 5. We'll have a lot of trouble with adding new functionality to this 
> function, especially if this functionality is unique for one construct and 
> not required for others.
> 1. It requires the new OMPDummyRAII class.

Sure, is it more than this?
```
struct OMPDummyRAII {
  OMPDummyRAII(...) {}
};
```

> 2. Thу functionality under control of the else branch also must be affected.

Right: `sed -e/OMPCancelStackRAII/RAII/` :)

> 3. We don't always need to check for HasLastprivate.

There is no cost in doing so though. 

> 4. The NumIteratorsGen might be different.

Might be or is? Eyeballing this it looks like 3 times exact the same code.

> 5. We'll have a lot of trouble with adding new functionality to this 
> function, especially if this functionality is unique for one construct and 
> not required for others.

What new functionality do you expect to be unique between them? If there is 
stuff planned, we might not want to unify the implementation, if it is just a 
hunch, we want to go ahead and have a single implemenation so it is easier to 
read and do global modifications. Finding out that something needs special 
handling is at the end of the day easier than finding all other (unrelated) 
locations that need to be changed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81478



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


[PATCH] D81972: [NFC] Cleanup of EmitCXXGlobalInitFunc() and EmitCXXGlobalDtorFunc()

2020-06-17 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added inline comments.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:596
   }
 
+  // Include the filename in the symbol name. Including "sub_" matches gcc

jasonliu wrote:
> I think this patch is missing what @hubert.reinterpretcast mentioned in 
> https://reviews.llvm.org/D74166?id=269900#inline-751064
> which is an early return like this:
> 
> ```
>  if (CXXGlobalInits.empty())
> return;
> ```
Please double check the above early return is desired though. It seems even 
when CXXGlobalInits is empty, `GenerateCXXGlobalInitFunc` is trying to do a lot 
of things with `Fn` passed in. Later, we also called `AddGlobalCtor(Fn)`. So a 
lot of behavior changes here, we want to make sure it's really 'NFC'.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81972



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


[PATCH] D78903: [Driver] Add option -fproc-stat-report

2020-06-17 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff marked 2 inline comments as done.
sepavloff added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:3782
+  = Cmd.getProcessStatistics();
+  if (ProcStat) {
+if (PrintProcessStat) {

aganea wrote:
> In the case where `!ProcStat`, I am wondering if we shouldn't emit zero 
> values, in the report file at least. Otherwise if an invocation fails, it 
> won't be there in the report and we might wonder why. Emitting 0 might 
> indicate that something went wrong.
The feature allows getting statistics using conventional tools like `make`. In 
this case the absence of numbers for a particular file is not an issue, maybe 
the file has already been built. If something goes wrong, clang must handle it 
in `Compilation::ExecuteCommand` and react properly. The fact of failed 
invocation would be handled by build tool. For the purpose of monitoring 
performance numbers it is more convenient to record successful compilations 
only.






Comment at: clang/lib/Driver/Driver.cpp:3814
+  llvm::raw_fd_ostream OS(StatReportFile, EC, 
llvm::sys::fs::OF_Append);
+  if (!EC) {
+if (auto L = OS.tryToLock())

aganea wrote:
> If the goal is to report accurate information, maybe it's worth looping here 
> a bit in case of an error, to give the chance to other clang.exe instances to 
> release the file lock? What do you think? (same for `tryToLock`)
Actually this method makes blocking request and waits infinitely.

There is long discussion of how this lock helper must be implemented: 
https://reviews.llvm.org/D79066. Finally the variant with timeout was removed, 
only blocking one remained. The method has prefix `try` because it requires 
handling result value.

If you think the name or interface might be better, you can participate in the 
discussion in D79066, that patch isn't committed yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78903



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


[PATCH] D79796: Sketch support for generating CC1 command line from CompilerInvocation

2020-06-17 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 271392.
dang added a comment.

Fixed a couple of bugs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79796

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CMakeLists.txt
  clang/unittests/Frontend/CompilerInvocationTest.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -10,11 +10,13 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/TableGen/Record.h"
 #include "llvm/TableGen/TableGenBackend.h"
 #include 
 #include 
 #include 
+#include 
 
 using namespace llvm;
 
@@ -33,6 +35,210 @@
   return OS;
 }
 
+static const std::string getOptionSpelling(const Record &R,
+   size_t &PrefixLength) {
+  std::vector Prefixes = R.getValueAsListOfStrings("Prefixes");
+  StringRef Name = R.getValueAsString("Name");
+  if (Prefixes.empty()) {
+PrefixLength = 0;
+return Name.str();
+  }
+  PrefixLength = Prefixes[0].size();
+  return (Twine(Prefixes[0]) + Twine(Name)).str();
+}
+
+static const std::string getOptionSpelling(const Record &R) {
+  size_t PrefixLength;
+  return getOptionSpelling(R, PrefixLength);
+}
+
+static void emitNameUsingSpelling(raw_ostream &OS, const Record &R) {
+  size_t PrefixLength;
+  OS << "&";
+  write_cstring(OS, StringRef(getOptionSpelling(R, PrefixLength)));
+  OS << "[" << PrefixLength << "]";
+}
+
+class MarshallingKindInfo {
+public:
+  const Record &R;
+  const char *MacroName;
+  bool ShouldAlwaysEmit;
+  StringRef KeyPath;
+  StringRef DefaultValue;
+  StringRef NormalizedValuesScope;
+
+  void emit(raw_ostream &OS) const {
+write_cstring(OS, StringRef(getOptionSpelling(R)));
+OS << ", ";
+OS << ShouldAlwaysEmit;
+OS << ", ";
+OS << KeyPath;
+OS << ", ";
+emitScopedNormalizedValue(OS, DefaultValue);
+OS << ", ";
+emitSpecific(OS);
+  }
+
+  virtual Optional emitValueTable(raw_ostream &OS) const {
+return None;
+  }
+
+  virtual ~MarshallingKindInfo() = default;
+
+  static std::unique_ptr create(const Record &R);
+
+protected:
+  void emitScopedNormalizedValue(raw_ostream &OS,
+ StringRef NormalizedValue) const {
+if (!NormalizedValuesScope.empty())
+  OS << NormalizedValuesScope << "::";
+OS << NormalizedValue;
+  }
+
+  virtual void emitSpecific(raw_ostream &OS) const = 0;
+  MarshallingKindInfo(const Record &R, const char *MacroName)
+  : R(R), MacroName(MacroName) {}
+};
+
+class MarshallingFlagInfo final : public MarshallingKindInfo {
+public:
+  bool IsPositive;
+
+  void emitSpecific(raw_ostream &OS) const override { OS << IsPositive; }
+
+  static std::unique_ptr create(const Record &R) {
+std::unique_ptr Ret(new MarshallingFlagInfo(R));
+Ret->IsPositive = R.getValueAsBit("IsPositive");
+return Ret;
+  }
+
+private:
+  MarshallingFlagInfo(const Record &R)
+  : MarshallingKindInfo(R, "OPTION_WITH_MARSHALLING_FLAG") {}
+};
+
+class MarshallingStringInfo final : public MarshallingKindInfo {
+public:
+  StringRef NormalizerRetTy;
+  StringRef Normalizer;
+  StringRef Denormalizer;
+  int TableIndex = -1;
+  std::vector Values;
+  std::vector NormalizedValues;
+  std::string ValueTableName;
+
+  static constexpr const char *ValueTablePreamble = R"(
+struct SimpleEnumValue {
+  const char *Name;
+  unsigned Value;
+};
+
+struct SimpleEnumValueTable {
+  const SimpleEnumValue *Table;
+  unsigned Size;
+};
+)";
+
+  static constexpr const char *ValueTablesDecl =
+  "static const SimpleEnumValueTable SimpleEnumValueTables[] = ";
+
+  void emitSpecific(raw_ostream &OS) const override {
+emitScopedNormalizedValue(OS, NormalizerRetTy);
+OS << ", ";
+OS << Normalizer;
+OS << ", ";
+OS << Denormalizer;
+OS << ", ";
+OS << TableIndex;
+  }
+
+  Optional emitValueTable(raw_ostream &OS) const override {
+if (TableIndex == -1)
+  return {};
+OS << "static const SimpleEnumValue " << ValueTableName << "[] = {\n";
+for (unsigned I = 0, E = Values.size(); I != E; ++I) {
+  OS << "{";
+  write_cstring(OS, Values[I]);
+  OS << ",";
+  OS << "static_cast(";
+  emitScopedNormalizedValue(OS, NormalizedValues[I]);
+  OS << ")},";
+}
+OS << "};\n";
+return StringRef(ValueTableName);
+  }
+
+  static std::unique_ptr create(const Record &R) {
+assert(!isa(R.getValueInit("NormalizerRetTy")) &&
+   "String options must have a type");
+
+std::unique_ptr Ret(new MarshallingStri

[PATCH] D81970: [Clang][Driver] Remove gold linker support for PS4 toolchain

2020-06-17 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 271394.
ychen added a comment.

- address comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81970

Files:
  clang/lib/Driver/ToolChains/PS4CPU.cpp
  clang/test/Driver/ps4-linker-non-win.c
  clang/test/Driver/ps4-linker-win.c

Index: clang/test/Driver/ps4-linker-win.c
===
--- clang/test/Driver/ps4-linker-win.c
+++ clang/test/Driver/ps4-linker-win.c
@@ -1,27 +1,19 @@
-// The full path to the gold linker was not found on Windows because the
-// driver fails to add an .exe extension to the name.
-// We check that gold linker's full name (with an extension) is specified
-// on the command line if -fuse-ld=gold, or -shared with no -fuse-ld option
-// are passed. Otherwise, we check that the PS4's linker's full name is
-// specified.
+// This test check that orbis-ld is used for linker all the time. Specifying
+// linker using -fuse-ld causes a error message emitted and compilation fail.
 
 // REQUIRES: system-windows, x86-registered-target
 
 // RUN: mkdir -p %t
 // RUN: touch %t/orbis-ld.exe
-// RUN: touch %t/orbis-ld.gold.exe
-
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -fuse-ld=gold -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-GOLD %s
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-GOLD %s
 
 // RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -fuse-ld=ps4 -### 2>&1 \
+// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared \
-// RUN: -fuse-ld=ps4 -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-LINKER %s
 
-// CHECK-PS4-GOLD: \\orbis-ld.gold
 // CHECK-PS4-LINKER: \\orbis-ld
+
+// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4 %s -fuse-ld=gold -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=ERROR %s
+
+// ERROR: error: unsupported option '-fuse-ld' for target 'x86_64-scei-ps4'
Index: clang/test/Driver/ps4-linker-non-win.c
===
--- clang/test/Driver/ps4-linker-non-win.c
+++ clang/test/Driver/ps4-linker-non-win.c
@@ -6,16 +6,14 @@
 // RUN: touch %t/orbis-ld
 // RUN: chmod +x %t/orbis-ld
 
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -fuse-ld=gold 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -shared 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-
 // RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -fuse-ld=ps4 2>&1 \
+// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -shared 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -shared \
-// RUN: -fuse-ld=ps4 2>&1 | FileCheck --check-prefix=CHECK-PS4-LINKER %s
 
 // CHECK-PS4-LINKER: /orbis-ld
+
+// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4 %s -fuse-ld=gold 2>&1 \
+// RUN:   | FileCheck --check-prefix=ERROR %s
+
+// ERROR: error: unsupported option '-fuse-ld' for target 'x86_64-scei-ps4'
Index: clang/lib/Driver/ToolChains/PS4CPU.cpp
===
--- clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -88,13 +88,13 @@
 CmdArgs.push_back("--dependent-lib=libSceDbgAddressSanitizer_stub_weak.a");
 }
 
-static void ConstructPS4LinkJob(const Tool &T, Compilation &C,
-const JobAction &JA, const InputInfo &Output,
-const InputInfoList &Inputs,
-const ArgList &Args,
-const char *LinkingOutput) {
+void tools::PS4cpu::Link::ConstructJob(Compilation &C, const JobAction &JA,
+   const InputInfo &Output,
+   const InputInfoList &Inputs,
+   const ArgList &Args,
+   const char *LinkingOutput) const {
   const toolchains::FreeBSD &ToolChain =
-  static_cast(T.getToolChain());
+  static_cast(getToolChain());
   const Driver &D = ToolChain.getDriver();
   ArgStringList CmdArgs;
 
@@ -143,216 +143,15 @@
 CmdArgs.push_back("-lpthread");
   }
 
-  const char *Exec = Args.MakeArgString(ToolChain.GetProgramPath("orbis-ld"))

[PATCH] D79167: [SVE][CodeGen] Legalisation of vsetcc with scalable types

2020-06-17 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 271391.
kmclaughlin retitled this revision from "[SVE][CodeGen] Legalise scalable 
vector types for vsetcc & vselect" to "[SVE][CodeGen] Legalisation of vsetcc 
with scalable types".
kmclaughlin edited the summary of this revision.
kmclaughlin added a comment.

- Rebased patch & updated checks in the tests with update_llc_test_checks.py


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

https://reviews.llvm.org/D79167

Files:
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/test/CodeGen/AArch64/llvm-ir-to-intrinsic.ll

Index: llvm/test/CodeGen/AArch64/llvm-ir-to-intrinsic.ll
===
--- llvm/test/CodeGen/AArch64/llvm-ir-to-intrinsic.ll
+++ llvm/test/CodeGen/AArch64/llvm-ir-to-intrinsic.ll
@@ -165,6 +165,95 @@
   ret  %min
 }
 
+define  @smin_split_i8( %a,  %b,  %c) {
+; CHECK-LABEL: smin_split_i8:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.b
+; CHECK-NEXT:smin z0.b, p0/m, z0.b, z2.b
+; CHECK-NEXT:smin z1.b, p0/m, z1.b, z3.b
+; CHECK-NEXT:ret
+  %cmp = icmp slt  %a, %b
+  %min = select  %cmp,  %a,  %b
+  ret  %min
+}
+
+define  @smin_split_i16( %a,  %b,  %c) {
+; CHECK-LABEL: smin_split_i16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.h
+; CHECK-NEXT:smin z0.h, p0/m, z0.h, z4.h
+; CHECK-NEXT:smin z1.h, p0/m, z1.h, z5.h
+; CHECK-NEXT:smin z2.h, p0/m, z2.h, z6.h
+; CHECK-NEXT:smin z3.h, p0/m, z3.h, z7.h
+; CHECK-NEXT:ret
+  %cmp = icmp slt  %a, %b
+  %min = select  %cmp,  %a,  %b
+  ret  %min
+}
+
+define  @smin_split_i32( %a,  %b,  %c) {
+; CHECK-LABEL: smin_split_i32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.s
+; CHECK-NEXT:smin z0.s, p0/m, z0.s, z2.s
+; CHECK-NEXT:smin z1.s, p0/m, z1.s, z3.s
+; CHECK-NEXT:ret
+  %cmp = icmp slt  %a, %b
+  %min = select  %cmp,  %a,  %b
+  ret  %min
+}
+
+define  @smin_split_i64( %a,  %b,  %c) {
+; CHECK-LABEL: smin_split_i64:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.d
+; CHECK-NEXT:smin z0.d, p0/m, z0.d, z2.d
+; CHECK-NEXT:smin z1.d, p0/m, z1.d, z3.d
+; CHECK-NEXT:ret
+  %cmp = icmp slt  %a, %b
+  %min = select  %cmp,  %a,  %b
+  ret  %min
+}
+
+define  @smin_promote_i8( %a,  %b,  %c) {
+; CHECK-LABEL: smin_promote_i8:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.h
+; CHECK-NEXT:sxtb z1.h, p0/m, z1.h
+; CHECK-NEXT:sxtb z0.h, p0/m, z0.h
+; CHECK-NEXT:smin z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT:ret
+  %cmp = icmp slt  %a, %b
+  %min = select  %cmp,  %a,  %b
+  ret  %min
+}
+
+define  @smin_promote_i16( %a,  %b,  %c) {
+; CHECK-LABEL: smin_promote_i16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.s
+; CHECK-NEXT:sxth z1.s, p0/m, z1.s
+; CHECK-NEXT:sxth z0.s, p0/m, z0.s
+; CHECK-NEXT:smin z0.s, p0/m, z0.s, z1.s
+; CHECK-NEXT:ret
+  %cmp = icmp slt  %a, %b
+  %min = select  %cmp,  %a,  %b
+  ret  %min
+}
+
+define  @smin_promote_i32( %a,  %b,  %c) {
+; CHECK-LABEL: smin_promote_i32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.d
+; CHECK-NEXT:sxtw z1.d, p0/m, z1.d
+; CHECK-NEXT:sxtw z0.d, p0/m, z0.d
+; CHECK-NEXT:smin z0.d, p0/m, z0.d, z1.d
+; CHECK-NEXT:ret
+  %cmp = icmp slt  %a, %b
+  %min = select  %cmp,  %a,  %b
+  ret  %min
+}
+
 ;
 ; UMIN
 ;
@@ -213,6 +302,31 @@
   ret  %min
 }
 
+define  @umin_split_i64( %a,  %b,  %c) {
+; CHECK-LABEL: umin_split_i64:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.d
+; CHECK-NEXT:umin z0.d, p0/m, z0.d, z2.d
+; CHECK-NEXT:umin z1.d, p0/m, z1.d, z3.d
+; CHECK-NEXT:ret
+  %cmp = icmp ult  %a, %b
+  %min = select  %cmp,  %a,  %b
+  ret  %min
+}
+
+define  @umin_promote_i8( %a,  %b,  %c) {
+; CHECK-LABEL: umin_promote_i8:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.h
+; CHECK-NEXT:and z1.h, z1.h, #0xff
+; CHECK-NEXT:and z0.h, z0.h, #0xff
+; CHECK-NEXT:umin z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT:ret
+  %cmp = icmp ult  %a, %b
+  %min = select  %cmp,  %a,  %b
+  ret  %min
+}
+
 ;
 ; SMAX
 ;
@@ -224,8 +338,8 @@
 ; CHECK-NEXT:smax z0.b, p0/m, z0.b, z1.b
 ; CHECK-NEXT:ret
   %cmp = icmp sgt  %a, %b
-  %min = select  %cmp,  %a,  %b
-  ret  %min
+  %max = select  %cmp,  %a,  %b
+  ret  %max
 }
 
 define  @smax_i16( %a,  %b,  %c) {
@@ -235,8 +349,8 @@
 ; CHECK-NEXT:smax z0.h, p0/m, z0.h, z1.h
 ; CHECK-NEXT:ret
   %cmp = icmp sgt  %a, %b
-  %min = select  %cmp,  %a,  %b
-  ret  %min
+  %max = select  %cmp,  %a,  %b
+  ret  %max
 }
 
 define  @smax_i32( %a,  %b,  %c) {
@@ -246,8 +360,8 @@
 ; CHECK-NEXT:smax z0.s, p0/m, z0.s, z1.s
 ; CHECK-NEXT:ret
   %cmp = icmp sgt  %a, %b
-  %min = select  %cmp,  %a,  %b
-  ret  %min
+  %max = select  %cmp,  %a,  %b
+  ret  %max
 }
 
 define  @smax_i64( %a,  %b,  %c) {
@@ -257,8 +371,33 @@
 ; CHECK-NEXT:smax z0.d, p0/m, z0.d, z1.d
 ; CHECK-NEXT:ret
   %cmp = icmp sgt  %a, %b
-  %min = select  %cmp,  %a,  %b
-  ret  %min
+  %max = select  %cmp,  %a, 

[PATCH] D81964: [clangd] Make use of preamble bounds from the patch inside ReplayPreamble

2020-06-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4317ee27bd64: [clangd] Make use of preamble bounds from the 
patch inside ReplayPreamble (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81964

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
  clang-tools-extra/clangd/unittests/PreambleTests.cpp

Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -488,6 +488,51 @@
   EXPECT_EQ(DecompLoc.first, SM.getMainFileID());
   EXPECT_EQ(SM.getLineNumber(DecompLoc.first, DecompLoc.second), 3U);
 }
+
+TEST(PreamblePatch, ModifiedBounds) {
+  struct {
+llvm::StringLiteral Baseline;
+llvm::StringLiteral Modified;
+  } Cases[] = {
+  // Size increased
+  {
+  "",
+  R"cpp(
+#define FOO
+FOO)cpp",
+  },
+  // Stayed same
+  {"#define FOO", "#define BAR"},
+  // Got smaller
+  {
+  R"cpp(
+#define FOO
+#undef FOO)cpp",
+  "#define FOO"},
+  };
+
+  for (const auto &Case : Cases) {
+auto TU = TestTU::withCode(Case.Baseline);
+auto BaselinePreamble = TU.preamble();
+ASSERT_TRUE(BaselinePreamble);
+
+Annotations Modified(Case.Modified);
+TU.Code = Modified.code().str();
+MockFSProvider FSProvider;
+auto PP = PreamblePatch::create(testPath(TU.Filename),
+TU.inputs(FSProvider), *BaselinePreamble);
+
+IgnoreDiagnostics Diags;
+auto CI = buildCompilerInvocation(TU.inputs(FSProvider), Diags);
+ASSERT_TRUE(CI);
+
+const auto ExpectedBounds =
+Lexer::ComputePreamble(Case.Modified, *CI->getLangOpts());
+EXPECT_EQ(PP.modifiedBounds().Size, ExpectedBounds.Size);
+EXPECT_EQ(PP.modifiedBounds().PreambleEndsAtStartOfLine,
+  ExpectedBounds.PreambleEndsAtStartOfLine);
+  }
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -444,24 +444,76 @@
 EXPECT_EQ(SkippedFiles[I].kind(), tok::header_name);
   }
 
+  TU.AdditionalFiles["a.h"] = "";
+  TU.AdditionalFiles["b.h"] = "";
+  TU.AdditionalFiles["c.h"] = "";
   // Make sure replay logic works with patched preambles.
-  TU.Code = "";
-  StoreDiags Diags;
+  llvm::StringLiteral Baseline = R"cpp(
+#include "a.h"
+#include "c.h")cpp";
   MockFSProvider FS;
+  TU.Code = Baseline.str();
   auto Inputs = TU.inputs(FS);
-  auto CI = buildCompilerInvocation(Inputs, Diags);
-  auto EmptyPreamble =
-  buildPreamble(testPath(TU.Filename), *CI, Inputs, true, nullptr);
-  ASSERT_TRUE(EmptyPreamble);
-  TU.Code = "#include ";
+  auto BaselinePreamble = TU.preamble();
+  ASSERT_TRUE(BaselinePreamble);
+
+  // First make sure we don't crash on various modifications to the preamble.
+  llvm::StringLiteral Cases[] = {
+  // clang-format off
+  // New include in middle.
+  R"cpp(
+#include "a.h"
+#include "b.h"
+#include "c.h")cpp",
+  // New include at top.
+  R"cpp(
+#include "b.h"
+#include "a.h"
+#include "c.h")cpp",
+  // New include at bottom.
+  R"cpp(
+#include "a.h"
+#include "c.h"
+#include "b.h")cpp",
+  // Same size with a missing include.
+  R"cpp(
+#include "a.h"
+#include "b.h")cpp",
+  // Smaller with no new includes.
+  R"cpp(
+#include "a.h")cpp",
+  // Smaller with a new includes.
+  R"cpp(
+#include "b.h")cpp",
+  // clang-format on
+  };
+  for (llvm::StringLiteral Case : Cases) {
+TU.Code = Case.str();
+
+IgnoreDiagnostics Diags;
+auto CI = buildCompilerInvocation(TU.inputs(FS), Diags);
+auto PatchedAST = ParsedAST::build(testPath(TU.Filename), TU.inputs(FS),
+   std::move(CI), {}, BaselinePreamble);
+ASSERT_TRUE(PatchedAST);
+EXPECT_TRUE(PatchedAST->getDiagnostics().empty());
+  }
+
+  // Then ensure correctness by making sure includes were seen only once.
+  // Note that we first see the includes from the patch, as preamble includes
+  // are replayed after exiting the built-in file.
   Includes.clear();
+  TU.Code = R"cpp(
+#include "a.h"
+#include "b.h")cpp";
+  IgnoreDiagnostics Diags;
+  auto CI = buildCompilerInvocation(TU.inputs(FS), Diags);
   auto PatchedAST = ParsedAST::build(testPath(TU.Filename

[PATCH] D79675: [OpenMP][OMPBuilder] Adding Privatization Requirements to OMPIRBuilder

2020-06-17 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks a lot! Sorry for the delay in reviewing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79675



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


[clang] 2956cc5 - [Clang][Driver] Remove gold linker support for PS4 toolchain

2020-06-17 Thread Yuanfang Chen via cfe-commits

Author: Yuanfang Chen
Date: 2020-06-17T09:45:14-07:00
New Revision: 2956cc50f3405ae32c8c6d6e2c63fe8cb6456fa2

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

LOG: [Clang][Driver] Remove gold linker support for PS4 toolchain

Reviewers: probinson

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/PS4CPU.cpp
clang/test/Driver/ps4-linker-non-win.c
clang/test/Driver/ps4-linker-win.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp 
b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index ebeed3803e06..49f26c370168 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -88,13 +88,13 @@ void tools::PS4cpu::addSanitizerArgs(const ToolChain &TC,
 CmdArgs.push_back("--dependent-lib=libSceDbgAddressSanitizer_stub_weak.a");
 }
 
-static void ConstructPS4LinkJob(const Tool &T, Compilation &C,
-const JobAction &JA, const InputInfo &Output,
-const InputInfoList &Inputs,
-const ArgList &Args,
-const char *LinkingOutput) {
+void tools::PS4cpu::Link::ConstructJob(Compilation &C, const JobAction &JA,
+   const InputInfo &Output,
+   const InputInfoList &Inputs,
+   const ArgList &Args,
+   const char *LinkingOutput) const {
   const toolchains::FreeBSD &ToolChain =
-  static_cast(T.getToolChain());
+  static_cast(getToolChain());
   const Driver &D = ToolChain.getDriver();
   ArgStringList CmdArgs;
 
@@ -143,216 +143,15 @@ static void ConstructPS4LinkJob(const Tool &T, 
Compilation &C,
 CmdArgs.push_back("-lpthread");
   }
 
-  const char *Exec = Args.MakeArgString(ToolChain.GetProgramPath("orbis-ld"));
-
-  C.addCommand(std::make_unique(JA, T, Exec, CmdArgs, Inputs));
-}
-
-static void ConstructGoldLinkJob(const Tool &T, Compilation &C,
- const JobAction &JA, const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &Args,
- const char *LinkingOutput) {
-  const toolchains::FreeBSD &ToolChain =
-  static_cast(T.getToolChain());
-  const Driver &D = ToolChain.getDriver();
-  ArgStringList CmdArgs;
-
-  // Silence warning for "clang -g foo.o -o foo"
-  Args.ClaimAllArgs(options::OPT_g_Group);
-  // and "clang -emit-llvm foo.o -o foo"
-  Args.ClaimAllArgs(options::OPT_emit_llvm);
-  // and for "clang -w foo.o -o foo". Other warning options are already
-  // handled somewhere else.
-  Args.ClaimAllArgs(options::OPT_w);
-
-  if (!D.SysRoot.empty())
-CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
-
-  if (Args.hasArg(options::OPT_pie))
-CmdArgs.push_back("-pie");
-
-  if (Args.hasArg(options::OPT_static)) {
-CmdArgs.push_back("-Bstatic");
-  } else {
-if (Args.hasArg(options::OPT_rdynamic))
-  CmdArgs.push_back("-export-dynamic");
-CmdArgs.push_back("--eh-frame-hdr");
-if (Args.hasArg(options::OPT_shared)) {
-  CmdArgs.push_back("-Bshareable");
-} else {
-  CmdArgs.push_back("-dynamic-linker");
-  CmdArgs.push_back("/libexec/ld-elf.so.1");
-}
-CmdArgs.push_back("--enable-new-dtags");
-  }
-
-  if (Output.isFilename()) {
-CmdArgs.push_back("-o");
-CmdArgs.push_back(Output.getFilename());
-  } else {
-assert(Output.isNothing() && "Invalid output.");
-  }
-
-  if(!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
-AddPS4SanitizerArgs(ToolChain, CmdArgs);
-
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
-const char *crt1 = nullptr;
-if (!Args.hasArg(options::OPT_shared)) {
-  if (Args.hasArg(options::OPT_pg))
-crt1 = "gcrt1.o";
-  else if (Args.hasArg(options::OPT_pie))
-crt1 = "Scrt1.o";
-  else
-crt1 = "crt1.o";
-}
-if (crt1)
-  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crt1)));
-
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crti.o")));
-
-const char *crtbegin = nullptr;
-if (Args.hasArg(options::OPT_static))
-  crtbegin = "crtbeginT.o";
-else if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_pie))
-  crtbegin = "crtbeginS.o";
-else
-  crtbegin = "crtbegin.o";
-
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
-  }
-
-  Args.AddAllArgs(CmdArgs, options::OPT_L);
-  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
-  Args.AddAllArgs(CmdArgs, o

[clang-tools-extra] d4f298c - [clang-tools-extra] Prevent linking to duplicate .a libs and dylib

2020-06-17 Thread Michał Górny via cfe-commits

Author: Michał Górny
Date: 2020-06-17T19:00:26+02:00
New Revision: d4f298c8206b435ce627b022efa0d5da620019cd

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

LOG: [clang-tools-extra] Prevent linking to duplicate .a libs and dylib

Fix various tool libraries not to link to clang's .a libraries and dylib
simultaneously.  This may cause breakage, in particular through
duplicate command-line option declarations.

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

Added: 


Modified: 
clang-tools-extra/clang-apply-replacements/CMakeLists.txt
clang-tools-extra/clang-change-namespace/CMakeLists.txt
clang-tools-extra/clang-doc/CMakeLists.txt
clang-tools-extra/clang-include-fixer/CMakeLists.txt
clang-tools-extra/clang-include-fixer/find-all-symbols/CMakeLists.txt
clang-tools-extra/clang-move/CMakeLists.txt
clang-tools-extra/clang-query/CMakeLists.txt
clang-tools-extra/clang-reorder-fields/CMakeLists.txt
clang-tools-extra/clang-tidy/CMakeLists.txt
clang-tools-extra/clang-tidy/abseil/CMakeLists.txt
clang-tools-extra/clang-tidy/android/CMakeLists.txt
clang-tools-extra/clang-tidy/boost/CMakeLists.txt
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/clang-tidy/cert/CMakeLists.txt
clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
clang-tools-extra/clang-tidy/darwin/CMakeLists.txt
clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt
clang-tools-extra/clang-tidy/google/CMakeLists.txt
clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt
clang-tools-extra/clang-tidy/linuxkernel/CMakeLists.txt
clang-tools-extra/clang-tidy/llvm/CMakeLists.txt
clang-tools-extra/clang-tidy/llvmlibc/CMakeLists.txt
clang-tools-extra/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/clang-tidy/mpi/CMakeLists.txt
clang-tools-extra/clang-tidy/objc/CMakeLists.txt
clang-tools-extra/clang-tidy/openmp/CMakeLists.txt
clang-tools-extra/clang-tidy/performance/CMakeLists.txt
clang-tools-extra/clang-tidy/plugin/CMakeLists.txt
clang-tools-extra/clang-tidy/portability/CMakeLists.txt
clang-tools-extra/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/clang-tidy/tool/CMakeLists.txt
clang-tools-extra/clang-tidy/utils/CMakeLists.txt
clang-tools-extra/clang-tidy/zircon/CMakeLists.txt
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/unittests/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clang-apply-replacements/CMakeLists.txt 
b/clang-tools-extra/clang-apply-replacements/CMakeLists.txt
index 5bfdcb487e17..27383b488e4d 100644
--- a/clang-tools-extra/clang-apply-replacements/CMakeLists.txt
+++ b/clang-tools-extra/clang-apply-replacements/CMakeLists.txt
@@ -4,8 +4,10 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_library(clangApplyReplacements
   lib/Tooling/ApplyReplacements.cpp
+)
 
-  LINK_LIBS
+clang_target_link_libraries(clangApplyReplacements
+  PRIVATE
   clangAST
   clangBasic
   clangRewrite

diff  --git a/clang-tools-extra/clang-change-namespace/CMakeLists.txt 
b/clang-tools-extra/clang-change-namespace/CMakeLists.txt
index 7c0363cd00d0..bfce9869dde8 100644
--- a/clang-tools-extra/clang-change-namespace/CMakeLists.txt
+++ b/clang-tools-extra/clang-change-namespace/CMakeLists.txt
@@ -5,8 +5,10 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_library(clangChangeNamespace
   ChangeNamespace.cpp
+)
 
-  LINK_LIBS
+clang_target_link_libraries(clangChangeNamespace
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic

diff  --git a/clang-tools-extra/clang-doc/CMakeLists.txt 
b/clang-tools-extra/clang-doc/CMakeLists.txt
index 8df7d3ef9098..56ec9eb6e94e 100644
--- a/clang-tools-extra/clang-doc/CMakeLists.txt
+++ b/clang-tools-extra/clang-doc/CMakeLists.txt
@@ -15,8 +15,10 @@ add_clang_library(clangDoc
   Representation.cpp
   Serialize.cpp
   YAMLGenerator.cpp
+)
 
-  LINK_LIBS
+clang_target_link_libraries(clangDoc
+  PRIVATE
   clangAnalysis
   clangAST
   clangASTMatchers

diff  --git a/clang-tools-extra/clang-include-fixer/CMakeLists.txt 
b/clang-tools-extra/clang-include-fixer/CMakeLists.txt
index f27f7403ea6a..d8685cb20758 100644
--- a/clang-tools-extra/clang-include-fixer/CMakeLists.txt
+++ b/clang-tools-extra/clang-include-fixer/CMakeLists.txt
@@ -11,6 +11,11 @@ add_clang_library(clangIncludeFixer
   YamlSymbolIndex.cpp
 
   LINK_LIBS
+  findAllSymbols
+  )
+
+clang_target_link_libraries(clangIncludeFixer
+  PRIVATE
   clangAST
   clangBasic
   clangFormat
@@ -21,7 +26,6 @@ add_clang_library(clangIncludeFixer
   clangSerialization
   clangTooling
   clangToolingCore
-  findAllSymbols
   )
 
 add_subdirectory(plugin)

diff  --git 
a/clang-tools-extra/clang-include-fixer/find-all-sym

[PATCH] D82019: [OPENMP]Fix PR46357: Do not allow types declarations in pragmas.

2020-06-17 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added reviewers: dreachem, kkwli0, trws.
jdoerfert added a comment.

Hm, does the standard say this is not allowed? I can see that we don't want it 
but I'm not 100% certain here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82019



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


[PATCH] D82026: [OPENMP50]Allow nonmonotonic modifier for all schedule kinds.

2020-06-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: sstefan1, guansong, yaxunl.
Herald added a project: clang.

According to OpenMP 5.0, nonmonotonic modifier can be used with all
schedule kinds, not only dynamic and guided as in OpenMP 4.5.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82026

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/for_ast_print.cpp
  clang/test/OpenMP/for_schedule_messages.cpp
  clang/test/OpenMP/schedule_codegen.cpp

Index: clang/test/OpenMP/schedule_codegen.cpp
===
--- clang/test/OpenMP/schedule_codegen.cpp
+++ clang/test/OpenMP/schedule_codegen.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm -fexceptions -fcxx-exceptions -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -emit-llvm -fexceptions -fcxx-exceptions -o - %s | FileCheck %s
 
-// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm -fexceptions -fcxx-exceptions -o - %s | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -emit-llvm -fexceptions -fcxx-exceptions -o - %s | FileCheck --check-prefix SIMD-ONLY0 %s
 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
 
 int main() {
@@ -134,6 +134,18 @@
 // CHECK: !llvm.access.group
 #pragma omp for simd schedule(nonmonotonic: dynamic)
   for(int i = 0; i < 10; ++i);
+// CHECK: call void @__kmpc_for_static_init_4(%struct.ident_t* {{.+}}, i32 %{{.+}}, i32 1073741858,
+// CHECK: !llvm.access.group
+#pragma omp for simd schedule(nonmonotonic: static)
+  for(int i = 0; i < 10; ++i);
+// CHECK: call void @__kmpc_dispatch_init_4(%struct.ident_t* {{.+}}, i32 %{{.+}}, i32 1073741862,
+// CHECK: !llvm.access.group
+#pragma omp for schedule(nonmonotonic: auto)
+  for(int i = 0; i < 10; ++i);
+// CHECK: call void @__kmpc_dispatch_init_4(%struct.ident_t* {{.+}}, i32 %{{.+}}, i32 1073741861,
+// CHECK: !llvm.access.group
+#pragma omp for simd schedule(nonmonotonic: runtime)
+  for(int i = 0; i < 10; ++i);
 // CHECK: @__kmpc_dispatch_init
 // CHECK-NOT: !llvm.access.group
 // CHECK: @__kmpc_dispatch_next
Index: clang/test/OpenMP/for_schedule_messages.cpp
===
--- clang/test/OpenMP/for_schedule_messages.cpp
+++ clang/test/OpenMP/for_schedule_messages.cpp
@@ -1,6 +1,8 @@
-// RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -fopenmp-version=50 %s -Wuninitialized
 
-// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -fopenmp-version=50 %s -Wuninitialized
 
 void foo() {
 }
@@ -32,7 +34,7 @@
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
   #pragma omp for schedule (monotonic, auto // expected-error {{expected ')'}} expected-warning {{missing ':' after schedule modifier - ignoring}} expected-error {{expected 'simd' in OpenMP clause 'schedule'}} expected-note {{to match this '('}}
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
-  #pragma omp for schedule (nonmonotonic: auto, // expected-error {{expected ')'}} expected-error {{'nonmonotonic' modifier can only be specified with 'dynamic' or 'guided' schedule kind}} expected-note {{to match this '('}}
+  #pragma omp for schedule (nonmonotonic: auto, // expected-error {{expected ')'}} omp45-error {{'nonmonotonic' modifier can only be specified with 'dynamic' or 'guided' schedule kind}} expected-note {{to match this '('}}
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
   #pragma omp for schedule (auto,  // expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
@@ -61,11 +63,11 @@
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
   #pragma omp for schedule (static, N) // expected-error {{argument to 'schedule' clause must be a strictly positive integer value}}
   for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
-  #pragma omp for schedule (nonmonotonic: static) // expected-error {{'nonmonotonic' modifier can only be specified with 'dynamic' or 'guided' schedule kind}}
+  #pragma omp for schedule (nonmonotonic: static) // omp45-error {{'nonmonotonic' modifier can only be specified with 'dynamic' or 'guided' schedule kind}}
   for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
-  #pragma omp for schedule (nonmonotonic: auto) // expected-error {{'nonmonotonic' modifier can only be specified with 'dyna

[PATCH] D72782: [Matrix] Add __builtin_matrix_column_store to Clang.

2020-06-17 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 271401.
fhahn added a comment.

Ping :)

Rebased and applied feedback from D72781 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72782

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/matrix-type-builtins.c
  clang/test/CodeGenCXX/matrix-type-builtins.cpp
  clang/test/CodeGenObjC/matrix-type-builtins.m
  clang/test/Sema/matrix-type-builtins.c
  clang/test/SemaCXX/matrix-type-builtins.cpp
  clang/test/SemaObjC/matrix-type-builtins.m

Index: clang/test/SemaObjC/matrix-type-builtins.m
===
--- clang/test/SemaObjC/matrix-type-builtins.m
+++ clang/test/SemaObjC/matrix-type-builtins.m
@@ -19,3 +19,13 @@
   m = __builtin_matrix_transpose(mv.value);
   // expected-error@-1 {{assigning to 'double3x3' (aka 'double __attribute__((matrix_type(3, 3)))') from incompatible type 'double __attribute__((matrix_type(4, 4)))'}}
 }
+
+double test_store(MatrixValue *mv, float *Ptr) {
+  __builtin_matrix_column_major_store(mv.value, Ptr, 1);
+  // expected-error@-1 {{the pointee of the second argument must match the element type of the first argument ('float' != 'double')}}
+  // expected-error@-2 {{stride must be greater or equal to the number of rows}}
+
+  __builtin_matrix_column_major_store(mv.value, mv.value, mv.value);
+  // expected-error@-1 {{second argument must be a pointer to a valid matrix element type}}
+  // expected-error@-2 {{casting 'double4x4' (aka 'double __attribute__((matrix_type(4, 4)))') to incompatible type 'unsigned long'}}
+}
Index: clang/test/SemaCXX/matrix-type-builtins.cpp
===
--- clang/test/SemaCXX/matrix-type-builtins.cpp
+++ clang/test/SemaCXX/matrix-type-builtins.cpp
@@ -101,3 +101,66 @@
   (void)__builtin_matrix_column_major_load(X, 2, 2, 2);
   // expected-error@-1 {{first argument must be a pointer to a valid matrix element type}}
 }
+
+template 
+void column_major_store(MyMatrix &A, PtrTy Ptr, unsigned Stride) {
+  __builtin_matrix_column_major_store(A.value, Ptr, Stride);
+  // expected-error@-1 {{the pointee of the second argument must match the element type of the first argument ('float' != 'unsigned int')}}
+}
+
+template 
+void column_major_store(MTy &A, PtrTy Ptr) {
+  __builtin_matrix_column_major_store(A.value, Ptr, Stride);
+  // expected-error@-1 {{stride must be greater or equal to the number of rows}}
+}
+
+void test_column_major_stores_template(MyMatrix &M1, unsigned *Ptr1, MyMatrix &M2, float *Ptr2) {
+  column_major_store(M1, Ptr2, 10);
+  // expected-note@-1 {{in instantiation of function template specialization 'column_major_store' requested here}}
+
+  column_major_store(M2, Ptr2);
+  // expected-note@-1 {{in instantiation of function template specialization 'column_major_store &, float *, 1>' requested here}}
+}
+
+template 
+void column_major_store(MyMatrix &A, EltTy1 *Ptr) {
+  __builtin_matrix_column_major_store(A.value, Ptr, 1);
+  // expected-error@-1 3 {{stride must be greater or equal to the number of rows}}
+  // expected-error@-2 {{the pointee of the second argument must match the element type of the first argument ('float' != 'unsigned int')}}
+  // expected-error@-3 {{the pointee of the second argument must match the element type of the first argument ('unsigned int' != 'float')}}
+
+  char *s;
+  return __builtin_matrix_column_major_store(A.value, s, 20);
+  // expected-error@-1 {{the pointee of the second argument must match the element type of the first argument ('char' != 'unsigned int')}}
+  // expected-error@-2 {{the pointee of the second argument must match the element type of the first argument ('char' != 'unsigned int')}}
+  // expected-error@-3 {{he pointee of the second argument must match the element type of the first argument ('char' != 'float')}}
+}
+
+void test_column_major_store_template(unsigned *Ptr1, float *Ptr2) {
+  MyMatrix Mat1;
+  column_major_store(Mat1, Ptr1);
+  // expected-note@-1 {{in instantiation of function template specialization 'column_major_store'}}
+  column_major_store(Mat1, Ptr2);
+  // expected-note@-1 {{in instantiation of function template specialization 'column_major_store'}}
+
+  MyMatrix Mat2;
+  column_major_store(Mat2, Ptr1);
+  // expected-note@-1 {{in instantiation of function template specialization 'column_major_store'}}
+}
+
+void test_column_major_store_constexpr(unsigned *Ptr, MyMatrix &M) {
+  __builtin_matrix_column_major_store(M.value, Ptr, constexpr1());
+  // expected-error@-1 {{stride must be greater or equal to the number of rows}}
+  __builtin_matrix_column_major_store(constexpr1(), Ptr, 1);
+  // expected-error@-1 {{first argument must be a matrix}}
+ 

[PATCH] D81478: [OPENMP50]Codegen for scan directives in parallel for regions.

2020-06-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked an inline comment as done.
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:3627
+  emitScanBasedDirective(CGF, S, NumIteratorsGen, FirstGen, SecondGen);
+} else {
+  OMPCancelStackRAII CancelRegion(CGF, OMPD_parallel_for, S.hasCancel());

jdoerfert wrote:
> ABataev wrote:
> > jdoerfert wrote:
> > > ABataev wrote:
> > > > jdoerfert wrote:
> > > > > This looks pretty much like D81658, right? Could we avoid the 
> > > > > duplication and maybe use a templated function (or something else)?
> > > > The duplication is quite small. Here we don't need to check for 
> > > > lastprivates update, we need to check for the cancellation region. I 
> > > > don't think that the outlined functions are going to be much simpler 
> > > > and easier to read.
> > > I mean, these ~25 lines will exist 3 times at least. 2 times tacking 
> > > lastprivate, which we can do for the third time at no extra cost, and 2 
> > > times with the cancelation RAII. Any change will need to be duplicated 3 
> > > times as well, etc.
> > > 
> > > If we do
> > > ```
> > > template
> > > void emitWorksharingHelper(..., bool &HasLastprivate)
> > > if (llvm::any_of(S.getClausesOfKind(),
> > >  [](const OMPReductionClause *C) {
> > >return C->getModifier() == OMPC_REDUCTION_inscan;
> > >  })) {
> > >   const auto &&NumIteratorsGen = [&S](CodeGenFunction &CGF) {
> > > OMPLocalDeclMapRAII Scope(CGF);
> > > OMPLoopScope LoopScope(CGF, S);
> > > return CGF.EmitScalarExpr(S.getNumIterations());
> > >   };
> > >   const auto &&FirstGen = [&S](CodeGenFunction &CGF) {
> > > RAII CancelRegion(CGF, OMPD_for, S.hasCancel());
> > > (void)CGF.EmitOMPWorksharingLoop(S, S.getEnsureUpperBound(),
> > >  emitForLoopBounds,
> > >  emitDispatchForLoopBounds);
> > > // Emit an implicit barrier at the end.
> > > CGF.CGM.getOpenMPRuntime().emitBarrierCall(CGF, S.getBeginLoc(),
> > >OMPD_for);
> > >   };
> > >   const auto &&SecondGen = [&S, &HasLastprivate](CodeGenFunction 
> > > &CGF) {
> > > RAII CancelRegion(CGF, OMPD_for, S.hasCancel());
> > > HasLastprivate = CGF.EmitOMPWorksharingLoop(S, 
> > > S.getEnsureUpperBound(),
> > >  emitForLoopBounds,
> > >  emitDispatchForLoopBounds);
> > >   };
> > >   emitScanBasedDirective(CGF, S, NumIteratorsGen, FirstGen, 
> > > SecondGen);
> > > } else {
> > >   OMPCancelStackRAII CancelRegion(CGF, OMPD_parallel_for, 
> > > S.hasCancel());
> > > CGF.EmitOMPWorksharingLoop(S, S.getEnsureUpperBound(), 
> > > emitForLoopBounds,
> > >emitDispatchForLoopBounds);
> > > }
> > > ```
> > > We can call it three times:
> > > ```
> > > emitWorksharingHelper(...);
> > > emitWorksharingHelper(...);
> > > emitWorksharingHelper(...);
> > > ```
> > > 
> > > Wouldn't that be cleaner?
> > 1. It requires the new `OMPDummyRAII` class.
> > 2. Thу functionality under control of the `else` branch also must be 
> > affected.
> > 3. We don't always need to check for `HasLastprivate`.
> > 4. The `NumIteratorsGen` might be different.
> > 5. We'll have a lot of trouble with adding new functionality to this 
> > function, especially if this functionality is unique for one construct and 
> > not required for others.
> > 1. It requires the new OMPDummyRAII class.
> 
> Sure, is it more than this?
> ```
> struct OMPDummyRAII {
>   OMPDummyRAII(...) {}
> };
> ```
> 
> > 2. Thу functionality under control of the else branch also must be affected.
> 
> Right: `sed -e/OMPCancelStackRAII/RAII/` :)
> 
> > 3. We don't always need to check for HasLastprivate.
> 
> There is no cost in doing so though. 
> 
> > 4. The NumIteratorsGen might be different.
> 
> Might be or is? Eyeballing this it looks like 3 times exact the same code.
> 
> > 5. We'll have a lot of trouble with adding new functionality to this 
> > function, especially if this functionality is unique for one construct and 
> > not required for others.
> 
> What new functionality do you expect to be unique between them? If there is 
> stuff planned, we might not want to unify the implementation, if it is just a 
> hunch, we want to go ahead and have a single implemenation so it is easier to 
> read and do global modifications. Finding out that something needs special 
> handling is at the end of the day easier than finding all other (unrelated) 
> locations that need to be changed.
> What new functionality do you expect to be unique between them? If there is 
> stuff planned, we might not want to unify the implementation, if it is just a 
> hunch, we want to go ahead and have a single implemenat

[PATCH] D81970: [Clang][Driver] Remove gold linker support for PS4 toolchain

2020-06-17 Thread Yuanfang Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2956cc50f340: [Clang][Driver] Remove gold linker support for 
PS4 toolchain (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81970

Files:
  clang/lib/Driver/ToolChains/PS4CPU.cpp
  clang/test/Driver/ps4-linker-non-win.c
  clang/test/Driver/ps4-linker-win.c

Index: clang/test/Driver/ps4-linker-win.c
===
--- clang/test/Driver/ps4-linker-win.c
+++ clang/test/Driver/ps4-linker-win.c
@@ -1,27 +1,19 @@
-// The full path to the gold linker was not found on Windows because the
-// driver fails to add an .exe extension to the name.
-// We check that gold linker's full name (with an extension) is specified
-// on the command line if -fuse-ld=gold, or -shared with no -fuse-ld option
-// are passed. Otherwise, we check that the PS4's linker's full name is
-// specified.
+// This test check that orbis-ld is used for linker all the time. Specifying
+// linker using -fuse-ld causes a error message emitted and compilation fail.
 
 // REQUIRES: system-windows, x86-registered-target
 
 // RUN: mkdir -p %t
 // RUN: touch %t/orbis-ld.exe
-// RUN: touch %t/orbis-ld.gold.exe
-
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -fuse-ld=gold -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-GOLD %s
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-GOLD %s
 
 // RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -fuse-ld=ps4 -### 2>&1 \
+// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared \
-// RUN: -fuse-ld=ps4 -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-LINKER %s
 
-// CHECK-PS4-GOLD: \\orbis-ld.gold
 // CHECK-PS4-LINKER: \\orbis-ld
+
+// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4 %s -fuse-ld=gold -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=ERROR %s
+
+// ERROR: error: unsupported option '-fuse-ld' for target 'x86_64-scei-ps4'
Index: clang/test/Driver/ps4-linker-non-win.c
===
--- clang/test/Driver/ps4-linker-non-win.c
+++ clang/test/Driver/ps4-linker-non-win.c
@@ -6,16 +6,14 @@
 // RUN: touch %t/orbis-ld
 // RUN: chmod +x %t/orbis-ld
 
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -fuse-ld=gold 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -shared 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-
 // RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -fuse-ld=ps4 2>&1 \
+// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -shared 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -shared \
-// RUN: -fuse-ld=ps4 2>&1 | FileCheck --check-prefix=CHECK-PS4-LINKER %s
 
 // CHECK-PS4-LINKER: /orbis-ld
+
+// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4 %s -fuse-ld=gold 2>&1 \
+// RUN:   | FileCheck --check-prefix=ERROR %s
+
+// ERROR: error: unsupported option '-fuse-ld' for target 'x86_64-scei-ps4'
Index: clang/lib/Driver/ToolChains/PS4CPU.cpp
===
--- clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -88,13 +88,13 @@
 CmdArgs.push_back("--dependent-lib=libSceDbgAddressSanitizer_stub_weak.a");
 }
 
-static void ConstructPS4LinkJob(const Tool &T, Compilation &C,
-const JobAction &JA, const InputInfo &Output,
-const InputInfoList &Inputs,
-const ArgList &Args,
-const char *LinkingOutput) {
+void tools::PS4cpu::Link::ConstructJob(Compilation &C, const JobAction &JA,
+   const InputInfo &Output,
+   const InputInfoList &Inputs,
+   const ArgList &Args,
+   const char *LinkingOutput) const {
   const toolchains::FreeBSD &ToolChain =
-  static_cast(T.getToolChain());
+  static_cast(getToolChain());
   const Driver &D = ToolChain.getDriver();
   ArgStringList CmdArgs;
 
@@ -143,216 +143,15 @@
 CmdArgs.push_b

  1   2   >