[PATCH] D93298: [RISCV] add the MC layer support of Zfinx extension

2021-02-01 Thread Shao-Ce Sun via Phabricator via cfe-commits
achieveartificialintelligence added a comment.
Herald added a subscriber: vkmr.

Ping


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

https://reviews.llvm.org/D93298

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


[PATCH] D95307: [StaticAnalyzer] Add checking for degenerate base class in MemRegion

2021-02-01 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D95307#2532669 , @RedDocMD wrote:

> I clearly am taking the wrong approach to this problem. I will need to 
> reconsider how PointerToMember is actually modelled before solving this 
> problem

I don't know if this is useful or not, but pointer-to-members used to be `void 
*` up until very recently.  Here is my change on that topic (and it probably 
where the bug you're trying to fix initiated): https://reviews.llvm.org/D85817
I thought, it can be useful to see the areas of code where it all happens.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95307

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


[PATCH] D69322: [hip][cuda] Enable extended lambda support on Windows.

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

I agree that we should aim to avoid broad memory impact for uncommon features, 
and this seems to apply.




Comment at: clang/include/clang/AST/DeclCXX.h:395-400
 /// The number used to indicate this lambda expression for name
 /// mangling in the Itanium C++ ABI.
 unsigned ManglingNumber : 31;
 
+/// The device side mangling number.
+unsigned DeviceManglingNumber = 0;

rnk wrote:
> hliao wrote:
> > rnk wrote:
> > > It seems a shame to grow LambdaDefinitionData by a pointer for all users 
> > > of C++ that do not use CUDA. Optimizing bitfields may be worth the time, 
> > > but I'll leave it to @rjmccall or @rsmith to give guidance on whether 
> > > that's worth it.
> > > 
> > > An alternative would be to store the device numbers in the mangling 
> > > context and look them up when needed, since they are so rarely needed.
> > I like the alternative way by storing all numbering into the 
> > mangle/numbering context instead of AST itself. But, it needs additional 
> > numbering post-processing after AST importing. Sound to me a major 
> > refactoring work likely to be addressed later.
> Generally, I don't think we can count on contributors to come back later and 
> optimize memory usage, so it seems reasonable to ask to avoid the regression 
> in the first place. Above I see the bitfield usage optimizing memory usage of 
> the number of captures, and then here we spent lots of memory storing device 
> mangling numbers that are only used for CUDA. I think the memory usage 
> concern still stands. I don't think it's unreasonable to maintain these 
> numbers on the side in a DenseMap.
> 
> @rsmith or @rjmccall, do you agree with that reasoning?
I think that's the right idea in general.  I don't know how much it really 
matters for LambdaData, because there aren't a huge number of lambdas in 
typical translation units.  But if you want to optimize this, a hashtable in 
the `ASTContext` or `ManglingContext` seems reasonable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69322

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


[PATCH] D69322: [hip][cuda] Enable extended lambda support on Windows.

2021-02-01 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 320409.
hliao added a comment.

Rebase to the main branch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69322

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/Mangle.h
  clang/include/clang/AST/MangleNumberingContext.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/CXXABI.h
  clang/lib/AST/ItaniumCXXABI.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftCXXABI.cpp
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CodeGenCUDA/ms-linker-options.cu
  clang/test/CodeGenCUDA/unnamed-types.cu

Index: clang/test/CodeGenCUDA/unnamed-types.cu
===
--- clang/test/CodeGenCUDA/unnamed-types.cu
+++ clang/test/CodeGenCUDA/unnamed-types.cu
@@ -1,12 +1,17 @@
 // RUN: %clang_cc1 -std=c++11 -x hip -triple x86_64-linux-gnu -aux-triple amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck %s --check-prefix=HOST
+// RUN: %clang_cc1 -std=c++11 -x hip -triple x86_64-pc-windows-msvc -aux-triple amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck %s --check-prefix=MSVC
 // RUN: %clang_cc1 -std=c++11 -x hip -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm %s -o - | FileCheck %s --check-prefix=DEVICE
 
 #include "Inputs/cuda.h"
 
 // HOST: @0 = private unnamed_addr constant [43 x i8] c"_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_\00", align 1
+// HOST: @1 = private unnamed_addr constant [60 x i8] c"_Z2k1IZ2f1PfEUlfE_Z2f1S0_EUlffE_Z2f1S0_EUlfE0_EvS0_T_T0_T1_\00", align 1
+// Check that, on MSVC, the same device kernel mangling name is generated.
+// MSVC: @0 = private unnamed_addr constant [43 x i8] c"_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_\00", align 1
+// MSVC: @1 = private unnamed_addr constant [60 x i8] c"_Z2k1IZ2f1PfEUlfE_Z2f1S0_EUlffE_Z2f1S0_EUlfE0_EvS0_T_T0_T1_\00", align 1
 
 __device__ float d0(float x) {
-  return [](float x) { return x + 2.f; }(x);
+  return [](float x) { return x + 1.f; }(x);
 }
 
 __device__ float d1(float x) {
@@ -14,11 +19,21 @@
 }
 
 // DEVICE: amdgpu_kernel void @_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_(
+// DEVICE: define internal float @_ZZZ2f1PfENKUlS_E_clES_ENKUlfE_clEf(
 template 
 __global__ void k0(float *p, F f) {
   p[0] = f(p[0]) + d0(p[1]) + d1(p[2]);
 }
 
+// DEVICE: amdgpu_kernel void @_Z2k1IZ2f1PfEUlfE_Z2f1S0_EUlffE_Z2f1S0_EUlfE0_EvS0_T_T0_T1_(
+// DEVICE: define internal float @_ZZ2f1PfENKUlfE_clEf(
+// DEVICE: define internal float @_ZZ2f1PfENKUlffE_clEff(
+// DEVICE: define internal float @_ZZ2f1PfENKUlfE0_clEf(
+template 
+__global__ void k1(float *p, F0 f0, F1 f1, F2 f2) {
+  p[0] = f0(p[0]) + f1(p[1], p[2]) + f2(p[3]);
+}
+
 void f0(float *p) {
   [](float *p) {
 *p = 1.f;
@@ -29,11 +44,17 @@
 // linkages are still required to keep the original `internal` linkage.
 
 // HOST: define internal void @_ZZ2f1PfENKUlS_E_clES_(
-// DEVICE: define internal float @_ZZZ2f1PfENKUlS_E_clES_ENKUlfE_clEf(
 void f1(float *p) {
   [](float *p) {
-k0<<<1,1>>>(p, [] __device__ (float x) { return x + 1.f; });
+k0<<<1,1>>>(p, [] __device__ (float x) { return x + 3.f; });
   }(p);
+  k1<<<1,1>>>(p,
+  [] __device__ (float x) { return x + 4.f; },
+  [] __device__ (float x, float y) { return x * y; },
+  [] __device__ (float x) { return x + 5.f; });
 }
 // HOST: @__hip_register_globals
 // HOST: __hipRegisterFunction{{.*}}@_Z17__device_stub__k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_{{.*}}@0
+// HOST: __hipRegisterFunction{{.*}}@_Z17__device_stub__k1IZ2f1PfEUlfE_Z2f1S0_EUlffE_Z2f1S0_EUlfE0_EvS0_T_T0_T1_{{.*}}@1
+// MSVC: __hipRegisterFunction{{.*}}@"??$k0@V@?0???R1?0??f1@@YAXPEAM@Z@QEBA@0@Z@@@YAXPEAMV@?0???R0?0??f1@@YAX0@Z@QEBA@0@Z@@Z{{.*}}@0
+// MSVC: __hipRegisterFunction{{.*}}@"??$k1@V@?0??f1@@YAXPEAM@Z@V@?0??2@YAX0@Z@V@?0??2@YAX0@Z@@@YAXPEAMV@?0??f1@@YAX0@Z@V@?0??1@YAX0@Z@V@?0??1@YAX0@Z@@Z{{.*}}@1
Index: clang/test/CodeGenCUDA/ms-linker-options.cu
===
--- clang/test/CodeGenCUDA/ms-linker-options.cu
+++ clang/test/CodeGenCUDA/ms-linker-options.cu
@@ -2,12 +2,12 @@
 // RUN:   -fno-autolink -triple amdgcn-amd-amdhsa \
 // RUN:   | FileCheck -check-prefix=DEV %s
 // RUN: %clang_cc1 -emit-llvm -o - -fms-extensions -x hip %s -triple \
-// RUN:x86_64-pc-windows-msvc | FileCheck -check-prefix=HOST %s
+// RUN:x86_64-pc-windows-msvc -aux-triple amdgcn | FileCheck -check-prefix=HOST %s
 // RUN: %clang_cc1 -emit-llvm -o - -fcuda-is-device -fms-extensions %s \
 // RUN:   -fno-autolink -triple amdgcn-amd-amdhsa \
 // RUN:   | FileCheck -check-prefix=DEV %s
 // RUN: %clang_cc1 -emit-llvm -o - -fms-extensions %s -triple \
-// RUN:x86_64-pc-windows-msvc | FileCheck -check-prefix=HOST %s
+// RUN:x86_64

[PATCH] D95776: [OpenCL] Add macro definitions of OpenCL C 3.0 features

2021-02-01 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov created this revision.
azabaznov added reviewers: Anastasia, mantognini.
Herald added subscribers: jfb, yaxunl.
azabaznov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch adds possibility to define OpenCL C 3.0 feature macros
via command line option or target setting.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95776

Files:
  clang/include/clang/Basic/OpenCLExtensions.def
  clang/lib/Basic/Targets.cpp
  clang/lib/Headers/opencl-c-base.h
  clang/lib/Headers/opencl-c.h
  clang/test/SemaOpenCL/features.cl

Index: clang/test/SemaOpenCL/features.cl
===
--- /dev/null
+++ clang/test/SemaOpenCL/features.cl
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -cl-std=CL1.1
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -cl-std=CL1.2
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -cl-std=CL2.0
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -cl-std=CL2.0 -finclude-default-header
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -cl-std=CL2.0 -cl-ext=+__opencl_c_pipes
+
+// All features are unsupported
+// RUN: %clang_cc1 %s -triple r600-unknown-unknown -verify -cl-std=CL3.0
+// RUN: %clang_cc1 %s -triple r600-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_pipes -DPIPES
+
+// expected-no-diagnostics
+
+// FULL OpenCL profile
+#ifndef __opencl_c_int64
+#pragma error "Macro __opencl_c_int64 should be defined"
+#endif
+
+#ifdef PIPES
+ #ifndef __opencl_c_pipes
+  #pragma error "Macro __opencl_c_pipes should be defined"
+ #endif
+#else
+ #ifdef __opencl_c_pipes
+  #pragma error "Macro __opencl_c_pipes should not be defined"
+ #endif
+#endif
Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -17157,6 +17157,20 @@
 // Disable any extensions we may have enabled previously.
 #pragma OPENCL EXTENSION all : disable
 
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200)
+#undef __opencl_c_pipes
+#undef __opencl_c_generic_address_space
+#undef __opencl_c_work_group_collective_functions
+#undef __opencl_c_atomic_order_acq_rel
+#undef __opencl_c_atomic_order_seq_cst
+#undef __opencl_c_atomic_scope_device
+#undef __opencl_c_atomic_scope_all_devices
+#undef __opencl_c_device_enqueue
+#undef __opencl_c_read_write_images
+#undef __opencl_c_program_scope_global_variables
+#undef __opencl_c_images
+#endif
+
 #undef __cnfn
 #undef __ovld
 #endif //_OPENCL_H_
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -24,6 +24,21 @@
 #endif // defined(__SPIR__)
 #endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
 
+// Define feature macros for OpenCL C 2.0
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200)
+#define __opencl_c_pipes 1
+#define __opencl_c_generic_address_space 1
+#define __opencl_c_work_group_collective_functions 1
+#define __opencl_c_atomic_order_acq_rel 1
+#define __opencl_c_atomic_order_seq_cst 1
+#define __opencl_c_atomic_scope_device 1
+#define __opencl_c_atomic_scope_all_devices 1
+#define __opencl_c_device_enqueue 1
+#define __opencl_c_read_write_images 1
+#define __opencl_c_program_scope_global_variables 1
+#define __opencl_c_images 1
+#endif
+
 // built-in scalar data types:
 
 /**
Index: clang/lib/Basic/Targets.cpp
===
--- clang/lib/Basic/Targets.cpp
+++ clang/lib/Basic/Targets.cpp
@@ -720,7 +720,9 @@
 /// and language version
 void TargetInfo::getOpenCLFeatureDefines(const LangOptions &Opts,
  MacroBuilder &Builder) const {
-
+  // FIXME: OpenCL options which affect language semantics/syntax
+  // should be moved into LangOptions, thus macro definitions of
+  // such options is better to be done in clang::InitializePreprocessor
   auto defineOpenCLExtMacro = [&](llvm::StringRef Name, unsigned AvailVer,
   unsigned CoreVersions,
   unsigned OptionalVersions) {
@@ -737,7 +739,6 @@
   defineOpenCLExtMacro(#Ext, Avail, Core, Opt);
 #include "clang/Basic/OpenCLExtensions.def"
 
-  // FIXME: OpenCL options which affect language semantics/syntax
-  // should be moved into LangOptions, thus macro definitions of
-  // such options is better to be done in clang::InitializePreprocessor
+  // Assume compiling for FULL profile
+  Builder.defineMacro("__opencl_c_int64");
 }
Index: clang/include/clang/Basic/OpenCLExtensions.def
===
--- clang/include/clang/Basic/OpenCLExtensions.def
+++ clang/include/clang/Basic/OpenCLExtensions.def
@@ -64,7 +64,7 @@

[PATCH] D89869: [OpenCL] Define OpenCL feature macros for all versions

2021-02-01 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov abandoned this revision.
azabaznov added a comment.

Due to refactoring in https://reviews.llvm.org/D92277 this flow is no longer 
valid.  New patch for this functionality is here: 
https://reviews.llvm.org/D95776.


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

https://reviews.llvm.org/D89869

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


[PATCH] D95776: [OpenCL] Add macro definitions of OpenCL C 3.0 features

2021-02-01 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

I suggest that renaming 'extension' to 'option' (extensions + features) concept 
to be done in separate commit. There are a lot of places to change all over the 
place in clang.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95776

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


[PATCH] D94961: [OpenMP] Add OpenMP offloading toolchain for AMDGPU

2021-02-01 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal added a comment.

Ping!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94961

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


[PATCH] D93040: [InlineFunction] Use llvm.experimental.noalias.scope.decl for noalias arguments.

2021-02-01 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added inline comments.



Comment at: llvm/lib/Transforms/Utils/InlineFunction.cpp:929
 
-if (MDNode *M = NI->getMetadata(LLVMContext::MD_alias_scope))
-  NI->setMetadata(LLVMContext::MD_alias_scope, MDMap[M]);
+if (MDNode *M = I->getMetadata(LLVMContext::MD_alias_scope))
+  I->setMetadata(LLVMContext::MD_alias_scope, MDMap[M]);

@nikic In the full restrict patches, we also check if the instruction was 
already handled. I was able to trigger this with an assertion and I have a more 
or less reduced testcase.

Either we keep a SmallPtrSet and check if the instruction was already handled 
(this is what the full restrict version does; See D68509 
InlineFunction.cpp#969). Or we only replace the metadata if it is in the MDMap 
(by using MDMap.lookup(M).

Any preference ?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93040

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


[PATCH] D95778: [OpenCL] Introduce new language options for OpenCL keywords.

2021-02-01 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov created this revision.
azabaznov added reviewers: Anastasia, svenvh.
Herald added subscribers: dexonsmith, yaxunl.
Herald added a reviewer: jansvoboda11.
azabaznov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

OpenCL keywords 'pipe' and 'generic' are unconditionally
supported for OpenCL C 2.0 or in OpenCL C++ mode. In OpenCL C 3.0
these keywords are available if corresponding optional core
feature is supported.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95778

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaType.cpp


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2060,10 +2060,9 @@
   !PointeeType->isSamplerT() &&
   !PointeeType.hasAddressSpace())
 PointeeType = S.getASTContext().getAddrSpaceQualType(
-PointeeType,
-S.getLangOpts().OpenCLCPlusPlus || S.getLangOpts().OpenCLVersion == 200
-? LangAS::opencl_generic
-: LangAS::opencl_private);
+PointeeType, S.getLangOpts().OpenCLGenericKeyword
+ ? LangAS::opencl_generic
+ : LangAS::opencl_private);
   return PointeeType;
 }
 
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -3894,8 +3894,7 @@
   isInvalid = DS.SetTypeAltiVecBool(true, Loc, PrevSpec, DiagID, Policy);
   break;
 case tok::kw_pipe:
-  if (!getLangOpts().OpenCL || (getLangOpts().OpenCLVersion < 200 &&
-!getLangOpts().OpenCLCPlusPlus)) {
+  if (!getLangOpts().OpenCLPipeKeyword) {
 // OpenCL 2.0 defined this keyword. OpenCL 1.2 and earlier should
 // support the "pipe" word as identifier.
 Tok.getIdentifierInfo()->revertTokenIDToIdentifier();
@@ -4017,8 +4016,7 @@
 case tok::kw___generic:
   // generic address space is introduced only in OpenCL v2.0
   // see OpenCL C Spec v2.0 s6.5.5
-  if (Actions.getLangOpts().OpenCLVersion < 200 &&
-  !Actions.getLangOpts().OpenCLCPlusPlus) {
+  if (!Actions.getLangOpts().OpenCLGenericKeyword) {
 DiagID = diag::err_opencl_unknown_type_specifier;
 PrevSpec = Tok.getIdentifierInfo()->getNameStart();
 isInvalid = true;
@@ -5070,8 +5068,7 @@
   default: return false;
 
   case tok::kw_pipe:
-return (getLangOpts().OpenCL && getLangOpts().OpenCLVersion >= 200) ||
-   getLangOpts().OpenCLCPlusPlus;
+return getLangOpts().OpenCLPipeKeyword;
 
   case tok::identifier:   // foo::bar
 // Unfortunate hack to support "Class.factoryMethod" notation.
@@ -5599,8 +5596,7 @@
   if (Kind == tok::star || Kind == tok::caret)
 return true;
 
-  if (Kind == tok::kw_pipe &&
-  ((Lang.OpenCL && Lang.OpenCLVersion >= 200) || Lang.OpenCLCPlusPlus))
+  if (Kind == tok::kw_pipe && Lang.OpenCLPipeKeyword)
 return true;
 
   if (!Lang.CPlusPlus)
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2098,6 +2098,9 @@
 Opts.ZVector = 0;
 Opts.setDefaultFPContractMode(LangOptions::FPM_On);
 Opts.OpenCLCPlusPlus = Opts.CPlusPlus;
+Opts.OpenCLPipeKeyword = Opts.OpenCLCPlusPlus || Opts.OpenCLVersion == 200;
+Opts.OpenCLGenericKeyword =
+Opts.OpenCLCPlusPlus || Opts.OpenCLVersion == 200;
 
 // Include default header file for OpenCL.
 if (Opts.IncludeDefaultHeader) {
Index: clang/include/clang/Basic/LangOptions.def
===
--- clang/include/clang/Basic/LangOptions.def
+++ clang/include/clang/Basic/LangOptions.def
@@ -215,6 +215,8 @@
 LANGOPT(OpenCLVersion , 32, 0, "OpenCL C version")
 LANGOPT(OpenCLCPlusPlus   , 1, 0, "C++ for OpenCL")
 LANGOPT(OpenCLCPlusPlusVersion , 32, 0, "C++ for OpenCL version")
+LANGOPT(OpenCLGenericKeyword, 1, 0, "OpenCL generic keyword")
+LANGOPT(OpenCLPipeKeyword   , 1, 0, "OpenCL pipe keyword")
 LANGOPT(NativeHalfType, 1, 0, "Native half type support")
 LANGOPT(NativeHalfArgsAndReturns, 1, 0, "Native half args and returns")
 LANGOPT(HalfArgsAndReturns, 1, 0, "half args and returns")


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2060,10 +2060,9 @@
   !PointeeType->isSamplerT() &&
   !PointeeType.hasAddressSpace())
 PointeeType = S.getASTContext().getAddrSpaceQualType(
-PointeeType,
-S.getLangOpts().OpenCLCPlusPlus || S.getLangOpts().OpenCLVersion == 200
-

[PATCH] D94955: [clang-format] Treat ForEachMacros as loops

2021-02-01 Thread Jiashu Zou via Phabricator via cfe-commits
GoBigorGoHome updated this revision to Diff 320426.
GoBigorGoHome added a comment.

Update tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94955

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -992,20 +992,39 @@
 }
 
 TEST_F(FormatTest, ForEachLoops) {
+  FormatStyle Style = getLLVMStyle();
+  EXPECT_NE("void f() {\n"
+"  foreach (Item *item, itemlist) {}\n"
+"  Q_FOREACH (Item *item, itemlist) {}\n"
+"  BOOST_FOREACH (Item *item, itemlist) {}\n"
+"  UNKNOWN_FORACH(Item * item, itemlist) {}\n"
+"}",
+format("void f() {\n"
+   "  foreach (Item *item, itemlist) {}\n"
+   "  Q_FOREACH (Item *item, itemlist) {}\n"
+   "  BOOST_FOREACH (Item *item, itemlist) {}\n"
+   "  UNKNOWN_FORACH(Item * item, itemlist) {}\n"
+   "}",
+   Style));
   verifyFormat("void f() {\n"
-   "  foreach (Item *item, itemlist) {}\n"
-   "  Q_FOREACH (Item *item, itemlist) {}\n"
-   "  BOOST_FOREACH (Item *item, itemlist) {}\n"
+   "  foreach (Item *item, itemlist) {\n"
+   "  }\n"
+   "  Q_FOREACH (Item *item, itemlist) {\n"
+   "  }\n"
+   "  BOOST_FOREACH (Item *item, itemlist) {\n"
+   "  }\n"
"  UNKNOWN_FORACH(Item * item, itemlist) {}\n"
"}");
 
-  FormatStyle Style = getLLVMStyle();
   Style.SpaceBeforeParens =
   FormatStyle::SBPO_ControlStatementsExceptForEachMacros;
   verifyFormat("void f() {\n"
-   "  foreach(Item *item, itemlist) {}\n"
-   "  Q_FOREACH(Item *item, itemlist) {}\n"
-   "  BOOST_FOREACH(Item *item, itemlist) {}\n"
+   "  foreach(Item *item, itemlist) {\n"
+   "  }\n"
+   "  Q_FOREACH(Item *item, itemlist) {\n"
+   "  }\n"
+   "  BOOST_FOREACH(Item *item, itemlist) {\n"
+   "  }\n"
"  UNKNOWN_FORACH(Item * item, itemlist) {}\n"
"}",
Style);
@@ -19021,6 +19040,18 @@
 "}",
 format(Source, Style));
 }
+
+TEST_F(FormatTest, TreatForEachMacrosAsLoops) {
+  FormatStyle Style = getLLVMStyle();
+  Style.ForEachMacros.push_back("rng");
+  Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Always;
+  verifyFormat("rng (i, 0, 10) { int j = 1; }", Style);
+  Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
+  verifyFormat("rng (i, 0, 10) {\n"
+   "  int j = 1;\n"
+   "}",
+   Style);
+}
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -306,7 +306,8 @@
 }
 // Try to merge a control statement block with left brace unwrapped
 if (TheLine->Last->is(tok::l_brace) && TheLine->First != TheLine->Last &&
-TheLine->First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_for)) {
+TheLine->First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_for,
+TT_ForEachMacro)) {
   return Style.AllowShortBlocksOnASingleLine != FormatStyle::SBS_Never
  ? tryMergeSimpleBlock(I, E, Limit)
  : 0;
@@ -421,7 +422,8 @@
  ? tryMergeSimpleControlStatement(I, E, Limit)
  : 0;
 }
-if (TheLine->First->isOneOf(tok::kw_for, tok::kw_while, tok::kw_do)) {
+if (TheLine->First->isOneOf(tok::kw_for, tok::kw_while, tok::kw_do,
+TT_ForEachMacro)) {
   return Style.AllowShortLoopsOnASingleLine
  ? tryMergeSimpleControlStatement(I, E, Limit)
  : 0;
@@ -474,7 +476,7 @@
 if (1 + I[1]->Last->TotalLength > Limit)
   return 0;
 if (I[1]->First->isOneOf(tok::semi, tok::kw_if, tok::kw_for, tok::kw_while,
- TT_LineComment))
+ TT_ForEachMacro, TT_LineComment))
   return 0;
 // Only inline simple if's (no nested if or else), unless specified
 if (Style.AllowShortIfStatementsOnASingleLine != FormatStyle::SIS_Always) {
@@ -578,12 +580,14 @@
   I + 2 != E && !I[2]->First->is(tok::r_brace))
 return 0;
   if (!Style.AllowShortLoopsOnASingleLine &&
-  Line.First->isOneOf(tok::kw_while, tok::kw_do, tok::kw_for) &&
+  Line.First->isOneOf(tok::kw_while, tok

[clang-tools-extra] 94fac81 - [Branch-Rename] Fix some links

2021-02-01 Thread via cfe-commits

Author: xgupta
Date: 2021-02-01T16:43:21+05:30
New Revision: 94fac81fccfef9917e94bed398781744fb82e159

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

LOG: [Branch-Rename] Fix some links

According to the [[ https://foundation.llvm.org/docs/branch-rename/ | status of 
branch rename ]], the master branch of the LLVM repository is removed on 28 Jan 
2021.

Reviewed By: mehdi_amini

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
clang-tools-extra/clangd/README.md
clang-tools-extra/docs/clang-rename.rst
clang-tools-extra/docs/clang-tidy/Contributing.rst
clang-tools-extra/docs/clang-tidy/Integrations.rst
clang/docs/ClangPlugins.rst
clang/docs/ClangTools.rst
clang/docs/ControlFlowIntegrityDesign.rst
clang/docs/InternalsManual.rst
clang/docs/LibTooling.rst
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/www/analyzer/checker_dev_manual.html
clang/www/analyzer/open_projects.html
clang/www/hacking.html
clang/www/menu.html.incl
compiler-rt/include/sanitizer/tsan_interface_atomic.h
compiler-rt/lib/tsan/rtl/tsan_interface.h
compiler-rt/www/menu.html.incl
flang/README.md
flang/docs/_templates/indexsidebar.html
flang/docs/flang-c-style.el
libcxx/docs/index.rst
libcxx/www/atomic_design.html
libcxx/www/atomic_design_a.html
libcxx/www/atomic_design_b.html
libcxx/www/atomic_design_c.html
libcxx/www/index.html
libcxx/www/ts1z_status.html
libcxx/www/type_traits_design.html
libcxx/www/upcoming_meeting.html
libcxxabi/www/index.html
libunwind/docs/index.rst
lldb/docs/resources/build.rst
lldb/docs/resources/test.rst
lldb/docs/use/python-reference.rst
llvm/docs/Vectorizers.rst
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/test/Transforms/SLPVectorizer/AArch64/matmul.ll
llvm/utils/lit/setup.py
mlir/docs/DeclarativeRewrites.md
mlir/docs/Dialects/SPIR-V.md
mlir/docs/Dialects/Vector.md
mlir/docs/OpDefinitions.md
mlir/docs/PatternRewriter.md
mlir/docs/Rationale/RationaleGenericDAGRewriter.md
mlir/docs/SPIRVToLLVMDialectConversion.md
mlir/docs/ShapeInference.md
mlir/docs/Tutorials/UnderstandingTheIRStructure.md
openmp/www/index.html
polly/www/menu.html.incl

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h 
b/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
index a9989ee51bcf..eb2b2bfcc6aa 100644
--- a/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
+++ b/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
@@ -17,7 +17,7 @@ namespace google {
 namespace readability {
 
 // Check for underscores in the names of googletest tests, per
-// 
https://github.com/google/googletest/blob/master/googletest/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
+// 
https://github.com/google/googletest/blob/master/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
 ///
 /// For the user-facing documentation see:
 /// 
http://clang.llvm.org/extra/clang-tidy/checks/google-readability-avoid-underscore-in-googletest-name.html

diff  --git a/clang-tools-extra/clangd/README.md 
b/clang-tools-extra/clangd/README.md
index 3ef9174c9529..c5ed07195060 100644
--- a/clang-tools-extra/clangd/README.md
+++ b/clang-tools-extra/clangd/README.md
@@ -5,7 +5,7 @@ This is not its documentation.
 
 - the **website** is https://clangd.llvm.org/.
 - the **bug tracker** is https://github.com/clangd/clangd/issues
-- the **source code** is hosted at 
https://github.com/llvm/llvm-project/tree/master/clang-tools-extra/clangd.
+- the **source code** is hosted at 
https://github.com/llvm/llvm-project/tree/main/clang-tools-extra/clangd.
 - the **website source code** is at https://github.com/llvm/clangd-www/
 
 ### Communication channels

diff  --git a/clang-tools-extra/docs/clang-rename.rst 
b/clang-tools-extra/docs/clang-rename.rst
index b45ba01c06a2..e797c9bafe8a 100644
--- a/clang-tools-extra/docs/clang-rename.rst
+++ b/clang-tools-extra/docs/clang-rename.rst
@@ -142,7 +142,7 @@ Vim Integration
 You can call :program:`clang-rename` directly from Vim! To set up
 :program:`clang-rename` integration for Vim see
 `clang/tools/clang-rename/clang-rename.py
-`_.
+`_.
 
 Please note that **you have to save all buffers, in which the replacement will
 h

[libunwind] 94fac81 - [Branch-Rename] Fix some links

2021-02-01 Thread via cfe-commits

Author: xgupta
Date: 2021-02-01T16:43:21+05:30
New Revision: 94fac81fccfef9917e94bed398781744fb82e159

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

LOG: [Branch-Rename] Fix some links

According to the [[ https://foundation.llvm.org/docs/branch-rename/ | status of 
branch rename ]], the master branch of the LLVM repository is removed on 28 Jan 
2021.

Reviewed By: mehdi_amini

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
clang-tools-extra/clangd/README.md
clang-tools-extra/docs/clang-rename.rst
clang-tools-extra/docs/clang-tidy/Contributing.rst
clang-tools-extra/docs/clang-tidy/Integrations.rst
clang/docs/ClangPlugins.rst
clang/docs/ClangTools.rst
clang/docs/ControlFlowIntegrityDesign.rst
clang/docs/InternalsManual.rst
clang/docs/LibTooling.rst
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/www/analyzer/checker_dev_manual.html
clang/www/analyzer/open_projects.html
clang/www/hacking.html
clang/www/menu.html.incl
compiler-rt/include/sanitizer/tsan_interface_atomic.h
compiler-rt/lib/tsan/rtl/tsan_interface.h
compiler-rt/www/menu.html.incl
flang/README.md
flang/docs/_templates/indexsidebar.html
flang/docs/flang-c-style.el
libcxx/docs/index.rst
libcxx/www/atomic_design.html
libcxx/www/atomic_design_a.html
libcxx/www/atomic_design_b.html
libcxx/www/atomic_design_c.html
libcxx/www/index.html
libcxx/www/ts1z_status.html
libcxx/www/type_traits_design.html
libcxx/www/upcoming_meeting.html
libcxxabi/www/index.html
libunwind/docs/index.rst
lldb/docs/resources/build.rst
lldb/docs/resources/test.rst
lldb/docs/use/python-reference.rst
llvm/docs/Vectorizers.rst
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/test/Transforms/SLPVectorizer/AArch64/matmul.ll
llvm/utils/lit/setup.py
mlir/docs/DeclarativeRewrites.md
mlir/docs/Dialects/SPIR-V.md
mlir/docs/Dialects/Vector.md
mlir/docs/OpDefinitions.md
mlir/docs/PatternRewriter.md
mlir/docs/Rationale/RationaleGenericDAGRewriter.md
mlir/docs/SPIRVToLLVMDialectConversion.md
mlir/docs/ShapeInference.md
mlir/docs/Tutorials/UnderstandingTheIRStructure.md
openmp/www/index.html
polly/www/menu.html.incl

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h 
b/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
index a9989ee51bcf..eb2b2bfcc6aa 100644
--- a/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
+++ b/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
@@ -17,7 +17,7 @@ namespace google {
 namespace readability {
 
 // Check for underscores in the names of googletest tests, per
-// 
https://github.com/google/googletest/blob/master/googletest/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
+// 
https://github.com/google/googletest/blob/master/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
 ///
 /// For the user-facing documentation see:
 /// 
http://clang.llvm.org/extra/clang-tidy/checks/google-readability-avoid-underscore-in-googletest-name.html

diff  --git a/clang-tools-extra/clangd/README.md 
b/clang-tools-extra/clangd/README.md
index 3ef9174c9529..c5ed07195060 100644
--- a/clang-tools-extra/clangd/README.md
+++ b/clang-tools-extra/clangd/README.md
@@ -5,7 +5,7 @@ This is not its documentation.
 
 - the **website** is https://clangd.llvm.org/.
 - the **bug tracker** is https://github.com/clangd/clangd/issues
-- the **source code** is hosted at 
https://github.com/llvm/llvm-project/tree/master/clang-tools-extra/clangd.
+- the **source code** is hosted at 
https://github.com/llvm/llvm-project/tree/main/clang-tools-extra/clangd.
 - the **website source code** is at https://github.com/llvm/clangd-www/
 
 ### Communication channels

diff  --git a/clang-tools-extra/docs/clang-rename.rst 
b/clang-tools-extra/docs/clang-rename.rst
index b45ba01c06a2..e797c9bafe8a 100644
--- a/clang-tools-extra/docs/clang-rename.rst
+++ b/clang-tools-extra/docs/clang-rename.rst
@@ -142,7 +142,7 @@ Vim Integration
 You can call :program:`clang-rename` directly from Vim! To set up
 :program:`clang-rename` integration for Vim see
 `clang/tools/clang-rename/clang-rename.py
-`_.
+`_.
 
 Please note that **you have to save all buffers, in which the replacement will
 h

[clang] 94fac81 - [Branch-Rename] Fix some links

2021-02-01 Thread via cfe-commits

Author: xgupta
Date: 2021-02-01T16:43:21+05:30
New Revision: 94fac81fccfef9917e94bed398781744fb82e159

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

LOG: [Branch-Rename] Fix some links

According to the [[ https://foundation.llvm.org/docs/branch-rename/ | status of 
branch rename ]], the master branch of the LLVM repository is removed on 28 Jan 
2021.

Reviewed By: mehdi_amini

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
clang-tools-extra/clangd/README.md
clang-tools-extra/docs/clang-rename.rst
clang-tools-extra/docs/clang-tidy/Contributing.rst
clang-tools-extra/docs/clang-tidy/Integrations.rst
clang/docs/ClangPlugins.rst
clang/docs/ClangTools.rst
clang/docs/ControlFlowIntegrityDesign.rst
clang/docs/InternalsManual.rst
clang/docs/LibTooling.rst
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/www/analyzer/checker_dev_manual.html
clang/www/analyzer/open_projects.html
clang/www/hacking.html
clang/www/menu.html.incl
compiler-rt/include/sanitizer/tsan_interface_atomic.h
compiler-rt/lib/tsan/rtl/tsan_interface.h
compiler-rt/www/menu.html.incl
flang/README.md
flang/docs/_templates/indexsidebar.html
flang/docs/flang-c-style.el
libcxx/docs/index.rst
libcxx/www/atomic_design.html
libcxx/www/atomic_design_a.html
libcxx/www/atomic_design_b.html
libcxx/www/atomic_design_c.html
libcxx/www/index.html
libcxx/www/ts1z_status.html
libcxx/www/type_traits_design.html
libcxx/www/upcoming_meeting.html
libcxxabi/www/index.html
libunwind/docs/index.rst
lldb/docs/resources/build.rst
lldb/docs/resources/test.rst
lldb/docs/use/python-reference.rst
llvm/docs/Vectorizers.rst
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/test/Transforms/SLPVectorizer/AArch64/matmul.ll
llvm/utils/lit/setup.py
mlir/docs/DeclarativeRewrites.md
mlir/docs/Dialects/SPIR-V.md
mlir/docs/Dialects/Vector.md
mlir/docs/OpDefinitions.md
mlir/docs/PatternRewriter.md
mlir/docs/Rationale/RationaleGenericDAGRewriter.md
mlir/docs/SPIRVToLLVMDialectConversion.md
mlir/docs/ShapeInference.md
mlir/docs/Tutorials/UnderstandingTheIRStructure.md
openmp/www/index.html
polly/www/menu.html.incl

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h 
b/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
index a9989ee51bcf..eb2b2bfcc6aa 100644
--- a/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
+++ b/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
@@ -17,7 +17,7 @@ namespace google {
 namespace readability {
 
 // Check for underscores in the names of googletest tests, per
-// 
https://github.com/google/googletest/blob/master/googletest/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
+// 
https://github.com/google/googletest/blob/master/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
 ///
 /// For the user-facing documentation see:
 /// 
http://clang.llvm.org/extra/clang-tidy/checks/google-readability-avoid-underscore-in-googletest-name.html

diff  --git a/clang-tools-extra/clangd/README.md 
b/clang-tools-extra/clangd/README.md
index 3ef9174c9529..c5ed07195060 100644
--- a/clang-tools-extra/clangd/README.md
+++ b/clang-tools-extra/clangd/README.md
@@ -5,7 +5,7 @@ This is not its documentation.
 
 - the **website** is https://clangd.llvm.org/.
 - the **bug tracker** is https://github.com/clangd/clangd/issues
-- the **source code** is hosted at 
https://github.com/llvm/llvm-project/tree/master/clang-tools-extra/clangd.
+- the **source code** is hosted at 
https://github.com/llvm/llvm-project/tree/main/clang-tools-extra/clangd.
 - the **website source code** is at https://github.com/llvm/clangd-www/
 
 ### Communication channels

diff  --git a/clang-tools-extra/docs/clang-rename.rst 
b/clang-tools-extra/docs/clang-rename.rst
index b45ba01c06a2..e797c9bafe8a 100644
--- a/clang-tools-extra/docs/clang-rename.rst
+++ b/clang-tools-extra/docs/clang-rename.rst
@@ -142,7 +142,7 @@ Vim Integration
 You can call :program:`clang-rename` directly from Vim! To set up
 :program:`clang-rename` integration for Vim see
 `clang/tools/clang-rename/clang-rename.py
-`_.
+`_.
 
 Please note that **you have to save all buffers, in which the replacement will
 h

[PATCH] D93040: [InlineFunction] Use llvm.experimental.noalias.scope.decl for noalias arguments.

2021-02-01 Thread Nikita Popov via Phabricator via cfe-commits
nikic added inline comments.



Comment at: llvm/lib/Transforms/Utils/InlineFunction.cpp:929
 
-if (MDNode *M = NI->getMetadata(LLVMContext::MD_alias_scope))
-  NI->setMetadata(LLVMContext::MD_alias_scope, MDMap[M]);
+if (MDNode *M = I->getMetadata(LLVMContext::MD_alias_scope))
+  I->setMetadata(LLVMContext::MD_alias_scope, MDMap[M]);

jeroen.dobbelaere wrote:
> @nikic In the full restrict patches, we also check if the instruction was 
> already handled. I was able to trigger this with an assertion and I have a 
> more or less reduced testcase.
> 
> Either we keep a SmallPtrSet and check if the instruction was already handled 
> (this is what the full restrict version does; See D68509 
> InlineFunction.cpp#969). Or we only replace the metadata if it is in the 
> MDMap (by using MDMap.lookup(M).
> 
> Any preference ?
> 
I don't understand under what circumstances we'd handle an instruction twice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93040

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


[PATCH] D88220: [C++20] P1825R0: More implicit moves

2021-02-01 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88220

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


[PATCH] D94961: [OpenMP] Add OpenMP offloading toolchain for AMDGPU

2021-02-01 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam added a comment.

LGTM. But, please wait from someone outside AMD to accept it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94961

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


[clang] eefa8a9 - Revert "[clang][cli] Port OpenMP-related LangOpts to marshalling system"

2021-02-01 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-02-01T12:50:48+01:00
New Revision: eefa8a9ff859153c510e740b33a9e721e42b88c5

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

LOG: Revert "[clang][cli] Port OpenMP-related LangOpts to marshalling system"

This reverts commit 9ad94c12

It turns out that to correctly generate command line flags for 
LangOptions::OpenMP and LangOptions::OpenMPSimd, we need the flexibility of C++.

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index a13a83eba6d5..aee312ea8e8a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2145,24 +2145,18 @@ def fopenmp_EQ : Joined<["-"], "fopenmp=">, 
Group;
 def fopenmp_use_tls : Flag<["-"], "fopenmp-use-tls">, Group,
   Flags<[NoArgumentUnused, HelpHidden]>;
 def fnoopenmp_use_tls : Flag<["-"], "fnoopenmp-use-tls">, Group,
-  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>,
-  MarshallingInfoNegativeFlag, !strconcat("(bool)", 
fopenmp.KeyPath)>,
-  ShouldParseIf;
+  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fopenmp_targets_EQ : CommaJoined<["-"], "fopenmp-targets=">, 
Flags<[NoXarchOption, CC1Option]>,
   HelpText<"Specify comma-separated list of triples OpenMP offloading targets 
to be supported">;
 def fopenmp_relocatable_target : Flag<["-"], "fopenmp-relocatable-target">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fnoopenmp_relocatable_target : Flag<["-"], "fnoopenmp-relocatable-target">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-defm openmp_simd : BoolFOption<"openmp-simd",
-  LangOpts<"OpenMPSimd">, DefaultFalse,
-  PosFlag,
-  NegFlag, BothFlags<[CC1Option, NoArgumentUnused]>>,
-  ShouldParseIf;
+def fopenmp_simd : Flag<["-"], "fopenmp-simd">, Group, 
Flags<[CC1Option, NoArgumentUnused]>,
+  HelpText<"Emit OpenMP code only for SIMD-based constructs.">;
 def fopenmp_enable_irbuilder : Flag<["-"], "fopenmp-enable-irbuilder">, 
Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>,
-  HelpText<"Use the experimental OpenMP-IR-Builder codegen path.">,
-  MarshallingInfoFlag>,
-  ShouldParseIf;
+  HelpText<"Use the experimental OpenMP-IR-Builder codegen path.">;
+def fno_openmp_simd : Flag<["-"], "fno-openmp-simd">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;
 def fopenmp_cuda_mode : Flag<["-"], "fopenmp-cuda-mode">, Group,
   Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fno_openmp_cuda_mode : Flag<["-"], "fno-openmp-cuda-mode">, Group,
@@ -5373,12 +5367,9 @@ def fno_cuda_host_device_constexpr : Flag<["-"], 
"fno-cuda-host-device-constexpr
 
//===--===//
 
 def fopenmp_is_device : Flag<["-"], "fopenmp-is-device">,
-  HelpText<"Generate code only for an OpenMP target device.">,
-  MarshallingInfoFlag>,
-  ShouldParseIf;
+  HelpText<"Generate code only for an OpenMP target device.">;
 def fopenmp_host_ir_file_path : Separate<["-"], "fopenmp-host-ir-file-path">,
-  HelpText<"Path to the IR file produced by the frontend for the host.">,
-  MarshallingInfoString>;
+  HelpText<"Path to the IR file produced by the frontend for the host.">;
 
 
//===--===//
 // SYCL Options

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index d602715ba03e..2f712ed6c706 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -494,12 +494,6 @@ static void FixupInvocation(CompilerInvocation &Invocation,
   << A->getSpelling() << T.getTriple();
   }
 
-  // Report if OpenMP host file does not exist.
-  if (!LangOpts.OMPHostIRFile.empty() &&
-  !llvm::sys::fs::exists(LangOpts.OMPHostIRFile))
-Diags.Report(diag::err_drv_omp_host_ir_file_not_found)
-<< LangOpts.OMPHostIRFile;
-
   if (!CodeGenOpts.ProfileRemappingFile.empty() && 
CodeGenOpts.LegacyPassManager)
 Diags.Report(diag::err_drv_argument_only_allowed_with)
 << Args.getLastArg(OPT_fprofile_remapping_file_EQ)->getAsString(Args)
@@ -2437,6 +2431,13 @@ void CompilerInvocation::ParseLangArgs(LangOptions 
&Opts, ArgList &Args,
   bool IsSimdSpecified =
   Args.hasFlag(options::OPT_fopenmp_simd, options::OPT_fno_openmp_simd,
/*Default=*/false);
+  Opts.OpenMPSimd = !Opts.OpenMP && IsSimdSpecified;
+  Opts.OpenMPUseTLS =
+  Opts.OpenMP && !Args.hasArg(options::OPT_fnoopenmp_use_tls);
+  Opts.OpenMPIsDevice =
+  Opts.OpenMP && Args.hasArg(options::OPT_fopenmp_is_device);
+  Opts.OpenMPIRBuilder =
+  Opts.OpenMP && Args.hasA

[PATCH] D95766: [Branch-Rename] Fix some links

2021-02-01 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta created this revision.
xgupta added reviewers: mehdi_amini, sqlbyme.
Herald added a reviewer: bollu.
Herald added subscribers: libcxx-commits, teijeong, rdzhabarov, tatianashp, 
ThomasRaoux, AlexeySotkin, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, 
liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, antiagainst, shauheen, 
rriddle, usaxena95, kadircet, jfb, arphaman, delcypher, hiraditya.
Herald added a reviewer: mravishankar.
Herald added a reviewer: antiagainst.
Herald added a reviewer: aartbik.
Herald added a reviewer: sscalpone.
Herald added a reviewer: ftynse.
Herald added a project: libunwind.
Herald added a reviewer: libunwind.
xgupta requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, openmp-commits, lldb-commits, 
Sanitizers, cfe-commits, sstefan1, stephenneuendorffer, nicolasvasilache.
Herald added projects: clang, Sanitizers, LLDB, libc++, OpenMP, libc++abi, 
MLIR, LLVM.
Herald added a reviewer: libc++.
Herald added a reviewer: libc++abi.

According to the status of branch rename 
, the master branch of the 
LLVM repository is removed on 28 Jan 2021.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95766

Files:
  clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
  clang-tools-extra/clangd/README.md
  clang-tools-extra/docs/clang-rename.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/Integrations.rst
  clang/docs/ClangPlugins.rst
  clang/docs/ClangTools.rst
  clang/docs/ControlFlowIntegrityDesign.rst
  clang/docs/InternalsManual.rst
  clang/docs/LibTooling.rst
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/www/analyzer/checker_dev_manual.html
  clang/www/analyzer/open_projects.html
  clang/www/hacking.html
  clang/www/menu.html.incl
  compiler-rt/include/sanitizer/tsan_interface_atomic.h
  compiler-rt/lib/tsan/rtl/tsan_interface.h
  compiler-rt/www/menu.html.incl
  flang/README.md
  flang/docs/_templates/indexsidebar.html
  flang/docs/flang-c-style.el
  libcxx/docs/index.rst
  libcxx/www/atomic_design.html
  libcxx/www/atomic_design_a.html
  libcxx/www/atomic_design_b.html
  libcxx/www/atomic_design_c.html
  libcxx/www/index.html
  libcxx/www/ts1z_status.html
  libcxx/www/type_traits_design.html
  libcxx/www/upcoming_meeting.html
  libcxxabi/www/index.html
  libunwind/docs/index.rst
  lldb/docs/resources/build.rst
  lldb/docs/resources/test.rst
  lldb/docs/use/python-reference.rst
  llvm/docs/Vectorizers.rst
  llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/test/Transforms/SLPVectorizer/AArch64/matmul.ll
  llvm/utils/lit/setup.py
  mlir/docs/DeclarativeRewrites.md
  mlir/docs/Dialects/SPIR-V.md
  mlir/docs/Dialects/Vector.md
  mlir/docs/OpDefinitions.md
  mlir/docs/PatternRewriter.md
  mlir/docs/Rationale/RationaleGenericDAGRewriter.md
  mlir/docs/SPIRVToLLVMDialectConversion.md
  mlir/docs/ShapeInference.md
  mlir/docs/Tutorials/UnderstandingTheIRStructure.md
  openmp/www/index.html
  polly/www/menu.html.incl

Index: polly/www/menu.html.incl
===
--- polly/www/menu.html.incl
+++ polly/www/menu.html.incl
@@ -34,7 +34,7 @@
 http://lab.llvm.org:8080/coverage/coverage-reports/polly/index.html";>Code Coverage
 http://llvm.org/reports/scan-build/";>Static analysis
 Doxygen
-https://github.com/llvm/llvm-project/tree/master/polly";>Source @ GitHub
+https://github.com/llvm/llvm-project/tree/main/polly";>Source @ GitHub
   
 
   
Index: openmp/www/index.html
===
--- openmp/www/index.html
+++ openmp/www/index.html
@@ -25,7 +25,7 @@
 https://lists.llvm.org/mailman/listinfo/openmp-dev";>openmp-dev
 https://lists.llvm.org/mailman/listinfo/openmp-commits";>openmp-commits
 https://bugs.llvm.org/";>Bug Reports
-https://github.com/llvm/llvm-project/tree/master/openmp";>Browse Sources
+https://github.com/llvm/llvm-project/tree/main/openmp";>Browse Sources
   
 
 
Index: mlir/docs/Tutorials/UnderstandingTheIRStructure.md
===
--- mlir/docs/Tutorials/UnderstandingTheIRStructure.md
+++ mlir/docs/Tutorials/UnderstandingTheIRStructure.md
@@ -86,7 +86,7 @@
 ```
 
 The code for the pass is available
-[here in the repo](https://github.com/llvm/llvm-project/blob/master/mlir/test/lib/IR/TestPrintNesting.cpp)
+[here in the repo](https://github.com/llvm/llvm-project/blob/main/mlir/test/lib/IR/TestPrintNesting.cpp)
 and can be exercised with `mlir-opt -test-print-nesting`.
 
 ### Example
@@ -273,7 +273,7 @@
 ```
 
 The illustrating code for this pass is available
-[here in the repo](https://github.com/llvm/llvm-project/blob/master/mlir/test/lib/IR/TestPrintDefUse.cpp)
+[here in the repo](https://github.com/llvm/llvm-project/blob/main/mlir

[PATCH] D95766: [Branch-Rename] Fix some links

2021-02-01 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini accepted this revision.
mehdi_amini added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h:20
 // Check for underscores in the names of googletest tests, per
-// 
https://github.com/google/googletest/blob/master/googletest/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
 ///

You removed the wrong word here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95766

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


[PATCH] D95766: [Branch-Rename] Fix some links

2021-02-01 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h:20
 // Check for underscores in the names of googletest tests, per
-// 
https://github.com/google/googletest/blob/master/googletest/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
 ///

mehdi_amini wrote:
> You removed the wrong word here?
Yes, docs were moved one step back.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95766

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


[PATCH] D95766: [Branch-Rename] Fix some links

2021-02-01 Thread Shivam Gupta via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG94fac81fccfe: [Branch-Rename] Fix some links (authored by 
xgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95766

Files:
  clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
  clang-tools-extra/clangd/README.md
  clang-tools-extra/docs/clang-rename.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/Integrations.rst
  clang/docs/ClangPlugins.rst
  clang/docs/ClangTools.rst
  clang/docs/ControlFlowIntegrityDesign.rst
  clang/docs/InternalsManual.rst
  clang/docs/LibTooling.rst
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/www/analyzer/checker_dev_manual.html
  clang/www/analyzer/open_projects.html
  clang/www/hacking.html
  clang/www/menu.html.incl
  compiler-rt/include/sanitizer/tsan_interface_atomic.h
  compiler-rt/lib/tsan/rtl/tsan_interface.h
  compiler-rt/www/menu.html.incl
  flang/README.md
  flang/docs/_templates/indexsidebar.html
  flang/docs/flang-c-style.el
  libcxx/docs/index.rst
  libcxx/www/atomic_design.html
  libcxx/www/atomic_design_a.html
  libcxx/www/atomic_design_b.html
  libcxx/www/atomic_design_c.html
  libcxx/www/index.html
  libcxx/www/ts1z_status.html
  libcxx/www/type_traits_design.html
  libcxx/www/upcoming_meeting.html
  libcxxabi/www/index.html
  libunwind/docs/index.rst
  lldb/docs/resources/build.rst
  lldb/docs/resources/test.rst
  lldb/docs/use/python-reference.rst
  llvm/docs/Vectorizers.rst
  llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/test/Transforms/SLPVectorizer/AArch64/matmul.ll
  llvm/utils/lit/setup.py
  mlir/docs/DeclarativeRewrites.md
  mlir/docs/Dialects/SPIR-V.md
  mlir/docs/Dialects/Vector.md
  mlir/docs/OpDefinitions.md
  mlir/docs/PatternRewriter.md
  mlir/docs/Rationale/RationaleGenericDAGRewriter.md
  mlir/docs/SPIRVToLLVMDialectConversion.md
  mlir/docs/ShapeInference.md
  mlir/docs/Tutorials/UnderstandingTheIRStructure.md
  openmp/www/index.html
  polly/www/menu.html.incl

Index: polly/www/menu.html.incl
===
--- polly/www/menu.html.incl
+++ polly/www/menu.html.incl
@@ -34,7 +34,7 @@
 http://lab.llvm.org:8080/coverage/coverage-reports/polly/index.html";>Code Coverage
 http://llvm.org/reports/scan-build/";>Static analysis
 Doxygen
-https://github.com/llvm/llvm-project/tree/master/polly";>Source @ GitHub
+https://github.com/llvm/llvm-project/tree/main/polly";>Source @ GitHub
   
 
   
Index: openmp/www/index.html
===
--- openmp/www/index.html
+++ openmp/www/index.html
@@ -25,7 +25,7 @@
 https://lists.llvm.org/mailman/listinfo/openmp-dev";>openmp-dev
 https://lists.llvm.org/mailman/listinfo/openmp-commits";>openmp-commits
 https://bugs.llvm.org/";>Bug Reports
-https://github.com/llvm/llvm-project/tree/master/openmp";>Browse Sources
+https://github.com/llvm/llvm-project/tree/main/openmp";>Browse Sources
   
 
 
Index: mlir/docs/Tutorials/UnderstandingTheIRStructure.md
===
--- mlir/docs/Tutorials/UnderstandingTheIRStructure.md
+++ mlir/docs/Tutorials/UnderstandingTheIRStructure.md
@@ -86,7 +86,7 @@
 ```
 
 The code for the pass is available
-[here in the repo](https://github.com/llvm/llvm-project/blob/master/mlir/test/lib/IR/TestPrintNesting.cpp)
+[here in the repo](https://github.com/llvm/llvm-project/blob/main/mlir/test/lib/IR/TestPrintNesting.cpp)
 and can be exercised with `mlir-opt -test-print-nesting`.
 
 ### Example
@@ -273,7 +273,7 @@
 ```
 
 The illustrating code for this pass is available
-[here in the repo](https://github.com/llvm/llvm-project/blob/master/mlir/test/lib/IR/TestPrintDefUse.cpp)
+[here in the repo](https://github.com/llvm/llvm-project/blob/main/mlir/test/lib/IR/TestPrintDefUse.cpp)
 and can be exercised with `mlir-opt -test-print-defuse`.
 
 The chaining of `Value`s and their uses can be viewed as following:
Index: mlir/docs/ShapeInference.md
===
--- mlir/docs/ShapeInference.md
+++ mlir/docs/ShapeInference.md
@@ -291,5 +291,5 @@
 the shape function. The reference implementation is general and can support the
 arbitrary computations needed to specify output shapes.
 
-[InferTypeOpInterface]: https://github.com/llvm/llvm-project/tree/master/mlir/include/mlir/Interfaces/InferTypeOpInterface.td
-[ShapedType]: https://github.com/llvm/llvm-project/tree/master/mlir/include/mlir/IR/BuiltinTypes.h
+[InferTypeOpInterface]: https://github.com/llvm/llvm-project/tree/main/mlir/include/mlir/Interfaces/InferTypeOpInte

[PATCH] D95448: [flang][driver] Add support for `-J/-module-dir`

2021-02-01 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

@arnamoy10 Thank you for addressing my comments!

As for testing that `-J/-module-dir` are taken into account when specifying the 
output directory for modules, could try adding the following:

  ! RUN: mkdir -p %t/dir-f18 && %f18 -fparse-only -I tools/flang/include/flang 
-module %t/dir-f18 %s  2>&1
  ! RUN: ls %t/dir/testmodule.mod && not ls %t/testmodule.mod
  
  ! RUN: mkdir -p %t/dir-flang-new && %flang-new -fsyntax-only -module-dir 
%t/dir-flang-new %s  2>&1
  ! RUN: ls %t/dir/testmodule.mod && not ls %t/testmodule.mod
  
  module testmodule
type::t2
end type
  end

It's possible that `flang-new` doesn't support writing modules yet, but IMHO 
this is the right moment to try and understand what might be missing. Thank you!




Comment at: clang/include/clang/Driver/Options.td:1006-1007
   MarshallingInfoString>;
+def module_dir : Separate<["-"], "module-dir">,
+  Flags<[FlangOption,FC1Option]>, HelpText<"Add to the list of directories to 
be searched by an USE statement">;
 def dsym_dir : JoinedOrSeparate<["-"], "dsym-dir">,

awarzynski wrote:
> As we are trying to follow `gfortran`, I suggest that we copy the help 
> message from there:
> 
> ```
> $ gfortran --help=separate | grep '\-J'
>   -J   Put MODULE files in 'directory'
> ```
> Also, we can add the long version (via `DocBrief` field) from here 
> https://gcc.gnu.org/onlinedocs/gfortran/Directory-Options.html:
> ```
> This option specifies where to put .mod files for compiled modules. It is 
> also added to the list of directories to searched by an USE statement.
> 
> The default is the current directory.
> ```
> 
> I appreciate that this patch only implements the 2nd part of what the option 
> is intended to offer (i.e. updates the search patch for module files). But I 
> think that it's worthwhile to make the intent behind this option clear from 
> the very beginning. We can use the commit message to document the current 
> limitations.
> 
> Also, please keep in mind that this help message is going to be re-used by 
> `-J`, which belongs to `gfortran_Group`. So the description needs to be valid 
> for both.
No indentation in `DocBrief`, see this [[ 
https://github.com/llvm/llvm-project/blob/21bfd068b32ece1c6fbc912208e7cd1782a8c3fc/clang/include/clang/Driver/Options.td#L680-L688
 | example ]]

Also, `Put MODULE files in 'directory'` -> `Put MODULE files in ` (the 
option is displayed as `-module-dir `).



Comment at: clang/include/clang/Driver/Options.td:4124
 def A_DASH : Joined<["-"], "A-">, Group;
-def J : JoinedOrSeparate<["-"], "J">, Flags<[RenderJoined]>, 
Group;
 def cpp : Flag<["-"], "cpp">, Group;

There's no need to move this, is there? I feel that it's better to keep all 
`gfortran` options together.



Comment at: flang/include/flang/Frontend/CompilerInstance.h:105
   /// {
+  Fortran::semantics::SemanticsContext &semaChecking() const { return 
*semantics_; }
 

tskeith wrote:
> `semanticsContext` would be a better name for this function.
We should follow Flang's [[ 
https://github.com/llvm/llvm-project/blob/main/flang/docs/C%2B%2Bstyle.md#naming
 | coding style ]] here:
```
Accessor member functions are named with the non-public data member's name, 
less the trailing underscore. 
```
i.e. `semantics()` rather than `semanticsContext()`. If we were to diverge from 
that, then I suggest that we follow the style prevalent in LLVM/Clang, see e.g. 
[[ 
https://github.com/llvm/llvm-project/blob/21bfd068b32ece1c6fbc912208e7cd1782a8c3fc/clang/include/clang/Frontend/CompilerInstance.h#L503-L506
 | getSema ]].

@tskeith, I'm guessing that you wanted the member variable to be updated too:
* semantics_ -> semanticsContext_
Makes sense to me. 




Comment at: flang/lib/Frontend/CompilerInstance.cpp:29
+  semantics_(new Fortran::semantics::SemanticsContext(*(new  
Fortran::common::IntrinsicTypeDefaultKinds()),*(new 
common::LanguageFeatureControl()),
+ *allCookedSources_)) {
 

tskeith wrote:
> Why is `semantics_` a `shared_ptr` rather than a simple data member of  type 
> `SemanticsContext`? It's owned by only `CompilerInstance`, not shared.
> The same question probably applies to the other fields too.
@tskeith You raise two important points here:

**Why shared_ptr if the resource is not shared?** 
From what I can see, at this point the `SemanticsContext` is not shared and we 
can safely use `unique_ptr` instead.

**Why are semantics_ and other members of CompilerInstance pointers?**
`CompilerInstance` doesn't really own much - it just encapsulates all 
classes/structs that are required for creating a _compiler instance_. It's kept 
lightweight and written in a way that makes it easy to _inject_ custom 
instances of these classes. This approach is expected to be helpful when 
creating new frontend actions (I expect that there will be a lot) and when 

[PATCH] D69764: [clang-format] Add East/West Const fixer capability

2021-02-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: djasper.
aaron.ballman added a comment.

In D69764#2532413 , @steveire wrote:

> What can be done to move this change along?

Here is my thinking, which is largely unchanged from previous discussion: a 
code formatting tool should not modify code such that it changes meaning. This 
sort of behavior causes serious problems in practice, such as difficulty using 
the formatter in CI pipelines (because the user can't conform to what the 
formatter wants in some cases) or a lack of trust in the tool when it inserts 
subtle bugs that don't cause compile errors. I don't think that's acceptable 
for a production-quality tool that's expected to be run in a (semi-)automated 
fashion. I don't think the fact that clang-format already has such behavior is 
a blessing that we should add more such features. Every time we do that, we 
make a less usable tool for our users. So to me, the acceptance criteria is: 
the change should not break code, regardless of whether it's behind a flag or 
not. Flags alleviate some of the pain, certainly, but in clang-format, flags 
can be shared between multiple users due to the presence of a .clang-format 
file, and so "just change the configuration" isn't always a trivial bar for 
everyone to hop over.

I should note that I see the code breaking behavior between #include sort 
orders changing behavior and the qualifier position code breaking as being 
slightly different levels of severity. With include order, my code was brittle 
and the tool exposes that fact. With the qualifier change, my code doesn't 
necessarily have to be brittle to be broken.

All that said, clang-format is precisely where I'd *expect* this functionality 
to live, logically, so I agree with the strong desire to land the feature here. 
But given the option between fast and correct, I want both. If I can't have 
both, I want correct. So a shorter path forward to surfacing the feature 
appears to be within clang-tidy where we can use an AST to ensure we get 
correct behavior (at the expense of performance). There are a lot of longer 
paths forward, such as exploring why use of an AST is too slow for a code 
formatting tool and seeing if that can be improved (note, wins here are likely 
to wind up being wins for compilation speed with Clang overall, which would be 
very impactful!), but I can understand if the authors don't want to work on 
that effort. But I don't think "it's hard to be both fast and correct" is a 
valid reason to add known-problematic functionality to the code formatting tool 
with no known solution aside from "disable this functionality or find a 
different tool".


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

https://reviews.llvm.org/D69764

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


[PATCH] D95771: [clang-tidy] fix modernize-loop-convert to retain needed array-like operator[]

2021-02-01 Thread Nathan James via Phabricator via cfe-commits
njames93 edited reviewers, added: aaron.ballman, alexfh, njames93; removed: 
sammccall, hokein.
njames93 accepted this revision.
njames93 added a comment.
This revision is now accepted and ready to land.

LGTM, Can you fix the formatting as well.




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize-loop-convert-multidimensional.cpp:50
+  Vector>> Y;
+  for (int J = 0; J < Y[3].size(); ++J) {
+if (Y[3][J][7])

Not essential, but how would this handle iterating the lowest dimension. 
```lang=c++
for (int J = 0; J < Y[3][4].size(); ++J)
```
Though I may have a feeling the check won't even try to convert that. If so 
disregard this comment. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95771

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


[PATCH] D95608: [OpenCL][PR48896] Fix address space in binding of initializer lists to references

2021-02-01 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 320447.
Anastasia added a comment.

Added address space compatibility check and improved testing.


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

https://reviews.llvm.org/D95608

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/test/CodeGenOpenCLCXX/addrspace-references.cl
  clang/test/SemaOpenCLCXX/address-space-references.cl

Index: clang/test/SemaOpenCLCXX/address-space-references.cl
===
--- clang/test/SemaOpenCLCXX/address-space-references.cl
+++ clang/test/SemaOpenCLCXX/address-space-references.cl
@@ -10,8 +10,20 @@
 // can't detect this case and therefore fails.
 int bar(const unsigned int &i);
 
+typedef short short2 __attribute__((ext_vector_type(2)));
+class C {
+public:
+  void gen(const short2 &);
+  void glob(__global const short2 &); //expected-note{{passing argument to parameter here}}
+  void nested_list(const short2 (&)[2]);
+};
+
 void foo() {
   bar(1); // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}}
+  C c;
+  c.gen({1, 2});
+  c.glob({1, 2}); //expected-error{{binding reference of type 'const __global short2' (vector of 2 'short' values) to value of type 'void' changes address space}}
+  c.nested_list({{1, 2}, {3, 4}});
 }
 
 // Test addr space conversion with nested pointers
Index: clang/test/CodeGenOpenCLCXX/addrspace-references.cl
===
--- clang/test/CodeGenOpenCLCXX/addrspace-references.cl
+++ clang/test/CodeGenOpenCLCXX/addrspace-references.cl
@@ -1,8 +1,16 @@
-//RUN: %clang_cc1 %s -cl-std=clc++ -triple spir -emit-llvm -o - | FileCheck %s
+//RUN: %clang_cc1 %s -cl-std=clc++ -triple spir -emit-llvm -o - -O0 | FileCheck %s
+
+typedef short short2 __attribute__((ext_vector_type(2)));
 
 int bar(const unsigned int &i);
-// CHECK-LABEL: define{{.*}} spir_func void @_Z3foov() 
-void foo() {
+
+class C {
+public:
+  void bar(const short2 &);
+};
+
+// CHECK-LABEL: define{{.*}} spir_func void @_Z6scalarv()
+void scalar() {
   // The generic addr space reference parameter object will be bound
   // to a temporary value allocated in private addr space. We need an
   // addrspacecast before passing the value to the function.
@@ -12,3 +20,14 @@
   // CHECK: call spir_func i32 @_Z3barRU3AS4Kj(i32 addrspace(4)* align 4 dereferenceable(4) [[REG]])
   bar(1);
 }
+
+// Test list initialization
+// CHECK-LABEL: define{{.*}} spir_func void @_Z4listv()
+void list() {
+  C c1;
+// CHECK: [[REF:%.*]] = alloca <2 x i16>
+// CHECK: store <2 x i16> , <2 x i16>* [[REF]]
+// CHECK: [[REG:%[.a-z0-9]+]] = addrspacecast <2 x i16>* [[REF]] to <2 x i16> addrspace(4)*
+// CHECK: call {{.*}}void @_ZNU3AS41C3barERU3AS4KDv2_s(%class.C addrspace(4)* {{.*}}, <2 x i16> addrspace(4)*{{.*}} [[REG]])
+  c1.bar({1, 2});
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -4289,17 +4289,36 @@
 if (Sequence.step_begin() != Sequence.step_end())
   Sequence.RewrapReferenceInitList(cv1T1, InitList);
   }
-
+  // Perform address space compatibility check.
+  QualType cv1T1IgnoreAS = cv1T1;
+  if (T1Quals.hasAddressSpace()) {
+Qualifiers T2Quals;
+static_cast(
+S.Context.getUnqualifiedArrayType(InitList->getType(), T2Quals));
+if (!T1Quals.isAddressSpaceSupersetOf(T2Quals)) {
+  Sequence.SetFailed(
+  InitializationSequence::FK_ReferenceInitDropsQualifiers);
+  return;
+}
+// Ignore address space of reference type at this point and perform address
+// space conversion after the reference binding step.
+cv1T1IgnoreAS =
+S.Context.getQualifiedType(T1, T1Quals.withoutAddressSpace());
+  }
   // Not reference-related. Create a temporary and bind to that.
-  InitializedEntity TempEntity = InitializedEntity::InitializeTemporary(cv1T1);
+  InitializedEntity TempEntity =
+  InitializedEntity::InitializeTemporary(cv1T1IgnoreAS);
 
   TryListInitialization(S, TempEntity, Kind, InitList, Sequence,
 TreatUnavailableAsInvalid);
   if (Sequence) {
 if (DestType->isRValueReferenceType() ||
-(T1Quals.hasConst() && !T1Quals.hasVolatile()))
-  Sequence.AddReferenceBindingStep(cv1T1, /*BindingTemporary=*/true);
-else
+(T1Quals.hasConst() && !T1Quals.hasVolatile())) {
+  Sequence.AddReferenceBindingStep(cv1T1IgnoreAS,
+   /*BindingTemporary=*/true);
+  if (T1Quals.hasAddressSpace())
+Sequence.AddQualificationConversionStep(cv1T1, VK_XValue);
+} else
   Sequence.SetFailed(
   InitializationSequence::FK_NonConstLValueReferenceBindingToTemporary);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listi

[PATCH] D95608: [OpenCL][PR48896] Fix address space in binding of initializer lists to references

2021-02-01 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked an inline comment as done.
Anastasia added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:4297
+  ? S.Context.getQualifiedType(T1, T1Quals.withoutAddressSpace())
+  : cv1T1;
   // Not reference-related. Create a temporary and bind to that.

rjmccall wrote:
> Should we be rejecting this path immediately if the address space in T1 can't 
> be converted to from the address space of temporaries?
I agree. I have updated the patch and added more test cases.



Comment at: clang/lib/Sema/SemaInit.cpp:4308
+  if (T1Quals.hasAddressSpace())
+Sequence.AddQualificationConversionStep(cv1T1, VK_XValue);
+} else

rjmccall wrote:
> This should only be `VK_XValue` if we're binding a r-value reference, I think.
Yes, I think so too.


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

https://reviews.llvm.org/D95608

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


[PATCH] D95448: [flang][driver] Add support for `-J/-module-dir`

2021-02-01 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added inline comments.



Comment at: flang/test/Flang-Driver/include-module.f90:15
+! RUN: not %flang-new -fsyntax-only -module-dir %S/Inputs %s  2>&1 | FileCheck 
%s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fsyntax-only -J %S/Inputs/module-dir -J %S/Inputs/ %s  
2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
+! RUN: not %flang-new -fsyntax-only -J %S/Inputs/module-dir -module-dir 
%S/Inputs/ %s 2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE

awarzynski wrote:
> Why `--check-prefix=SINGLEINCLUDE` here and below? Both directories are 
> included, so there should be no errors.
Apologies, I was wrong with regard to how `-J/-module-dir` should work:

```
$ gfortran -J test-dir/ -J test-dir/ test.f
f951: Fatal Error: gfortran: Only one ‘-J’ option allowed
compilation terminated.
```

`gfortran` behavior makes a lot of sense to me and I suggest that we replicate 
that. This means that we should issue a diagnostic when `-J/-module-dir` is 
used twice.


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

https://reviews.llvm.org/D95448

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


[PATCH] D93222: [analyzer] Introduce MacroExpansionContext to libAnalysis

2021-02-01 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.

Still looks good to me! Thanks for handling the pragma cases!


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

https://reviews.llvm.org/D93222

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


[PATCH] D93223: [analyzer] Create MacroExpansionContext member in AnalysisConsumer

2021-02-01 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

Still looks good. 
(The parent is an NFC and only this patch changes the behavior (and only if the 
cmdline flag is there), right? So, I'd expect the big impact from this patch.)


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

https://reviews.llvm.org/D93223

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


[PATCH] D95759: [clangd] Rename: merge index/AST refs path-insensitively where needed

2021-02-01 Thread Sam McCall via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb63cd4db915c: [clangd] Rename: merge index/AST refs 
path-insensitively where needed (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95759

Files:
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/support/CMakeLists.txt
  clang-tools-extra/clangd/support/Path.cpp
  clang-tools-extra/clangd/support/Path.h
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1067,6 +1067,52 @@
   }
 }
 
+MATCHER_P(newText, T, "") { return arg.newText == T; }
+
+TEST(RenameTest, IndexMergeMainFile) {
+  Annotations Code("int ^x();");
+  TestTU TU = TestTU::withCode(Code.code());
+  TU.Filename = "main.cc";
+  auto AST = TU.build();
+
+  auto Main = testPath("main.cc");
+
+  auto Rename = [&](const SymbolIndex *Idx) {
+auto GetDirtyBuffer = [&](PathRef Path) -> llvm::Optional {
+  return Code.code().str(); // Every file has the same content.
+};
+RenameOptions Opts;
+Opts.AllowCrossFile = true;
+RenameInputs Inputs{Code.point(), "xPrime", AST,   Main,
+Idx,  Opts, GetDirtyBuffer};
+auto Results = rename(Inputs);
+EXPECT_TRUE(bool(Results)) << llvm::toString(Results.takeError());
+return std::move(*Results);
+  };
+
+  // We do not expect to see duplicated edits from AST vs index.
+  auto Results = Rename(TU.index().get());
+  EXPECT_THAT(Results.GlobalChanges.keys(), ElementsAre(Main));
+  EXPECT_THAT(Results.GlobalChanges[Main].asTextEdits(),
+  ElementsAre(newText("xPrime")));
+
+  // Sanity check: we do expect to see index results!
+  TU.Filename = "other.cc";
+  Results = Rename(TU.index().get());
+  EXPECT_THAT(Results.GlobalChanges.keys(),
+  UnorderedElementsAre(Main, testPath("other.cc")));
+
+#if defined(_WIN32) || defined(__APPLE__)
+  // On case-insensitive systems, no duplicates if AST vs index case differs.
+  // https://github.com/clangd/clangd/issues/665
+  TU.Filename = "MAIN.CC";
+  Results = Rename(TU.index().get());
+  EXPECT_THAT(Results.GlobalChanges.keys(), ElementsAre(Main));
+  EXPECT_THAT(Results.GlobalChanges[Main].asTextEdits(),
+  ElementsAre(newText("xPrime")));
+#endif
+}
+
 TEST(RenameTest, MainFileReferencesOnly) {
   // filter out references not from main file.
   llvm::StringRef Test =
Index: clang-tools-extra/clangd/support/Path.h
===
--- clang-tools-extra/clangd/support/Path.h
+++ clang-tools-extra/clangd/support/Path.h
@@ -22,6 +22,12 @@
 /// signatures.
 using PathRef = llvm::StringRef;
 
+// For platforms where paths are case-insensitive (but case-preserving),
+// we need to do case-insensitive comparisons and use lowercase keys.
+// FIXME: Make Path a real class with desired semantics instead.
+std::string maybeCaseFoldPath(PathRef Path);
+bool pathEqual(PathRef, PathRef);
+
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/support/Path.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/support/Path.cpp
@@ -0,0 +1,30 @@
+//===--- Path.cpp ---*- C++-*--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "support/Path.h"
+namespace clang {
+namespace clangd {
+
+std::string maybeCaseFoldPath(PathRef Path) {
+#if defined(_WIN32) || defined(__APPLE__)
+  return Path.lower();
+#else
+  return std::string(Path);
+#endif
+}
+
+bool pathEqual(PathRef A, PathRef B) {
+#if defined(_WIN32) || defined(__APPLE__)
+  return A.equals_lower(B);
+#else
+  return A == B;
+#endif
+}
+
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/support/CMakeLists.txt
===
--- clang-tools-extra/clangd/support/CMakeLists.txt
+++ clang-tools-extra/clangd/support/CMakeLists.txt
@@ -23,6 +23,7 @@
   Logger.cpp
   Markup.cpp
   MemoryTree.cpp
+  Path.cpp
   Shutdown.cpp
   Threading.cpp
   ThreadsafeFS.cpp
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd

[clang-tools-extra] b63cd4d - [clangd] Rename: merge index/AST refs path-insensitively where needed

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

Author: Sam McCall
Date: 2021-02-01T15:15:21+01:00
New Revision: b63cd4db915c08e0cb4cf668a18de24b67f2c44c

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

LOG: [clangd] Rename: merge index/AST refs path-insensitively where needed

If you have c:\foo open, and C:\foo indexed (case difference) then these
need to be considered the same file. Otherwise we emit edits to both,
and editors do... something that isn't pretty.

Maybe more centralized normalization is called for, but it's not trivial
to do this while also being case-preserving. see
https://github.com/clangd/clangd/issues/108

Fixes https://github.com/clangd/clangd/issues/665

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

Added: 
clang-tools-extra/clangd/support/Path.cpp

Modified: 
clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/support/CMakeLists.txt
clang-tools-extra/clangd/support/Path.h
clang-tools-extra/clangd/unittests/RenameTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index 1a5379acfe7d..afe38993ef28 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -395,20 +395,6 @@ 
DirectoryBasedGlobalCompilationDatabase::getCompileCommand(PathRef File) const {
   return None;
 }
 
-// For platforms where paths are case-insensitive (but case-preserving),
-// we need to do case-insensitive comparisons and use lowercase keys.
-// FIXME: Make Path a real class with desired semantics instead.
-//This class is not the only place this problem exists.
-// FIXME: Mac filesystems default to case-insensitive, but may be sensitive.
-
-static std::string maybeCaseFoldPath(PathRef Path) {
-#if defined(_WIN32) || defined(__APPLE__)
-  return Path.lower();
-#else
-  return std::string(Path);
-#endif
-}
-
 std::vector
 DirectoryBasedGlobalCompilationDatabase::getDirectoryCaches(
 llvm::ArrayRef Dirs) const {

diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index d3c7da96a441..a857b3479871 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -68,7 +68,7 @@ llvm::Optional getOtherRefFile(const Decl &D, 
StringRef MainFile,
 if (OtherFile)
   return;
 if (auto RefFilePath = filePath(R.Location, /*HintFilePath=*/MainFile)) {
-  if (*RefFilePath != MainFile)
+  if (!pathEqual(*RefFilePath, MainFile))
 OtherFile = *RefFilePath;
 }
   });
@@ -474,7 +474,7 @@ findOccurrencesOutsideFile(const NamedDecl &RenameDecl,
 if ((R.Kind & RefKind::Spelled) == RefKind::Unknown)
   return;
 if (auto RefFilePath = filePath(R.Location, /*HintFilePath=*/MainFile)) {
-  if (*RefFilePath != MainFile)
+  if (!pathEqual(*RefFilePath, MainFile))
 AffectedFiles[*RefFilePath].push_back(toRange(R.Location));
 }
   });

diff  --git a/clang-tools-extra/clangd/support/CMakeLists.txt 
b/clang-tools-extra/clangd/support/CMakeLists.txt
index f0fe073eb136..fc7d7a28117b 100644
--- a/clang-tools-extra/clangd/support/CMakeLists.txt
+++ b/clang-tools-extra/clangd/support/CMakeLists.txt
@@ -23,6 +23,7 @@ add_clang_library(clangdSupport
   Logger.cpp
   Markup.cpp
   MemoryTree.cpp
+  Path.cpp
   Shutdown.cpp
   Threading.cpp
   ThreadsafeFS.cpp

diff  --git a/clang-tools-extra/clangd/support/Path.cpp 
b/clang-tools-extra/clangd/support/Path.cpp
new file mode 100644
index ..f72d00070f34
--- /dev/null
+++ b/clang-tools-extra/clangd/support/Path.cpp
@@ -0,0 +1,30 @@
+//===--- Path.cpp ---*- 
C++-*--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "support/Path.h"
+namespace clang {
+namespace clangd {
+
+std::string maybeCaseFoldPath(PathRef Path) {
+#if defined(_WIN32) || defined(__APPLE__)
+  return Path.lower();
+#else
+  return std::string(Path);
+#endif
+}
+
+bool pathEqual(PathRef A, PathRef B) {
+#if defined(_WIN32) || defined(__APPLE__)
+  return A.equals_lower(B);
+#else
+  return A == B;
+#endif
+}
+
+} // namespace clangd
+} // namespace clang

diff  --git a/clang-tools-extra/clangd/support/Path.h 
b/clang-tools-extra/clangd/support/Path.h
index 4d4ad7f49047..402903130f01 100644
--- a/clang-tools-extra/clangd/support/Path.h
+++ b/clang-tools-extra/clangd/support/Path.h
@@ -22,6 +22,12 @@

[PATCH] D95782: [Syntax] Support condition for IfStmt.

2021-02-01 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
hokein requested review of this revision.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95782

Files:
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
  clang/unittests/Tooling/Syntax/SynthesisTest.cpp

Index: clang/unittests/Tooling/Syntax/SynthesisTest.cpp
===
--- clang/unittests/Tooling/Syntax/SynthesisTest.cpp
+++ clang/unittests/Tooling/Syntax/SynthesisTest.cpp
@@ -238,12 +238,13 @@
 |-IfStatement Statement synthesized
 | |-'if' IntroducerKeyword synthesized
 | |-'(' synthesized
-| |-BinaryOperatorExpression synthesized
-| | |-IntegerLiteralExpression LeftHandSide synthesized
-| | | `-'1' LiteralToken synthesized
-| | |-'+' OperatorToken synthesized
-| | `-IntegerLiteralExpression RightHandSide synthesized
-| |   `-'1' LiteralToken synthesized
+| |-ExpressionStatement Condition synthesized
+| | `-BinaryOperatorExpression Expression synthesized
+| |   |-IntegerLiteralExpression LeftHandSide synthesized
+| |   | `-'1' LiteralToken synthesized
+| |   |-'+' OperatorToken synthesized
+| |   `-IntegerLiteralExpression RightHandSide synthesized
+| | `-'1' LiteralToken synthesized
 | |-')' synthesized
 | |-CompoundStatement ThenStatement synthesized
 | | |-'{' OpenParen synthesized
Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -204,8 +204,9 @@
 IfStatement Statement
 |-'if' IntroducerKeyword
 |-'('
-|-IntegerLiteralExpression
-| `-'1' LiteralToken
+|-ExpressionStatement Condition
+| `-IntegerLiteralExpression Expression
+|   `-'1' LiteralToken
 |-')'
 `-CompoundStatement ThenStatement
   |-'{' OpenParen
@@ -215,8 +216,9 @@
 IfStatement Statement
 |-'if' IntroducerKeyword
 |-'('
-|-IntegerLiteralExpression
-| `-'1' LiteralToken
+|-ExpressionStatement Condition
+| `-IntegerLiteralExpression Expression
+|   `-'1' LiteralToken
 |-')'
 |-CompoundStatement ThenStatement
 | |-'{' OpenParen
@@ -225,8 +227,9 @@
 `-IfStatement ElseStatement
   |-'if' IntroducerKeyword
   |-'('
-  |-IntegerLiteralExpression
-  | `-'0' LiteralToken
+  |-ExpressionStatement Condition
+  | `-IntegerLiteralExpression Expression
+  |   `-'0' LiteralToken
   |-')'
   `-CompoundStatement ThenStatement
 |-'{' OpenParen
@@ -234,6 +237,61 @@
 )txt"}));
 }
 
+TEST_P(BuildSyntaxTreeTest, IfDecl) {
+  if (!GetParam().isCXX17OrLater()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+  R"cpp(
+void test() {
+  [[if (int a = 5) {}]]
+  [[if (int a; a == 5) {}]]
+}
+)cpp",
+  {R"txt(
+IfStatement Statement
+|-'if' IntroducerKeyword
+|-'('
+|-DeclarationStatement Condition
+| `-SimpleDeclaration
+|   |-'int'
+|   `-DeclaratorList Declarators
+| `-SimpleDeclarator ListElement
+|   |-'a'
+|   |-'='
+|   `-IntegerLiteralExpression
+| `-'5' LiteralToken
+|-')'
+`-CompoundStatement ThenStatement
+  |-'{' OpenParen
+  `-'}' CloseParen
+  )txt",
+   R"txt(
+IfStatement Statement
+|-'if' IntroducerKeyword
+|-'('
+|-DeclarationStatement
+| |-SimpleDeclaration
+| | |-'int'
+| | `-DeclaratorList Declarators
+| |   `-SimpleDeclarator ListElement
+| | `-'a'
+| `-';'
+|-ExpressionStatement Condition
+| `-BinaryOperatorExpression Expression
+|   |-IdExpression LeftHandSide
+|   | `-UnqualifiedId UnqualifiedId
+|   |   `-'a'
+|   |-'==' OperatorToken
+|   `-IntegerLiteralExpression RightHandSide
+| `-'5' LiteralToken
+|-')'
+`-CompoundStatement ThenStatement
+  |-'{' OpenParen
+  `-'}' CloseParen
+)txt"}));
+}
+
 TEST_P(BuildSyntaxTreeTest, For) {
   EXPECT_TRUE(treeDumpEqualOnAnnotations(
   R"cpp(
@@ -420,8 +478,9 @@
 |-IfStatement Statement
 | |-'if' IntroducerKeyword
 | |-'('
-| |-IntegerLiteralExpression
-| | `-'1' LiteralToken
+| |-ExpressionStatement Condition
+| | `-IntegerLiteralExpression Expression
+| |   `-'1' LiteralToken
 | |-')'
 | |-ExpressionStatement ThenStatement
 | | |-CallExpression Expression
@@ -3992,12 +4051,13 @@
 |-IfStatement Statement
 | |-'if' IntroducerKeyword unmodifiable
 | |-'(' unmodifiable
-| |-BinaryOperatorExpression unmodifiable
-| | |-IntegerLiteralExpression LeftHandSide unmodifiable
-| | | `-'1' LiteralToken unmodifiable
-| | |-'+' OperatorToken unmodifiable
-| | `-IntegerLiteralExpression RightHandSide unmodifiable
-| |   `-'1' LiteralToken unmodifiable
+| |-ExpressionStatement Condition unmodifiable
+| | `-BinaryOperatorExpression Expression unmodifiable
+| |   |-IntegerLiteralExpression LeftHandSide unmodifiable
+| |   | `-'1' LiteralToken unmodifiable
+| |   |-'+' OperatorTok

[PATCH] D95670: [clangd] Don't rely on builtin headers for document-link.test.

2021-02-01 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.

Thanks for fixing this, we don't want to depend on clang and I didn't realize 
we still did!




Comment at: clang-tools-extra/clangd/test/document-link.test:3
+# create a fake resource_dir so that the test can find the headers.
+# RUN: mkdir -p %t/include/ && touch %t/include/foo.h
+# RUN: clangd -lit-test -resource-dir=%t < %s | FileCheck -strict-whitespace %s

kadircet wrote:
> this is clever! I believe there was a reason for this test to be asserting 
> built-in headers (I can't seem to remember, maybe @sammccall does), but 
> asserting through a mock header should also be fine, I suppose.
> 
> one thing though, we need to clean up `%t`, e.g. `rm -rf %t`.
> 
> (and regrading the failure at head, resource_dir path has changed with 
> release cut from `something/12.0.0` to `something/13.0.0` so it should go 
> away once you build new clang via `ninja clang`)
> this is clever!
Indeed, I almost wish we had a less-clever way to do this but I can't think of 
one :-)

> I believe there was a reason for this test to be asserting built-in headers 
> (I can't seem to remember, maybe @sammccall does), but asserting through a 
> mock header should also be fine, I suppose.

Nah, I think it was just to avoid complex setup (and builtin over stdlib as 
it's a somewhat less crazy dep).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95670

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


[PATCH] D94880: Add clang-query support for mapAnyOf

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



Comment at: clang/include/clang/ASTMatchers/Dynamic/Registry.h:36-37
 
+/// A smart (owning) pointer for MatcherDescriptor
+/// We can't use unique_ptr because MatcherDescriptor is forward declared
+class MatcherDescriptorPtr {





Comment at: clang/include/clang/ASTMatchers/Dynamic/Registry.h:40
+public:
+  MatcherDescriptorPtr(MatcherDescriptor * = nullptr);
+  ~MatcherDescriptorPtr();

I think it'd be cleaner to make callers be explicit about forming the smart 
pointer.



Comment at: clang/lib/ASTMatchers/Dynamic/Marshallers.h:586-587
+  std::unique_ptr
+  buildMatcherCtor(SourceRange NameRange, ArrayRef Args,
+   Diagnostics *Error) const override {
+return {};

Might as well make it obvious the function doesn't care about its arguments 
(same elsewhere in the patch).



Comment at: clang/lib/ASTMatchers/Dynamic/Marshallers.h:1081-1083
+if (NodeKinds.empty()) {
+  return {};
+}





Comment at: clang/lib/ASTMatchers/Dynamic/Parser.cpp:372
   std::string BindID;
-  if (!parseBindID(BindID))
+  Tokenizer->consumeNextToken(); // consume the period.
+  const TokenInfo ChainCallToken = Tokenizer->consumeNextToken();





Comment at: clang/lib/ASTMatchers/Dynamic/Parser.cpp:373
+  Tokenizer->consumeNextToken(); // consume the period.
+  const TokenInfo ChainCallToken = Tokenizer->consumeNextToken();
+  if (ChainCallToken.Kind == TokenInfo::TK_CodeCompletion) {





Comment at: clang/lib/ASTMatchers/Dynamic/Parser.cpp:435
+  assert(NameToken.Kind == TokenInfo::TK_Ident);
+  const TokenInfo OpenToken = Tokenizer->consumeNextToken();
+  if (OpenToken.Kind != TokenInfo::TK_OpenParen) {





Comment at: clang/lib/ASTMatchers/Dynamic/Parser.cpp:449
+bool Parser::parseBindID(TokenInfo BindToken, std::string &BindID) {
   // Parse .bind("foo")
   const TokenInfo OpenToken = Tokenizer->consumeNextToken();

The comment is a bit misleading in that this doesn't parse the `.bind` part, 
only the `("foo")` bits.

Also, why does the function now accept `BindToken` but not use it?



Comment at: clang/lib/ASTMatchers/Dynamic/Parser.cpp:491
+// We must find a , token to continue.
+const TokenInfo CommaToken = Tokenizer->consumeNextToken();
+if (CommaToken.Kind != TokenInfo::TK_Comma) {





Comment at: clang/lib/ASTMatchers/Dynamic/Parser.cpp:510
+
+  const auto NodeMatcherToken = Tokenizer->consumeNextToken();
+





Comment at: clang/lib/ASTMatchers/Dynamic/Parser.cpp:521
+
+  auto MappedMatcher = S->lookupMatcherCtor(ArgValue.Text);
+





Comment at: clang/lib/ASTMatchers/Dynamic/Parser.cpp:553
+
+  auto BuiltCtor = S->buildMatcherCtor(Ctor, NameToken.Range, Args, Error);
+

unique_ptr? or is this our custom smart pointer? Either way, please spell the 
type out.



Comment at: clang/lib/ASTMatchers/Dynamic/Parser.cpp:563
+  if (Tokenizer->peekNextToken().Kind == TokenInfo::TK_Period) {
+Tokenizer->consumeNextToken(); // consume the period.
+const TokenInfo ChainCallToken = Tokenizer->consumeNextToken();





Comment at: clang/lib/ASTMatchers/Dynamic/Parser.cpp:638-641
+  if (Ctor && *Ctor && S->isBuilderMatcher(*Ctor)) {
+return parseMatcherBuilder(*Ctor, NameToken, OpenToken, Value);
+  }
+





Comment at: clang/lib/ASTMatchers/Dynamic/Parser.cpp:691
+Tokenizer->consumeNextToken();
+const TokenInfo ChainCallToken = Tokenizer->consumeNextToken();
+if (ChainCallToken.Kind == TokenInfo::TK_CodeCompletion) {





Comment at: clang/lib/ASTMatchers/Dynamic/Registry.cpp:580
+   ArrayRef Args, Diagnostics *Error) {
+  return Ctor->buildMatcherCtor(NameRange, Args, Error).release();
+}

I think that having the explicit ctor call here would make it more obvious that 
the `.release()` is being picked up by another smart pointer type.



Comment at: clang/lib/ASTMatchers/Dynamic/Registry.cpp:697
 
-  if (IsPolymorphic) {
-OS << "Matcher " << Name << "(Matcher";
+  std::string TypedText = std::string(Name);
+

Any reason this declaration needed to move?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94880

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


[PATCH] D95670: [clangd] Don't rely on builtin headers for document-link.test.

2021-02-01 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 320454.
hokein added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95670

Files:
  clang-tools-extra/clangd/test/document-link.test


Index: clang-tools-extra/clangd/test/document-link.test
===
--- clang-tools-extra/clangd/test/document-link.test
+++ clang-tools-extra/clangd/test/document-link.test
@@ -1,9 +1,10 @@
-# for %resource_dir: REQUIRES: clang
-# %resource_dir actually points at builtin_include_dir, go up one directory.
-# RUN: clangd -lit-test -resource-dir=%resource_dir/.. < %s | FileCheck 
-strict-whitespace %s
+# Create a fake resource_dir so that the test can find the headers.
+# RUN: rm -rf %/t
+# RUN: mkdir -p %t/include/ && touch %t/include/foo.h
+# RUN: clangd -lit-test -resource-dir=%t < %s | FileCheck -strict-whitespace %s
 
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
-{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"#include
 \n#include "}}}
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"#include
 "}}}
 ---
 
{"jsonrpc":"2.0","id":2,"method":"textDocument/documentLink","params":{"textDocument":{"uri":"test:///main.cpp"}}}
 #  CHECK:  "id": 2,
@@ -12,7 +13,7 @@
 # CHECK-NEXT:{
 # CHECK-NEXT:  "range": {
 # CHECK-NEXT:"end": {
-# CHECK-NEXT:  "character": 19,
+# CHECK-NEXT:  "character": 16,
 # CHECK-NEXT:  "line": 0
 # CHECK-NEXT:},
 # CHECK-NEXT:"start": {
@@ -20,20 +21,7 @@
 # CHECK-NEXT:  "line": 0
 # CHECK-NEXT:}
 # CHECK-NEXT:  },
-# CHECK-NEXT:  "target": "file://{{.*}}/stdint.h"
-# CHECK-NEXT:},
-# CHECK-NEXT:{
-# CHECK-NEXT:  "range": {
-# CHECK-NEXT:"end": {
-# CHECK-NEXT:  "character": 19,
-# CHECK-NEXT:  "line": 1
-# CHECK-NEXT:},
-# CHECK-NEXT:"start": {
-# CHECK-NEXT:  "character": 9,
-# CHECK-NEXT:  "line": 1
-# CHECK-NEXT:}
-# CHECK-NEXT:  },
-# CHECK-NEXT:  "target": "file://{{.*}}/stddef.h"
+# CHECK-NEXT:  "target": "file://{{.*}}/foo.h"
 # CHECK-NEXT:}
 # CHECK-NEXT:  ]
 # CHECK-NEXT:}


Index: clang-tools-extra/clangd/test/document-link.test
===
--- clang-tools-extra/clangd/test/document-link.test
+++ clang-tools-extra/clangd/test/document-link.test
@@ -1,9 +1,10 @@
-# for %resource_dir: REQUIRES: clang
-# %resource_dir actually points at builtin_include_dir, go up one directory.
-# RUN: clangd -lit-test -resource-dir=%resource_dir/.. < %s | FileCheck -strict-whitespace %s
+# Create a fake resource_dir so that the test can find the headers.
+# RUN: rm -rf %/t
+# RUN: mkdir -p %t/include/ && touch %t/include/foo.h
+# RUN: clangd -lit-test -resource-dir=%t < %s | FileCheck -strict-whitespace %s
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
-{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"#include \n#include "}}}
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"#include "}}}
 ---
 {"jsonrpc":"2.0","id":2,"method":"textDocument/documentLink","params":{"textDocument":{"uri":"test:///main.cpp"}}}
 #  CHECK:  "id": 2,
@@ -12,7 +13,7 @@
 # CHECK-NEXT:{
 # CHECK-NEXT:  "range": {
 # CHECK-NEXT:"end": {
-# CHECK-NEXT:  "character": 19,
+# CHECK-NEXT:  "character": 16,
 # CHECK-NEXT:  "line": 0
 # CHECK-NEXT:},
 # CHECK-NEXT:"start": {
@@ -20,20 +21,7 @@
 # CHECK-NEXT:  "line": 0
 # CHECK-NEXT:}
 # CHECK-NEXT:  },
-# CHECK-NEXT:  "target": "file://{{.*}}/stdint.h"
-# CHECK-NEXT:},
-# CHECK-NEXT:{
-# CHECK-NEXT:  "range": {
-# CHECK-NEXT:"end": {
-# CHECK-NEXT:  "character": 19,
-# CHECK-NEXT:  "line": 1
-# CHECK-NEXT:},
-# CHECK-NEXT:"start": {
-# CHECK-NEXT:  "character": 9,
-# CHECK-NEXT:  "line": 1
-# CHECK-NEXT:}
-# CHECK-NEXT:  },
-# CHECK-NEXT:  "target": "file://{{.*}}/stddef.h"
+# CHECK-NEXT:  "target": "file://{{.*}}/foo.h"
 # CHECK-NEXT:}
 # CHECK-NEXT:  ]
 # CHECK-NEXT:}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 78c22fb - [clangd] Don't rely on builtin headers for document-link.test.

2021-02-01 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2021-02-01T15:36:34+01:00
New Revision: 78c22fbce991bb5ef49db36473b71fc4386e1e85

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

LOG: [clangd] Don't rely on builtin headers for document-link.test.

This test seems to be failing at HEAD.

Reviewed By: kadircet, sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/test/document-link.test

Removed: 




diff  --git a/clang-tools-extra/clangd/test/document-link.test 
b/clang-tools-extra/clangd/test/document-link.test
index 63f8ca099322..36977753478a 100644
--- a/clang-tools-extra/clangd/test/document-link.test
+++ b/clang-tools-extra/clangd/test/document-link.test
@@ -1,9 +1,10 @@
-# for %resource_dir: REQUIRES: clang
-# %resource_dir actually points at builtin_include_dir, go up one directory.
-# RUN: clangd -lit-test -resource-dir=%resource_dir/.. < %s | FileCheck 
-strict-whitespace %s
+# Create a fake resource_dir so that the test can find the headers.
+# RUN: rm -rf %/t
+# RUN: mkdir -p %t/include/ && touch %t/include/foo.h
+# RUN: clangd -lit-test -resource-dir=%t < %s | FileCheck -strict-whitespace %s
 
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
-{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"#include
 \n#include "}}}
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"#include
 "}}}
 ---
 
{"jsonrpc":"2.0","id":2,"method":"textDocument/documentLink","params":{"textDocument":{"uri":"test:///main.cpp"}}}
 #  CHECK:  "id": 2,
@@ -12,7 +13,7 @@
 # CHECK-NEXT:{
 # CHECK-NEXT:  "range": {
 # CHECK-NEXT:"end": {
-# CHECK-NEXT:  "character": 19,
+# CHECK-NEXT:  "character": 16,
 # CHECK-NEXT:  "line": 0
 # CHECK-NEXT:},
 # CHECK-NEXT:"start": {
@@ -20,20 +21,7 @@
 # CHECK-NEXT:  "line": 0
 # CHECK-NEXT:}
 # CHECK-NEXT:  },
-# CHECK-NEXT:  "target": "file://{{.*}}/stdint.h"
-# CHECK-NEXT:},
-# CHECK-NEXT:{
-# CHECK-NEXT:  "range": {
-# CHECK-NEXT:"end": {
-# CHECK-NEXT:  "character": 19,
-# CHECK-NEXT:  "line": 1
-# CHECK-NEXT:},
-# CHECK-NEXT:"start": {
-# CHECK-NEXT:  "character": 9,
-# CHECK-NEXT:  "line": 1
-# CHECK-NEXT:}
-# CHECK-NEXT:  },
-# CHECK-NEXT:  "target": "file://{{.*}}/stddef.h"
+# CHECK-NEXT:  "target": "file://{{.*}}/foo.h"
 # CHECK-NEXT:}
 # CHECK-NEXT:  ]
 # CHECK-NEXT:}



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


[PATCH] D95670: [clangd] Don't rely on builtin headers for document-link.test.

2021-02-01 Thread Haojian Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
hokein marked 3 inline comments as done.
Closed by commit rG78c22fbce991: [clangd] Don't rely on builtin headers 
for document-link.test. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95670

Files:
  clang-tools-extra/clangd/test/document-link.test


Index: clang-tools-extra/clangd/test/document-link.test
===
--- clang-tools-extra/clangd/test/document-link.test
+++ clang-tools-extra/clangd/test/document-link.test
@@ -1,9 +1,10 @@
-# for %resource_dir: REQUIRES: clang
-# %resource_dir actually points at builtin_include_dir, go up one directory.
-# RUN: clangd -lit-test -resource-dir=%resource_dir/.. < %s | FileCheck 
-strict-whitespace %s
+# Create a fake resource_dir so that the test can find the headers.
+# RUN: rm -rf %/t
+# RUN: mkdir -p %t/include/ && touch %t/include/foo.h
+# RUN: clangd -lit-test -resource-dir=%t < %s | FileCheck -strict-whitespace %s
 
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
-{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"#include
 \n#include "}}}
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"#include
 "}}}
 ---
 
{"jsonrpc":"2.0","id":2,"method":"textDocument/documentLink","params":{"textDocument":{"uri":"test:///main.cpp"}}}
 #  CHECK:  "id": 2,
@@ -12,7 +13,7 @@
 # CHECK-NEXT:{
 # CHECK-NEXT:  "range": {
 # CHECK-NEXT:"end": {
-# CHECK-NEXT:  "character": 19,
+# CHECK-NEXT:  "character": 16,
 # CHECK-NEXT:  "line": 0
 # CHECK-NEXT:},
 # CHECK-NEXT:"start": {
@@ -20,20 +21,7 @@
 # CHECK-NEXT:  "line": 0
 # CHECK-NEXT:}
 # CHECK-NEXT:  },
-# CHECK-NEXT:  "target": "file://{{.*}}/stdint.h"
-# CHECK-NEXT:},
-# CHECK-NEXT:{
-# CHECK-NEXT:  "range": {
-# CHECK-NEXT:"end": {
-# CHECK-NEXT:  "character": 19,
-# CHECK-NEXT:  "line": 1
-# CHECK-NEXT:},
-# CHECK-NEXT:"start": {
-# CHECK-NEXT:  "character": 9,
-# CHECK-NEXT:  "line": 1
-# CHECK-NEXT:}
-# CHECK-NEXT:  },
-# CHECK-NEXT:  "target": "file://{{.*}}/stddef.h"
+# CHECK-NEXT:  "target": "file://{{.*}}/foo.h"
 # CHECK-NEXT:}
 # CHECK-NEXT:  ]
 # CHECK-NEXT:}


Index: clang-tools-extra/clangd/test/document-link.test
===
--- clang-tools-extra/clangd/test/document-link.test
+++ clang-tools-extra/clangd/test/document-link.test
@@ -1,9 +1,10 @@
-# for %resource_dir: REQUIRES: clang
-# %resource_dir actually points at builtin_include_dir, go up one directory.
-# RUN: clangd -lit-test -resource-dir=%resource_dir/.. < %s | FileCheck -strict-whitespace %s
+# Create a fake resource_dir so that the test can find the headers.
+# RUN: rm -rf %/t
+# RUN: mkdir -p %t/include/ && touch %t/include/foo.h
+# RUN: clangd -lit-test -resource-dir=%t < %s | FileCheck -strict-whitespace %s
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
-{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"#include \n#include "}}}
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"#include "}}}
 ---
 {"jsonrpc":"2.0","id":2,"method":"textDocument/documentLink","params":{"textDocument":{"uri":"test:///main.cpp"}}}
 #  CHECK:  "id": 2,
@@ -12,7 +13,7 @@
 # CHECK-NEXT:{
 # CHECK-NEXT:  "range": {
 # CHECK-NEXT:"end": {
-# CHECK-NEXT:  "character": 19,
+# CHECK-NEXT:  "character": 16,
 # CHECK-NEXT:  "line": 0
 # CHECK-NEXT:},
 # CHECK-NEXT:"start": {
@@ -20,20 +21,7 @@
 # CHECK-NEXT:  "line": 0
 # CHECK-NEXT:}
 # CHECK-NEXT:  },
-# CHECK-NEXT:  "target": "file://{{.*}}/stdint.h"
-# CHECK-NEXT:},
-# CHECK-NEXT:{
-# CHECK-NEXT:  "range": {
-# CHECK-NEXT:"end": {
-# CHECK-NEXT:  "character": 19,
-# CHECK-NEXT:  "line": 1
-# CHECK-NEXT:},
-# CHECK-NEXT:"start": {
-# CHECK-NEXT:  "character": 9,
-# CHECK-NEXT:  "line": 1
-# CHECK-NEXT:}
-# CHECK-NEXT:  },
-# CHECK-NEXT:  "target": "file://{{.*}}/stddef.h"
+# CHECK-NEXT:  "target": "file://{{.*}}/foo.h"
 # CHECK-NEXT:}
 # CHECK-NEXT:  ]
 # CHECK-NEXT:}
___
cfe

[PATCH] D95307: [StaticAnalyzer] Add checking for degenerate base class in MemRegion

2021-02-01 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

In D95307#2533259 , @vsavchenko wrote:

> I don't know if this is useful or not, but pointer-to-members used to be 
> `void *` up until very recently.  Here is my change on that topic (and it 
> probably where the bug you're trying to fix initiated): 
> https://reviews.llvm.org/D85817
> I thought, it can be useful to see the areas of code where it all happens.

Thank you @vsavchenko. I had actually seen this review by examining the file 
blames. I don't think the problem is in your review. The trouble is that when 
the CXXBaseSpecifier list in PointerToMemberData is initialized, it receives a 
list. That list I suspect contains passed in the base class of the struct. But 
this list is supposed to be for following static casts. I have to localize that 
logic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95307

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


[PATCH] D95695: [clang-tblgen] AnnotateAttr::printPretty has spurious comma when no variadic argument is specified

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



Comment at: clang/test/AST/ast-print-attr.c:31
+// CHECK: int fun_annotate() __attribute__((annotate("annotation")))
+int fun_annotate() __attribute__((annotate("annotation")));

Can you add a second test that shows we properly print the comma? e.g., `int 
fun_annotate2() __attribute__((annotate("annotation one", "annotation two")));`



Comment at: clang/utils/TableGen/ClangAttrEmitter.cpp:2252
+  // Helper to print the starting character of an attribute argument. If there
+  // hasn't been an argument yet, it prints an opening parenthese; otherwise it
+  // prints a comma.

One downside to printing the opening paren is that this can't be used in a 
generic way for generating any comma-separate list. That said, I think this 
functionality is clean -- perhaps renaming the function from `Comma` to 
`PrintAttributeArgListElement` or something would be an improvement?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95695

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


[PATCH] D77811: [clangd] Implement semanticTokens modifiers

2021-02-01 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 320464.
sammccall marked an inline comment as done.
sammccall added a comment.

add missing test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77811

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/test/semantic-tokens.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
  clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp
  llvm/lib/Testing/Support/Annotations.cpp

Index: llvm/lib/Testing/Support/Annotations.cpp
===
--- llvm/lib/Testing/Support/Annotations.cpp
+++ llvm/lib/Testing/Support/Annotations.cpp
@@ -53,7 +53,8 @@
   continue;
 }
 if (Text.consume_front("$")) {
-  Name = Text.take_while(llvm::isAlnum);
+  Name =
+  Text.take_while([](char C) { return llvm::isAlnum(C) || C == '_'; });
   Text = Text.drop_front(Name->size());
   continue;
 }
Index: clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp
@@ -18,15 +18,17 @@
 TEST_F(AnnotateHighlightingsTest, Test) {
   EXPECT_AVAILABLE("^vo^id^ ^f(^) {^}^"); // available everywhere.
   EXPECT_AVAILABLE("[[int a; int b;]]");
-  EXPECT_EQ("void /* entity.name.function.cpp */f() {}", apply("void ^f() {}"));
+  EXPECT_EQ("void /* Function [decl] */f() {}", apply("void ^f() {}"));
 
-  EXPECT_EQ(apply("[[void f1(); void f2();]]"),
-"void /* entity.name.function.cpp */f1(); "
-"void /* entity.name.function.cpp */f2();");
+  EXPECT_EQ(
+  apply("[[int f1(); const int x = f1();]]"),
+  "int /* Function [decl] */f1(); "
+  "const int /* Variable [decl] [readonly] */x = /* Function */f1();");
 
+  // Only the targeted range is annotated.
   EXPECT_EQ(apply("void f1(); void f2() {^}"),
 "void f1(); "
-"void /* entity.name.function.cpp */f2() {}");
+"void /* Function [decl] */f2() {}");
 }
 
 } // namespace
Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -18,6 +18,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/raw_ostream.h"
 #include "gmock/gmock.h"
 #include 
 
@@ -86,7 +87,8 @@
 return L.R.start < R.R.start;
   }));
 
-  std::string Result;
+  std::string Buf;
+  llvm::raw_string_ostream OS(Buf);
   unsigned NextChar = 0;
   for (auto &T : Tokens) {
 unsigned StartOffset = llvm::cantFail(positionToOffset(Input, T.R.start));
@@ -94,14 +96,18 @@
 assert(StartOffset <= EndOffset);
 assert(NextChar <= StartOffset);
 
-Result += Input.substr(NextChar, StartOffset - NextChar);
-Result += std::string(
-llvm::formatv("${0}[[{1}]]", T.Kind,
-  Input.substr(StartOffset, EndOffset - StartOffset)));
+OS << Input.substr(NextChar, StartOffset - NextChar);
+OS << '$' << T.Kind;
+for (unsigned I = 0;
+ I <= static_cast(HighlightingModifier::LastModifier); ++I) {
+  if (T.Modifiers & (1 << I))
+OS << '_' << static_cast(I);
+}
+OS << "[[" << Input.substr(StartOffset, EndOffset - StartOffset) << "]]";
 NextChar = EndOffset;
   }
-  Result += Input.substr(NextChar);
-  return Result;
+  OS << Input.substr(NextChar);
+  return std::move(OS.str());
 }
 
 void checkHighlightings(llvm::StringRef Code,
@@ -160,337 +166,340 @@
 TEST(SemanticHighlighting, GetsCorrectTokens) {
   const char *TestCases[] = {
   R"cpp(
-  struct $Class[[AS]] {
-double $Field[[SomeMember]];
+  struct $Class_decl[[AS]] {
+double $Field_decl[[SomeMember]];
   };
   struct {
-  } $Variable[[S]];
-  void $Function[[foo]](int $Parameter[[A]], $Class[[AS]] $Parameter[[As]]) {
-$Primitive[[auto]] $LocalVariable[[VeryLongVariableName]] = 12312;
-$Class[[AS]] $LocalVariable[[AA]];
-$Primitive[[auto]] $LocalVariable[[L]] = $LocalVariable[[AA]].$Field[[SomeMember]] + $Parameter[[A]];
-auto $LocalVariable[[FN]] = [ $LocalVariable[[AA]]](int $Parameter[[A]]) -> void {};
+  } $Variable_decl[[S]];
+  void $Function_decl[[foo]](int $Parameter_decl[[A]], $Class[[AS]] $Parameter_decl[[As]]) {
+

[PATCH] D77811: [clangd] Implement semanticTokens modifiers

2021-02-01 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D77811#2533237 , @nridge wrote:

> Thanks a lot for working on this! I agree this is well aligned with the goals 
> of D77702  (and in fact goes even further 
> and meets the goals of D66990  via the 
> `declaration` modifier).

Ooh, I hadn't seen D66990 , thanks for the 
pointer and also giving the upstream feedback to LSP folks! I'm also really 
happy about the multi-dimensional nature of highlightings in the new protocol, 
looks like you pushed it in that directyon.

>> - no split between primitive/typedef. (Is introducing a nonstandard kind is 
>> worth this distinction?)
>
> Here's my general take on this:
>
> - There is too much variety between programming languages to expect that a 
> standard list of highlighting kinds is going to satisfactorily cover all 
> languages.
> - If LSP aims to be the basis for tools that are competitive with 
> purpose-built language-specific tools, it's reasonable to allow for clients 
> willing to go the extra mile in terms of customization (e.g. use a 
> language-specific theme which provides colors for language-specific token 
> kinds).
> - Therefore, I would say yes, we should take the liberty of adding 
> nonstandard highlighting kinds and modifiers where it makes sense from a 
> language POV.

Totally agree, I should have been more explicit.
Introducing nonstandard kinds is **backwards-incompatible**. If the client 
doesn't understand primitiveType, then the token kind is now completely 
unknown. This could be a regression from the current state (type).
But for primitive type specifically, the information we're losing is "auto 
denotes a type" which the client's non-semantic highlighting should manage 
anyway. So I agree we should do this.

> That said... for typedef specifically, I wonder if it actually makes more 
> sense as a modifier than a kind. That is, have the kind be the target type 
> (falling back to Unknown/Dependent if we don't know), and have a modifier 
> flag for "the type is referred to via an alias" (as opposed to "the type is 
> referred to directly"). WDYT?

Agree. Do you think it should be the *same* modifier as `deduced` which I 
included here?
(In a similar vein, there's an argument for pointer, ref, rvalue-ref as 
modifiers)

>> - no nonstandard local attribute This probably makes sense, I'm wondering if 
>> we want others and how they fit together.
>
> Are you referring to local-scope variables (i.e. `FunctionScope` in D95701 
> )? If so, I think the approach in that patch 
> is promising.

Yes, exactly.




Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:264
+$Class[[D]] $Field_decl[[E]];
+static double $StaticField_decl_static[[S]];
+static void $StaticMethod_decl_static[[bar]]() {}

nridge wrote:
> Presumably, the highlighting kinds `StaticField` and `StaticMethod` are going 
> to be collapsed into `Field` and `Method` in a future change (after the 
> removal of TheiaSemanticHighlighting, I guess)?
Yeah, merging any kinds that are exported with the same name should be NFC at 
that point.

Hmm, though currently StaticField --> Variable, not Field (similarly 
StaticMethod --> Method).
So we can have static fields be Variable+Static+ClassScope or 
Field+Static+ClassScope.

I can see arguments for either...



Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:718
+  };
+  )cpp",
+  };

nridge wrote:
> Should we add a test case for `_deprecated` as well?
Oops, done!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77811

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


[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2021-02-01 Thread Alexey Bader via Phabricator via cfe-commits
bader added a subscriber: aaron.ballman.
bader added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:9996
+  if (CGM.isTypeConstant(D->getType(), false)) {
+if (auto ConstAS = CGM.getTarget().getConstantAddressSpace())
+  return ConstAS.getValue();

@aaron.ballman, suggests we call out `auto` here.

I took this code from [[ 
https://github.com/intel/llvm/blob/sycl/clang/lib/CodeGen/TargetInfo.cpp#L9089-L9091
 | AMDGPUTargetCodeGenInfo::getGlobalVarAddressSpace]]. 

I also found a few other places where `getConstantAddressSpace` is called and 
authors use `auto`: [[ 
https://github.com/llvm/llvm-project/blob/bb9eb198298099742c823dce11c5edacc9c48d4e/clang/lib/CodeGen/CodeGenModule.cpp#L4053
 | CodeGenModule::getStringLiteralAddressSpace ]] [[ 
https://github.com/llvm/llvm-project/blob/bb9eb198298099742c823dce11c5edacc9c48d4e/clang/lib/CodeGen/CodeGenModule.cpp#L4071
 | castStringLiteralToDefaultAddressSpace ]] and [[ 
https://github.com/llvm/llvm-project/blob/55488bd3cd1a468941e26ad4cf94f2bad887fc02/clang/lib/CodeGen/CGExpr.cpp#L405
 | createReferenceTemporary ]]. 

@rjmccall, should I update all these instances? I can create an NFC patch for 
changes outside of this patch and push it before this change to the style 
consistent across the code base.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89909

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


[PATCH] D94961: [OpenMP] Add OpenMP offloading toolchain for AMDGPU

2021-02-01 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Overall, looks reasonable. I'm not a fan of the way things are hooked up but 
that is also true for the NVPTX toolchain and for now unavoidable I guess. Some 
nits below.




Comment at: clang/lib/Driver/Driver.cpp:2999
+if (VStr.startswith("-march=")) {
+  if (StringRef(VStr.str().substr(7)).startswith("gfx"))
+IsAMDGCN = true;

Why the `substr` copy?



Comment at: clang/lib/Driver/ToolChains/AMDGPU.h:72
+  bool isPICDefaultForced() const override { return false; }
+  bool SupportsProfiling() const override { return false; }
+

What is the coding style here? Pick upper case or lower case, form the above I 
assume upper case.



Comment at: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp:65
+ .Case("g", "1")
+ .Default("2");
+}

To verify, O0 is not mapped to O2, correct?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94961

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


[clang-tools-extra] ff4832d - [clangd] Respect ReferencesParams.context.includeDeclarations

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

Author: Sam McCall
Date: 2021-02-01T17:07:02+01:00
New Revision: ff4832dbff0ccf1fd29f726efe72fd1220cd645a

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

LOG: [clangd] Respect ReferencesParams.context.includeDeclarations

Unfortunately this treats overrides declarations as declarations, not as
references. I don't plan to land this until I have a fix for that issue.

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/XRefs.h
clang-tools-extra/clangd/test/references.test
clang-tools-extra/clangd/unittests/PreambleTests.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 35aed2166f03..42e865d764ae 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -1339,14 +1339,23 @@ void ClangdLSPServer::onChangeConfiguration(
 
 void ClangdLSPServer::onReference(const ReferenceParams &Params,
   Callback> Reply) {
-  Server->findReferences(Params.textDocument.uri.file(), Params.position,
- Opts.CodeComplete.Limit,
- [Reply = std::move(Reply)](
- llvm::Expected Refs) mutable {
-   if (!Refs)
- return Reply(Refs.takeError());
-   return Reply(std::move(Refs->References));
- });
+  Server->findReferences(
+  Params.textDocument.uri.file(), Params.position, Opts.CodeComplete.Limit,
+  [Reply = std::move(Reply),
+   IncludeDecl(Params.context.includeDeclaration)](
+  llvm::Expected Refs) mutable {
+if (!Refs)
+  return Reply(Refs.takeError());
+// Filter out declarations if the client asked.
+std::vector Result;
+Result.reserve(Refs->References.size());
+for (auto &Ref : Refs->References) {
+  bool IsDecl = Ref.Attributes & ReferencesResult::Declaration;
+  if (IncludeDecl || !IsDecl)
+Result.push_back(std::move(Ref.Loc));
+}
+return Reply(std::move(Result));
+  });
 }
 
 void ClangdLSPServer::onGoToImplementation(

diff  --git a/clang-tools-extra/clangd/Protocol.cpp 
b/clang-tools-extra/clangd/Protocol.cpp
index 76cf813e6808..1543b7c1e09c 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -1219,10 +1219,17 @@ bool fromJSON(const llvm::json::Value &Params,
  O.map("direction", R.direction);
 }
 
+bool fromJSON(const llvm::json::Value &Params, ReferenceContext &R,
+  llvm::json::Path P) {
+  llvm::json::ObjectMapper O(Params, P);
+  return O && O.mapOptional("includeDeclaration", R.includeDeclaration);
+}
+
 bool fromJSON(const llvm::json::Value &Params, ReferenceParams &R,
   llvm::json::Path P) {
   TextDocumentPositionParams &Base = R;
-  return fromJSON(Params, Base, P);
+  llvm::json::ObjectMapper O(Params, P);
+  return fromJSON(Params, Base, P) && O && O.mapOptional("context", R.context);
 }
 
 llvm::json::Value toJSON(SymbolTag Tag) {

diff  --git a/clang-tools-extra/clangd/Protocol.h 
b/clang-tools-extra/clangd/Protocol.h
index 43c95686868b..a6498088647c 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -1472,8 +1472,13 @@ struct CallHierarchyOutgoingCall {
 };
 llvm::json::Value toJSON(const CallHierarchyOutgoingCall &);
 
+struct ReferenceContext {
+  /// Include the declaration of the current symbol.
+  bool includeDeclaration = false;
+};
+
 struct ReferenceParams : public TextDocumentPositionParams {
-  // For now, no options like context.includeDeclaration are supported.
+  ReferenceContext context;
 };
 bool fromJSON(const llvm::json::Value &, ReferenceParams &, llvm::json::Path);
 

diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index d4dc6212553f..8123b9bc452f 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -1312,9 +1312,13 @@ ReferencesResult findReferences(ParsedAST &AST, Position 
Pos, uint32_t Limit,
   auto Refs = IDToRefs.find(MacroSID);
   if (Refs != IDToRefs.end()) {
 for (const auto &Ref : Refs->second) {
-  Location Result;
-  Result.range = Ref.Rng;
-  Result.uri = URIMainFile;
+  ReferencesResult::Reference Result;
+  Result.Loc.range = Ref.Rng;
+  Result.Loc.uri = URI

[PATCH] D95450: [clangd] Respect ReferencesParams.context.includeDeclarations

2021-02-01 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.h:86
+  enum ReferenceAttributes : unsigned {
+Plain = 0,
+Declaration = 1 << 0,

kbobyrev wrote:
> nit: `Plain` means neither `Declaration` nor `Definition`, right? Maybe 
> `None` then?
Haha, this is actually unused.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95450

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


[PATCH] D95450: [clangd] Respect ReferencesParams.context.includeDeclarations

2021-02-01 Thread Sam McCall via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
sammccall marked 2 inline comments as done.
Closed by commit rGff4832dbff0c: [clangd] Respect 
ReferencesParams.context.includeDeclarations (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D95450?vs=319306&id=320472#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95450

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/test/references.test
  clang-tools-extra/clangd/unittests/PreambleTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -37,6 +37,7 @@
 namespace clangd {
 namespace {
 
+using ::testing::AllOf;
 using ::testing::ElementsAre;
 using ::testing::Eq;
 using ::testing::IsEmpty;
@@ -290,7 +291,8 @@
 
 MATCHER_P(Sym, Name, "") { return arg.Name == Name; }
 
-MATCHER_P(RangeIs, R, "") { return arg.range == R; }
+MATCHER_P(RangeIs, R, "") { return arg.Loc.range == R; }
+MATCHER_P(AttrsAre, A, "") { return arg.Attributes == A; }
 
 TEST(LocateSymbol, WithIndex) {
   Annotations SymbolHeader(R"cpp(
@@ -1688,11 +1690,34 @@
   << Test;
 }
 
+void checkFindRefs(llvm::StringRef Test, bool UseIndex = false) {
+  Annotations T(Test);
+  auto TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  std::vector> ExpectedLocations;
+  for (const auto &R : T.ranges())
+ExpectedLocations.push_back(AllOf(RangeIs(R), AttrsAre(0u)));
+  // $def is actually shorthand for both definition and declaration.
+  // If we have cases that are definition-only, we should change this.
+  for (const auto &R : T.ranges("def"))
+ExpectedLocations.push_back(
+AllOf(RangeIs(R), AttrsAre(ReferencesResult::Definition |
+   ReferencesResult::Declaration)));
+  for (const auto &R : T.ranges("decl"))
+ExpectedLocations.push_back(
+AllOf(RangeIs(R), AttrsAre(ReferencesResult::Declaration)));
+  EXPECT_THAT(
+  findReferences(AST, T.point(), 0, UseIndex ? TU.index().get() : nullptr)
+  .References,
+  UnorderedElementsAreArray(ExpectedLocations))
+  << Test;
+}
+
 TEST(FindReferences, WithinAST) {
   const char *Tests[] = {
   R"cpp(// Local variable
 int main() {
-  int [[foo]];
+  int $def[[foo]];
   [[^foo]] = 2;
   int test1 = [[foo]];
 }
@@ -1700,7 +1725,7 @@
 
   R"cpp(// Struct
 namespace ns1 {
-struct [[Foo]] {};
+struct $def[[Foo]] {};
 } // namespace ns1
 int main() {
   ns1::[[Fo^o]]* Params;
@@ -1708,15 +1733,15 @@
   )cpp",
 
   R"cpp(// Forward declaration
-class [[Foo]];
-class [[Foo]] {};
+class $decl[[Foo]];
+class $def[[Foo]] {};
 int main() {
   [[Fo^o]] foo;
 }
   )cpp",
 
   R"cpp(// Function
-int [[foo]](int) {}
+int $def[[foo]](int) {}
 int main() {
   auto *X = &[[^foo]];
   [[foo]](42);
@@ -1725,7 +1750,7 @@
 
   R"cpp(// Field
 struct Foo {
-  int [[foo]];
+  int $def[[foo]];
   Foo() : [[foo]](0) {}
 };
 int main() {
@@ -1735,8 +1760,8 @@
   )cpp",
 
   R"cpp(// Method call
-struct Foo { int [[foo]](); };
-int Foo::[[foo]]() {}
+struct Foo { int $decl[[foo]](); };
+int Foo::$def[[foo]]() {}
 int main() {
   Foo f;
   f.[[^foo]]();
@@ -1745,7 +1770,7 @@
 
   R"cpp(// Constructor
 struct Foo {
-  [[F^oo]](int);
+  $decl[[F^oo]](int);
 };
 void foo() {
   Foo f = [[Foo]](42);
@@ -1753,14 +1778,14 @@
   )cpp",
 
   R"cpp(// Typedef
-typedef int [[Foo]];
+typedef int $def[[Foo]];
 int main() {
   [[^Foo]] bar;
 }
   )cpp",
 
   R"cpp(// Namespace
-namespace [[ns]] {
+namespace $decl[[ns]] { // FIXME: def?
 struct Foo {};
 } // namespace ns
 int main() { [[^ns]]::Foo foo; }
@@ -1770,7 +1795,7 @@
 #define TYPE(X) X
 #define FOO Foo
 #define CAT(X, Y) X##Y
-class [[Fo^o]] {};
+class $def[[Fo^o]] {};
 void test() {
   TYPE([[Foo]]) foo;
   [[FOO]] foo2;
@@ -1780,7 +1805,7 @@
   )cpp",
 
   R"cpp(// Macros
-#define [[MA^CRO]](X) (X+1)
+#define $def[[MA^CRO]](X) (X+1)
 void test() {
   int x = [[MACRO]]

[PATCH] D95448: [flang][driver] Add support for `-J/-module-dir`

2021-02-01 Thread Tim Keith via Phabricator via cfe-commits
tskeith added inline comments.



Comment at: flang/include/flang/Frontend/CompilerInstance.h:105
   /// {
+  Fortran::semantics::SemanticsContext &semaChecking() const { return 
*semantics_; }
 

awarzynski wrote:
> tskeith wrote:
> > `semanticsContext` would be a better name for this function.
> We should follow Flang's [[ 
> https://github.com/llvm/llvm-project/blob/main/flang/docs/C%2B%2Bstyle.md#naming
>  | coding style ]] here:
> ```
> Accessor member functions are named with the non-public data member's name, 
> less the trailing underscore. 
> ```
> i.e. `semantics()` rather than `semanticsContext()`. If we were to diverge 
> from that, then I suggest that we follow the style prevalent in LLVM/Clang, 
> see e.g. [[ 
> https://github.com/llvm/llvm-project/blob/21bfd068b32ece1c6fbc912208e7cd1782a8c3fc/clang/include/clang/Frontend/CompilerInstance.h#L503-L506
>  | getSema ]].
> 
> @tskeith, I'm guessing that you wanted the member variable to be updated too:
> * semantics_ -> semanticsContext_
> Makes sense to me. 
> 
> @tskeith, I'm guessing that you wanted the member variable to be updated too:
> * semantics_ -> semanticsContext_

Right.




Comment at: flang/lib/Frontend/CompilerInstance.cpp:29
+  semantics_(new Fortran::semantics::SemanticsContext(*(new  
Fortran::common::IntrinsicTypeDefaultKinds()),*(new 
common::LanguageFeatureControl()),
+ *allCookedSources_)) {
 

awarzynski wrote:
> tskeith wrote:
> > Why is `semantics_` a `shared_ptr` rather than a simple data member of  
> > type `SemanticsContext`? It's owned by only `CompilerInstance`, not shared.
> > The same question probably applies to the other fields too.
> @tskeith You raise two important points here:
> 
> **Why shared_ptr if the resource is not shared?** 
> From what I can see, at this point the `SemanticsContext` is not shared and 
> we can safely use `unique_ptr` instead.
> 
> **Why are semantics_ and other members of CompilerInstance pointers?**
> `CompilerInstance` doesn't really own much - it just encapsulates all 
> classes/structs that are required for creating a _compiler instance_. It's 
> kept lightweight and written in a way that makes it easy to _inject_ custom 
> instances of these classes. This approach is expected to be helpful when 
> creating new frontend actions (I expect that there will be a lot) and when 
> compiling projects with many source files.
> 
> @tskeith, I intend to document the design of the new driver soon and suggest 
> that that's when we re-open the discussion on the design of 
> `CompilerInstance`.
> 
> IMO this change is consistent with the current design and I think that we 
> should accept it as is.
> 
> **Small suggestion**
> @arnamoy10 , I think that you can safely add `IntrinsicTypeDefaultKinds` and 
> `LanguageFeatureControl` members too. We will need them shortly and this way 
> this constructor becomes much cleaner. I'm fine either way!
> 
> 
> **Why are semantics_ and other members of CompilerInstance pointers?**
> `CompilerInstance` doesn't really own much - it just encapsulates all 
> classes/structs that are required for creating a _compiler instance_.

As it stands it does own the instance of `SemanticsContext` etc. No one else 
does.

> @tskeith, I intend to document the design of the new driver soon and suggest 
> that that's when we re-open the discussion on the design of 
> `CompilerInstance`.

OK



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

https://reviews.llvm.org/D95448

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


[PATCH] D94961: [OpenMP] Add OpenMP offloading toolchain for AMDGPU

2021-02-01 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

In D94961#2533848 , @jdoerfert wrote:

> Overall, looks reasonable. I'm not a fan of the way things are hooked up but 
> that is also true for the NVPTX toolchain and for now unavoidable I guess.

This is loosely based on the nvptx and hip toolchain files, but looking at 
others in clang the style seems similar.




Comment at: clang/lib/Driver/Driver.cpp:2999
+if (VStr.startswith("-march=")) {
+  if (StringRef(VStr.str().substr(7)).startswith("gfx"))
+IsAMDGCN = true;

jdoerfert wrote:
> Why the `substr` copy?
As in `VStr.startswith("-march=gfx")`? Slightly prettier. Not sure ad hoc arg 
parsing like this is ever good though



Comment at: clang/lib/Driver/ToolChains/AMDGPU.h:72
+  bool isPICDefaultForced() const override { return false; }
+  bool SupportsProfiling() const override { return false; }
+

jdoerfert wrote:
> What is the coding style here? Pick upper case or lower case, form the above 
> I assume upper case.
Yeah, should be `supportsProfiling()` as it's a function. Should probably 
propose that as a minimal patch to the existing code. There may be other casing 
mistakes. ConstructJob looks suspect, but all the files call it that instead of 
constructJob, so maybe I'm missing a part of the style guide.



Comment at: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp:65
+ .Case("g", "1")
+ .Default("2");
+}

jdoerfert wrote:
> To verify, O0 is not mapped to O2, correct?
I think `opt -O0` is an error, though it does look like this will rewrite it to 
O2 instead. Which seems bad.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94961

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


[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

2021-02-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 7 inline comments as done.
yaxunl added inline comments.



Comment at: clang/include/clang/Basic/TargetInfo.h:1478
+  enum class AtomicOperationKind {
+Unsupported,
+Init,

rjmccall wrote:
> This shouldn't be here; if you have places that don't always represent an 
> atomic operation, queries for the kind should return an 
> `Optional` from the classification.
Removed.



Comment at: clang/include/clang/Basic/TargetInfo.h:1479
+Unsupported,
+Init,
+C11LoadStore,

rjmccall wrote:
> `atomic_init` is not actually an atomic operation, so there's never an 
> inherent reason it can't be supported.
> 
> In general, I am torn about this list, because it's simultaneously rather 
> fine-grained while not seeming nearly fine-grained enough to be truly 
> general.  What's actually going on on your target?  You have ISA support for 
> doing some specific operations atomically, but not a general atomic 
> compare-and-swap operation?  Which means that you then cannot support support 
> other operations?
> 
> It is unfortunate that our layering prevents TargetInfo from simply being 
> passed the appropriate expression.
The target hook getAtomicSupport needs an argument for atomic operation. Since 
not all targets support fp add/sub, we need an enum for add/sub. Since certain 
release of iOS/macOS does not support C11 load/store, we need an enum for C11 
load/store. We could define the enums as {AddSub, C11LoadStore, Other}. 
However, this would cause a difficulty for emitting diagnostic message for 
unsupported atomic operations since we map this enum to a string for the atomic 
operation and use it in the diagnostic message. 'Other' would be mapped to 
'other atomic operation' which is not clear what it is.



Comment at: clang/include/clang/Basic/TargetInfo.h:1497
+Unsupported,
+  };
+

rjmccall wrote:
> I think this reflects our current strategies for emitting atomics, but it's a 
> somewhat misleading enum in general because this isn't an exhaustive list of 
> the options — there are certainly possible inline expansions that aren't 
> lock-free.  (For example, you could have an inline spin-lock embedded in the 
> atomic object.)  The goal of this enum is so that TargetInfo only has to have 
> one hook for checking atomic operations?  I would be happier if you included 
> an inline-but-not-lock-free alternative in this enum, even if it's never 
> currently used, so that clients can do the right test.
Added InlineWithLock



Comment at: clang/include/clang/Basic/TargetInfo.h:1501
+  virtual AtomicSupportKind
+  getFPAtomicAddSubSupport(const llvm::fltSemantics &FS) const;
+

rjmccall wrote:
> Why is this needed as a separate hook?
Most target shares getAtomicSupport except FP atomic support, so define a 
virtual function for FP atomic support and let getAtomicSupport call it.



Comment at: clang/lib/AST/ASTContext.cpp:11046
+TargetInfo::AtomicOperationKind
+ASTContext::getTargetAtomicOp(const AtomicExpr *E) const {
+  switch (E->getOp()) {

rjmccall wrote:
> Should this be a method on `AtomicExpr`?  It seems like an intrinsic, 
> target-independent property of the expression.
Yes. moved to AtomicExpr



Comment at: clang/lib/Basic/TargetInfo.cpp:870
+return TargetInfo::AtomicSupportKind::Unsupported;
+  }
+  return AtomicWidthInBits <= AlignmentInBits &&

rjmccall wrote:
> Darwin targets should all be subclasses of `DarwinTargetInfo` in OSTargets.h, 
> so you should be able to just override this there instead of having it in the 
> base case.
done



Comment at: clang/lib/Basic/Targets/AArch64.h:143
+}
+  }
 };

rjmccall wrote:
> Why can't targets reliably expand this to an atomic compare-and-exchange if 
> they support that for the target width?
There are some bugs in either the middle end or backend causing this not 
working. For example, half type atomic fadd on amdgcn is not lowered to cmpxchg 
and the backend has isel failure, bf16 type atomic fadd on arm is not lowered 
to cmpxchg and the backend has isel failure. The support for each fp type needs 
to be done case by case. So far there is no target support atomic fadd/sub with 
half and bf16 type.


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

https://reviews.llvm.org/D71726

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


[clang-tools-extra] 8712df7 - [clangd] references: decls of overrides of x are refs to x, not decls

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

Author: Sam McCall
Date: 2021-02-01T17:19:19+01:00
New Revision: 8712df7a621d1d00a3fd4641ef72639a8faa6284

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

LOG: [clangd] references: decls of overrides of x are refs to x, not decls

This requires a second index query for refs to overrides, as the refs
call doesn't tell you which ref points at which symbol.

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

Added: 


Modified: 
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/index/Index.h
clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index 8123b9bc452f..55b55da80fda 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -872,6 +872,7 @@ class ReferenceFinder : public index::IndexDataConsumer {
   struct Reference {
 syntax::Token SpelledTok;
 index::SymbolRoleSet Role;
+SymbolID Target;
 
 Range range(const SourceManager &SM) const {
   return halfOpenToRange(SM, SpelledTok.range(SM).toCharRange(SM));
@@ -906,13 +907,15 @@ class ReferenceFinder : public index::IndexDataConsumer {
SourceLocation Loc,
index::IndexDataConsumer::ASTNodeInfo ASTNode) override 
{
 const SourceManager &SM = AST.getSourceManager();
-if (!isInsideMainFile(Loc, SM) ||
-TargetIDs.find(getSymbolID(D)) == TargetIDs.end())
+if (!isInsideMainFile(Loc, SM))
+  return true;
+SymbolID ID = getSymbolID(D);
+if (!TargetIDs.contains(ID))
   return true;
 const auto &TB = AST.getTokens();
 Loc = SM.getFileLoc(Loc);
 if (const auto *Tok = TB.spelledTokenAt(Loc))
-  References.push_back({*Tok, Roles});
+  References.push_back({*Tok, Roles, ID});
 return true;
   }
 
@@ -1297,7 +1300,7 @@ ReferencesResult findReferences(ParsedAST &AST, Position 
Pos, uint32_t Limit,
 return {};
   }
 
-  RefsRequest Req;
+  llvm::DenseSet IDs, Overrides;
 
   const auto *IdentifierAtCursor =
   syntax::spelledIdentifierTouching(*CurLoc, AST.getTokens());
@@ -1322,7 +1325,7 @@ ReferencesResult findReferences(ParsedAST &AST, Position 
Pos, uint32_t Limit,
   Results.References.push_back(std::move(Result));
 }
   }
-  Req.IDs.insert(MacroSID);
+  IDs.insert(MacroSID);
 }
   } else {
 // Handle references to Decls.
@@ -1336,7 +1339,6 @@ ReferencesResult findReferences(ParsedAST &AST, Position 
Pos, uint32_t Limit,
   if (auto ID = getSymbolID(D))
 Targets.insert(ID);
 
-llvm::DenseSet Overrides;
 if (Index) {
   RelationsRequest FindOverrides;
   FindOverrides.Predicate = RelationKind::OverriddenBy;
@@ -1374,16 +1376,18 @@ ReferencesResult findReferences(ParsedAST &AST, 
Position Pos, uint32_t Limit,
   ReferencesResult::Reference Result;
   Result.Loc.range = Ref.range(SM);
   Result.Loc.uri = URIMainFile;
-  if (Ref.Role & static_cast(index::SymbolRole::Declaration))
-Result.Attributes |= ReferencesResult::Declaration;
-  // clang-index doesn't report definitions as declarations, but they are.
-  if (Ref.Role & static_cast(index::SymbolRole::Definition))
-Result.Attributes |=
-ReferencesResult::Definition | ReferencesResult::Declaration;
+  // Overrides are always considered references, not defs/decls.
+  if (!Overrides.contains(Ref.Target)) {
+if (Ref.Role & static_cast(index::SymbolRole::Declaration))
+  Result.Attributes |= ReferencesResult::Declaration;
+// clang-index doesn't report definitions as declarations, but they 
are.
+if (Ref.Role & static_cast(index::SymbolRole::Definition))
+  Result.Attributes |=
+  ReferencesResult::Definition | ReferencesResult::Declaration;
+  }
   Results.References.push_back(std::move(Result));
 }
 if (Index && Results.References.size() <= Limit) {
-  Req.IDs = std::move(Overrides);
   for (const Decl *D : Decls) {
 // Not all symbols can be referenced from outside (e.g.
 // function-locals).
@@ -1392,13 +1396,17 @@ ReferencesResult findReferences(ParsedAST &AST, 
Position Pos, uint32_t Limit,
 if (D->getParentFunctionOrMethod())
   continue;
 if (auto ID = getSymbolID(D))
-  Req.IDs.insert(ID);
+  IDs.insert(ID);
   }
 }
   }
   // Now query the index for references from other files.
-  if (!Req.IDs.empty() && Index && Results.References.size() <= Limit) {
+  auto QueryIndex = [&](llvm::DenseSet IDs, bool AllowAttributes) {
+RefsRequest Req;
+Req.IDs = std::move(IDs);
 Req.Limit = Limit;
+if (Req.IDs.empty() || !Index || Resul

[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

2021-02-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 320477.
yaxunl marked 7 inline comments as done.
yaxunl added a comment.
Herald added a reviewer: jfb.

revised by John's comments


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

https://reviews.llvm.org/D71726

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/ARM.h
  clang/lib/Basic/Targets/Hexagon.h
  clang/lib/Basic/Targets/Mips.h
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/fp-atomic-ops.c
  clang/test/CodeGenCUDA/amdgpu-atomic-ops.cu
  clang/test/CodeGenOpenCL/atomic-ops.cl
  clang/test/Sema/atomic-ops.c
  clang/test/Sema/atomic-requires-library-error.c
  clang/test/SemaCUDA/amdgpu-atomic-ops.cu
  clang/test/SemaOpenCL/atomic-ops.cl

Index: clang/test/SemaOpenCL/atomic-ops.cl
===
--- clang/test/SemaOpenCL/atomic-ops.cl
+++ clang/test/SemaOpenCL/atomic-ops.cl
@@ -1,10 +1,13 @@
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only -triple=spir64
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only -triple=amdgcn-amdhsa-amd-opencl
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify=expected,spir \
+// RUN:   -fsyntax-only -triple=spir64
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only \
+// RUN:   -triple=amdgcn-amd-amdhsa
 
 // Basic parsing/Sema tests for __opencl_atomic_*
 
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable
 #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
 typedef __INTPTR_TYPE__ intptr_t;
 typedef int int8 __attribute__((ext_vector_type(8)));
@@ -36,7 +39,7 @@
 
 atomic_int gn;
 void f(atomic_int *i, const atomic_int *ci,
-   atomic_intptr_t *p, atomic_float *d,
+   atomic_intptr_t *p, atomic_float *f, atomic_double *d, atomic_half *h, // expected-error {{unknown type name 'atomic_half'}}
int *I, const int *CI,
intptr_t *P, float *D, struct S *s1, struct S *s2,
global atomic_int *i_g, local atomic_int *i_l, private atomic_int *i_p,
@@ -57,37 +60,38 @@
 
   __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_load(p, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_load(d, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_load(f, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_load(ci, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_load(i_c, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to non-constant _Atomic type ('__constant atomic_int *' (aka '__constant _Atomic(int) *') invalid)}}
 
   __opencl_atomic_store(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_store(p, 1, memory_order_seq_cst, memory_scope_work_group);
-  (int)__opencl_atomic_store(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{operand of type 'void' where arithmetic or pointer type is required}}
+  (int)__opencl_atomic_store(f, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{operand of type 'void' where arithmetic or pointer type is required}}
 
   int exchange_1 = __opencl_atomic_exchange(i, 1, memory_order_seq_cst, memory_scope_work_group);
   int exchange_2 = __opencl_atomic_exchange(I, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to _Atomic}}
 
   __opencl_atomic_fetch_add(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_add(p, 1, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_fetch_add(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer or pointer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
+  __opencl_atomic_fetch_add(f, 1.0f, memory_order_seq_cst, memory_scope_work_group); // spir-error {{atomic add/sub of '__generic atomic_float' (aka '__generic _Atomic(float)') type requires runtime support that is not available for this target}}
+  __opencl_atomic_fetch_add(d, 1.0, memory_order_seq_cst, memory_scope_work_group); // spir-error {{atomic add/sub of '__generic atomic_double' (aka '__generic _Atomic(double)') type requires runtime support that is not available for this target}}
   __opencl_atomic_fetch_and(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_and(p, 1, memory_order_seq_cst, m

[PATCH] D95451: [clangd] references: decls of overrides of x are refs to x, not decls

2021-02-01 Thread Sam McCall via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.
Closed by commit rG8712df7a621d: [clangd] references: decls of overrides of x 
are refs to x, not decls (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D95451?vs=319318&id=320479#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95451

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/index/Index.h
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1871,7 +1871,7 @@
 };
 class Derived : public Base {
 public:
-  void $decl[[func]]() override; // FIXME: ref, not decl
+  void [[func]]() override;
 };
 void test(Derived* D) {
   D->[[func]]();
Index: clang-tools-extra/clangd/index/Index.h
===
--- clang-tools-extra/clangd/index/Index.h
+++ clang-tools-extra/clangd/index/Index.h
@@ -104,11 +104,12 @@
   lookup(const LookupRequest &Req,
  llvm::function_ref Callback) const = 0;
 
-  /// Finds all occurrences (e.g. references, declarations, definitions) of a
-  /// symbol and applies \p Callback on each result.
+  /// Finds all occurrences (e.g. references, declarations, definitions) of
+  /// symbols and applies \p Callback on each result.
   ///
   /// Results should be returned in arbitrary order.
   /// The returned result must be deep-copied if it's used outside Callback.
+  /// FIXME: there's no indication which result references which symbol.
   ///
   /// Returns true if there will be more results (limited by Req.Limit);
   virtual bool refs(const RefsRequest &Req,
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -872,6 +872,7 @@
   struct Reference {
 syntax::Token SpelledTok;
 index::SymbolRoleSet Role;
+SymbolID Target;
 
 Range range(const SourceManager &SM) const {
   return halfOpenToRange(SM, SpelledTok.range(SM).toCharRange(SM));
@@ -906,13 +907,15 @@
SourceLocation Loc,
index::IndexDataConsumer::ASTNodeInfo ASTNode) override {
 const SourceManager &SM = AST.getSourceManager();
-if (!isInsideMainFile(Loc, SM) ||
-TargetIDs.find(getSymbolID(D)) == TargetIDs.end())
+if (!isInsideMainFile(Loc, SM))
+  return true;
+SymbolID ID = getSymbolID(D);
+if (!TargetIDs.contains(ID))
   return true;
 const auto &TB = AST.getTokens();
 Loc = SM.getFileLoc(Loc);
 if (const auto *Tok = TB.spelledTokenAt(Loc))
-  References.push_back({*Tok, Roles});
+  References.push_back({*Tok, Roles, ID});
 return true;
   }
 
@@ -1297,7 +1300,7 @@
 return {};
   }
 
-  RefsRequest Req;
+  llvm::DenseSet IDs, Overrides;
 
   const auto *IdentifierAtCursor =
   syntax::spelledIdentifierTouching(*CurLoc, AST.getTokens());
@@ -1322,7 +1325,7 @@
   Results.References.push_back(std::move(Result));
 }
   }
-  Req.IDs.insert(MacroSID);
+  IDs.insert(MacroSID);
 }
   } else {
 // Handle references to Decls.
@@ -1336,7 +1339,6 @@
   if (auto ID = getSymbolID(D))
 Targets.insert(ID);
 
-llvm::DenseSet Overrides;
 if (Index) {
   RelationsRequest FindOverrides;
   FindOverrides.Predicate = RelationKind::OverriddenBy;
@@ -1374,16 +1376,18 @@
   ReferencesResult::Reference Result;
   Result.Loc.range = Ref.range(SM);
   Result.Loc.uri = URIMainFile;
-  if (Ref.Role & static_cast(index::SymbolRole::Declaration))
-Result.Attributes |= ReferencesResult::Declaration;
-  // clang-index doesn't report definitions as declarations, but they are.
-  if (Ref.Role & static_cast(index::SymbolRole::Definition))
-Result.Attributes |=
-ReferencesResult::Definition | ReferencesResult::Declaration;
+  // Overrides are always considered references, not defs/decls.
+  if (!Overrides.contains(Ref.Target)) {
+if (Ref.Role & static_cast(index::SymbolRole::Declaration))
+  Result.Attributes |= ReferencesResult::Declaration;
+// clang-index doesn't report definitions as declarations, but they are.
+if (Ref.Role & static_cast(index::SymbolRole::Definition))
+  Result.Attributes |=
+  ReferencesResult::Definition | ReferencesResult::Declaration;
+  }
   Results.References.push_back(std::move(Result));
 }
 if (Index && Results.Refere

[PATCH] D94961: [OpenMP] Add OpenMP offloading toolchain for AMDGPU

2021-02-01 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp:65
+ .Case("g", "1")
+ .Default("2");
+}

JonChesterfield wrote:
> jdoerfert wrote:
> > To verify, O0 is not mapped to O2, correct?
> I think `opt -O0` is an error, though it does look like this will rewrite it 
> to O2 instead. Which seems bad.
Suggest we drop the opt invocation. llvm-link is required for the case where 
multiple files are passed to clang as a single invocation, but I don't see why 
we need an opt invocation here. Passing the llvm-link'ed code to llc as-is, 
without this implicit lto style opt invocation, is probably a better default.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94961

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


[PATCH] D95571: [clangd] Remove some obsolete options that are now always on

2021-02-01 Thread Sam McCall via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1eb7fd089e2f: [clangd] Remove some obsolete options that are 
now always on (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D95571?vs=319776&id=320481#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95571

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/BackgroundIndexTests.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
@@ -154,8 +154,7 @@
 
 std::unique_ptr TestTU::index() const {
   auto AST = build();
-  auto Idx = std::make_unique(/*UseDex=*/true,
- /*CollectMainFileRefs=*/true);
+  auto Idx = std::make_unique();
   Idx->updatePreamble(testPath(Filename), /*Version=*/"null",
   AST.getASTContext(), AST.getPreprocessorPtr(),
   AST.getCanonicalIncludes());
Index: clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
@@ -190,7 +190,6 @@
   MemoryShardStorage MSS(Storage, CacheHits);
   OverlayCDB CDB(/*Base=*/nullptr);
   BackgroundIndex::Options Opts;
-  Opts.CollectMainFileRefs = true;
   BackgroundIndex Idx(
   FS, CDB, [&](llvm::StringRef) { return &MSS; }, Opts);
 
@@ -241,52 +240,25 @@
   FS.Files[testPath("root/A.cc")] =
   "#include \"A.h\"\nstatic void main_sym() { (void)header_sym; }";
 
-  // Check the behaviour with CollectMainFileRefs = false (the default
-  // at the SymbolCollector level).
-  {
-llvm::StringMap Storage;
-size_t CacheHits = 0;
-MemoryShardStorage MSS(Storage, CacheHits);
-OverlayCDB CDB(/*Base=*/nullptr);
-BackgroundIndex Idx(FS, CDB, [&](llvm::StringRef) { return &MSS; },
-/*Opts=*/{});
-
-tooling::CompileCommand Cmd;
-Cmd.Filename = testPath("root/A.cc");
-Cmd.Directory = testPath("root");
-Cmd.CommandLine = {"clang++", testPath("root/A.cc")};
-CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
-
-ASSERT_TRUE(Idx.blockUntilIdleForTest());
-EXPECT_THAT(
-runFuzzyFind(Idx, ""),
-UnorderedElementsAre(AllOf(Named("header_sym"), NumReferences(1U)),
- AllOf(Named("main_sym"), NumReferences(0U;
-  }
-
-  // Check the behaviour with CollectMainFileRefs = true.
-  {
-llvm::StringMap Storage;
-size_t CacheHits = 0;
-MemoryShardStorage MSS(Storage, CacheHits);
-OverlayCDB CDB(/*Base=*/nullptr);
-BackgroundIndex::Options Opts;
-Opts.CollectMainFileRefs = true;
-BackgroundIndex Idx(
-FS, CDB, [&](llvm::StringRef) { return &MSS; }, Opts);
+  llvm::StringMap Storage;
+  size_t CacheHits = 0;
+  MemoryShardStorage MSS(Storage, CacheHits);
+  OverlayCDB CDB(/*Base=*/nullptr);
+  BackgroundIndex::Options Opts;
+  BackgroundIndex Idx(
+  FS, CDB, [&](llvm::StringRef) { return &MSS; }, Opts);
 
-tooling::CompileCommand Cmd;
-Cmd.Filename = testPath("root/A.cc");
-Cmd.Directory = testPath("root");
-Cmd.CommandLine = {"clang++", testPath("root/A.cc")};
-CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
+  tooling::CompileCommand Cmd;
+  Cmd.Filename = testPath("root/A.cc");
+  Cmd.Directory = testPath("root");
+  Cmd.CommandLine = {"clang++", testPath("root/A.cc")};
+  CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
 
-ASSERT_TRUE(Idx.blockUntilIdleForTest());
-EXPECT_THAT(
-runFuzzyFind(Idx, ""),
-UnorderedElementsAre(AllOf(Named("header_sym"), NumReferences(1U)),
- AllOf(Named("main_sym"), NumReferences(1U;
-  }
+  ASSERT_TRUE(Idx.blockUntilIdleForTest());
+  EXPECT_THAT(
+  runFuzzyFind(Idx, ""),
+  UnorderedElementsAre(AllOf(Named("header_sym"), NumReferences(1U)),
+   AllOf(Named("main_sym"), NumReferences(1U;
 }
 
 TEST_F(BackgroundIndexTest, ShardStorageTest) {
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/

[clang-tools-extra] 1eb7fd0 - [clangd] Remove some obsolete options that are now always on

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

Author: Sam McCall
Date: 2021-02-01T17:24:03+01:00
New Revision: 1eb7fd089e2fcf3fe211f865b28e2fed12128c3f

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

LOG: [clangd] Remove some obsolete options that are now always on

 - always collect main-file refs when indexing
 - always build preambles asynchronously
 - always use dex for fast preamble index

Retire associated flags

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/TUScheduler.cpp
clang-tools-extra/clangd/TUScheduler.h
clang-tools-extra/clangd/index/Background.cpp
clang-tools-extra/clangd/index/Background.h
clang-tools-extra/clangd/index/FileIndex.cpp
clang-tools-extra/clangd/index/FileIndex.h
clang-tools-extra/clangd/tool/ClangdMain.cpp
clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
clang-tools-extra/clangd/unittests/TestTU.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index ab9903197d08..fd89ec1c45dc 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -122,7 +122,6 @@ ClangdServer::Options ClangdServer::optsForTest() {
   Opts.StorePreamblesInMemory = true;
   Opts.AsyncThreadsCount = 4; // Consistent!
   Opts.TheiaSemanticHighlighting = true;
-  Opts.AsyncPreambleBuilds = true;
   return Opts;
 }
 
@@ -132,7 +131,6 @@ ClangdServer::Options::operator TUScheduler::Options() 
const {
   Opts.RetentionPolicy = RetentionPolicy;
   Opts.StorePreamblesInMemory = StorePreamblesInMemory;
   Opts.UpdateDebounce = UpdateDebounce;
-  Opts.AsyncPreambleBuilds = AsyncPreambleBuilds;
   Opts.ContextProvider = ContextProvider;
   return Opts;
 }
@@ -141,10 +139,7 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase 
&CDB,
const ThreadsafeFS &TFS, const Options &Opts,
Callbacks *Callbacks)
 : CDB(CDB), TFS(TFS),
-  DynamicIdx(Opts.BuildDynamicSymbolIndex
- ? new FileIndex(Opts.HeavyweightDynamicSymbolIndex,
- Opts.CollectMainFileRefs)
- : nullptr),
+  DynamicIdx(Opts.BuildDynamicSymbolIndex ? new FileIndex() : nullptr),
   ClangTidyProvider(Opts.ClangTidyProvider),
   WorkspaceRoot(Opts.WorkspaceRoot),
   // Pass a callback into `WorkScheduler` to extract symbols from a newly
@@ -175,7 +170,6 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase 
&CDB,
 Callbacks->onBackgroundIndexProgress(S);
 };
 BGOpts.ContextProvider = Opts.ContextProvider;
-BGOpts.CollectMainFileRefs = Opts.CollectMainFileRefs;
 BackgroundIdx = std::make_unique(
 TFS, CDB,
 BackgroundIndexStorage::createDiskBackedStorageFactory(

diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index fd5a4bf9a40d..e3de7013ba32 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -97,22 +97,14 @@ class ClangdServer {
 
 /// Cached preambles are potentially large. If false, store them on disk.
 bool StorePreamblesInMemory = true;
-/// Reuse even stale preambles, and rebuild them in the background.
-/// This improves latency at the cost of accuracy.
-bool AsyncPreambleBuilds = true;
 
 /// If true, ClangdServer builds a dynamic in-memory index for symbols in
 /// opened files and uses the index to augment code completion results.
 bool BuildDynamicSymbolIndex = false;
-/// Use a heavier and faster in-memory index implementation.
-bool HeavyweightDynamicSymbolIndex = true;
 /// If true, ClangdServer automatically indexes files in the current 
project
 /// on background threads. The index is stored in the project root.
 bool BackgroundIndex = false;
 
-/// Store refs to main-file symbols in the index.
-bool CollectMainFileRefs = true;
-
 /// If set, use this index to augment code completion results.
 SymbolIndex *StaticIndex = nullptr;
 

diff  --git a/clang-tools-extra/clangd/TUScheduler.cpp 
b/clang-tools-extra/clangd/TUScheduler.cpp
index 1cd669945198..dd4312c4a7c2 100644
--- a/clang-tools-extra/clangd/TUScheduler.cpp
+++ b/clang-tools-extra/clangd/TUScheduler.cpp
@@ -596,8 +596,8 @@ ASTWorker::ASTWorker(PathRef FileName, const 
GlobalCompilationDatabase &CDB,
   FileName(FileName), ContextProvider(Opts.ContextProvider), CDB(CDB),
   Callbacks(Callbacks), Barrier(Barrier), Done(false),
   Status(FileName, Callbacks),
-  PreamblePeer(FileName, Callbacks, Opts.StorePreamblesInMemory,
-

[PATCH] D95714: [clang-tidy] fix modernize-use-nullptr false positive with spaceship operator comparisons

2021-02-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D95714#2532957 , @poelmanc wrote:

> In D95714#2532565 , @njames93 wrote:
>
>> This does highlight an issue where the mimicked std library stubs used for 
>> tests don't correspond exactly to what the stdlib actually looks like and 
>> can result in subtly different ASTs that have added/removed implicit nodes.
>>
>> Going a little off point here but a few months back I pushed a fix for 
>> another check that passed its tests. 
>> However the bug report was re-opened as the bug was still observable in the 
>> real word. 
>> Turned out the implementation of std::string used for the test had a trivial 
>> destructor resulting in the AST not needed to emit `CXXBindTemporaryExpr`s 
>> all over the place, which threw off the matching logic.
>>
>> Unfortunately this kind of disparity is hard to detect in tests so it may be 
>> wise to test this locally using the compare header from a real standard 
>> library implementation (preferably all 3 main ones if you have the machines) 
>> and see if this behaviour is correct.
>
> Indeed the //mimicked std library// approach has real advantages like running 
> fast and giving consistent results across platforms. But it also has 
> drawbacks like the replication of //mimicked std// code across tests, and 
> possible differences between test and real world behaviour. We could give 
> tests a `CLANG_TIDY_TEST_NATIVE_STD` macro to switch between //mimicked std// 
> code and real headers, and set up CI to test both ways, to catch these issues 
> at the expense of added complexity. But that's a broader discussion.

I think the benefits from the mimicked std library outweigh the problems from 
trying to test against a moving target in multiple dimensions, and so I think 
we want to keep the mimicked std library approach as the default for tests. 
However, I also think the lack of testing against real world STL 
implementations is a problem that hurts us, for all the reasons pointed out 
already. Ultimately, the problem with testing against a real STL will boil down 
to who is responsible for changes when a test case starts failing after the 
check author has moved on. However, we might be able to solve this with policy 
decisions like changing a test to an expected failure + bug report while 
waiting for someone to step up to solve the issue. But this is orthogonal to 
your patch and would require a larger community discussion.

In D95714#2533046 , @steveire wrote:

> I think you should be able to correctly match everything. Try a matcher like 
> (can probably be cleaned up a bit):

Thank you for that matcher suggestion; you are a powerful wizard. :-)

Generally, the changes LGTM.




Comment at: clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp:58
+// that if an implicit cast is found, it is not from another
+// nested rewritten operator
+expr().bind("matchBinopOperands"),




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

https://reviews.llvm.org/D95714

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


[PATCH] D95624: [OpenCL][PR48896] Fix default address space in template argument deduction

2021-02-01 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 320484.
Anastasia retitled this revision from "[OpenCL][PR48896] Add default address 
space in template argument deduction only if missing" to "[OpenCL][PR48896] Fix 
default address space in template argument deduction".
Anastasia edited the summary of this revision.
Anastasia added reviewers: rjmccall, olestrohm, mantognini.
Anastasia added a subscriber: cfe-commits.
Anastasia added a comment.

Added test.


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

https://reviews.llvm.org/D95624

Files:
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaOpenCLCXX/address-space-templates.cl


Index: clang/test/SemaOpenCLCXX/address-space-templates.cl
===
--- clang/test/SemaOpenCLCXX/address-space-templates.cl
+++ clang/test/SemaOpenCLCXX/address-space-templates.cl
@@ -1,4 +1,4 @@
-//RUN: %clang_cc1 %s -cl-std=clc++ -pedantic -verify -fsyntax-only
+//RUN: %clang_cc1 %s -cl-std=clc++ -pedantic -verify -ast-dump  | FileCheck %s
 
 template 
 struct S {
@@ -28,8 +28,10 @@
 typedef typename remove_reference<_Tp>::type* type;
 };
 
+// Check address space deduction in template parameter deduction.
 struct rep {
-  // CHECK |-CXXConstructorDecl {{.*}} rep 'void (const __generic rep 
&__private) __generic'
+  // When there is no address space on a reference use __generic.
+  // CHECK: |-CXXConstructorDecl {{.*}} rep 'void (const __generic rep 
&__private) __generic'
   template::type>
   rep(U&& v) {}
 };
@@ -39,11 +41,22 @@
 : rep(0) {}
 };
 
+
+template
+void foo4(T t, F f){
+  f(t);
+}
+
 void bar() {
   S sintgl; // expected-note{{in instantiation of template 
class 'S' requested here}}
 
   foo1<__local int>(1); // expected-error{{no matching function for call to 
'foo1'}}
   foo2<__global int>(0);
   foo3<__global int>(); // expected-note{{in instantiation of function 
template specialization 'foo3<__global int>' requested here}}
+
   rep_outer r;
+  int i;
+  // Preserve the address space of the type in forwarding reference.
+  // CHECK: CXXMethodDecl {{.*}} operator() 'void (__private int &__private) 
const __generic'
+  foo4(i, [](auto&& x){;});
 }
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3886,7 +3886,7 @@
 //   "lvalue reference to A" is used in place of A for type deduction.
 if (isForwardingReference(QualType(ParamRefType, 0), FirstInnerIndex) &&
 Arg->isLValue()) {
-  if (S.getLangOpts().OpenCL)
+  if (S.getLangOpts().OpenCL  && !ArgType.hasAddressSpace())
 ArgType = S.Context.getAddrSpaceQualType(ArgType, 
LangAS::opencl_generic);
   ArgType = S.Context.getLValueReferenceType(ArgType);
 }


Index: clang/test/SemaOpenCLCXX/address-space-templates.cl
===
--- clang/test/SemaOpenCLCXX/address-space-templates.cl
+++ clang/test/SemaOpenCLCXX/address-space-templates.cl
@@ -1,4 +1,4 @@
-//RUN: %clang_cc1 %s -cl-std=clc++ -pedantic -verify -fsyntax-only
+//RUN: %clang_cc1 %s -cl-std=clc++ -pedantic -verify -ast-dump  | FileCheck %s
 
 template 
 struct S {
@@ -28,8 +28,10 @@
 typedef typename remove_reference<_Tp>::type* type;
 };
 
+// Check address space deduction in template parameter deduction.
 struct rep {
-  // CHECK |-CXXConstructorDecl {{.*}} rep 'void (const __generic rep &__private) __generic'
+  // When there is no address space on a reference use __generic.
+  // CHECK: |-CXXConstructorDecl {{.*}} rep 'void (const __generic rep &__private) __generic'
   template::type>
   rep(U&& v) {}
 };
@@ -39,11 +41,22 @@
 : rep(0) {}
 };
 
+
+template
+void foo4(T t, F f){
+  f(t);
+}
+
 void bar() {
   S sintgl; // expected-note{{in instantiation of template class 'S' requested here}}
 
   foo1<__local int>(1); // expected-error{{no matching function for call to 'foo1'}}
   foo2<__global int>(0);
   foo3<__global int>(); // expected-note{{in instantiation of function template specialization 'foo3<__global int>' requested here}}
+
   rep_outer r;
+  int i;
+  // Preserve the address space of the type in forwarding reference.
+  // CHECK: CXXMethodDecl {{.*}} operator() 'void (__private int &__private) const __generic'
+  foo4(i, [](auto&& x){;});
 }
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3886,7 +3886,7 @@
 //   "lvalue reference to A" is used in place of A for type deduction.
 if (isForwardingReference(QualType(ParamRefType, 0), FirstInnerIndex) &&
 Arg->isLValue()) {
-  if (S.getLangOpts().OpenCL)
+  if (S.getLangOpts().OpenCL  && !ArgType.hasAddressSpace())
 ArgType = S.Context.getAddrSpaceQualType(ArgT

[PATCH] D95782: [Syntax] Support condition for IfStmt.

2021-02-01 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/lib/Tooling/Syntax/BuildTree.cpp:803
 
+  bool TraverseIfStmt(IfStmt *S) {
+bool Result = [&, this]() {

is it clear to you what all this code is doing?
It does seem to fit the pattern used elsewhere, it just looks pretty different 
than the RAVs I've seen in the pass (e.g. overriding WalkUp functions).

It seems correct, but I think I'll need to study later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95782

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


[PATCH] D95739: [ASTMatchers] Add matchers for decomposition decls

2021-02-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thanks for this! It generally looks good, aside from some minor nits. Btw, it 
looks like the HTML documentation wasn't regenerated for the patch.




Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:7392
 
+/// Matches the DecompositionDecl the binding belongs to.
+AST_MATCHER_P(BindingDecl, forDecomposition, internal::Matcher,

Can you add code examples to all of the new functionality?



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:7395-7397
+  if (!Node.getDecomposedDecl())
+return false;
+  return InnerMatcher.matches(*Node.getDecomposedDecl(), Finder, Builder);





Comment at: clang/lib/ASTMatchers/Dynamic/Registry.cpp:274
   REGISTER_MATCHER(hasBase);
+  REGISTER_MATCHER(hasAnyBinding);
+  REGISTER_MATCHER(hasBinding);

This should be kept in alphabetical order.



Comment at: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp:2142-2144
+  EXPECT_TRUE(matchesConditionally(
+  Code, decompositionDecl(hasBinding(0, bindingDecl(hasName("f", true,
+  {"-std=c++17"}));

Can you add some test coverage for the invalid cases as well, like asking for 
an out-of-range binding?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95739

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


[PATCH] D95790: [WIP][clang][cli] Documentation of CompilerInvocation parsing/generation

2021-02-01 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95790

Files:
  clang/docs/InternalsManual.rst

Index: clang/docs/InternalsManual.rst
===
--- clang/docs/InternalsManual.rst
+++ clang/docs/InternalsManual.rst
@@ -572,6 +572,180 @@
 The Frontend library contains functionality useful for building tools on top of
 the Clang libraries, for example several methods for outputting diagnostics.
 
+Compiler Invocation
+---
+
+One of the classes provided by the Frontend library is ``CompilerInvocation``,
+which holds information that describe current invocation of the Clang frontend.
+The information typically comes from the command line constructed by the Clang
+driver, or directly from clients performing custom initialization. The data
+structure is split into logical units used by different parts of the compiler,
+for example ``PreprocessorOptions``, ``LanguageOptions`` or ``CodeGenOptions``.
+
+Command Line Interface
+--
+
+The command line interface of the Clang ``-cc1`` frontend is defined alongside
+the driver options in ``clang/Driver/Options.td``. The information making up an
+option definition include the name and prefix (for example ``-std=``), form and
+position of the option value, help text, aliases and more. Each option may
+belong to a certain group and can be marked with zero or more flags. Options
+accepted by the ``-cc1`` frontend are marked with the ``CC1Option`` flag.
+
+Command Line Parsing
+
+
+The option definitions are processed by the ``-gen-opt-parser-defs`` tablegen
+backend, transformed into a list of invocations of the ``OPTION`` macro and
+stored in ``clang/Driver/Driver.inc``. This file is then used to create instance
+of ``llvm::opt::OptTable``, which acts as a command line preprocessor. The
+preprocessed command line is stored in ``llvm::opt::ArgList``, an object that
+provides an API for performing simple queries on the contents of the command
+line.
+
+Finally, the ``CompilerInvocation::CreateFromArgs`` function is responsible for
+the actual parsing of command line arguments. It maps the contents of
+``llvm::opt::ArgList`` onto fields of ``CompilerInvocation``, normalizing the
+values in the process.
+
+Command Line Generation
+---
+
+Any valid instance of ``CompilerInvocation`` can be also serialized back into
+semantically equivalent command line arguments in a deterministic manner. This
+enables features such as explicit modules. TODO: Link to appropriate section of
+Modules.rst.
+
+Option Marshalling infrastructure
+-
+
+The code for parsing and generating command line is in large automatically
+generated from the ``Marshalling`` annotations on the tablegen option
+definitions. The following sections describes the basics of adding marshalling
+annotations to command line options.
+
+First, it is necessary to create a class for constructing references to the
+``CompilerInvocation`` member.
+
+.. code-block::
+
+  class LangOpts : KeyPathAndMacro<"LangOpts->", field, "LANG_"> {}
+  //   CompilerInvocation member  ^^
+  //OPTION_WITH_MARSHALLING prefix ^
+
+This facility is used to construct key paths that refer to a specific field of
+the ``CompilerInvocation`` member.
+
+.. code-block::
+
+  LangOpts<"ImplicitModules">
+  //^^^ LanguageOptions member
+
+Key paths can be passed to the marshalling utilities that specify what happens
+with the key path during command line parsing and generation:
+
+  def fignore_exceptions : Flag<["-"], "fignore-exceptions">, Flags<[CC1Option]>,
+MarshallingInfoFlag>;
+
+TODO: Mention PARSE_ and GENERATE_ macros.
+
+Currently, there are several marshalling utilities for different kinds of
+command line options:
+
+**Positive Flag**
+
+The key path defaults to ``false``, is set to ``true`` when the flag is present
+on the command line.
+
+.. code-block::
+
+  def fignore_exceptions : Flag<["-"], "fignore-exceptions">, Flags<[CC1Option]>,
+MarshallingInfoFlag>;
+
+**Negative Flag**
+
+Key path defaults to ``true``, is set to ``false`` when the flag is present on
+the command line.
+
+.. code-block::
+
+  def fno_verbose_asm : Flag<["-"], "fno-verbose-asm">, Flags<[CC1Option]>,
+MarshallingInfoNegativeFlag>;
+
+**Negative and Positive Flag**
+
+Key path defaults to the specified value, takes on the value of the flag that
+appears last on the command line.
+
+.. code-block::
+
+  defm pthread : BoolOption<"", "pthread",
+LangOpts<"POSIXThreads">, DefaultFalse,  // default => false
+PosFlag, // -pthread=> true
+NegFlag, 

[PATCH] D95792: [clang][cli] Report result of ParseLangArgs

2021-02-01 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch correctly reports success/failure of `ParseLangArgs`. Besides being 
consistent with  other `Parse` functions, this is requires to make 
round-tripping of `LangOptions` work.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95792

Files:
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2632,10 +2632,11 @@
 GenerateArg(Args, OPT_fdeclare_opencl_builtins, SA);
 }
 
-void CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
+bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
InputKind IK, const llvm::Triple &T,
std::vector &Includes,
DiagnosticsEngine &Diags) {
+  bool Success = true;
   // FIXME: Cleanup per-file based stuff.
   LangStandard::Kind LangStd = LangStandard::lang_unspecified;
   if (const Arg *A = Args.getLastArg(OPT_std_EQ)) {
@@ -2643,6 +2644,7 @@
 if (LangStd == LangStandard::lang_unspecified) {
   Diags.Report(diag::err_drv_invalid_value)
 << A->getAsString(Args) << A->getValue();
+  Success = false;
   // Report supported standards with short description.
   for (unsigned KindValue = 0;
KindValue != LangStandard::lang_unspecified;
@@ -2673,6 +2675,7 @@
   if (!IsInputCompatibleWithStandard(IK, Std)) {
 Diags.Report(diag::err_drv_argument_not_allowed_with)
   << A->getAsString(Args) << GetInputKindName(IK);
+Success = false;
   }
 }
   }
@@ -2694,6 +2697,7 @@
 if (OpenCLLangStd == LangStandard::lang_unspecified) {
   Diags.Report(diag::err_drv_invalid_value)
 << A->getAsString(Args) << A->getValue();
+  Success = false;
 }
 else
   LangStd = OpenCLLangStd;
@@ -2708,7 +2712,6 @@
   // The key paths of codegen options defined in Options.td start with
   // "LangOpts->". Let's provide the expected variable name and type.
   LangOptions *LangOpts = &Opts;
-  bool Success = true;
 
 #define LANG_OPTION_WITH_MARSHALLING(  \
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
@@ -2732,8 +2735,10 @@
   if (Opts.ObjC) {
 if (Arg *arg = Args.getLastArg(OPT_fobjc_runtime_EQ)) {
   StringRef value = arg->getValue();
-  if (Opts.ObjCRuntime.tryParse(value))
+  if (Opts.ObjCRuntime.tryParse(value)) {
 Diags.Report(diag::err_drv_unknown_objc_runtime) << value;
+Success = false;
+  }
 }
 
 if (Args.hasArg(OPT_fobjc_gc_only))
@@ -2742,8 +2747,10 @@
   Opts.setGC(LangOptions::HybridGC);
 else if (Args.hasArg(OPT_fobjc_arc)) {
   Opts.ObjCAutoRefCount = 1;
-  if (!Opts.ObjCRuntime.allowsARC())
+  if (!Opts.ObjCRuntime.allowsARC()) {
 Diags.Report(diag::err_arc_unsupported_on_runtime);
+Success = false;
+  }
 }
 
 // ObjCWeakRuntime tracks whether the runtime supports __weak, not
@@ -2762,8 +2769,10 @@
 assert(!Opts.ObjCWeak);
   } else if (Opts.getGC() != LangOptions::NonGC) {
 Diags.Report(diag::err_objc_weak_with_gc);
+Success = false;
   } else if (!Opts.ObjCWeakRuntime) {
 Diags.Report(diag::err_objc_weak_unsupported);
+Success = false;
   } else {
 Opts.ObjCWeak = 1;
   }
@@ -2787,6 +2796,7 @@
 if (Invalid || GNUCVer.getBuild() || Minor >= 100 || Patch >= 100) {
   Diags.Report(diag::err_drv_invalid_value)
   << A->getAsString(Args) << A->getValue();
+  Success = false;
 }
 Opts.GNUCVersion = Major * 100 * 100 + Minor * 100 + Patch;
   }
@@ -2803,9 +2813,11 @@
   Opts.MSCompatibilityVersion = 0;
   if (const Arg *A = Args.getLastArg(OPT_fms_compatibility_version)) {
 VersionTuple VT;
-if (VT.tryParse(A->getValue()))
+if (VT.tryParse(A->getValue())) {
   Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
 << A->getValue();
+  Success = false;
+}
 Opts.MSCompatibilityVersion = VT.getMajor() * 1000 +
   VT.getMinor().getValueOr(0) * 10 +
   VT.getSubminor().getValueOr(0);
@@ -2839,13 +2851,17 @@
 
   // -mrtd option
   if (Arg *A = Args.getLastArg(OPT_mrtd)) {
-if (Opts.getDefaultCallingConv() != LangOptions::DCC_None)
+if (Opts.getDefaultCallingConv() != LangOptions::DCC_None) {
   Diags.Report(diag::err_drv_argument_not_allowed_with

[PATCH] D95793: [clang][cli] Generate and round-trip language options

2021-02-01 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: dexonsmith, Bigcheese.
Herald added subscribers: dang, mgorny.
jansvoboda11 requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

This patch implements generation of remaining language options and tests it by 
performing parse-generate-parse round trip (on by default for assert builds, 
off otherwise).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95793

Files:
  clang/include/clang/Basic/Sanitizers.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Basic/Sanitizers.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Basic/CMakeLists.txt
  clang/unittests/Basic/SanitizersTest.cpp

Index: clang/unittests/Basic/SanitizersTest.cpp
===
--- /dev/null
+++ clang/unittests/Basic/SanitizersTest.cpp
@@ -0,0 +1,49 @@
+//===- unittests/Basic/SanitizersTest.cpp - Test Sanitizers ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Basic/Sanitizers.h"
+
+#include "gmock/gmock-matchers.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+
+using testing::Contains;
+using testing::Not;
+
+TEST(SanitizersTest, serializeSanitizers) {
+  SanitizerSet Set;
+  Set.set(parseSanitizerValue("memory", false), true);
+  Set.set(parseSanitizerValue("nullability-arg", false), true);
+
+  SmallVector Serialized;
+  serializeSanitizerSet(Set, Serialized);
+
+  ASSERT_EQ(Serialized.size(), 2u);
+  ASSERT_THAT(Serialized, Contains("memory"));
+  ASSERT_THAT(Serialized, Contains("nullability-arg"));
+}
+
+TEST(SanitizersTest, serializeSanitizersIndividual) {
+  SanitizerSet Set;
+  Set.set(parseSanitizerValue("memory", false), true);
+  Set.set(parseSanitizerValue("nullability-arg", false), true);
+  Set.set(parseSanitizerValue("nullability-assign", false), true);
+  Set.set(parseSanitizerValue("nullability-return", false), true);
+
+  SmallVector Serialized;
+  serializeSanitizerSet(Set, Serialized);
+
+  ASSERT_EQ(Serialized.size(), 4u);
+  ASSERT_THAT(Serialized, Contains("memory"));
+  ASSERT_THAT(Serialized, Contains("nullability-arg"));
+  ASSERT_THAT(Serialized, Contains("nullability-assign"));
+  ASSERT_THAT(Serialized, Contains("nullability-return"));
+  // Individual sanitizers don't get squashed into a single group.
+  ASSERT_THAT(Serialized, Not(Contains("nullability")));
+}
Index: clang/unittests/Basic/CMakeLists.txt
===
--- clang/unittests/Basic/CMakeLists.txt
+++ clang/unittests/Basic/CMakeLists.txt
@@ -8,6 +8,7 @@
   FileEntryTest.cpp
   FileManagerTest.cpp
   LineOffsetMappingTest.cpp
+  SanitizersTest.cpp
   SourceManagerTest.cpp
   )
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -214,6 +214,7 @@
 Args.push_back(SA(Value));
 break;
   case Option::JoinedClass:
+  case Option::CommaJoinedClass:
 Args.push_back(SA(Twine(Spelling) + Value));
 break;
   default:
@@ -1190,16 +1191,28 @@
   return Success;
 }
 
-static void parseSanitizerKinds(StringRef FlagName,
+static bool parseSanitizerKinds(StringRef FlagName,
 const std::vector &Sanitizers,
 DiagnosticsEngine &Diags, SanitizerSet &S) {
+  bool Success = true;
+
   for (const auto &Sanitizer : Sanitizers) {
 SanitizerMask K = parseSanitizerValue(Sanitizer, /*AllowGroups=*/false);
-if (K == SanitizerMask())
+if (K == SanitizerMask()) {
   Diags.Report(diag::err_drv_invalid_value) << FlagName << Sanitizer;
+  Success = false;
+}
 else
   S.set(K, true);
   }
+
+  return Success;
+}
+
+static SmallVector serializeSanitizerKinds(SanitizerSet S) {
+  SmallVector Values;
+  serializeSanitizerSet(S, Values);
+  return Values;
 }
 
 static void parseXRayInstrumentationBundle(StringRef FlagName, StringRef Bundle,
@@ -2623,19 +2636,211 @@
   llvm_unreachable("unknown input language");
 }
 
-static void GenerateLangArgs(const LangOptions &Opts,
- SmallVectorImpl &Args,
- CompilerInvocation::StringAllocator SA) {
+void CompilerInvocation::GenerateLangArgs(const LangOptions &Opts,
+  SmallVectorImpl &Args,
+  StringAllocator SA,
+  const llvm::Triple &T) {
+  auto LangStandard = LangS

[PATCH] D95616: [OpenCL] Change extension handling for -fdeclare-opencl-builtins

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

LGTM! Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95616

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


[PATCH] D94955: [clang-format] Treat ForEachMacros as loops

2021-02-01 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.
This revision is now accepted and ready to land.

LGTM. I let you coordinate with @Mydeveloperday concerning the tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94955

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


[PATCH] D93844: [clang-format] Add possibility to be based on parent directory

2021-02-01 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:160
+parent directory (or its parent if there is none). If there is no parent
+file found it falls back to the ``LLVM`` style.
+

Why should it fallback to LLVM and not the fallback style?
It seems to me that it's a documentation problem.



Comment at: clang/docs/ClangFormatStyleOptions.rst:160
+parent directory (or its parent if there is none). If there is no parent
+file fount it falls back to the ``LLVM`` style.
+

Typo: fount -> found.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93844

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


[PATCH] D95753: [CoverageMapping] Don't absolutize source paths

2021-02-01 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

For context, the reason abspaths are used here is because users don't expect 
coverage results to go missing if the build directory changes (e.g. given `cd 
A; cc x.c; cd ../B; cc x.c`, the expectation is that coverage for two distinct 
x.c's is reported).

I think it's important that this continues to work by default. Default-enabling 
the suggested `-fcoverage-mapping-abspath` option sounds like a workable 
solution. I haven't kept up with the work on -f(debug-)?compilation-dir, but if 
that option were specified, it could make sense to make coverage filenames 
"absolute" (relative to `chroot `).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95753

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


[PATCH] D94961: [OpenMP] Add OpenMP offloading toolchain for AMDGPU

2021-02-01 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

I believe this is 'safe', in the sense that it can't break anything other than 
AMDGPU's openmp implementation, which doesn't work yet anyway. The change to 
non-amd code is to OpenMPActionBuilder, and while parsing `-march=gfx` isn't 
pretty, it won't fire on nvptx. I'm not particularly confident it is correct, 
but it's hard to do comprehensive testing before there's an end to end spike. 
I'd like to iterate in tree, with an expectation that parts of this will need 
to change - @jdoerfert does the OpenMP patch look adequate for now?




Comment at: clang/lib/Driver/Driver.cpp:755
   TC = CudaTC.get();
+} else if (TT.isAMDGCN()) {
+  const ToolChain *HostTC =

This follows the same logic as nvptx so is likely to be correct


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94961

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


[PATCH] D95772: [DebugInfo] Normalize paths by removing unnecessary dots

2021-02-01 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a subscriber: rnk.
dblaikie added a comment.

Does this address @rnk's feedback about symlinks? ( 
https://reviews.llvm.org/D87657#2296028 )


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95772

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


[PATCH] D76802: [InstrProfiling] Use !associated metadata for counters, data and values

2021-02-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> The !associated metadata may be attached to a global object declaration with 
> a single argument that references another global object. This metadata 
> prevents discarding of the global object in linker GC unless the referenced 
> object is also discarded.

"prevents discarding" is not accurate in the context. `__llvm_prf_*` cannot be 
discarded because C identifier name input sections are GC roots.

Add "C identifier name input sections are GC roots. In LLD, the SHF_LINK_ORDER 
flag overrides the C identifier name semantics." in appropriate place.

> Furthermore, when a function symbol is discarded by the linker, setting up 
> !associated metadata allows linker to discard counters, data and values 
> associated with that function symbol. This is not possible today because 
> there's metadata to guide the linker. This approach is also used by other 
> instrumentations like sanitizers.

This C identifier name GC currently only works with LLD but does no harm to 
gold/GNU ld.

Do you think `__llvm_prf_*` can link to the text section so that the self-link 
trick is not needed? (https://sourceware.org/bugzilla/show_bug.cgi?id=27259)


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

https://reviews.llvm.org/D76802

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


[PATCH] D93095: Introduce -Wreserved-identifier

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



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:377
+  "%0 is a reserved identifier">,
+  InGroup, DefaultIgnore;
+

Quuxplusone wrote:
> If you leave it like this, you //will// receive multiple bug reports per year 
> about how in some contexts the compiler diagnoses `_X` and `_x` equally, and 
> in other contexts the compiler diagnoses `_X` but fails to diagnose `_x`.
> 
> You should make two diagnostics: `-Wreserved-extern-identifier` and 
> `-Wreserved-pp-identifier` (or something along those lines), and their 
> messages should be carefully worded to explain //why// the warning is 
> happening — "identifier %0 is reserved for use at file scope," "identifier %0 
> is reserved in all contexts," etc.
> 
> Btw, the reason some identifiers (like `_X`) are reserved in all contexts is 
> so that the implementation can define them as macros (e.g. header guards).
I think splitting the diagnostic into two groups could be useful, but I'd still 
like the groups to be under a common grouping so I can enable/disable all 
reserved identifier warnings at once.

As for adding the extra rationale to the diagnostic message: I think if we want 
to add extra wording, it should be more about how the user can fix the name and 
less about why the standard reserves something. e.g., `"identifier %0 is 
reserved because %select{it starts with '__'|it contains '__'|it is the same 
identifier as a keyword|etc}0"`. Knowing that something is reserved at file 
scope is somewhat helpful, but knowing how to change the name to appease the 
compiler is too.



Comment at: clang/lib/AST/Decl.cpp:1096
+// Walk up the lexical parents to determine if we're at TU level or not.
+const DeclContext * DC = getLexicalDeclContext();
+while(DC->isTransparentContext())

You may want to run the patch through clang-format.



Comment at: clang/lib/Sema/SemaDecl.cpp:5554
+  // Avoid warning twice on the same identifier, and don't warn on 
redeclaration
+  // of system decl
+  if (D->getPreviousDecl())





Comment at: clang/lib/Sema/SemaDeclCXX.cpp:10018
   if (DeclaratorDecl *DD = dyn_cast(D)) {
-for (unsigned i = 0; i < DD->getNumTemplateParameterLists(); ++i)
+for (unsigned i = 0; i < DD->getNumTemplateParameterLists(); ++i) {
   ParameterLists.push_back(DD->getTemplateParameterList(i));

Unrelated changes?



Comment at: clang/lib/Sema/SemaStmt.cpp:544
 
+  if (!Context.getSourceManager().isInSystemHeader(IdentLoc) &&
+  TheDecl->isReserved(getLangOpts()))

Can you not call `warnOnReservedIdentifier(TheDecl)` in this case?



Comment at: clang/test/Sema/reserved-identifier.c:49-50
+// FIXME: According to clang declaration context layering, _preserved belongs 
to
+// the translation unit, so we emit a warning. It's unclear that's what the
+// standard mandate, but it's such a corner case we can live with it.
+void func(struct _preserved { int a; } r) {} // expected-warning 
{{'_preserved' is a reserved identifier}}

I think we're correct to warn on this. Because the type specifier appears 
within the parameter list, it has function prototype scope per C2x 6.2.1p4. 
However, the identifier `_preserved` is put into the struct name space, which 
hits the "in the tag name spaces" part of: "All identifiers that begin with an 
underscore are reserved for use as identifiers with file scope in both the 
ordinary and tag name spaces".



Comment at: clang/test/Sema/reserved-identifier.c:53
+
+extern char *_strdup(const char *); // expected-warning {{'_strdup' is a 
reserved identifier}}
+

This is a case I don't think we should warn on. As some examples showing this 
sort of thing in the wild:

https://codesearch.isocpp.org/actcd19/main/m/mcrl2/mcrl2_201409.0-1/3rd-party/svc/source/lz.cpp
https://codesearch.isocpp.org/actcd19/main/m/mcrl2/mcrl2_201409.0-1/3rd-party/svc/source/svc1.cpp



Comment at: clang/test/Sema/reserved-identifier.c:9
+int _foo() { return 0; }// expected-warning {{'_foo' is a reserved 
identifier}}
+
+// This one is explicitly skipped by -Wreserved-identifier

serge-sans-paille wrote:
> Quuxplusone wrote:
> > aaron.ballman wrote:
> > > Can you add a test that we do not warn on an extern declaration? e.g.,
> > > ```
> > > extern char *_strdup(const char *);
> > > ```
> > > This is sometimes used (esp in older C code bases) to avoid having to 
> > > include an entire header to scrape one declaration out of it, and there 
> > > are popular libraries (like the MSVC CRT) that have APIs starting with a 
> > > single underscore and lowercase letter.
> > > 
> > > The idea here is: if it's an extern declaration, the identifier is 
> > > "owned" by some other declaration and this is not likely something the 

[PATCH] D92808: [ObjC][ARC] Use operand bundle 'clang.arc.rv' instead of explicitly emitting retainRV or claimRV calls in the IR

2021-02-01 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

Thanks for the update! The approach with operand bundles and the no-op uses 
looks cleaner than the original version. The special handling in the inliner 
seems a bit unfortunate, but I guess there's no way around that?

(as a side note, it might be easier to submit if this would be split up in the 
changes adding the bundle, followed by the ARC optimization & clang changes)




Comment at: llvm/include/llvm/Analysis/ObjCARCUtil.h:41
+static inline bool hasRVOpBundle(const CallBase *CB) {
+  return CB->getOperandBundle(LLVMContext::OB_clang_arc_rv).hasValue();
+}

I think we should include `LLVMContext.h` explicitly?



Comment at: llvm/include/llvm/IR/InstrTypes.h:1217
 
+  static CallBase *addOperandBundle(CallBase *CB, uint32_t ID,
+OperandBundleDef OB,

Please add documentation for the new functions.



Comment at: llvm/include/llvm/IR/Intrinsics.td:449
 [llvm_vararg_ty]>;
+def int_objc_clang_arc_noop_use : Intrinsic<[],
+[llvm_vararg_ty],

Can this be a `DefaultAttrIntrinsics` (which adds ` nofree nosync nounwind 
willreturn`)?

Same probably for all/most objc_* intrinsics.



Comment at: llvm/lib/Transforms/Utils/InlineFunction.cpp:1650
+static void
+insertRetainOrClaimRVCalls(CallBase &CB,
+   const SmallVectorImpl &Returns) {

Could you add a comment elaborating what this function does and why it is 
needed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92808

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


[PATCH] D95799: [analyzer] Symbolicate float values with integral casting

2021-02-01 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov created this revision.
ASDenysPetrov added reviewers: NoQ, xazax.hun, baloghadamsoftware, steakhal, 
vsavchenko.
ASDenysPetrov added a project: clang.
Herald added subscribers: martong, Charusso, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet.
ASDenysPetrov requested review of this revision.
Herald added a subscriber: cfe-commits.

Create nonloc::SymbolVal with SymbolCast expression from //integral// type to 
//float// type.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95799

Files:
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/Store.cpp
  clang/test/Analysis/svalbuilder-float-cast.c


Index: clang/test/Analysis/svalbuilder-float-cast.c
===
--- clang/test/Analysis/svalbuilder-float-cast.c
+++ clang/test/Analysis/svalbuilder-float-cast.c
@@ -4,17 +4,23 @@
 
 void SymbolCast_of_float_type_aux(int *p) {
   *p += 0;
-  // FIXME: Ideally, all unknown values should be symbolicated.
-  clang_analyzer_denote(*p, "$x"); // expected-warning{{Not a symbol}}
+  clang_analyzer_denote(*p, "$x");
 
   *p += 1;
-  // This should NOT be (float)$x + 1. Symbol $x was never casted to float.
-  // FIXME: Ideally, this should be $x + 1.
-  clang_analyzer_express(*p); // expected-warning{{Not a symbol}}
+  // expected-warning@+3{{(float)$x + 1}}
+  // expected-warning@+2{{(double)$x + 1}}
+  // expected-warning@+1{{(long double)$x + 1}}
+  clang_analyzer_express(*p);
 }
 
 void SymbolCast_of_float_type() {
-  extern float x;
+  extern float x1;
+  extern double x2;
+  extern long double x3;
+
   void (*f)() = SymbolCast_of_float_type_aux;
-  f(&x);
+
+  f(&x1);
+  f(&x2);
+  f(&x3);
 }
Index: clang/lib/StaticAnalyzer/Core/Store.cpp
===
--- clang/lib/StaticAnalyzer/Core/Store.cpp
+++ clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -409,14 +409,8 @@
 
   // The dispatchCast() call below would convert the int into a float.
   // What we want, however, is a bit-by-bit reinterpretation of the int
-  // as a float, which usually yields nothing garbage. For now skip casts
-  // from ints to floats.
+  // as a float, which usually yields nothing garbage.
   // TODO: What other combinations of types are affected?
-  if (castTy->isFloatingType()) {
-SymbolRef Sym = V.getAsSymbol();
-if (Sym && !Sym->getType()->isFloatingType())
-  return UnknownVal();
-  }
 
   // When retrieving symbolic pointer and expecting a non-void pointer,
   // wrap them into element regions of the expected type if necessary.
Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -501,8 +501,9 @@
   if (getContext().getTypeSize(castTy) >= getContext().getTypeSize(originalTy))
 return evalCast(val, castTy, originalTy);
 
+  // Let evalCast handle non symbolic expressions.
   SymbolRef se = val.getAsSymbol();
-  if (!se) // Let evalCast handle non symbolic expressions.
+  if (!se || se->getType()->isFloatingType())
 return evalCast(val, castTy, originalTy);
 
   // Find the maximum value of the target type.


Index: clang/test/Analysis/svalbuilder-float-cast.c
===
--- clang/test/Analysis/svalbuilder-float-cast.c
+++ clang/test/Analysis/svalbuilder-float-cast.c
@@ -4,17 +4,23 @@
 
 void SymbolCast_of_float_type_aux(int *p) {
   *p += 0;
-  // FIXME: Ideally, all unknown values should be symbolicated.
-  clang_analyzer_denote(*p, "$x"); // expected-warning{{Not a symbol}}
+  clang_analyzer_denote(*p, "$x");
 
   *p += 1;
-  // This should NOT be (float)$x + 1. Symbol $x was never casted to float.
-  // FIXME: Ideally, this should be $x + 1.
-  clang_analyzer_express(*p); // expected-warning{{Not a symbol}}
+  // expected-warning@+3{{(float)$x + 1}}
+  // expected-warning@+2{{(double)$x + 1}}
+  // expected-warning@+1{{(long double)$x + 1}}
+  clang_analyzer_express(*p);
 }
 
 void SymbolCast_of_float_type() {
-  extern float x;
+  extern float x1;
+  extern double x2;
+  extern long double x3;
+
   void (*f)() = SymbolCast_of_float_type_aux;
-  f(&x);
+
+  f(&x1);
+  f(&x2);
+  f(&x3);
 }
Index: clang/lib/StaticAnalyzer/Core/Store.cpp
===
--- clang/lib/StaticAnalyzer/Core/Store.cpp
+++ clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -409,14 +409,8 @@
 
   // The dispatchCast() call below would convert the int into a float.
   // What we want, however, is a bit-by-bit reinterpretation of the int
-  // as a float, which usually yields nothing garbage. For now skip casts
-  // from ints to floats.
+  // as a float, which usually yields nothing garbage.
   // TODO: What other combinations of types are affected?
-  if (castTy->isFloatingType()) {
-

[PATCH] D94627: [PowerPC][PC Rel] Implement option to omit P10 instructions from stubs

2021-02-01 Thread Stefan Pintilie via Phabricator via cfe-commits
stefanp added a comment.

There is one more thing that does not look quite right. It may be an encoding 
problem for one of the instructions. I found it in the test but you will have 
to trace it back to the place where it is generated in order to fix it.




Comment at: lld/ELF/Driver.cpp:770
+
+  StringRef SelectedOpt = args.getLastArgValue(OPT_power10_stubs_eq);
+

MaskRay wrote:
> `value`
You may even be able to inline this since it is only used in one place that I 
can see.



Comment at: lld/ELF/Options.td:450
+def power10_stubs_eq:
+  J<"power10-stubs=">, HelpText<"Enables Power10 instsructions in all stubs 
without options, "
+ "options override previous flags."

nit:
Is this line too long? Or does it just appear too long in my browser. If the 
length is ok ignore my comment. 



Comment at: lld/ELF/Thunks.cpp:930
+uint64_t addi = ADDI_R12_TO_R12_NO_DISP | (tocOffset & 0x);
+const uint64_t addis = ADDIS_R12_TO_R2_NO_DISP | ((tocOffset >> 16) & 
0x);
+write32(buf + 4, addis); // addis r12, r2 , top of offset

nit:
You can mark both as const.
Also below in this same function.



Comment at: lld/test/ELF/ppc64-pcrel-call-to-toc.s:55
+# CHECK-NOP10-NEXT:  mtlr 12
+# CHECK-NOP10-NEXT:  addis 12, 12, -1
+# CHECK-NOP10-NEXT:  addi 12, 12, -24

This is not correct.
You should be adding to `r11` and not `r12` here.
ie.
```
addis 12, 11, -1
```
The encoding above may not be correct.


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

https://reviews.llvm.org/D94627

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


[PATCH] D95673: [dllimport] Honor always_inline when deciding whether a dllimport function should be available for inlining (PR48925)

2021-02-01 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95673

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


[PATCH] D95660: [NFC] Disallow unused prefixes under clang/test/Driver

2021-02-01 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

LGTM for CUDA.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95660

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


[PATCH] D95740: [ASTMatchers] Ignore parts of BindingDecls which are not spelled in source

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



Comment at: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:2607
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }

Can you help me to better understand the proposed change? I find this to be 
surprising behavior -- the thing the user wrote in the source are the binding 
declarations, the hidden thing they didn't write in the source was the 
decomposition declaration. e.g., the user introduced some names `f`, `s`, and 
`t` in the declaration so I would imagine that these *are* spelled in source. 
What I don't think is necessarily spelled in source is the decomposition 
declaration for the `int[3]` to bind to. So I was expecting this to be 
`EXPECT_TRUE` instead of `EXPECT_FALSE`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95740

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


[clang] c4d6f27 - [NFC] Disallow unused prefixes under clang/test/Driver

2021-02-01 Thread Mircea Trofin via cfe-commits

Author: Mircea Trofin
Date: 2021-02-01T10:34:38-08:00
New Revision: c4d6f2707a1e6c4e9bd93480dd913121fef122b7

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

LOG: [NFC] Disallow unused prefixes under clang/test/Driver

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

Added: 


Modified: 
clang/test/Driver/amdgpu-macros.cl
clang/test/Driver/cuda-detect.cu
clang/test/Driver/fsanitize.c
clang/test/Driver/lit.local.cfg
clang/test/Driver/ps4-visibility-dllstorageclass.c
clang/test/Driver/rocm-device-libs.cl

Removed: 




diff  --git a/clang/test/Driver/amdgpu-macros.cl 
b/clang/test/Driver/amdgpu-macros.cl
index e5611446eace..d708e29e1acf 100644
--- a/clang/test/Driver/amdgpu-macros.cl
+++ b/clang/test/Driver/amdgpu-macros.cl
@@ -67,52 +67,52 @@
 // AMDGCN-based processors.
 //
 
-// RUN: %clang -E -dM -target amdgcn -mcpu=gfx600 %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX600,FAST_FMAF %s -DWAVEFRONT_SIZE=64 -DCPU=gfx600
-// RUN: %clang -E -dM -target amdgcn -mcpu=tahiti %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX600,FAST_FMAF %s -DWAVEFRONT_SIZE=64 -DCPU=gfx600
-// RUN: %clang -E -dM -target amdgcn -mcpu=gfx601 %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX601,SLOW_FMAF %s -DWAVEFRONT_SIZE=64 -DCPU=gfx601
-// RUN: %clang -E -dM -target amdgcn -mcpu=pitcairn %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX601,SLOW_FMA %s -DWAVEFRONT_SIZE=64 -DCPU=gfx601
-// RUN: %clang -E -dM -target amdgcn -mcpu=verde %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX601,SLOW_FMA %s -DWAVEFRONT_SIZE=64 -DCPU=gfx601
-// RUN: %clang -E -dM -target amdgcn -mcpu=gfx602 %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX602,SLOW_FMA %s -DWAVEFRONT_SIZE=64 -DCPU=gfx602
-// RUN: %clang -E -dM -target amdgcn -mcpu=hainan %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX602,SLOW_FMA %s -DWAVEFRONT_SIZE=64 -DCPU=gfx602
-// RUN: %clang -E -dM -target amdgcn -mcpu=oland %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX602,SLOW_FMA %s -DWAVEFRONT_SIZE=64 -DCPU=gfx602
-// RUN: %clang -E -dM -target amdgcn -mcpu=gfx700 %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX700,SLOW_FMA %s -DWAVEFRONT_SIZE=64 -DCPU=gfx700
-// RUN: %clang -E -dM -target amdgcn -mcpu=kaveri %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX700,SLOW_FMA %s -DWAVEFRONT_SIZE=64 -DCPU=gfx700
-// RUN: %clang -E -dM -target amdgcn -mcpu=gfx701 %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX701,FAST_FMAF %s -DWAVEFRONT_SIZE=64 -DCPU=gfx701
-// RUN: %clang -E -dM -target amdgcn -mcpu=hawaii %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX701,FAST_FMAF %s -DWAVEFRONT_SIZE=64 -DCPU=gfx701
-// RUN: %clang -E -dM -target amdgcn -mcpu=gfx702 %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX702,FAST_FMAF %s -DWAVEFRONT_SIZE=64 -DCPU=gfx702
-// RUN: %clang -E -dM -target amdgcn -mcpu=gfx703 %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX703,SLOW_FMA %s -DWAVEFRONT_SIZE=64 -DCPU=gfx703
-// RUN: %clang -E -dM -target amdgcn -mcpu=kabini %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX703,SLOW_FMA %s -DWAVEFRONT_SIZE=64 -DCPU=gfx703
-// RUN: %clang -E -dM -target amdgcn -mcpu=mullins %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX703,SLOW_FMA %s -DWAVEFRONT_SIZE=64 -DCPU=gfx703
-// RUN: %clang -E -dM -target amdgcn -mcpu=gfx704 %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX704,SLOW_FMA %s -DWAVEFRONT_SIZE=64 -DCPU=gfx704
-// RUN: %clang -E -dM -target amdgcn -mcpu=bonaire %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX704,SLOW_FMA %s -DWAVEFRONT_SIZE=64 -DCPU=gfx704
-// RUN: %clang -E -dM -target amdgcn -mcpu=gfx705 %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX705,SLOW_FMA %s -DWAVEFRONT_SIZE=64 -DCPU=gfx705
-// RUN: %clang -E -dM -target amdgcn -mcpu=gfx801 %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX801,FAST_FMAF %s -DWAVEFRONT_SIZE=64 -DCPU=gfx801
-// RUN: %clang -E -dM -target amdgcn -mcpu=carrizo %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX801,FAST_FMAF %s -DWAVEFRONT_SIZE=64 -DCPU=gfx801
-// RUN: %clang -E -dM -target amdgcn -mcpu=gfx802 %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX802,SLOW_FMA %s -DWAVEFRONT_SIZE=64 -DCPU=gfx802
-// RUN: %clang -E -dM -target amdgcn -mcpu=iceland %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX802,SLOW_FMA %s -DWAVEFRONT_SIZE=64 -DCPU=gfx802
-// RUN: %clang -E -dM -target amdgcn -mcpu=tonga %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX802,SLOW_FMA %s -DWAVEFRONT_SIZE=64 -DCPU=gfx802
-// RUN: %clang -E -dM -target amdgcn -mcpu=gfx803 %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX803,SLOW_FMA %s -DWAVEFRONT_SIZE=64 -DCPU=gfx803
-// RUN: %clang -E -dM -target amdgcn -mcpu=fiji %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX803,SLOW_FMA %s -DWAVEFRONT_SIZE=64 -DCPU=gfx803
-// RUN: %clang -E -dM -target amdgcn -mcp

[PATCH] D95660: [NFC] Disallow unused prefixes under clang/test/Driver

2021-02-01 Thread Mircea Trofin via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc4d6f2707a1e: [NFC] Disallow unused prefixes under 
clang/test/Driver (authored by mtrofin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95660

Files:
  clang/test/Driver/amdgpu-macros.cl
  clang/test/Driver/cuda-detect.cu
  clang/test/Driver/fsanitize.c
  clang/test/Driver/lit.local.cfg
  clang/test/Driver/ps4-visibility-dllstorageclass.c
  clang/test/Driver/rocm-device-libs.cl

Index: clang/test/Driver/rocm-device-libs.cl
===
--- clang/test/Driver/rocm-device-libs.cl
+++ clang/test/Driver/rocm-device-libs.cl
@@ -78,46 +78,46 @@
 // RUN:   -x cl -mcpu=gfx803 \
 // RUN:   -cl-unsafe-math-optimizations \
 // RUN:   --rocm-path=%S/Inputs/rocm \
-// RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMON,COMMON-UNSAFE,GFX803,WAVE64 %s
+// RUN:   %s 2>&1 | \
+// RUN:   FileCheck  --check-prefixes=COMMON,GFX803,WAVE64 %s
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa\
 // RUN:   -x cl -mcpu=gfx1010\
 // RUN:   --rocm-path=%S/Inputs/rocm \
-// RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMMON,GFX1010,WAVE32 %s
+// RUN:   %s 2>&1 | \
+// RUN:   FileCheck  --check-prefix=WAVE32 %s
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa\
 // RUN:   -x cl -mcpu=gfx1011\
 // RUN:   --rocm-path=%S/Inputs/rocm \
-// RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMMON,GFX1011,WAVE32 %s
+// RUN:   %s 2>&1 | \
+// RUN:   FileCheck  --check-prefix=WAVE32 %s
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa\
 // RUN:   -x cl -mcpu=gfx1012\
 // RUN:   --rocm-path=%S/Inputs/rocm \
-// RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMMON,GFX1012,WAVE32 %s
+// RUN:   %s 2>&1 | \
+// RUN:   FileCheck  --check-prefix=WAVE32 %s
 
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa\
 // RUN:   -x cl -mcpu=gfx1010 -mwavefrontsize64  \
 // RUN:   --rocm-path=%S/Inputs/rocm \
-// RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMMON,GFX1010,WAVE64 %s
+// RUN:   %s 2>&1 | \
+// RUN:   FileCheck  --check-prefix=WAVE64 %s
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa\
 // RUN:   -x cl -mcpu=gfx1010 -mwavefrontsize64 -mno-wavefrontsize64  \
 // RUN:   --rocm-path=%S/Inputs/rocm \
-// RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMMON,GFX1010,WAVE32 %s
+// RUN:   %s 2>&1 | \
+// RUN:   FileCheck  --check-prefix=WAVE32 %s
 
 // Ignore -mno-wavefrontsize64 without wave32 support
 // RUN: %clang -### -target amdgcn-amd-amdhsa   \
 // RUN:   -x cl -mcpu=gfx803  -mno-wavefrontsize64  \
 // RUN:   --rocm-path=%S/Inputs/rocm\
-// RUN:   %s \
-// RUN: 2>&1 | FileCheck  --check-prefixes=COMMMON,GFX803,WAVE64 %s
+// RUN:   %s 2>&1 | \
+// RUN:   FileCheck  --check-prefixes=GFX803,WAVE64 %s
 
 
 
Index: clang/test/Driver/ps4-visibility-dllstorageclass.c
===
--- clang/test/Driver/ps4-visibility-dllstorageclass.c
+++ clang/test/Driver/ps4-visibility-dllstorageclass.c
@@ -1,7 +1,7 @@
 // Check behaviour of -fvisibility-from-dllstorageclass options for PS4
 
 // RUN: %clang -### -target x86_64-scei-ps4 %s -Werror -o - 2>&1 | \
-// RUN:   FileCheck %s -check-prefixes=DEFAULTS,DEFAULTS1 \
+// RUN:   FileCheck %s --check-prefix=DEFAULTS \
 // RUN: --implicit-check-not=-fvisibility-from-dllstorageclass \
 // RUN: --implicit-check-not=-fvisibility-dllexport \
 // RUN: --implicit-check-not=-fvisibility-nodllstorageclass \
@@ -13,7 +13,7 @@
 // RUN: -fvisibility-from-dllstorageclass \
 // RUN: -Werror \
 // RUN: %s -o - 2>&1 | \
-// RUN:   FileCheck %s -check-prefixes=DEFAULTS,DEFAULTS2 \
+// RUN:   FileCheck %s --check-prefix=DEFAULTS \
 // RUN: --implicit-check-not=-fvisibility-from-dllstorageclass \
 // RUN: --implicit-check-not=-fvisibility-dllexport \
 // RUN: --implicit-check-not=-fvisibility-nodllstorageclass \
Index: clang/test/Driver/lit.local.cfg
===
--- clang/test/Driver/lit.local.cfg
+++ clang/test/Driver/lit.local.cfg
@@ -1,3 +1,11 @@
+from lit.llvm.subst import ToolSubst
+
+fc = ToolSubst('FileCheck', unresolved='fatal')
+# Insert this first. Then, we'll first update the blank FileCheck command; then,
+# the default substitution of FileCheck will replace it to its full path.
+config.substitutions.insert(0, (fc.regex,
+'FileCheck --allow-unused-prefixes=false'))
+
 config.suffixes = ['.c', '.cpp', '.h', '.m', '.mm', '.S', '.s', '.f90', '.F90', '.f95',
'.cu', '.rs', '.cl', '.hip']
 config.substitutions = list(config.substi

[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2021-02-01 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D89909#2496269 , @bader wrote:

> In D89909#2448443 , @Anastasia wrote:
>
>> If you prefer to continue this route then you should just document your 
>> dialect sematic somewhere publicly accessible and avoid aliasing to OpenCL, 
>> or target address spaces. So it would become a proper language dialect 
>> implementation.
>
> I've added a section to our internal design document about address space 
> handling in SYCL mode: pull request  
> (more readable version 
> ).
>  Please, take a look and let me know if it can be improved.

The documentation looks like a good starting point but it would be better to 
add it to clang docs, then we can also refine the details during the review. 
For now I can tell that the following points are too high-level and unclear:

> To utilize existing clang's functionality, we re-use following OpenCL address 
> space attributes in SYCL mode with modified semantic rules and unmodified 
> parser and IR generation components.

You should provide more details on the difference to OpenCL address spaces - in 
particular looking at your patch I don't think this statement is correct 
"unmodified <...> IR generation components."

> SYCL mode allows conversion from annotated pointer to unannotated pointer to 
> enable integration of accelerated code with standard C++ code.

I don't understand what integration you mean. Also C++ has many different kinds 
of conversions, which conversions do you mean exactly?

Otherwise, the overall design of address spaces seems a lot more clear now.

Regarding `SYCLDevice` and `SYCLAddrSpaceMap` I am still not very convinced 
about the flow. Have you had any design discussion regarding this already that 
you could point to?

My main concern is that I am not sure it fits with the main design of Clang - 
producing IR that is to be consumed by multiple targets rather than only one 
specific target or even an external tool. Why do you add a triple component 
that is used only for one target SPIR:

1. How would existing toolchains that consume LLVM-IR for SPIR cope with the 
fact that the `Default` address space is different for C++ and SYCL.
2. Why is changing of `the address space map necessary for SPIR but not the 
other targets?

I also think it would be good if @rjmccall could look at the Codegen changes.




Comment at: clang/include/clang/AST/Type.h:499
+other.getAddressSpace()) ||
+   (!hasAddressSpace() &&
+(other.getAddressSpace() == LangAS::sycl_private ||

This should be done in the method above.



Comment at: clang/include/clang/Sema/ParsedAttr.h:624
 
+  // TBD: SYCL-specific ParsedAttr?
+  /// If this is an OpenCL address space attribute returns its SYCL

Do you still plan to resolve this?



Comment at: clang/lib/Basic/Targets/SPIR.h:71
 LongWidth = LongAlign = 64;
-AddrSpaceMap = &SPIRAddrSpaceMap;
+if (Triple.getEnvironment() == llvm::Triple::SYCLDevice) {
+  AddrSpaceMap = &SYCLAddrSpaceMap;

bader wrote:
> Anastasia wrote:
> > bader wrote:
> > > Anastasia wrote:
> > > > This deserves clarification - address space map reflect the physical 
> > > > address space of the target - how will upstream users get to physical 
> > > > address spaces of targets for SYCL?
> > > The same way. The only difference for SYCL is that "Default" language 
> > > address space is mapped to "4" LLVM AS, which is equivalent to 
> > > "opencl_generic" language address space.
> > If you are aiming at following the Embedded C semantic then this change is 
> > not legitimate. In Embedded C generic address space corresponds to no 
> > address space:
> > 
> > > When not specified otherwise, objects are allocated by default in a 
> > > generic address space, which corresponds to the single address space of 
> > > ISO/IEC 9899:1999
> > 
> > I.e. in LLVM project default address space is a flat address space of 
> > C/C++. You should either inherit it as is or use a different entry in the 
> > map... As a matter of fact, OpenCL generic address space is not the same as 
> > the generic address space of C and C++. It is only used for the pointers.
> According to my understanding Embedded C semantics is applicable to LLVM 
> address spaces and their mapping to SPIR(-V). SPIR-V translator treats "no 
> address space" as private, rather than generic.
I am talking about the llvm-project btw. You can't just customize it to any 
arbitrary GitHub project as there has to be some core design flow to be 
respected.


Repository:
  rG LLVM Github Monorepo

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

https://revi

[PATCH] D95482: [PATCH] [clang] Fix bug 48848 by removing assertion related to recoverFromMSUnqualifiedLookup

2021-02-01 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

In the absence of a response, let's land this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95482

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


[PATCH] D95558: [NFC][CUDA] Refactor registering device variable

2021-02-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 4 inline comments as done.
yaxunl added inline comments.



Comment at: clang/lib/CodeGen/CGCUDANV.cpp:157
   llvm::Function *makeModuleDtorFunction() override;
+  void
+  adjustShadowVarLinkage(const VarDecl *D,

tra wrote:
> clang-format it? `void` hanging all by itself looks odd.
Although it looks strange, it is a result of clang-format.



Comment at: clang/lib/CodeGen/CGCUDANV.cpp:924
+
+void CGNVCUDARuntime::adjustShadowVarLinkage(
+const VarDecl *D, llvm::GlobalValue::LinkageTypes &Linkage) {

tra wrote:
> The name and the functionality do not match -- despite what the name says, 
> the function will set internal linkage on any var with device-side attributes.
> 
> Rename to `internalizeDeviceSideVars` ?
done



Comment at: clang/lib/CodeGen/CGCUDARuntime.h:86
+  /// Check whether a variable is a device variable and register it if true.
+  virtual void mayRegisterDeviceVar(const VarDecl *VD,
+llvm::GlobalVariable &Var) = 0;

tra wrote:
> `handleVarRegistration` to make it distinct from the implementation of 
> specific registration kinds.
> 
> Maybe, move `registerDevice*` functions under `private:` as they will only be 
> used from the top-level handler called by CGM.
done



Comment at: clang/lib/CodeGen/CGCUDARuntime.h:89
+  /// Register regular device variable (not surface or texture).
+  virtual void registerDeviceVarRegular(const VarDecl *VD,
+llvm::GlobalVariable &Var, bool Extern,

tra wrote:
> Just `registerDeviceVar` would do.
done


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

https://reviews.llvm.org/D95558

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


[PATCH] D95558: [NFC][CUDA] Refactor registering device variable

2021-02-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 320526.
yaxunl marked 4 inline comments as done.
yaxunl added a comment.

Revised by Artem's comments


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

https://reviews.llvm.org/D95558

Files:
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CGCUDARuntime.h
  clang/lib/CodeGen/CodeGenModule.cpp

Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4267,59 +4267,8 @@
   (D->hasAttr() || D->hasAttr()))
 GV->setExternallyInitialized(true);
 } else {
-  // Host-side shadows of external declarations of device-side
-  // global variables become internal definitions. These have to
-  // be internal in order to prevent name conflicts with global
-  // host variables with the same name in a different TUs.
-  if (D->hasAttr() || D->hasAttr()) {
-Linkage = llvm::GlobalValue::InternalLinkage;
-// Shadow variables and their properties must be registered with CUDA
-// runtime. Skip Extern global variables, which will be registered in
-// the TU where they are defined.
-//
-// Don't register a C++17 inline variable. The local symbol can be
-// discarded and referencing a discarded local symbol from outside the
-// comdat (__cuda_register_globals) is disallowed by the ELF spec.
-// TODO: Reject __device__ constexpr and __device__ inline in Sema.
-if (!D->hasExternalStorage() && !D->isInline())
-  getCUDARuntime().registerDeviceVar(D, *GV, !D->hasDefinition(),
- D->hasAttr());
-  } else if (D->hasAttr()) {
-// __shared__ variables are odd. Shadows do get created, but
-// they are not registered with the CUDA runtime, so they
-// can't really be used to access their device-side
-// counterparts. It's not clear yet whether it's nvcc's bug or
-// a feature, but we've got to do the same for compatibility.
-Linkage = llvm::GlobalValue::InternalLinkage;
-  } else if (D->getType()->isCUDADeviceBuiltinSurfaceType() ||
- D->getType()->isCUDADeviceBuiltinTextureType()) {
-// Builtin surfaces and textures and their template arguments are
-// also registered with CUDA runtime.
-Linkage = llvm::GlobalValue::InternalLinkage;
-const ClassTemplateSpecializationDecl *TD =
-cast(
-D->getType()->getAs()->getDecl());
-const TemplateArgumentList &Args = TD->getTemplateArgs();
-if (TD->hasAttr()) {
-  assert(Args.size() == 2 &&
- "Unexpected number of template arguments of CUDA device "
- "builtin surface type.");
-  auto SurfType = Args[1].getAsIntegral();
-  if (!D->hasExternalStorage())
-getCUDARuntime().registerDeviceSurf(D, *GV, !D->hasDefinition(),
-SurfType.getSExtValue());
-} else {
-  assert(Args.size() == 3 &&
- "Unexpected number of template arguments of CUDA device "
- "builtin texture type.");
-  auto TexType = Args[1].getAsIntegral();
-  auto Normalized = Args[2].getAsIntegral();
-  if (!D->hasExternalStorage())
-getCUDARuntime().registerDeviceTex(D, *GV, !D->hasDefinition(),
-   TexType.getSExtValue(),
-   Normalized.getZExtValue());
-}
-  }
+  getCUDARuntime().internalizeDeviceSideVars(D, Linkage);
+  getCUDARuntime().handleVarRegistration(D, *GV);
 }
   }
 
Index: clang/lib/CodeGen/CGCUDARuntime.h
===
--- clang/lib/CodeGen/CGCUDARuntime.h
+++ clang/lib/CodeGen/CGCUDARuntime.h
@@ -16,6 +16,7 @@
 #define LLVM_CLANG_LIB_CODEGEN_CGCUDARUNTIME_H
 
 #include "llvm/ADT/StringRef.h"
+#include "llvm/IR/GlobalValue.h"
 
 namespace llvm {
 class Function;
@@ -80,12 +81,10 @@
 
   /// Emits a kernel launch stub.
   virtual void emitDeviceStub(CodeGenFunction &CGF, FunctionArgList &Args) = 0;
-  virtual void registerDeviceVar(const VarDecl *VD, llvm::GlobalVariable &Var,
- bool Extern, bool Constant) = 0;
-  virtual void registerDeviceSurf(const VarDecl *VD, llvm::GlobalVariable &Var,
-  bool Extern, int Type) = 0;
-  virtual void registerDeviceTex(const VarDecl *VD, llvm::GlobalVariable &Var,
- bool Extern, int Type, bool Normalized) = 0;
+
+  /// Check whether a variable is a device variable and register it if true.
+  virtual void handleVarRegistration(const VarDecl *VD,
+ llvm::GlobalVariable &Var) = 0;
 
   /// Constructs and r

[clang] 08d46d5 - [clang][PATCH] Fix bug 48848 assertion related to recoverFromMSUnqualifiedLookup

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

Author: Melanie Blower
Date: 2021-02-01T10:56:47-08:00
New Revision: 08d46d50599a7005380e1a9eebb276ceb2b0ad93

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

LOG: [clang][PATCH] Fix bug 48848 assertion related to 
recoverFromMSUnqualifiedLookup

Reviewed By: rnk

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

Added: 


Modified: 
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaCXX/lambda-expressions.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index d91db60f17a0..a708ccd58dd4 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -1176,15 +1176,11 @@ QualType Sema::getCurrentThisType() {
   }
 
   if (ThisTy.isNull() && isLambdaCallOperator(CurContext) &&
-  inTemplateInstantiation()) {
-
-assert(isa(DC) &&
-   "Trying to get 'this' type from static method?");
+  inTemplateInstantiation() && isa(DC)) {
 
 // This is a lambda call operator that is being instantiated as a default
 // initializer. DC must point to the enclosing class type, so we can 
recover
 // the 'this' type from it.
-
 QualType ClassTy = Context.getTypeDeclType(cast(DC));
 // There are no cv-qualifiers for 'this' within default initializers,
 // per [expr.prim.general]p4.

diff  --git a/clang/test/SemaCXX/lambda-expressions.cpp 
b/clang/test/SemaCXX/lambda-expressions.cpp
index 22e0939379f5..03bf13733d7b 100644
--- a/clang/test/SemaCXX/lambda-expressions.cpp
+++ b/clang/test/SemaCXX/lambda-expressions.cpp
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify 
-verify=expected-cxx14 -fblocks %s
 // RUN: %clang_cc1 -std=c++17 -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
+// RUN: %clang_cc1 -std=c++17 -fblocks -DSHOW_MS -Wno-unused-value 
-fms-compatibility -fdelayed-template-parsing -fsyntax-only -verify %s
 
+#ifndef SHOW_MS
 namespace std { class type_info; };
 
 namespace ExplicitCapture {
@@ -664,3 +666,22 @@ void Test() {
 
 }
 };
+
+#else
+template 
+void Decider(const RT &sp, ET &ep) {
+  [=](auto i) { ep[i] = sp[i + j]; };
+// expected-error@-1 {{use of undeclared identifier 'j'}}
+}
+
+template  void LS() {
+  int *ep;
+  Decider(5, ep);
+}
+
+void runChapter4()
+{
+  LS(); // expected-note {{in instantiation of}}
+}
+
+#endif



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


[PATCH] D95482: [PATCH] [clang] Fix bug 48848 by removing assertion related to recoverFromMSUnqualifiedLookup

2021-02-01 Thread Melanie Blower via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG08d46d50599a: [clang][PATCH] Fix bug 48848 assertion related 
to recoverFromMSUnqualifiedLookup (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95482

Files:
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/lambda-expressions.cpp


Index: clang/test/SemaCXX/lambda-expressions.cpp
===
--- clang/test/SemaCXX/lambda-expressions.cpp
+++ clang/test/SemaCXX/lambda-expressions.cpp
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify 
-verify=expected-cxx14 -fblocks %s
 // RUN: %clang_cc1 -std=c++17 -Wno-unused-value -fsyntax-only -verify -fblocks 
%s
+// RUN: %clang_cc1 -std=c++17 -fblocks -DSHOW_MS -Wno-unused-value 
-fms-compatibility -fdelayed-template-parsing -fsyntax-only -verify %s
 
+#ifndef SHOW_MS
 namespace std { class type_info; };
 
 namespace ExplicitCapture {
@@ -664,3 +666,22 @@
 
 }
 };
+
+#else
+template 
+void Decider(const RT &sp, ET &ep) {
+  [=](auto i) { ep[i] = sp[i + j]; };
+// expected-error@-1 {{use of undeclared identifier 'j'}}
+}
+
+template  void LS() {
+  int *ep;
+  Decider(5, ep);
+}
+
+void runChapter4()
+{
+  LS(); // expected-note {{in instantiation of}}
+}
+
+#endif
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -1176,15 +1176,11 @@
   }
 
   if (ThisTy.isNull() && isLambdaCallOperator(CurContext) &&
-  inTemplateInstantiation()) {
-
-assert(isa(DC) &&
-   "Trying to get 'this' type from static method?");
+  inTemplateInstantiation() && isa(DC)) {
 
 // This is a lambda call operator that is being instantiated as a default
 // initializer. DC must point to the enclosing class type, so we can 
recover
 // the 'this' type from it.
-
 QualType ClassTy = Context.getTypeDeclType(cast(DC));
 // There are no cv-qualifiers for 'this' within default initializers,
 // per [expr.prim.general]p4.


Index: clang/test/SemaCXX/lambda-expressions.cpp
===
--- clang/test/SemaCXX/lambda-expressions.cpp
+++ clang/test/SemaCXX/lambda-expressions.cpp
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify -verify=expected-cxx14 -fblocks %s
 // RUN: %clang_cc1 -std=c++17 -Wno-unused-value -fsyntax-only -verify -fblocks %s
+// RUN: %clang_cc1 -std=c++17 -fblocks -DSHOW_MS -Wno-unused-value -fms-compatibility -fdelayed-template-parsing -fsyntax-only -verify %s
 
+#ifndef SHOW_MS
 namespace std { class type_info; };
 
 namespace ExplicitCapture {
@@ -664,3 +666,22 @@
 
 }
 };
+
+#else
+template 
+void Decider(const RT &sp, ET &ep) {
+  [=](auto i) { ep[i] = sp[i + j]; };
+// expected-error@-1 {{use of undeclared identifier 'j'}}
+}
+
+template  void LS() {
+  int *ep;
+  Decider(5, ep);
+}
+
+void runChapter4()
+{
+  LS(); // expected-note {{in instantiation of}}
+}
+
+#endif
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -1176,15 +1176,11 @@
   }
 
   if (ThisTy.isNull() && isLambdaCallOperator(CurContext) &&
-  inTemplateInstantiation()) {
-
-assert(isa(DC) &&
-   "Trying to get 'this' type from static method?");
+  inTemplateInstantiation() && isa(DC)) {
 
 // This is a lambda call operator that is being instantiated as a default
 // initializer. DC must point to the enclosing class type, so we can recover
 // the 'this' type from it.
-
 QualType ClassTy = Context.getTypeDeclType(cast(DC));
 // There are no cv-qualifiers for 'this' within default initializers,
 // per [expr.prim.general]p4.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95523: [OpenCL] Add cl_khr_subgroup_ballot to TableGen BIFs

2021-02-01 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl:35
+// Enable extensions that are enabled in opencl-c-base.h.
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#define cl_khr_subgroup_ballot 1

Not related to this patch - I think we should have included `opencl-c-base.h` 
by default when passing `-fdeclare-opencl-builtins` or do you see any issues 
with that?





Comment at: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl:141
+kernel void extended_subgroup(global uint4 *out) {
+  out[0] = get_sub_group_eq_mask();
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0 && !defined(__OPENCL_CPP_VERSION__)

I appreciate we haven't addressed the standard header testing holistically yet 
and this functionality was added in `opencl-c.h` without testing the functions, 
but would it be better to test each function at least here?

Even though the final goal should be testing all overloads, this is outside of 
the scope of this work that is closing the gap between `opencl-c.h` and this 
experimental function declaration mechanism.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95523

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


[PATCH] D95482: [PATCH] [clang] Fix bug 48848 by removing assertion related to recoverFromMSUnqualifiedLookup

2021-02-01 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Sorry, yeah, I'm OK with this change.




Comment at: clang/test/SemaCXX/lambda-expressions.cpp:671
+#else
+template 
+void Decider(const RT &sp, ET &ep) {

I think it makes more sense for this test to be in its own file since entire 
rest of the test is `#ifndef`ed out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95482

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


[PATCH] D95735: [ASTMatchers] Fix matching after generic top-level matcher

2021-02-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I'm a bit confused -- I only get one match when I try out your example: 
https://godbolt.org/z/xn9efY Are there other changes in-flight that necessitate 
this, or is something else going on?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95735

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


[PATCH] D95534: clang-cl: Invent a /winsysroot concept

2021-02-01 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added subscribers: smeenai, compnerd.
rnk added a comment.

+People who have spent time on cross-compilation Windows sysroots in the past: 
@smeenai @compnerd


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95534

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


[PATCH] D95808: [test] Use host platform specific error message substitution in lit tests - continued

2021-02-01 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
abhina.sreeskantharajan added reviewers: muiez, fanbo-meng, Kai, jhenderson, 
grimar.
Herald added subscribers: delcypher, emaste.
abhina.sreeskantharajan requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay.
Herald added projects: clang, LLVM.

On z/OS, the another error message is not matched correctly in lit tests.

  EDC5121I Invalid argument.

This patch adds a lit substitution to fix it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95808

Files:
  clang/test/Analysis/taint-generic.c
  clang/test/Format/style-on-command-line.cpp
  llvm/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml
  llvm/utils/lit/lit/llvm/config.py


Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -349,12 +349,15 @@
 if (sys.platform == 'zos'):
 self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No 
such file or directory.\''))
 self.config.substitutions.append(('%errc_EISDIR', '\'EDC5123I Is a 
directory.\''))
+self.config.substitutions.append(('%errc_EINVAL', '\'EDC5121I 
Invalid argument.\''))
 elif (sys.platform == 'win32'):
 self.config.substitutions.append(('%errc_ENOENT', '\'no such file 
or directory\''))
 self.config.substitutions.append(('%errc_EISDIR', '\'is a 
directory\''))
+self.config.substitutions.append(('%errc_EINVAL', '\'invalid 
argument\''))
 else:
 self.config.substitutions.append(('%errc_ENOENT', '\'No such file 
or directory\''))
 self.config.substitutions.append(('%errc_EISDIR', '\'Is a 
directory\''))
+self.config.substitutions.append(('%errc_EINVAL', '\'Invalid 
argument\''))
 
 def use_default_substitutions(self):
 tool_patterns = [
Index: llvm/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml
===
--- llvm/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml
+++ llvm/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml
@@ -225,12 +225,12 @@
 
 ## h) Test that yaml2obj emits an error if 'Descriptor' is missing.
 
-# RUN: not yaml2obj --docnum=8 %s -o %t8.o 2>&1 | FileCheck %s 
--check-prefix=MISSING-KEY --ignore-case
+# RUN: not yaml2obj --docnum=8 %s -o %t8.o 2>&1 | FileCheck -DMSG=%errc_EINVAL 
%s --check-prefix=MISSING-KEY --ignore-case
 
 #  MISSING-KEY: YAML:{{.*}}:9: error: missing required key 'Descriptor'
 # MISSING-KEY-NEXT:   - DieOffset: 0x12345678
 # MISSING-KEY-NEXT: ^
-# MISSING-KEY-NEXT: yaml2obj: error: failed to parse YAML input: Invalid 
argument
+# MISSING-KEY-NEXT: yaml2obj: error: failed to parse YAML input: [[MSG]]
 
 --- !ELF
 FileHeader:
Index: clang/test/Format/style-on-command-line.cpp
===
--- clang/test/Format/style-on-command-line.cpp
+++ clang/test/Format/style-on-command-line.cpp
@@ -1,7 +1,7 @@
 // RUN: clang-format -style="{BasedOnStyle: Google, IndentWidth: 8}" %s | 
FileCheck -strict-whitespace -check-prefix=CHECK1 %s
 // RUN: clang-format -style="{BasedOnStyle: LLVM, IndentWidth: 7}" %s | 
FileCheck -strict-whitespace -check-prefix=CHECK2 %s
-// RUN: not clang-format -style="{BasedOnStyle: invalid, IndentWidth: 7}" 
-fallback-style=LLVM %s 2>&1 | FileCheck -strict-whitespace 
-check-prefix=CHECK3 %s
-// RUN: not clang-format -style="{lsjd}" %s -fallback-style=LLVM 2>&1 | 
FileCheck -strict-whitespace -check-prefix=CHECK4 %s
+// RUN: not clang-format -style="{BasedOnStyle: invalid, IndentWidth: 7}" 
-fallback-style=LLVM %s 2>&1 | FileCheck -DMSG=%errc_EINVAL -strict-whitespace 
-check-prefix=CHECK3 %s
+// RUN: not clang-format -style="{lsjd}" %s -fallback-style=LLVM 2>&1 | 
FileCheck -DMSG=%errc_EINVAL -strict-whitespace -check-prefix=CHECK4 %s
 // RUN: mkdir -p %t
 // RUN: printf "BasedOnStyle: google\nIndentWidth: 5\n" > %t/.clang-format
 // RUN: clang-format -style=file -assume-filename=%t/foo.cpp < %s | FileCheck 
-strict-whitespace -check-prefix=CHECK5 %s
@@ -24,8 +24,8 @@
 // CHECK1: {{^int\* i;$}}
 // CHECK2: {{^   int \*i;$}}
 // CHECK3: Unknown value for BasedOnStyle: invalid
-// CHECK3: Error parsing -style: {{I|i}}nvalid argument
-// CHECK4: Error parsing -style: {{I|i}}nvalid argument
+// CHECK3: Error parsing -style: [[MSG]]
+// CHECK4: Error parsing -style: [[MSG]]
 // CHECK5: {{^ int\* i;$}}
 // CHECK6: {{^Error reading .*\.clang-format: (I|i)nvalid argument}}
 // CHECK7: {{^  int\* i;$}}
Index: clang/test/Analysis/taint-generic.c
===
--- clang/test/Analysis/taint-generic.c
+++ clang/test/Analysis/taint-generic.c
@@ -28,11 +28,11 @@
 // RUN:   -analyzer-checker=alpha.security.taint \
 // RUN:   -analyzer-config \
 // RUN: 

[PATCH] D95534: clang-cl: Invent a /winsysroot concept

2021-02-01 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

I saw this on LLVM Weekly, and I like it a lot :)

Now if only Windows could case-correct their SDKs so we didn't need VFS 
overlays and symlinks for the linker...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95534

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


[PATCH] D95753: [CoverageMapping] Don't absolutize source paths

2021-02-01 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D95753#2534061 , @vsk wrote:

> For context, the reason abspaths are used here is because users don't expect 
> coverage results to go missing if the build directory changes (e.g. given `cd 
> A; cc x.c; cd ../B; cc x.c`, the expectation is that coverage for two 
> distinct x.c's is reported).
>
> I think it's important that this continues to work by default. 
> Default-enabling the suggested `-fcoverage-mapping-abspath` option sounds 
> like a workable solution. I haven't kept up with the work on 
> -f(debug-)?compilation-dir, but if that option were specified, it could make 
> sense to make coverage filenames "absolute" (relative to `chroot 
> `).

That's a useful context, thank you!

In the case of debug info, we store the compilation directory 
(`DW_AT_comp_dir`)  separately from the file (`DW_AT_decl_file`) so even if we 
use relative path for the file by default, you can still get the absolute path 
by concatenating it with the directory which is absolute by default. In the 
case of coverage, there's no separate directory field, hence using the absolute 
path by default.

To produce a fully relocatable debug info, you can use `-fdebug-compilation-dir 
.`, but then it's the responsibility of the developer/build system to ensure 
that processing is done from the correct build directory to avoid the issue you 
mentioned. Given that, I think it makes sense to similarly gate the use of 
relative paths in coverage mapping on a flag.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95753

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


[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

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

I still have the same fundamental objection as before to the parts of this 
patch for prohibiting FP add/sub on some targets.

If a particular LLVM target cannot handle transforming an FP add/sub (or any 
other RMW operations!) into the correct cmpxchg or LL/SC loop, that's a bug in 
the backend which should be fixed. I don't see why we ought to add a bunch of 
functionality in the frontend to workaround this?

(Some of the other changes, e.g. to diagnose lack of support for large atomics 
is useful, though.)


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

https://reviews.llvm.org/D71726

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


[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

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



Comment at: clang/include/clang/Basic/TargetInfo.h:1479
+Unsupported,
+Init,
+C11LoadStore,

yaxunl wrote:
> rjmccall wrote:
> > `atomic_init` is not actually an atomic operation, so there's never an 
> > inherent reason it can't be supported.
> > 
> > In general, I am torn about this list, because it's simultaneously rather 
> > fine-grained while not seeming nearly fine-grained enough to be truly 
> > general.  What's actually going on on your target?  You have ISA support 
> > for doing some specific operations atomically, but not a general atomic 
> > compare-and-swap operation?  Which means that you then cannot support 
> > support other operations?
> > 
> > It is unfortunate that our layering prevents TargetInfo from simply being 
> > passed the appropriate expression.
> The target hook getAtomicSupport needs an argument for atomic operation. 
> Since not all targets support fp add/sub, we need an enum for add/sub. Since 
> certain release of iOS/macOS does not support C11 load/store, we need an enum 
> for C11 load/store. We could define the enums as {AddSub, C11LoadStore, 
> Other}. However, this would cause a difficulty for emitting diagnostic 
> message for unsupported atomic operations since we map this enum to a string 
> for the atomic operation and use it in the diagnostic message. 'Other' would 
> be mapped to 'other atomic operation' which is not clear what it is.
It's not obviously true that not all targets support FP add/sub, though.  Any 
target that provides compare-and-swap at the width of an FP type can do an 
atomic FP add/sub at that width; it might be less efficient than it would be 
with specific ISA support, but that's true for a lot of atomic operations.  
Surely it's better to just fix whatever bugs LLVM has with lowering atomic FP 
add/sub than to add more abstraction to Clang to handle a special case that 
shouldn't exist.

I don't know what issues Darwin has with C11 load/store; that might be a more 
compelling reason to have this abstraction, although again it seems strange 
that we're outlawing a specific operation when in principle we can just emit it 
less efficiently.



Comment at: clang/lib/Basic/Targets/AArch64.h:143
+}
+  }
 };

yaxunl wrote:
> rjmccall wrote:
> > Why can't targets reliably expand this to an atomic compare-and-exchange if 
> > they support that for the target width?
> There are some bugs in either the middle end or backend causing this not 
> working. For example, half type atomic fadd on amdgcn is not lowered to 
> cmpxchg and the backend has isel failure, bf16 type atomic fadd on arm is not 
> lowered to cmpxchg and the backend has isel failure. The support for each fp 
> type needs to be done case by case. So far there is no target support atomic 
> fadd/sub with half and bf16 type.
Are we legalizing atomicrmw to cmpxchg loops in the backend instead of as LLVM 
IR pass?  That seems like an architectural mistake.  Regardless, this bug 
should just be fixed.


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

https://reviews.llvm.org/D71726

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


[PATCH] D95812: [clangd] Report only decl of overridding method in xref.

2021-02-01 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 created this revision.
Herald added subscribers: kadircet, arphaman.
usaxena95 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

See: https://github.com/clangd/clangd/issues/668

  struct A { virtual void foo() = 0; };
  struct B : A { void foo() override; };

Find refs on `A::foo()` will show:

- decls of `A::foo()`
- decls of `B::foo()`
- refs to `A::foo()`
- no refs to `B::foo()`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95812

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1850,14 +1850,14 @@
   R"cpp(
 class Base {
 public:
-  virtual void [[f^unc]]() = 0;
+  virtual void [[f^unc]]();
 };
 class Derived : public Base {
 public:
   void [[func]]() override;
 };
 void test(Derived* D) {
-  D->[[func]]();
+  D->func();  // No references to the overrides.
 })cpp";
   Annotations T(Test);
   auto TU = TestTU::withCode(T.code());
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1298,6 +1298,7 @@
   }
 
   RefsRequest Req;
+  RelationsRequest OverriddenBy;
 
   const auto *IdentifierAtCursor =
   syntax::spelledIdentifierTouching(*CurLoc, AST.getTokens());
@@ -1332,26 +1333,18 @@
   if (auto ID = getSymbolID(D))
 Targets.insert(ID);
 
-llvm::DenseSet Overrides;
 if (Index) {
-  RelationsRequest FindOverrides;
-  FindOverrides.Predicate = RelationKind::OverriddenBy;
+  OverriddenBy.Predicate = RelationKind::OverriddenBy;
   for (const NamedDecl *ND : Decls) {
-// Special case: virtual void meth^od() = 0 includes refs of overrides.
+// Special case: Inlcude declaration of overridding methods.
 if (const auto *CMD = llvm::dyn_cast(ND)) {
-  if (CMD->isPure())
+  if (CMD->isVirtual())
 if (IdentifierAtCursor && SM.getSpellingLoc(CMD->getLocation()) ==
   IdentifierAtCursor->location())
   if (auto ID = getSymbolID(CMD))
-FindOverrides.Subjects.insert(ID);
+OverriddenBy.Subjects.insert(ID);
 }
   }
-  if (!FindOverrides.Subjects.empty())
-Index->relations(FindOverrides,
- [&](const SymbolID &Subject, const Symbol &Object) {
-   Overrides.insert(Object.ID);
- });
-  Targets.insert(Overrides.begin(), Overrides.end());
 }
 
 // We traverse the AST to find references in the main file.
@@ -1373,7 +1366,6 @@
   Results.References.push_back(std::move(Result));
 }
 if (Index && Results.References.size() <= Limit) {
-  Req.IDs = std::move(Overrides);
   for (const Decl *D : Decls) {
 // Not all symbols can be referenced from outside (e.g.
 // function-locals).
@@ -1386,6 +1378,15 @@
   }
 }
   }
+  // Add declaration of overridding methods.
+  if (Index && !OverriddenBy.Subjects.empty())
+Index->relations(
+OverriddenBy, [&](const SymbolID &Subject, const Symbol &Object) {
+  if (auto LSPLoc =
+  toLSPLocation(Object.CanonicalDeclaration, *MainFilePath))
+Results.References.push_back(std::move(*LSPLoc));
+});
+
   // Now query the index for references from other files.
   if (!Req.IDs.empty() && Index && Results.References.size() <= Limit) {
 Req.Limit = Limit;


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1850,14 +1850,14 @@
   R"cpp(
 class Base {
 public:
-  virtual void [[f^unc]]() = 0;
+  virtual void [[f^unc]]();
 };
 class Derived : public Base {
 public:
   void [[func]]() override;
 };
 void test(Derived* D) {
-  D->[[func]]();
+  D->func();  // No references to the overrides.
 })cpp";
   Annotations T(Test);
   auto TU = TestTU::withCode(T.code());
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1298,6 +1298,7 @@
   }
 
   RefsRequest Req;
+  RelationsRequest OverriddenBy;
 
   const auto *IdentifierAtCursor =
   syntax::spelledIdentifierTouching(*C

[PATCH] D76802: [InstrProfiling] Use !associated metadata for counters, data and values

2021-02-01 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 320562.

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

https://reviews.llvm.org/D76802

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  compiler-rt/test/profile/instrprof-gc-sections.c
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  llvm/test/Instrumentation/InstrProfiling/icall.ll
  llvm/test/Instrumentation/InstrProfiling/linkage.ll
  llvm/test/Transforms/PGOProfile/associated.ll
  llvm/test/Transforms/PGOProfile/counter_promo.ll
  llvm/test/Transforms/PGOProfile/counter_promo_mexits.ll

Index: llvm/test/Transforms/PGOProfile/counter_promo_mexits.ll
===
--- llvm/test/Transforms/PGOProfile/counter_promo_mexits.ll
+++ llvm/test/Transforms/PGOProfile/counter_promo_mexits.ll
@@ -69,7 +69,7 @@
 ; PROMO-NEXT:  %pgocount{{.*}} = load {{.*}} @__profc_foo{{.*}} 4)
 ; PROMO-NEXT: add 
 ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}4)
-; PROMO-NOT: @__profc_foo
+; PROMO-NOT: @__profc_foo{{.*}})
 
 
 bb15: ; preds = %bb14, %bb4
Index: llvm/test/Transforms/PGOProfile/counter_promo.ll
===
--- llvm/test/Transforms/PGOProfile/counter_promo.ll
+++ llvm/test/Transforms/PGOProfile/counter_promo.ll
@@ -60,7 +60,7 @@
 ; ATOMIC_PROMO: atomicrmw add {{.*}} @__profc_foo{{.*}}0), i64 %[[LIVEOUT1]] seq_cst
 ; ATOMIC_PROMO-NEXT: atomicrmw add {{.*}} @__profc_foo{{.*}}1), i64 %[[LIVEOUT2]] seq_cst
 ; ATOMIC_PROMO-NEXT: atomicrmw add {{.*}} @__profc_foo{{.*}}2), i64 %[[LIVEOUT3]] seq_cst
-; PROMO-NOT: @__profc_foo
+; PROMO-NOT: @__profc_foo{{.*}})
 
 
 }
Index: llvm/test/Transforms/PGOProfile/associated.ll
===
--- /dev/null
+++ llvm/test/Transforms/PGOProfile/associated.ll
@@ -0,0 +1,12 @@
+; RUN: opt < %s -pgo-instr-gen -instrprof -counter-link-order -S | FileCheck %s
+; RUN: opt < %s -passes=pgo-instr-gen,instrprof -counter-link-order -S | FileCheck %s
+
+; CHECK: @__profc_foo = private global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", align 8, !associated !0
+; CHECK: @__profd_foo = private global {{.*}}, section "__llvm_prf_data", align 8, !associated !1
+
+define void @foo() {
+  ret void
+}
+
+; CHECK: !0 = !{void ()* @foo}
+; CHECK: !1 = !{[1 x i64]* @__profc_foo}
Index: llvm/test/Instrumentation/InstrProfiling/linkage.ll
===
--- llvm/test/Instrumentation/InstrProfiling/linkage.ll
+++ llvm/test/Instrumentation/InstrProfiling/linkage.ll
@@ -8,6 +8,8 @@
 ; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=POSIX,LINUX
 ; RUN: opt < %s -mtriple=x86_64-unknown-fuchsia -passes=instrprof -S | FileCheck %s --check-prefixes=POSIX,LINUX
 ; RUN: opt < %s  -mtriple=x86_64-pc-win32-coff -passes=instrprof -S | FileCheck %s --check-prefixes=COFF
+; RUN: opt < %s -mtriple=x86_64-unknown-linux -instrprof -counter-link-order -S | FileCheck %s --check-prefixes=LINUX,POSIX,METADATA
+; RUN: opt < %s -mtriple=x86_64-unknown-linux -passes=instrprof -counter-link-order -S | FileCheck %s --check-prefixes=LINUX,POSIX,METADATA
 
 ; MACHO: @__llvm_profile_runtime = external global i32
 ; LINUX-NOT: @__llvm_profile_runtime = external global i32
@@ -19,7 +21,9 @@
 @__profn_foo_extern = linkonce_odr hidden constant [10 x i8] c"foo_extern"
 
 ; POSIX: @__profc_foo = hidden global
+; METADATA-SAME: !associated !0
 ; POSIX: @__profd_foo = hidden global
+; METADATA-SAME: !associated !1
 ; COFF: @__profc_foo = internal global
 ; COFF-NOT: comdat
 ; COFF: @__profd_foo = internal global
@@ -29,7 +33,9 @@
 }
 
 ; POSIX: @__profc_foo_weak = weak hidden global
+; METADATA: !associated !2
 ; POSIX: @__profd_foo_weak = weak hidden global
+; METADATA: !associated !3
 ; COFF: @__profc_foo_weak = internal global
 ; COFF: @__profd_foo_weak = internal global
 define weak void @foo_weak() {
@@ -38,7 +44,9 @@
 }
 
 ; POSIX: @"__profc_linkage.ll:foo_internal" = internal global
+; METADATA-SAME: !associated !4
 ; POSIX: @"__profd_linkage.ll:foo_internal" = internal global
+; METADATA-SAME: !associated !5
 ; COFF: @"__profc_linkage.ll:foo_internal" = internal global
 ; COFF: @"__profd_linkage.ll:foo_internal" = internal global
 define internal void @foo_internal() {
@@ -47,7 +55,9 @@
 }
 
 ; POSIX: @__profc_foo_inline = linkonce_odr hidden global
+; METADATA-SAME: !associated !6
 ; POSIX: @__profd_foo_inline = linkonce_odr hidden global
+; METADATA-SAME: !associated !7
 ; COFF: @__profc_foo_inline = internal global{{.*}} section ".lprfc$M", align 8
 ; COFF: @__profd_foo_inline = internal global{{.*}} section ".lprfd$M", align 8
 define linkonce_odr void @foo_inline() {
@@ -56,7 +66,9 @@
 }
 
 ; LINUX: @__profc_foo_extern = linkonce_odr hidden global {{.*

[PATCH] D76802: [InstrProfiling] Use !associated metadata for counters, data and values

2021-02-01 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D76802#2534118 , @MaskRay wrote:

> "prevents discarding" is not accurate in the context. `__llvm_prf_*` cannot 
> be discarded because C identifier name input sections are GC roots.
>
> Add "C identifier name input sections are GC roots. In LLD, the 
> SHF_LINK_ORDER flag overrides the C identifier name semantics." in 
> appropriate place.

Done, I have revised the change description.

> This C identifier name GC currently only works with LLD but does no harm to 
> gold/GNU ld.
>
> Do you think `__llvm_prf_*` can link to the text section so that the 
> self-link trick is not needed? 
> (https://sourceware.org/bugzilla/show_bug.cgi?id=27259)

I associated the counter with the function symbol which seems to be working and 
we no longer need the self-link trick.


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

https://reviews.llvm.org/D76802

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


[PATCH] D95812: [clangd] Report only decl of overridding method in xref.

2021-02-01 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 320563.
usaxena95 added a comment.

Move Index query to more logical place.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95812

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1850,14 +1850,14 @@
   R"cpp(
 class Base {
 public:
-  virtual void [[f^unc]]() = 0;
+  virtual void [[f^unc]]();
 };
 class Derived : public Base {
 public:
   void [[func]]() override;
 };
 void test(Derived* D) {
-  D->[[func]]();
+  D->func();  // No references to the overrides.
 })cpp";
   Annotations T(Test);
   auto TU = TestTU::withCode(T.code());
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1332,26 +1332,19 @@
   if (auto ID = getSymbolID(D))
 Targets.insert(ID);
 
-llvm::DenseSet Overrides;
+RelationsRequest OverriddenBy;
 if (Index) {
-  RelationsRequest FindOverrides;
-  FindOverrides.Predicate = RelationKind::OverriddenBy;
+  OverriddenBy.Predicate = RelationKind::OverriddenBy;
   for (const NamedDecl *ND : Decls) {
-// Special case: virtual void meth^od() = 0 includes refs of overrides.
+// Special case: Inlcude declaration of overridding methods.
 if (const auto *CMD = llvm::dyn_cast(ND)) {
-  if (CMD->isPure())
+  if (CMD->isVirtual())
 if (IdentifierAtCursor && SM.getSpellingLoc(CMD->getLocation()) ==
   IdentifierAtCursor->location())
   if (auto ID = getSymbolID(CMD))
-FindOverrides.Subjects.insert(ID);
+OverriddenBy.Subjects.insert(ID);
 }
   }
-  if (!FindOverrides.Subjects.empty())
-Index->relations(FindOverrides,
- [&](const SymbolID &Subject, const Symbol &Object) {
-   Overrides.insert(Object.ID);
- });
-  Targets.insert(Overrides.begin(), Overrides.end());
 }
 
 // We traverse the AST to find references in the main file.
@@ -1372,8 +1365,17 @@
   Result.uri = URIMainFile;
   Results.References.push_back(std::move(Result));
 }
+// Add declaration of overridding methods.
+if (Index && Results.References.size() <= Limit &&
+!OverriddenBy.Subjects.empty())
+  Index->relations(
+  OverriddenBy, [&](const SymbolID &Subject, const Symbol &Object) {
+if (auto LSPLoc =
+toLSPLocation(Object.CanonicalDeclaration, *MainFilePath))
+  Results.References.push_back(std::move(*LSPLoc));
+  });
+
 if (Index && Results.References.size() <= Limit) {
-  Req.IDs = std::move(Overrides);
   for (const Decl *D : Decls) {
 // Not all symbols can be referenced from outside (e.g.
 // function-locals).
@@ -1386,6 +1388,7 @@
   }
 }
   }
+
   // Now query the index for references from other files.
   if (!Req.IDs.empty() && Index && Results.References.size() <= Limit) {
 Req.Limit = Limit;


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1850,14 +1850,14 @@
   R"cpp(
 class Base {
 public:
-  virtual void [[f^unc]]() = 0;
+  virtual void [[f^unc]]();
 };
 class Derived : public Base {
 public:
   void [[func]]() override;
 };
 void test(Derived* D) {
-  D->[[func]]();
+  D->func();  // No references to the overrides.
 })cpp";
   Annotations T(Test);
   auto TU = TestTU::withCode(T.code());
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1332,26 +1332,19 @@
   if (auto ID = getSymbolID(D))
 Targets.insert(ID);
 
-llvm::DenseSet Overrides;
+RelationsRequest OverriddenBy;
 if (Index) {
-  RelationsRequest FindOverrides;
-  FindOverrides.Predicate = RelationKind::OverriddenBy;
+  OverriddenBy.Predicate = RelationKind::OverriddenBy;
   for (const NamedDecl *ND : Decls) {
-// Special case: virtual void meth^od() = 0 includes refs of overrides.
+// Special case: Inlcude declaration of over

[PATCH] D76802: [InstrProfiling] Use !associated metadata for counters, data and values

2021-02-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.

Thanks!


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

https://reviews.llvm.org/D76802

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


[PATCH] D95814: [NFC] Simplify test to use multiple FileCheck prefixes.

2021-02-01 Thread Varun Gandhi via Phabricator via cfe-commits
varungandhi-apple created this revision.
varungandhi-apple added a reviewer: aschwaighofer.
varungandhi-apple requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Minor cleanup where we can avoid calling the compiler
twice with the same arguments.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95814

Files:
  clang/test/CodeGen/64bit-swiftcall.c


Index: clang/test/CodeGen/64bit-swiftcall.c
===
--- clang/test/CodeGen/64bit-swiftcall.c
+++ clang/test/CodeGen/64bit-swiftcall.c
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -target-cpu core2 -emit-llvm 
-o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -target-cpu core2 -emit-llvm 
-o - %s | FileCheck %s --check-prefix=X86-64
-// RUN: %clang_cc1 -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm -o 
- %s | FileCheck %s
-// RUN: %clang_cc1 -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm -o 
- %s | FileCheck %s --check-prefix=ARM64
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -target-cpu core2 -emit-llvm 
-o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=X86-64
+// RUN: %clang_cc1 -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm -o 
- %s | FileCheck %s --check-prefix=CHECK --check-prefix=ARM64
 
 // REQUIRES: aarch64-registered-target,x86-registered-target
 


Index: clang/test/CodeGen/64bit-swiftcall.c
===
--- clang/test/CodeGen/64bit-swiftcall.c
+++ clang/test/CodeGen/64bit-swiftcall.c
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -target-cpu core2 -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -target-cpu core2 -emit-llvm -o - %s | FileCheck %s --check-prefix=X86-64
-// RUN: %clang_cc1 -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s --check-prefix=ARM64
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -target-cpu core2 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=X86-64
+// RUN: %clang_cc1 -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=ARM64
 
 // REQUIRES: aarch64-registered-target,x86-registered-target
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >