[PATCH] D73545: Fix a crash when casting _Complex and ignoring the results

2020-01-28 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D73545



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


[PATCH] D73495: [CodeGen] Attach no-builtin attributes to function definitions with no Decl

2020-01-28 Thread Francis Visoiu Mistrih via Phabricator via cfe-commits
thegameg updated this revision to Diff 240914.
thegameg added a comment.

Add the attribute to all TargetDecls.


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

https://reviews.llvm.org/D73495

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGenCXX/global-init.cpp

Index: clang/test/CodeGenCXX/global-init.cpp
===
--- clang/test/CodeGenCXX/global-init.cpp
+++ clang/test/CodeGenCXX/global-init.cpp
@@ -2,6 +2,8 @@
 // RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm %s -o - |FileCheck -check-prefix CHECK-NOEXC %s
 // RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm -mframe-pointer=non-leaf %s -o - \
 // RUN:   | FileCheck -check-prefix CHECK-FP %s
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm %s -o - -fno-builtin \
+// RUN:   | FileCheck -check-prefix CHECK-NOBUILTIN %s
 
 struct A {
   A();
@@ -202,9 +204,12 @@
 
 // rdar://problem/8090834: this should be nounwind
 // CHECK-NOEXC: define internal void @_GLOBAL__sub_I_global_init.cpp() [[NUW:#[0-9]+]] section "__TEXT,__StaticInit,regular,pure_instructions" {
-
 // CHECK-NOEXC: attributes [[NUW]] = { noinline nounwind{{.*}} }
 
+// Make sure we mark global initializers with the no-builtins attribute.
+// CHECK-NOBUILTIN: define internal void @_GLOBAL__sub_I_global_init.cpp() [[NUW:#[0-9]+]] section "__TEXT,__StaticInit,regular,pure_instructions" {
+// CHECK-NOBUILTIN: attributes [[NUW]] = { noinline nounwind{{.*}}"no-builtins"{{.*}} }
+
 // PR21811: attach the appropriate attribute to the global init function
 // CHECK-FP: define internal void @_GLOBAL__sub_I_global_init.cpp() [[NUX:#[0-9]+]] section "__TEXT,__StaticInit,regular,pure_instructions" {
 // CHECK-FP: attributes [[NUX]] = { noinline nounwind {{.*}}"frame-pointer"="non-leaf"{{.*}} }
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -1832,6 +1832,42 @@
   F.addAttributes(llvm::AttributeList::FunctionIndex, FuncAttrs);
 }
 
+static void addNoBuiltinAttributes(llvm::AttrBuilder &FuncAttrs,
+   const LangOptions &LangOpts,
+   const NoBuiltinAttr *NBA = nullptr) {
+  auto AddNoBuiltinAttr = [&FuncAttrs](StringRef BuiltinName) {
+SmallString<32> AttributeName;
+AttributeName += "no-builtin-";
+AttributeName += BuiltinName;
+FuncAttrs.addAttribute(AttributeName);
+  };
+
+  // First, handle the language options passed through -fno-builtin[-]
+  if (LangOpts.NoBuiltin) {
+// -fno-builtin disables them all.
+FuncAttrs.addAttribute("no-builtins");
+return;
+  }
+
+  // Then, add attributes for builtins specified through -fno-builtin-.
+  llvm::for_each(LangOpts.NoBuiltinFuncs, AddNoBuiltinAttr);
+
+  // Now, let's check the __attribute__((no_builtin("...")) attribute added to
+  // the source.
+  if (!NBA)
+return;
+
+  // If there is a wildcard in the builtin names specified through the
+  // attribute, disable them all.
+  if (llvm::is_contained(NBA->builtinNames(), "*")) {
+FuncAttrs.addAttribute("no-builtins");
+return;
+  }
+
+  // And last, add the rest of the builtin names.
+  llvm::for_each(NBA->builtinNames(), AddNoBuiltinAttr);
+}
+
 void CodeGenModule::ConstructAttributeList(
 StringRef Name, const CGFunctionInfo &FI, CGCalleeInfo CalleeInfo,
 llvm::AttributeList &AttrList, unsigned &CallingConv, bool AttrOnCallSite) {
@@ -1850,6 +1886,8 @@
   const Decl *TargetDecl = CalleeInfo.getCalleeDecl().getDecl();
 
   bool HasOptnone = false;
+  // The NoBuiltinAttr attached to a TargetDecl (only allowed on FunctionDecls).
+  const NoBuiltinAttr *NBA = nullptr;
   // FIXME: handle sseregparm someday...
   if (TargetDecl) {
 if (TargetDecl->hasAttr())
@@ -1875,22 +1913,7 @@
   if (!(AttrOnCallSite && IsVirtualCall)) {
 if (Fn->isNoReturn())
   FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
-
-const auto *NBA = Fn->getAttr();
-bool HasWildcard = NBA && llvm::is_contained(NBA->builtinNames(), "*");
-if (getLangOpts().NoBuiltin || HasWildcard)
-  FuncAttrs.addAttribute("no-builtins");
-else {
-  auto AddNoBuiltinAttr = [&FuncAttrs](StringRef BuiltinName) {
-SmallString<32> AttributeName;
-AttributeName += "no-builtin-";
-AttributeName += BuiltinName;
-FuncAttrs.addAttribute(AttributeName);
-  };
-  llvm::for_each(getLangOpts().NoBuiltinFuncs, AddNoBuiltinAttr);
-  if (NBA)
-llvm::for_each(NBA->builtinNames(), AddNoBuiltinAttr);
-}
+NBA = Fn->getAttr();
   }
 }
 
@@ -1925,6 +1948,14 @@
 }
   }
 
+  // Attach "no-builtins" attributes to:
+  // * call sites: both `nobuiltin` and "no-builtins" or "no-builtin-".
+  // * definitions: "no-builtins" or "no-builtin-" only.
+  // The a

[PATCH] D73562: [ASTMatchers] Add isPlacement traversal matcher for CXXNewExpr

2020-01-28 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
Herald added subscribers: cfe-commits, dexonsmith, steven_wu, hiraditya, 
mehdi_amini.
Herald added a project: clang.
njames93 added a reviewer: aaron.ballman.

Adds a traversal matcher called `isPlacement` that matches on `placement new` 
operators.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73562

Files:
  clang-tools-extra/clang-tidy/cert/DefaultOperatorNewAlignmentCheck.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -3124,5 +3124,37 @@
   EXPECT_TRUE(notMatches("template class A {};", Matcher));
 }
 
+TEST(CXXNewExpr, Array) {
+  StatementMatcher NewArray = cxxNewExpr(isArray());
+
+  EXPECT_TRUE(matches("void foo() { int *Ptr = new int[10]; }", NewArray));
+  EXPECT_TRUE(notMatches("void foo() { int *Ptr = new int; }", NewArray));
+
+  StatementMatcher NewArraySize10 =
+  cxxNewExpr(hasArraySize(integerLiteral(equals(10;
+  EXPECT_TRUE(
+  matches("void foo() { int *Ptr = new int[10]; }", NewArraySize10));
+  EXPECT_TRUE(
+  notMatches("void foo() { int *Ptr = new int[20]; }", NewArraySize10));
+}
+
+TEST(CXXNewExpr, IsPlacement) {
+  StatementMatcher PlacementNew = cxxNewExpr(isPlacement());
+
+  EXPECT_TRUE(matches(R"(
+void* operator new(decltype(sizeof(void*)), void*); 
+int *foo(void* Storage) {
+  return new (Storage) int; 
+})",
+  PlacementNew));
+
+  EXPECT_TRUE(notMatches(R"(
+void* operator new(decltype(sizeof(void*)), void*); 
+int *foo(void* Storage) {
+  return new int; 
+})",
+ PlacementNew));
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -394,6 +394,7 @@
   REGISTER_MATCHER(isNoneKind);
   REGISTER_MATCHER(isOMPStructuredBlock);
   REGISTER_MATCHER(isOverride);
+  REGISTER_MATCHER(isPlacement)
   REGISTER_MATCHER(isPrivate);
   REGISTER_MATCHER(isProtected);
   REGISTER_MATCHER(isPublic);
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -6752,6 +6752,16 @@
   return Node.isArray();
 }
 
+/// Matches placement new expressions.
+///
+/// Given:
+/// \code
+///   MyClass *p1 = new (Storage) MyClass();
+/// \endcode
+/// cxxNewExpr(isPlacement())
+///   matches the expression 'new (Storage) MyClass()'.
+AST_MATCHER(CXXNewExpr, isPlacement) { return Node.getNumPlacementArgs() > 0; }
+
 /// Matches array new expressions with a given array size.
 ///
 /// Given:
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -2547,6 +2547,16 @@
 
 
 
+MatcherCXXNewExpr>isPlacement
+Matches placement new expressions.
+
+Given:
+  MyClass *p1 = new (Storage) MyClass();
+cxxNewExpr(isPlacement())
+  matches the expression 'new (Storage) MyClass()'.
+
+
+
 MatcherCXXOperatorCallExpr>hasOverloadedOperatorNameStringRef Name
 Matches overloaded operator names.
 
Index: clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -91,7 +91,7 @@
   hasArgument(0,
   cxxNewExpr(hasType(pointsTo(qualType(hasCanonicalType(
  equalsBoundNode(PointerType),
- CanCallCtor)
+ CanCallCtor, unless(isPlacement()))
   .bind(NewExpression)),
   unless(isInTemplateInstantiation()))
   .bind(ConstructorCall,
@@ -101,7 +101,8 @@
   cxxMemberCallExpr(
   thisPointerType(getSmartPointerTypeMatcher()),
   callee(cxxMethodDecl(hasName("reset"))),
-  hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression)),
+  hasArgument(0, cxxNewExpr(CanCallCtor, unless(isPlacement()))
+ .bind(Ne

[PATCH] D73437: [mlir][spirv] Convert linalg.generic for reduction to SPIR-V ops

2020-01-28 Thread Nicolas Vasilache via Phabricator via cfe-commits
nicolasvasilache requested changes to this revision.
nicolasvasilache added inline comments.
This revision now requires changes to proceed.



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:27
+/// types.
+static bool areAllValuesMemref(Operation *op) {
+  auto isOfMemrefType = [](Value val) {

Please use `LinalgOp::hasBufferSemantics` instead of rolling your own



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:37
+/// Returns true if the given Linalg `iterators` is one reduction.
+static bool isLinalgSingleReductionIterator(ArrayAttr iterators) {
+  if (iterators.getValue().size() != 1)

Can we create a `singleReductionIterator()` somewhere in the existing utils and 
directly equality compare the `ArrayAttr iterators` against that?
I anticipate this type of things is soon going to become more and more useful, 
including from Tablegen. 



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:78
+/// ```
+static BinaryOpKind getScalarBinaryOpKind(linalg::GenericOp op) {
+  auto ®ion = op.region();

Same thing here, we should move these to utils on the Linalg side and make 
reusable as things are soon going to blow up out of control otherwise.



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:125
+
+PatternMatchResult SingleWorkgroupReduction::matchAndRewrite(
+linalg::GenericOp genericOp, ArrayRef operands,

Please split this into a precondition and an apply that must succeed so we can 
use the precondition as a Constraint and the apply as a simple Rewrite.
I have found this split to be crucial to write custom fused passes with DRR.
I claim this is generally the way we should be writing transformations when we 
can, which is the case for Linalg ops. 



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:156
+
+  auto inputMap = 
genericOp.indexing_maps().getValue()[0].cast();
+  auto outputMap =

I have similar comments re utils here but it will take a bit longer to put 
things in a reasonable form so please just add a TODO that this should use 
generic Linalg utils when available. 



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:260
+
+void mlir::populateLinalgToSPIRVPatterns(MLIRContext *context,
+ SPIRVTypeConverter &typeConverter,

Thanks for doing this as a pattern, it will compose nicely thanks to all of 
@rriddle's great work!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73437



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


[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2020-01-28 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

Adding @svenvh mainly to check if any fix is needed for the TableGen BIFs too?


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

https://reviews.llvm.org/D71460



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


[PATCH] D73231: [CUDA] Assume the latest known CUDA version if we've found an unknown one.

2020-01-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73231



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


[PATCH] D71460: [OpenCL] Fix support for cl_khr_mipmap_image_writes

2020-01-28 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!




Comment at: clang/lib/Headers/opencl-c.h:14686
+#if defined(cl_khr_mipmap_image_writes)
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : begin
 void __ovld write_imagef(write_only image1d_t image, int coord, int lod, 
float4 color);

AlexeySotkin wrote:
> Anastasia wrote:
> > AlexeySotkin wrote:
> > > Anastasia wrote:
> > > > Do we actually need pragma for this extension? I.e. does it need to 
> > > > activate any special mode in the compiler?
> > > I'm not aware of any special mode required for this extension. These 
> > > begin/end pragma lines were added to disable the extension by default as 
> > > it is [[ 
> > > https://github.com/KhronosGroup/OpenCL-Docs/blob/master/ext/introduction.asciidoc#compiler-directives-for-optional-extensions
> > >  | required ]] by the OpenCL extension spec. Is there any other mechanism 
> > > which should be used for this purpose?
> > > Probably, we should do the same for `cl_khr_mipmap_image`(and maybe 
> > > others?), because with the current compiler, built-ins from this 
> > > extension can be compiled successfully even if `#pragma OPENCL EXTENSION 
> > > cl_khr_mipmap_image : disable` is specified. See 
> > > https://godbolt.org/z/fNEWuG
> > What I am saying is that `pragma` is only typically used to activate some 
> > special mode in the compiler. If we don't need to activate anything perhaps 
> > we don't need to add `pragma` at all? It simplifies compiler and 
> > application code too. Would regular include mechanisms be enough to guard 
> > the availability of those functions?
> > 
> > Maybe this thread will help to understand the topic better: 
> > https://github.com/KhronosGroup/OpenCL-Docs/issues/82
> I think you are right. I have removed the pragma.
I think we probably should get rid of most of extensions in 
clang/include/clang/Basic/OpenCLExtensions.def and just try to implement the 
extensions macro using target specific header.

But it doesn't belong to your change and it's probably too big of the change 
anyway. Just a thought. :)


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

https://reviews.llvm.org/D71460



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


[clang] ac9b2a6 - Add missing clang tests for 6d614a82a4230ea69e322f56dc18dcbd815ed37b (AMDGPU MFMA built-ins)

2020-01-28 Thread Konstantin Pyzhov via cfe-commits

Author: Konstantin Pyzhov
Date: 2020-01-28T04:41:21-05:00
New Revision: ac9b2a6297420a461f7b9db9e2dbd67f5f07f301

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

LOG: Add missing clang tests for 6d614a82a4230ea69e322f56dc18dcbd815ed37b 
(AMDGPU MFMA built-ins)

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

Added: 


Modified: 
clang/test/CodeGenOpenCL/builtins-amdgcn-mfma.cl
clang/test/SemaOpenCL/builtins-amdgcn-error-gfx908-param.cl

Removed: 




diff  --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-mfma.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-mfma.cl
index e69de29bb2d1..c7db942b871a 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn-mfma.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-mfma.cl
@@ -0,0 +1,161 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx908 -S 
-emit-llvm -o - %s | FileCheck %s
+
+#pragma OPENCL EXTENSION cl_khr_fp64:enable
+
+typedef float  v4f   __attribute__((ext_vector_type(4)));
+typedef float  v16f  __attribute__((ext_vector_type(16)));
+typedef float  v32f  __attribute__((ext_vector_type(32)));
+typedef half   v4h   __attribute__((ext_vector_type(4)));
+typedef half   v16h  __attribute__((ext_vector_type(16)));
+typedef half   v32h  __attribute__((ext_vector_type(32)));
+typedef intv4i   __attribute__((ext_vector_type(4)));
+typedef intv16i  __attribute__((ext_vector_type(16)));
+typedef intv32i  __attribute__((ext_vector_type(32)));
+typedef short  v2s   __attribute__((ext_vector_type(2)));
+typedef short  v4s   __attribute__((ext_vector_type(4)));
+typedef short  v16s  __attribute__((ext_vector_type(16)));
+typedef short  v32s  __attribute__((ext_vector_type(32)));
+typedef double v4d   __attribute__((ext_vector_type(4)));
+
+
+// CHECK-LABEL: @test_mfma_f32_32x32x1f32
+// CHECK: call <32 x float> @llvm.amdgcn.mfma.f32.32x32x1f32(float %a, float 
%b, <32 x float> %c, i32 0, i32 0, i32 0)
+void test_mfma_f32_32x32x1f32(global v32f* out, float a, float b, v32f c)
+{
+  *out = __builtin_amdgcn_mfma_f32_32x32x1f32(a, b, c, 0, 0, 0);
+}
+
+// CHECK-LABEL: @test_mfma_f32_16x16x1f32
+// CHECK: call <16 x float> @llvm.amdgcn.mfma.f32.16x16x1f32(float %a, float 
%b, <16 x float> %c, i32 0, i32 0, i32 0)
+void test_mfma_f32_16x16x1f32(global v16f* out, float a, float b, v16f c)
+{
+  *out = __builtin_amdgcn_mfma_f32_16x16x1f32(a, b, c, 0, 0, 0);
+}
+
+// CHECK-LABEL: @test_mfma_f32_4x4x1f32
+// CHECK: call <4 x float> @llvm.amdgcn.mfma.f32.4x4x1f32(float %a, float %b, 
<4 x float> %c, i32 0, i32 0, i32 0)
+void test_mfma_f32_4x4x1f32(global v4f* out, float a, float b, v4f c)
+{
+  *out = __builtin_amdgcn_mfma_f32_4x4x1f32(a, b, c, 0, 0, 0);
+}
+
+// CHECK-LABEL: @test_mfma_f32_32x32x2f32
+// CHECK: call <16 x float> @llvm.amdgcn.mfma.f32.32x32x2f32(float %a, float 
%b, <16 x float> %c, i32 0, i32 0, i32 0)
+void test_mfma_f32_32x32x2f32(global v16f* out, float a, float b, v16f c)
+{
+  *out = __builtin_amdgcn_mfma_f32_32x32x2f32(a, b, c, 0, 0, 0);
+}
+
+// CHECK-LABEL: @test_mfma_f32_16x16x4f32
+// CHECK: call <4 x float> @llvm.amdgcn.mfma.f32.16x16x4f32(float %a, float 
%b, <4 x float> %c, i32 0, i32 0, i32 0)
+void test_mfma_f32_16x16x4f32(global v4f* out, float a, float b, v4f c)
+{
+  *out = __builtin_amdgcn_mfma_f32_16x16x4f32(a, b, c, 0, 0, 0);
+}
+
+// CHECK-LABEL: @test_mfma_f32_32x32x4f16
+// CHECK: call <32 x float> @llvm.amdgcn.mfma.f32.32x32x4f16(<4 x half> %a, <4 
x half> %b, <32 x float> %c, i32 0, i32 0, i32 0)
+void test_mfma_f32_32x32x4f16(global v32f* out, v4h a, v4h b, v32f c)
+{
+  *out = __builtin_amdgcn_mfma_f32_32x32x4f16(a, b, c, 0, 0, 0);
+}
+
+// CHECK-LABEL: @test_mfma_f32_16x16x4f16
+// CHECK: call <16 x float> @llvm.amdgcn.mfma.f32.16x16x4f16(<4 x half> %a, <4 
x half> %b, <16 x float> %c, i32 0, i32 0, i32 0)
+void test_mfma_f32_16x16x4f16(global v16f* out, v4h a, v4h b, v16f c)
+{
+  *out = __builtin_amdgcn_mfma_f32_16x16x4f16(a, b, c, 0, 0, 0);
+}
+
+// CHECK-LABEL: @test_mfma_f32_4x4x4f16
+// CHECK: call <4 x float> @llvm.amdgcn.mfma.f32.4x4x4f16(<4 x half> %a, <4 x 
half> %b, <4 x float> %c, i32 0, i32 0, i32 0)
+void test_mfma_f32_4x4x4f16(global v4f* out, v4h a, v4h b, v4f c)
+{
+  *out = __builtin_amdgcn_mfma_f32_4x4x4f16(a, b, c, 0, 0, 0);
+}
+
+// CHECK-LABEL: @test_mfma_f32_32x32x8f16
+// CHECK: call <16 x float> @llvm.amdgcn.mfma.f32.32x32x8f16(<4 x half> %a, <4 
x half> %b, <16 x float> %c, i32 0, i32 0, i32 0)
+void test_mfma_f32_32x32x8f16(global v16f* out, v4h a, v4h b, v16f c)
+{
+  *out = __builtin_amdgcn_mfma_f32_32x32x8f16(a, b, c, 0, 0, 0);
+}
+
+// CHECK-LABEL: @test_mfma_f32_16x16x16f16
+// CHECK: call <4 x float> @llvm.amdgcn.mfma.f32.16x16x16f16(<4 x half> %a, <4 
x half> %b, <4 x float> %c, i32 0, i32 0, i

[PATCH] D72723: Built-in functions for AMDGPU MFMA instructions.

2020-01-28 Thread Konstantin Pyzhov via Phabricator via cfe-commits
kpyzhov added a comment.

Thanks for reporting this. Somehow I managed to push empty test files. I'll 
push the fix soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72723



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


[PATCH] D73437: [mlir][spirv] Convert linalg.generic for reduction to SPIR-V ops

2020-01-28 Thread River Riddle via Phabricator via cfe-commits
rriddle added inline comments.



Comment at: mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td:463
+Location loc, Value condition,
+llvm::function_ref thenBody,
+OpBuilder *builder);

Drop the llvm::.



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:32
+
+  return llvm::all_of(op->getOperands(), isOfMemrefType) &&
+ llvm::all_of(op->getResults(), isOfMemrefType);

nit: You can use getOperandTypes() && getResultTypes() respectively.



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:38
+static bool isLinalgSingleReductionIterator(ArrayAttr iterators) {
+  if (iterators.getValue().size() != 1)
+return false;

Can you use size() directly on the ArrayAttr?



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:66
+};
+}
+

nit: Missing end namespace comment.



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:80
+  auto ®ion = op.region();
+  if (region.empty() || !has_single_element(region.getBlocks()))
+return BinaryOpKind::Unknown;

You should be able to remove the .empty() call as well as the .getBlocks()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73437



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


[PATCH] D71469: [AArch64] Add IR intrinsics for sq(r)dmulh_lane(q)

2020-01-28 Thread Sanne Wouda via Phabricator via cfe-commits
sanwou01 updated this revision to Diff 240902.
sanwou01 retitled this revision from "[AArch64] Add sq(r)dmulh_lane(q) LLVM IR 
intrinsics" to "[AArch64] Add IR intrinsics for sq(r)dmulh_lane(q)".
sanwou01 edited the summary of this revision.
sanwou01 added a comment.

Address Eli's feedback; clarified commit message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71469

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-neon-2velem.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64RegisterBankInfo.cpp
  llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
  llvm/lib/Target/AArch64/AArch64RegisterInfo.td
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/test/CodeGen/AArch64/arm64-neon-2velem.ll

Index: llvm/test/CodeGen/AArch64/arm64-neon-2velem.ll
===
--- llvm/test/CodeGen/AArch64/arm64-neon-2velem.ll
+++ llvm/test/CodeGen/AArch64/arm64-neon-2velem.ll
@@ -9,20 +9,36 @@
 declare <2 x float> @llvm.aarch64.neon.fmulx.v2f32(<2 x float>, <2 x float>)
 
 declare <4 x i32> @llvm.aarch64.neon.sqrdmulh.v4i32(<4 x i32>, <4 x i32>)
+declare <4 x i32> @llvm.aarch64.neon.sqrdmulh.lane.v4i32.v2i32(<4 x i32>, <2 x i32>, i32)
+declare <4 x i32> @llvm.aarch64.neon.sqrdmulh.laneq.v4i32.v4i32(<4 x i32>, <4 x i32>, i32)
 
 declare <2 x i32> @llvm.aarch64.neon.sqrdmulh.v2i32(<2 x i32>, <2 x i32>)
+declare <2 x i32> @llvm.aarch64.neon.sqrdmulh.lane.v2i32.v2i32(<2 x i32>, <2 x i32>, i32)
+declare <2 x i32> @llvm.aarch64.neon.sqrdmulh.laneq.v2i32.v4i32(<2 x i32>, <4 x i32>, i32)
 
 declare <8 x i16> @llvm.aarch64.neon.sqrdmulh.v8i16(<8 x i16>, <8 x i16>)
+declare <8 x i16> @llvm.aarch64.neon.sqrdmulh.lane.v8i16.v4i16(<8 x i16>, <4 x i16>, i32)
+declare <8 x i16> @llvm.aarch64.neon.sqrdmulh.laneq.v8i16.v8i16(<8 x i16>, <8 x i16>, i32)
 
 declare <4 x i16> @llvm.aarch64.neon.sqrdmulh.v4i16(<4 x i16>, <4 x i16>)
+declare <4 x i16> @llvm.aarch64.neon.sqrdmulh.lane.v4i16.v4i16(<4 x i16>, <4 x i16>, i32)
+declare <4 x i16> @llvm.aarch64.neon.sqrdmulh.laneq.v4i16.v8i16(<4 x i16>, <8 x i16>, i32)
 
 declare <4 x i32> @llvm.aarch64.neon.sqdmulh.v4i32(<4 x i32>, <4 x i32>)
+declare <4 x i32> @llvm.aarch64.neon.sqdmulh.lane.v4i32.v2i32(<4 x i32>, <2 x i32>, i32)
+declare <4 x i32> @llvm.aarch64.neon.sqdmulh.laneq.v4i32.v4i32(<4 x i32>, <4 x i32>, i32)
 
 declare <2 x i32> @llvm.aarch64.neon.sqdmulh.v2i32(<2 x i32>, <2 x i32>)
+declare <2 x i32> @llvm.aarch64.neon.sqdmulh.lane.v2i32.v2i32(<2 x i32>, <2 x i32>, i32)
+declare <2 x i32> @llvm.aarch64.neon.sqdmulh.laneq.v2i32.v4i32(<2 x i32>, <4 x i32>, i32)
 
 declare <8 x i16> @llvm.aarch64.neon.sqdmulh.v8i16(<8 x i16>, <8 x i16>)
+declare <8 x i16> @llvm.aarch64.neon.sqdmulh.lane.v8i16.v4i16(<8 x i16>, <4 x i16>, i32)
+declare <8 x i16> @llvm.aarch64.neon.sqdmulh.laneq.v8i16.v8i16(<8 x i16>, <8 x i16>, i32)
 
 declare <4 x i16> @llvm.aarch64.neon.sqdmulh.v4i16(<4 x i16>, <4 x i16>)
+declare <4 x i16> @llvm.aarch64.neon.sqdmulh.lane.v4i16.v4i16(<4 x i16>, <4 x i16>, i32)
+declare <4 x i16> @llvm.aarch64.neon.sqdmulh.laneq.v4i16.v8i16(<4 x i16>, <8 x i16>, i32)
 
 declare <2 x i64> @llvm.aarch64.neon.sqdmull.v2i64(<2 x i32>, <2 x i32>)
 
@@ -1515,6 +1531,37 @@
   ret <4 x i16> %vqdmulh2.i
 }
 
+define <4 x i16> @test_vqdmulh_lane_s16_intrinsic(<4 x i16> %a, <4 x i16> %v) {
+; CHECK-LABEL: test_vqdmulh_lane_s16_intrinsic:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:// kill: def $d1 killed $d1 def $q1
+; CHECK-NEXT:sqdmulh v0.4h, v0.4h, v1.h[3]
+; CHECK-NEXT:ret
+entry:
+  %vqdmulh2.i = tail call <4 x i16> @llvm.aarch64.neon.sqdmulh.lane.v4i16.v4i16(<4 x i16> %a, <4 x i16> %v, i32 3)
+  ret <4 x i16> %vqdmulh2.i
+}
+
+define <4 x i16> @test_vqdmulh_laneq_s16_intrinsic_lo(<4 x i16> %a, <8 x i16> %v) {
+; CHECK-LABEL: test_vqdmulh_laneq_s16_intrinsic_lo:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sqdmulh v0.4h, v0.4h, v1.h[3]
+; CHECK-NEXT:ret
+entry:
+  %vqdmulh2.i = tail call <4 x i16> @llvm.aarch64.neon.sqdmulh.laneq.v4i16.v8i16(<4 x i16> %a, <8 x i16> %v, i32 3)
+  ret <4 x i16> %vqdmulh2.i
+}
+
+define <4 x i16> @test_vqdmulh_laneq_s16_intrinsic_hi(<4 x i16> %a, <8 x i16> %v) {
+; CHECK-LABEL: test_vqdmulh_laneq_s16_intrinsic_hi:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sqdmulh v0.4h, v0.4h, v1.h[7]
+; CHECK-NEXT:ret
+entry:
+  %vqdmulh2.i = tail call <4 x i16> @llvm.aarch64.neon.sqdmulh.laneq.v4i16.v8i16(<4 x i16> %a, <8 x i16> %v, i32 7)
+  ret <4 x i16> %vqdmulh2.i
+}
+
 define <8 x i16> @test_vqdmulhq_lane_s16(<8 x i16> %a, <4 x i16> %v) {
 ; CHECK-LABEL: test_vqdmulhq_lane_s16:
 ; CHECK:   // %bb.0: // %entry
@@ -1527,6 +1574,37 @@
   ret <8 x i16> %vqdmulh2.i
 }
 
+define <8 x i16> @test_vqdmulhq_la

[PATCH] D72723: Built-in functions for AMDGPU MFMA instructions.

2020-01-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This seems to break check-clang everywhere. If the fix isn't obvious, please 
revert and analyze asynchronously.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72723



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


[PATCH] D72723: Built-in functions for AMDGPU MFMA instructions.

2020-01-28 Thread Konstantin Pyzhov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6d614a82a423: Summary: This CL adds clang declarations of 
built-in functions for AMDGPU MFMA… (authored by kpyzhov).
Herald added a subscriber: kerbowa.

Changed prior to commit:
  https://reviews.llvm.org/D72723?vs=238263&id=240898#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72723

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/test/CodeGenOpenCL/builtins-amdgcn-mfma.cl
  clang/test/SemaOpenCL/builtins-amdgcn-error-gfx908-param.cl
  llvm/include/llvm/IR/IntrinsicsAMDGPU.td

Index: llvm/include/llvm/IR/IntrinsicsAMDGPU.td
===
--- llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -1725,105 +1725,125 @@
 def int_amdgcn_global_atomic_fadd: AMDGPUGlobalAtomicNoRtn;
 
 // llvm.amdgcn.mfma.f32.* vdst, srcA, srcB, srcC, cbsz, abid, blgp
-def int_amdgcn_mfma_f32_32x32x1f32 : Intrinsic<[llvm_v32f32_ty],
-  [llvm_float_ty, llvm_float_ty, llvm_v32f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_16x16x1f32 : Intrinsic<[llvm_v16f32_ty],
-  [llvm_float_ty, llvm_float_ty, llvm_v16f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_4x4x1f32 : Intrinsic<[llvm_v4f32_ty],
-  [llvm_float_ty, llvm_float_ty, llvm_v4f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_32x32x2f32 : Intrinsic<[llvm_v16f32_ty],
-  [llvm_float_ty, llvm_float_ty, llvm_v16f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_16x16x4f32 : Intrinsic<[llvm_v4f32_ty],
-  [llvm_float_ty, llvm_float_ty, llvm_v4f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_32x32x4f16 : Intrinsic<[llvm_v32f32_ty],
-  [llvm_v4f16_ty, llvm_v4f16_ty, llvm_v32f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_16x16x4f16 : Intrinsic<[llvm_v16f32_ty],
-  [llvm_v4f16_ty, llvm_v4f16_ty, llvm_v16f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_4x4x4f16 : Intrinsic<[llvm_v4f32_ty],
-  [llvm_v4f16_ty, llvm_v4f16_ty, llvm_v4f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_32x32x8f16 : Intrinsic<[llvm_v16f32_ty],
-  [llvm_v4f16_ty, llvm_v4f16_ty, llvm_v16f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_16x16x16f16 : Intrinsic<[llvm_v4f32_ty],
-  [llvm_v4f16_ty, llvm_v4f16_ty, llvm_v4f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_i32_32x32x4i8 : Intrinsic<[llvm_v32i32_ty],
-  [llvm_i32_ty, llvm_i32_ty, llvm_v32i32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_i32_16x16x4i8 : Intrinsic<[llvm_v16i32_ty],
-  [llvm_i32_ty, llvm_i32_ty, llvm_v16i32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_i32_4x4x4i8 : Intrinsic<[llvm_v4i32_ty],
-  [llvm_i32_ty, llvm_i32_ty, llvm_v4i32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_i32_32x32x8i8 : Intrinsic<[llvm_v16i32_ty],
-  [llvm_i32_ty, llvm_i32_ty, llvm_v16i32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_i32_16x16x16i8 : Intrinsic<[llvm_v4i32_ty],
-  [llvm_i32_ty, llvm_i32_ty, llvm_v4i32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_32x32x2bf16 : Intrinsic<[llvm_v32f32_ty],
-  [llvm_v2i16_ty, llvm_v2i16_ty, llvm_v32f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_16x16x2bf16 : Intrinsic<[llvm_v16f32_ty],
-  [llvm_v2i16_ty, llvm_v2i16_ty, llvm_v16f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_4x4x2bf16 : Intrinsic<[llvm_v4f32_t

[clang] 6d614a8 - Summary:

2020-01-28 Thread Konstantin Pyzhov via cfe-commits

Author: Konstantin Pyzhov
Date: 2020-01-28T03:51:27-05:00
New Revision: 6d614a82a4230ea69e322f56dc18dcbd815ed37b

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

LOG: Summary:
This CL adds clang declarations of built-in functions for AMDGPU MFMA 
intrinsics and instructions.
OpenCL tests for new built-ins are included.

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

Added: 
clang/test/CodeGenOpenCL/builtins-amdgcn-mfma.cl
clang/test/SemaOpenCL/builtins-amdgcn-error-gfx908-param.cl

Modified: 
clang/include/clang/Basic/BuiltinsAMDGPU.def
clang/lib/Basic/Targets/AMDGPU.cpp
llvm/include/llvm/IR/IntrinsicsAMDGPU.td

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def 
b/clang/include/clang/Basic/BuiltinsAMDGPU.def
index 9b3a0f96798f..a9143ad8292c 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -212,5 +212,30 @@ BUILTIN(__builtin_r600_read_tidig_z, "Ui", "nc")
 BUILTIN(__builtin_r600_recipsqrt_ieee, "dd", "nc")
 BUILTIN(__builtin_r600_recipsqrt_ieeef, "ff", "nc")
 
+//===--===//
+// MFMA builtins.
+//===--===//
+
+TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_32x32x1f32, "V32fffV32fIiIiIi", "nc", 
"mai-insts")
+TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_16x16x1f32, "V16fffV16fIiIiIi", "nc", 
"mai-insts")
+TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_4x4x1f32, "V4fffV4fIiIiIi", "nc", 
"mai-insts")
+TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_32x32x2f32, "V16fffV16fIiIiIi", "nc", 
"mai-insts")
+TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_16x16x4f32, "V4fffV4fIiIiIi", "nc", 
"mai-insts")
+TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_32x32x4f16, "V32fV4hV4hV32fIiIiIi", 
"nc", "mai-insts")
+TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_16x16x4f16, "V16fV4hV4hV16fIiIiIi", 
"nc", "mai-insts")
+TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_4x4x4f16, "V4fV4hV4hV4fIiIiIi", "nc", 
"mai-insts")
+TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_32x32x8f16, "V16fV4hV4hV16fIiIiIi", 
"nc", "mai-insts")
+TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_16x16x16f16, "V4fV4hV4hV4fIiIiIi", 
"nc", "mai-insts")
+TARGET_BUILTIN(__builtin_amdgcn_mfma_i32_32x32x4i8, "V32iiiV32iIiIiIi", "nc", 
"mai-insts")
+TARGET_BUILTIN(__builtin_amdgcn_mfma_i32_16x16x4i8, "V16iiiV16iIiIiIi", "nc", 
"mai-insts")
+TARGET_BUILTIN(__builtin_amdgcn_mfma_i32_4x4x4i8, "V4iiiV4iIiIiIi", "nc", 
"mai-insts")
+TARGET_BUILTIN(__builtin_amdgcn_mfma_i32_32x32x8i8, "V16iiiV16iIiIiIi", "nc", 
"mai-insts")
+TARGET_BUILTIN(__builtin_amdgcn_mfma_i32_16x16x16i8, "V4iiiV4iIiIiIi", "nc", 
"mai-insts")
+TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_32x32x2bf16, "V32fV2sV2sV32fIiIiIi", 
"nc", "mai-insts")
+TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_16x16x2bf16, "V16fV2sV2sV16fIiIiIi", 
"nc", "mai-insts")
+TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_4x4x2bf16, "V4fV2sV2sV4fIiIiIi", 
"nc", "mai-insts")
+TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_32x32x4bf16, "V16fV2sV2sV16fIiIiIi", 
"nc", "mai-insts")
+TARGET_BUILTIN(__builtin_amdgcn_mfma_f32_16x16x8bf16, "V4fV2sV2sV4fIiIiIi", 
"nc", "mai-insts")
+
 #undef BUILTIN
 #undef TARGET_BUILTIN

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index 249a123ea605..0aaf6813442a 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -163,6 +163,7 @@ bool AMDGPUTargetInfo::initFeatureMap(
   Features["dot4-insts"] = true;
   Features["dot5-insts"] = true;
   Features["dot6-insts"] = true;
+  Features["mai-insts"] = true;
   LLVM_FALLTHROUGH;
 case GK_GFX906:
   Features["dl-insts"] = true;

diff  --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-mfma.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-mfma.cl
new file mode 100644
index ..e69de29bb2d1

diff  --git a/clang/test/SemaOpenCL/builtins-amdgcn-error-gfx908-param.cl 
b/clang/test/SemaOpenCL/builtins-amdgcn-error-gfx908-param.cl
new file mode 100644
index ..e69de29bb2d1

diff  --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td 
b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
index 71cea8c1f3d5..68e8a830ecac 100644
--- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -1725,105 +1725,125 @@ def int_amdgcn_buffer_atomic_fadd: 
AMDGPUBufferAtomicNoRtn;
 def int_amdgcn_global_atomic_fadd: AMDGPUGlobalAtomicNoRtn;
 
 // llvm.amdgcn.mfma.f32.* vdst, srcA, srcB, srcC, cbsz, abid, blgp
-def int_amdgcn_mfma_f32_32x32x1f32 : Intrinsic<[llvm_v32f32_ty],
-  [llvm_float_ty, llvm_float_ty, llvm_v32f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def in

[clang] f117f2c - [OPENMP50]Check for lastprivate conditional updates in atomic

2020-01-28 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-01-28T11:40:31-05:00
New Revision: f117f2cc7837fbca75bf97fcca2a55423f3023ca

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

LOG: [OPENMP50]Check for lastprivate conditional updates in atomic
constructs.

Added analysis in atomic constrcuts to support checks for updates of
conditional lastprivate variables.

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/parallel_for_lastprivate_conditional.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 0e41d520da20..fcc619da837d 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -3984,6 +3984,7 @@ static void emitOMPAtomicReadExpr(CodeGenFunction &CGF, 
bool IsSeqCst,
   if (IsSeqCst)
 CGF.CGM.getOpenMPRuntime().emitFlush(CGF, llvm::None, Loc);
   CGF.emitOMPSimpleStore(VLValue, Res, X->getType().getNonReferenceType(), 
Loc);
+  CGF.CGM.getOpenMPRuntime().checkAndEmitLastprivateConditional(CGF, V);
 }
 
 static void emitOMPAtomicWriteExpr(CodeGenFunction &CGF, bool IsSeqCst,
@@ -3992,6 +3993,7 @@ static void emitOMPAtomicWriteExpr(CodeGenFunction &CGF, 
bool IsSeqCst,
   // x = expr;
   assert(X->isLValue() && "X of 'omp atomic write' is not lvalue");
   emitSimpleAtomicStore(CGF, IsSeqCst, CGF.EmitLValue(X), CGF.EmitAnyExpr(E));
+  CGF.CGM.getOpenMPRuntime().checkAndEmitLastprivateConditional(CGF, X);
   // OpenMP, 2.12.6, atomic Construct
   // Any atomic construct with a seq_cst clause forces the atomically
   // performed operation to include an implicit flush operation without a
@@ -4148,6 +4150,7 @@ static void emitOMPAtomicUpdateExpr(CodeGenFunction &CGF, 
bool IsSeqCst,
   };
   (void)CGF.EmitOMPAtomicSimpleUpdateExpr(
   XLValue, ExprRValue, BOUE->getOpcode(), IsXLHSInRHSPart, AO, Loc, Gen);
+  CGF.CGM.getOpenMPRuntime().checkAndEmitLastprivateConditional(CGF, X);
   // OpenMP, 2.12.6, atomic Construct
   // Any atomic construct with a seq_cst clause forces the atomically
   // performed operation to include an implicit flush operation without a
@@ -4214,6 +4217,7 @@ static void emitOMPAtomicCaptureExpr(CodeGenFunction 
&CGF, bool IsSeqCst,
 };
 auto Res = CGF.EmitOMPAtomicSimpleUpdateExpr(
 XLValue, ExprRValue, BOUE->getOpcode(), IsXLHSInRHSPart, AO, Loc, Gen);
+CGF.CGM.getOpenMPRuntime().checkAndEmitLastprivateConditional(CGF, X);
 if (Res.first) {
   // 'atomicrmw' instruction was generated.
   if (IsPostfixUpdate) {
@@ -4240,6 +4244,7 @@ static void emitOMPAtomicCaptureExpr(CodeGenFunction 
&CGF, bool IsSeqCst,
 auto Res = CGF.EmitOMPAtomicSimpleUpdateExpr(
 XLValue, ExprRValue, /*BO=*/BO_Assign, /*IsXLHSInRHSPart=*/false, AO,
 Loc, Gen);
+CGF.CGM.getOpenMPRuntime().checkAndEmitLastprivateConditional(CGF, X);
 if (Res.first) {
   // 'atomicrmw' instruction was generated.
   NewVVal = IsPostfixUpdate ? Res.second : ExprRValue;
@@ -4247,6 +4252,7 @@ static void emitOMPAtomicCaptureExpr(CodeGenFunction 
&CGF, bool IsSeqCst,
   }
   // Emit post-update store to 'v' of old/new 'x' value.
   CGF.emitOMPSimpleStore(VLValue, NewVVal, NewVValType, Loc);
+  CGF.CGM.getOpenMPRuntime().checkAndEmitLastprivateConditional(CGF, V);
   // OpenMP, 2.12.6, atomic Construct
   // Any atomic construct with a seq_cst clause forces the atomically
   // performed operation to include an implicit flush operation without a

diff  --git a/clang/test/OpenMP/parallel_for_lastprivate_conditional.cpp 
b/clang/test/OpenMP/parallel_for_lastprivate_conditional.cpp
index e05a5b977a4c..50282354a87a 100644
--- a/clang/test/OpenMP/parallel_for_lastprivate_conditional.cpp
+++ b/clang/test/OpenMP/parallel_for_lastprivate_conditional.cpp
@@ -19,6 +19,8 @@ int main() {
   a = 0;
 #pragma omp parallel reduction(+:a) num_threads(10)
   a += i;
+#pragma omp atomic
+  a += i;
 }
   }
   return 0;
@@ -40,6 +42,18 @@ int main() {
 // CHECK: br label %[[DONE]]
 // CHECK: [[DONE]]:
 // CHECK: call void @__kmpc_end_critical(%struct.ident_t* @{{.+}}, i32 
%{{.+}}, [8 x i32]* @{{.+}})
+// CHECK: atomicrmw add i32*
+// CHECK: call void @__kmpc_critical(%struct.ident_t* @{{.+}}, i32 %{{.+}}, [8 
x i32]* @{{.+}})
+// CHECK: [[LAST_IV_VAL:%.+]] = load i32, i32* [[LAST_IV:@.+]],
+// CHECK: [[RES:%.+]] = icmp sle i32 [[LAST_IV_VAL]], [[IV:%.+]]
+// CHECK: br i1 [[RES]], label %[[THEN:.+]], label %[[DONE:.+]]
+// CHECK: [[THEN]]:
+// CHECK: store i32 [[IV]], i32* [[LAST_IV]],
+// CHECK: [[A_VAL:%.+]] = load i32, i32* [[A_PRIV:%.+]],
+// CHECK: store i32 [[A_VAL]], i32* [[A_GLOB:@.+]],
+// CHECK: br label %[[DONE]]
+// CHECK: [[DONE]]:
+// CHECK: call void @__kmpc_end_critical(%struct.ident_t* @{{.+}}, i32 
%{{.+}}, [8 x i32]* @{{.

[PATCH] D73548: [clang-tidy] Added option for disabling const qualifiers in readability-qualified-auto

2020-01-28 Thread Nathan James via Phabricator via cfe-commits
njames93 marked 7 inline comments as done.
njames93 added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst:41
+   auto *const Bar = cast(Baz2);
+   auto *volatile FooBar = cast(Baz3);
+

Quuxplusone wrote:
> Is it worth adding an example of a double pointer?
> 
> auto BarN = cast(FooN);
> 
> Does that become `auto*` or `auto**` (and why)? My wild guess is that it 
> becomes `auto*` (and because nobody cares about double pointers), but I could 
> be wrong.
Double pointers are just resolved to `auto *`.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst:64
+
+   Otherwise it will get be transformed into:
+

Quuxplusone wrote:
> s/Will be/will be/
> s/will get be/will be/
> 
> In the preceding section you give an example with `volatile`. How about here? 
> What happens with
> 
> auto *volatile Foo3 = cast(Bar3);
> auto *Foo4 = cast(Bar4);
> 
> Do they become
> 
> const auto *volatile Foo3 = cast(Bar3);
> volatile auto *Foo4 = cast(Bar4);
> 
> as I would expect?
Good spot on the Will/be/get/(whatever I tried to type)

the check keeps local volatile qualifiers, but it wont add volatile pointer (or 
ref) qualifiers even if the deduced type is a volatile pointer. In the first 
patch we came to the conclusion not to add them.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst:69
+   const auto *Foo1 = cast(Bar1);
+   const auto &Foo2 = cast(Bar2);
+

Quuxplusone wrote:
> How does this option interact with
> 
> const int range[10];
> for (auto&& elt : range)
> 
> Does it (incorrectly IMHO) make that `const auto&& elt`, or (correctly IMHO) 
> `const auto& elt`, or (also correctly) leave it as [`auto&&`, which Always 
> Works](https://quuxplusone.github.io/blog/2018/12/15/autorefref-always-works/)?
RValueReferences are ignored



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/llvm-qualified-auto.cpp:20
+  auto &NakedRef = *getIntPtr();
+  auto &NakedConstRef = *getCIntPtr();
+}

Quuxplusone wrote:
> It is worth adding one test case to show that the LLVM alias does not 
> gratuitously //remove// `const` from declarations:
> 
> auto const &ExtendedConstPtr = getCIntPtr();
> // becomes
> auto *const &ExtendedConstPtr = getCIntPtr();
That test case looks malformed as the function getCIntPtr() doesn't return a 
reference. as for removing const etc those cases are all in the 
`readability-qualified-auto.cpp` test file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73548



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


[PATCH] D73299: [HIP] Fix environment variable HIP_DEVICE_LIB_PATH

2020-01-28 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb7e415f37f38: [HIP] Fix environment variable 
HIP_DEVICE_LIB_PATH (authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73299

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/Driver/hip-device-libs.hip


Index: clang/test/Driver/hip-device-libs.hip
===
--- clang/test/Driver/hip-device-libs.hip
+++ clang/test/Driver/hip-device-libs.hip
@@ -19,6 +19,13 @@
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck %s --check-prefixes=COM,NOFLUSHD
 
+// Test environment variable HIP_DEVICE_LIB_PATH
+
+// RUN: HIP_DEVICE_LIB_PATH=%S/Inputs/hip_dev_lib \
+// RUN:   %clang -### -target x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx900 \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=COM
 
 // COM: {{"[^"]*clang[^"]*"}}
 // COM-SAME: "-mlink-builtin-bitcode" "{{.*}}hip.amdgcn.bc"
Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -327,7 +327,7 @@
DriverArgs.getAllArgValues(options::OPT_hip_device_lib_path_EQ))
 LibraryPaths.push_back(DriverArgs.MakeArgString(Path));
 
-  addDirectoryList(DriverArgs, LibraryPaths, "-L", "HIP_DEVICE_LIB_PATH");
+  addDirectoryList(DriverArgs, LibraryPaths, "", "HIP_DEVICE_LIB_PATH");
 
   llvm::SmallVector BCLibs;
 
Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -94,6 +94,11 @@
 
 bool isUseSeparateSections(const llvm::Triple &Triple);
 
+/// \p EnvVar is split by system delimiter for environment variables.
+/// If \p ArgName is "-I", "-L", or an empty string, each entry from \p EnvVar
+/// is prefixed by \p ArgName then added to \p Args. Otherwise, for each
+/// entry of \p EnvVar, \p ArgName is added to \p Args first, then the entry
+/// itself is added.
 void addDirectoryList(const llvm::opt::ArgList &Args,
   llvm::opt::ArgStringList &CmdArgs, const char *ArgName,
   const char *EnvVar);
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -91,7 +91,7 @@
 return; // Nothing to do.
 
   StringRef Name(ArgName);
-  if (Name.equals("-I") || Name.equals("-L"))
+  if (Name.equals("-I") || Name.equals("-L") || Name.empty())
 CombinedArg = true;
 
   StringRef Dirs(DirList);


Index: clang/test/Driver/hip-device-libs.hip
===
--- clang/test/Driver/hip-device-libs.hip
+++ clang/test/Driver/hip-device-libs.hip
@@ -19,6 +19,13 @@
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck %s --check-prefixes=COM,NOFLUSHD
 
+// Test environment variable HIP_DEVICE_LIB_PATH
+
+// RUN: HIP_DEVICE_LIB_PATH=%S/Inputs/hip_dev_lib \
+// RUN:   %clang -### -target x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx900 \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=COM
 
 // COM: {{"[^"]*clang[^"]*"}}
 // COM-SAME: "-mlink-builtin-bitcode" "{{.*}}hip.amdgcn.bc"
Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -327,7 +327,7 @@
DriverArgs.getAllArgValues(options::OPT_hip_device_lib_path_EQ))
 LibraryPaths.push_back(DriverArgs.MakeArgString(Path));
 
-  addDirectoryList(DriverArgs, LibraryPaths, "-L", "HIP_DEVICE_LIB_PATH");
+  addDirectoryList(DriverArgs, LibraryPaths, "", "HIP_DEVICE_LIB_PATH");
 
   llvm::SmallVector BCLibs;
 
Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -94,6 +94,11 @@
 
 bool isUseSeparateSections(const llvm::Triple &Triple);
 
+/// \p EnvVar is split by system delimiter for environment variables.
+/// If \p ArgName is "-I", "-L", or an empty string, each entry from \p EnvVar
+/// is prefixed by \p ArgName then added to \p Args. Otherwise, for each
+/// entry of \p EnvVar, \p ArgName is added to \p Args first, then the entry
+/// itself is added.
 void addDirectoryList(const llvm::opt::ArgList &Args,
   llvm::opt::ArgStringList &CmdArgs, const ch

[clang] b7e415f - [HIP] Fix environment variable HIP_DEVICE_LIB_PATH

2020-01-28 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-01-28T11:27:01-05:00
New Revision: b7e415f37f38c65ced6d725d100790526920bc0c

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

LOG: [HIP] Fix environment variable HIP_DEVICE_LIB_PATH

Currently device lib path set by environment variable HIP_DEVICE_LIB_PATH
does not work due to extra "-L" added to each entry.

This patch fixes that by allowing argument name to be empty in addDirectoryList.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/CommonArgs.h
clang/lib/Driver/ToolChains/HIP.cpp
clang/test/Driver/hip-device-libs.hip

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 4adccaaa4cb7..bdf72a025f04 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -91,7 +91,7 @@ void tools::addDirectoryList(const ArgList &Args, 
ArgStringList &CmdArgs,
 return; // Nothing to do.
 
   StringRef Name(ArgName);
-  if (Name.equals("-I") || Name.equals("-L"))
+  if (Name.equals("-I") || Name.equals("-L") || Name.empty())
 CombinedArg = true;
 
   StringRef Dirs(DirList);

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.h 
b/clang/lib/Driver/ToolChains/CommonArgs.h
index 84b9d2cf59b4..bf1ab8153de7 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.h
+++ b/clang/lib/Driver/ToolChains/CommonArgs.h
@@ -94,6 +94,11 @@ bool areOptimizationsEnabled(const llvm::opt::ArgList &Args);
 
 bool isUseSeparateSections(const llvm::Triple &Triple);
 
+/// \p EnvVar is split by system delimiter for environment variables.
+/// If \p ArgName is "-I", "-L", or an empty string, each entry from \p EnvVar
+/// is prefixed by \p ArgName then added to \p Args. Otherwise, for each
+/// entry of \p EnvVar, \p ArgName is added to \p Args first, then the entry
+/// itself is added.
 void addDirectoryList(const llvm::opt::ArgList &Args,
   llvm::opt::ArgStringList &CmdArgs, const char *ArgName,
   const char *EnvVar);

diff  --git a/clang/lib/Driver/ToolChains/HIP.cpp 
b/clang/lib/Driver/ToolChains/HIP.cpp
index 7039ddeabd57..07af73421b7b 100644
--- a/clang/lib/Driver/ToolChains/HIP.cpp
+++ b/clang/lib/Driver/ToolChains/HIP.cpp
@@ -327,7 +327,7 @@ void HIPToolChain::addClangTargetOptions(
DriverArgs.getAllArgValues(options::OPT_hip_device_lib_path_EQ))
 LibraryPaths.push_back(DriverArgs.MakeArgString(Path));
 
-  addDirectoryList(DriverArgs, LibraryPaths, "-L", "HIP_DEVICE_LIB_PATH");
+  addDirectoryList(DriverArgs, LibraryPaths, "", "HIP_DEVICE_LIB_PATH");
 
   llvm::SmallVector BCLibs;
 

diff  --git a/clang/test/Driver/hip-device-libs.hip 
b/clang/test/Driver/hip-device-libs.hip
index 14401a947e6f..d546645a9d0b 100644
--- a/clang/test/Driver/hip-device-libs.hip
+++ b/clang/test/Driver/hip-device-libs.hip
@@ -19,6 +19,13 @@
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck %s --check-prefixes=COM,NOFLUSHD
 
+// Test environment variable HIP_DEVICE_LIB_PATH
+
+// RUN: HIP_DEVICE_LIB_PATH=%S/Inputs/hip_dev_lib \
+// RUN:   %clang -### -target x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx900 \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=COM
 
 // COM: {{"[^"]*clang[^"]*"}}
 // COM-SAME: "-mlink-builtin-bitcode" "{{.*}}hip.amdgcn.bc"



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


[PATCH] D71469: [AArch64] Add sq(r)dmulh_lane(q) LLVM IR intrinsics

2020-01-28 Thread Sanne Wouda via Phabricator via cfe-commits
sanwou01 marked 2 inline comments as done.
sanwou01 added a comment.

Thanks Eli.

> The "trick" is something like the following?
>  [...]

Yeah, that's exactly right. Your assessment of the options (dedicated pass, 
"volatile") matches our thinking as well. I'll update the commit message to 
make this a bit clearer.




Comment at: llvm/lib/IR/Function.cpp:1374
+  auto *RefVTy = dyn_cast(ArgTys[D.getArgumentNumber()]);
+  if (!VTy || !RefVTy || VTy->getBitWidth() != 64)
+return true;

efriedma wrote:
> Hardcoding "64" and "128" in target-independent code here seems like a bad 
> idea.
> 
> Can we just let both vector operands have any vector type, and reject in the 
> backend if we see an unexpected type?
Makes sense. Any type vector for both operands is certainly doable. Instruction 
selection will fail if you try to use a non-existent intrinsic, which is not 
the nicest failure mode, but probably good enough for intrinsics? Emitting the 
correct arm_neon.h for clang is a little less trivial, but not by too much.



Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:6054
+  if (VT.getSizeInBits() == 64)
+return std::make_pair(0U, &AArch64::FPR64_loRegClass);
   if (VT.getSizeInBits() == 128)

efriedma wrote:
> Is this related somehow?
This popped up when I was looking for uses of FPR128_loRegClass; it made sense 
to do the same for FPR64_lo. Doesn't seem essential though, so I'm happy to 
leave this out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71469



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


[PATCH] D72326: [clang-format] Rebased on master: Add option to specify explicit config file

2020-01-28 Thread Thibault North via Phabricator via cfe-commits
tnorth marked 7 inline comments as done.
tnorth added a comment.

> This makes sense for command-line args, but if I understand correctly this 
> patch will also allow BasedOnStyle: file:some/path. Is that the case?

No, it should not, and I also think it's better not to.

I think that all points are addressed now. Looking forward to have your 
feedback.


Repository:
  rC Clang

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

https://reviews.llvm.org/D72326



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


[clang] 39fe440 - [clang] Fix EOL whitespace. NFC

2020-01-28 Thread Jonathan Roelofs via cfe-commits

Author: Jonathan Roelofs
Date: 2020-01-28T08:47:37-07:00
New Revision: 39fe44024689cf6d10b249db8694efbdcc6afc14

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

LOG: [clang] Fix EOL whitespace. NFC

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 75919566aa83..72969490e32d 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -636,7 +636,7 @@ comments::FullComment *ASTContext::getCommentForDecl(
   return FC;
 }
 
-void 
+void
 ASTContext::CanonicalTemplateTemplateParm::Profile(llvm::FoldingSetNodeID &ID,
const ASTContext &C,
TemplateTemplateParmDecl *Parm) 
{



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


[PATCH] D73271: [clang][CodeComplete] Support for designated initializers

2020-01-28 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
kadircet marked 2 inline comments as done.
Closed by commit rG42e9478e0bbb: [clang][CodeComplete] Support for designated 
initializers (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73271

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseInit.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/desig-init.cpp

Index: clang/test/CodeCompletion/desig-init.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/desig-init.cpp
@@ -0,0 +1,54 @@
+struct Base {
+  int t;
+};
+struct Foo : public Base {
+  int x;
+  Base b;
+  void foo();
+};
+
+void foo() {
+  Foo F{.x = 2, .b.t = 0};
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:11:10 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:11:18 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC1 %s
+  // CHECK-CC1: COMPLETION: b : [#Base#]b
+  // CHECK-CC1-NEXT: COMPLETION: x : [#int#]x
+  // CHECK-CC1-NOT: foo
+  // CHECK-CC1-NOT: t
+
+  // FIXME: Handle nested designators
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:11:20 %s -o - | count 0
+
+  Base B = {.t = 2};
+  auto z = [](Base B) {};
+  z({.t = 1});
+  z(Base{.t = 2});
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:22:14 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:24:7 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:25:11 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC2 %s
+  // CHECK-CC2: COMPLETION: t : [#int#]t
+}
+
+// Handle templates
+template 
+struct Test { T x; };
+template <>
+struct Test {
+  int x;
+  char y;
+};
+void bar() {
+  Test T{.x = 2};
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:41:17 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC3 %s
+  // CHECK-CC3: COMPLETION: x : [#T#]x
+  Test X{.x = 2};
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:44:16 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC4 %s
+  // CHECK-CC4: COMPLETION: x : [#int#]x
+  // CHECK-CC4-NEXT: COMPLETION: y : [#char#]y
+}
+
+template 
+void aux() {
+  Test X{.x = T(2)};
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:52:14 %s -o - -std=c++2a | FileCheck -check-prefix=CHECK-CC3 %s
+}
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -13,6 +13,8 @@
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/DeclTemplate.h"
+#include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/QualTypeNames.h"
@@ -23,11 +25,14 @@
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
+#include "clang/Sema/Designator.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Overload.h"
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/ScopeInfo.h"
+#include "clang/Sema/Sema.h"
 #include "clang/Sema/SemaInternal.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/SmallBitVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -36,6 +41,7 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -4723,6 +4729,23 @@
   }
 }
 
+// Returns the RecordDecl inside the BaseType, falling back to primary template
+// in case of specializations. Since we might not have a decl for the
+// instantiation/specialization yet, e.g. dependent code.
+static RecordDecl *getAsRecordDecl(const QualType BaseType) {
+  if (auto *RD = BaseType->getAsRecordDecl())
+return RD;
+
+  if (const auto *TST = BaseType->getAs()) {
+if (const auto *TD = dyn_cast_or_null(
+TST->getTemplateName().getAsTemplateDecl())) {
+  return TD->getTemplatedDecl();
+}
+  }
+
+  return nullptr;
+}
+
 void Sema::CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
Expr *OtherOpBase,
SourceLocation OpLoc, bool IsArrow,
@@ -4771,6 +4794,8 @@
 Base = ConvertedBas

[PATCH] D72326: [clang-format] Rebased on master: Add option to specify explicit config file

2020-01-28 Thread Thibault North via Phabricator via cfe-commits
tnorth updated this revision to Diff 240888.
tnorth added a comment.

- Add a unit-test loading a format and test file from temporary files.


Repository:
  rC Clang

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

https://reviews.llvm.org/D72326

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -14350,6 +14350,59 @@
   auto StyleTd = getStyle("file", "x.td", "llvm", "", &FS);
   ASSERT_TRUE((bool)StyleTd);
   ASSERT_EQ(*StyleTd, getLLVMStyle(FormatStyle::LK_TableGen));
+
+  // Test 9: explicit format file in parent directory.
+  ASSERT_TRUE(
+  FS.addFile("/e/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: LLVM")));
+  ASSERT_TRUE(
+  FS.addFile("/e/explicit.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  ASSERT_TRUE(FS.addFile("/e/sub/sub/sub/test.cpp", 0,
+ llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style8 = getStyle("file:/e/explicit.clang-format",
+ "/e/sub/sub/sub/test.cpp", "LLVM", "", &FS);
+  ASSERT_TRUE((bool)Style8);
+  ASSERT_EQ(*Style8, getGoogleStyle());
+
+  // Test 10: relative pah to a format file
+  ASSERT_TRUE(
+  FS.addFile("../../e/explicit.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  auto Style9 = getStyle("file:../../e/explicit.clang-format",
+ "/e/sub/sub/sub/test.cpp", "LLVM", "", &FS);
+  ASSERT_TRUE((bool)Style9);
+  ASSERT_EQ(*Style9, getGoogleStyle());
+
+  // Test 11: missing explicit format file
+  auto Style10 = getStyle("file:/e/missing.clang-format",
+  "/e/sub/sub/sub/test.cpp", "LLVM", "", &FS);
+  ASSERT_FALSE((bool)Style10);
+  llvm::consumeError(Style10.takeError());
+
+  // Test 12: format file from the filesystem
+  SmallString<128> FormatFilePath;
+  std::error_code ECF = llvm::sys::fs::createTemporaryFile("FormatFileTest", "tpl", FormatFilePath);
+  EXPECT_FALSE((bool)ECF);
+  llvm::raw_fd_ostream  FormatFileTest(FormatFilePath, ECF);
+  EXPECT_FALSE((bool)ECF);
+  FormatFileTest << "BasedOnStyle: Google\n";
+  FormatFileTest.close();
+
+  SmallString<128> TestFilePath;
+  std::error_code ECT = llvm::sys::fs::createTemporaryFile("CodeFileTest", "cc", TestFilePath);
+  EXPECT_FALSE((bool)ECT);
+  llvm::raw_fd_ostream  CodeFileTest(TestFilePath, ECT);
+  CodeFileTest << "int i;\n";
+  CodeFileTest.close();
+
+  std::string format_file_arg = std::string("file:") + FormatFilePath.c_str();
+  auto Style11 = getStyle(format_file_arg, TestFilePath, "LLVM", "", nullptr);
+  
+  llvm::sys::fs::remove(FormatFilePath.c_str());
+  llvm::sys::fs::remove(TestFilePath.c_str());
+  ASSERT_TRUE((bool)Style11);
+  ASSERT_EQ(*Style11, getGoogleStyle());
 }
 
 TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -2519,6 +2519,8 @@
 ".clang-format file located in one of the parent\n"
 "directories of the source file (or current\n"
 "directory for stdin).\n"
+"Use -style=file: to explicitly specify"
+"the configuration file.\n"
 "Use -style=\"{key: value, ...}\" to set specific\n"
 "parameters, e.g.:\n"
 "  -style=\"{BasedOnStyle: llvm, IndentWidth: 8}\"";
@@ -2568,6 +2570,22 @@
 
 const char *DefaultFallbackStyle = "LLVM";
 
+/// Attempts to load a format file
+llvm::Expected LoadConfigFile(StringRef ConfigFile, llvm::vfs::FileSystem *FS) {
+  llvm::ErrorOr> Text =
+  FS->getBufferForFile(ConfigFile.str());
+  std::error_code ReadFileError = Text.getError();
+  if (ReadFileError) {
+return make_string_error("Error reading config file " + ReadFileError.message());
+  }
+  FormatStyle Style = getLLVMStyle();
+  std::error_code ParseFileError = parseConfiguration(Text.get()->getBuffer(), &Style);
+  if (ParseFileError != ParseError::Success) {
+return make_string_error("Error parsing config file " + ParseFileError.message());
+  }
+  return Style;
+}
+
 llvm::Expected getStyle(StringRef StyleName, StringRef FileName,
  StringRef FallbackStyleName,
  StringRef Code,
@@ -2588,6 +2606,12 @@
 return Style;
   }
 
+  // User provided clang-format file using -style=file:/path/to/format/file
+  // Check for explicit config filename
+  if (StyleName.startswith_lower("file:")) {
+return LoadConfigFile(StyleName.substr(5), FS);
+  }
+
   if (!StyleName.equals_lower("file")) {
 if (!getPredefinedStyle(StyleName, Style.Language, &Style))
   return make_string_error("Invalid value for -style");
@@ -2628,24 +2652,7 @@
  

[clang] 42e9478 - [clang][CodeComplete] Support for designated initializers

2020-01-28 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-01-28T16:34:15+01:00
New Revision: 42e9478e0bbbe3468a74d9d07275a61558b220c4

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

LOG: [clang][CodeComplete] Support for designated initializers

Reviewers: sammccall

Subscribers: cfe-commits

Tags: #clang

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

Added: 
clang/test/CodeCompletion/desig-init.cpp

Modified: 
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Parse/ParseInit.cpp
clang/lib/Sema/SemaCodeComplete.cpp

Removed: 




diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 187982387487..d1e97843f599 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -1952,7 +1952,8 @@ class Parser : public CodeCompletionHandler {
   }
   bool MayBeDesignationStart();
   ExprResult ParseBraceInitializer();
-  ExprResult ParseInitializerWithPotentialDesignator();
+  ExprResult ParseInitializerWithPotentialDesignator(
+  llvm::function_ref CodeCompleteCB);
 
   
//======//
   // clang Expressions

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 5a33e4aa6ffc..bc77989ad35d 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11555,6 +11555,12 @@ class Sema final {
   IdentifierInfo *II,
   SourceLocation OpenParLoc);
   void CodeCompleteInitializer(Scope *S, Decl *D);
+  /// Trigger code completion for a record of \p BaseType. \p InitExprs are
+  /// expressions in the initializer list seen so far and \p D is the current
+  /// Designation being parsed.
+  void CodeCompleteDesignator(const QualType BaseType,
+  llvm::ArrayRef InitExprs,
+  const Designation &D);
   void CodeCompleteAfterIf(Scope *S);
 
   void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool 
EnteringContext,

diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 4af993c4527f..871ca2512598 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -2460,6 +2460,7 @@ Decl 
*Parser::ParseDeclarationAfterDeclaratorAndAttributes(
 
 InitializerScopeRAII InitScope(*this, D, ThisDecl);
 
+PreferredType.enterVariableInit(Tok.getLocation(), ThisDecl);
 ExprResult Init(ParseBraceInitializer());
 
 InitScope.pop();

diff  --git a/clang/lib/Parse/ParseExprCXX.cpp 
b/clang/lib/Parse/ParseExprCXX.cpp
index 5b604f940ab8..1a8e0342cb08 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -1866,6 +1866,7 @@ Parser::ParseCXXTypeConstructExpression(const DeclSpec 
&DS) {
  && "Expected '(' or '{'!");
 
   if (Tok.is(tok::l_brace)) {
+PreferredType.enterTypeCast(Tok.getLocation(), TypeRep.get());
 ExprResult Init = ParseBraceInitializer();
 if (Init.isInvalid())
   return Init;

diff  --git a/clang/lib/Parse/ParseInit.cpp b/clang/lib/Parse/ParseInit.cpp
index 5ab055130dc2..9ac2b2e6f79b 100644
--- a/clang/lib/Parse/ParseInit.cpp
+++ b/clang/lib/Parse/ParseInit.cpp
@@ -10,11 +10,14 @@
 //
 
//===--===//
 
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Parse/ParseDiagnostic.h"
 #include "clang/Parse/Parser.h"
 #include "clang/Parse/RAIIObjectsForParser.h"
 #include "clang/Sema/Designator.h"
+#include "clang/Sema/Ownership.h"
 #include "clang/Sema/Scope.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 using namespace clang;
 
@@ -154,7 +157,9 @@ static void CheckArrayDesignatorSyntax(Parser &P, 
SourceLocation Loc,
 /// initializer (because it is an expression).  We need to consider this case
 /// when parsing array designators.
 ///
-ExprResult Parser::ParseInitializerWithPotentialDesignator() {
+/// \p CodeCompleteCB is called with Designation parsed so far.
+ExprResult Parser::ParseInitializerWithPotentialDesignator(
+llvm::function_ref CodeCompleteCB) {
 
   // If this is the old-style GNU extension:
   //   designation ::= identifier ':'
@@ -193,6 +198,11 @@ ExprResult 
Parser::ParseInitializerWithPotentialDesignator() {
   // designator: '.' identifier
   SourceLocation DotLoc = ConsumeToken();
 
+  if (Tok.is(tok::code_completion)) {
+CodeCompleteCB(Desig);
+cutOffParsing();
+return ExprError();
+  }
   if (Tok.isNot(tok::identifier)) {
 Diag(Tok.getLocation(), diag::err_expected_field_designator);

[PATCH] D73285: [OpenMP][OMPIRBuilder][BugFix] Handle Unreachable Finalization blocks in `parallel` generation

2020-01-28 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim updated this revision to Diff 240886.
fghanim added a comment.

Adding lit test to clang for testing the fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73285

Files:
  clang/test/OpenMP/parallel_codegen.cpp


Index: clang/test/OpenMP/parallel_codegen.cpp
===
--- clang/test/OpenMP/parallel_codegen.cpp
+++ clang/test/OpenMP/parallel_codegen.cpp
@@ -21,11 +21,13 @@
 // CHECK-DEBUG-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* }
 // CHECK-DEBUG-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] 
c";unknown;unknown;0;0;;\00"
 // CHECK-DEBUG-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr global 
%struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x 
i8], [23 x i8]* [[STR]], i32 0, i32 0) }
-// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x i8] 
c";{{.*}}parallel_codegen.cpp;main;[[@LINE+22]];1;;\00"
-// CHECK-DEBUG-DAG: [[LOC2:@.+]] = private unnamed_addr constant [{{.+}} x i8] 
c";{{.*}}parallel_codegen.cpp;tmain;[[@LINE+11]];1;;\00"
+// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x i8] 
c";{{.*}}parallel_codegen.cpp;main;[[@LINE+29]];1;;\00"
+// CHECK-DEBUG-DAG: [[LOC2:@.+]] = private unnamed_addr constant [{{.+}} x i8] 
c";{{.*}}parallel_codegen.cpp;tmain;[[@LINE+13]];1;;\00"
+// CHECK-DEBUG-DAG: [[LOC3:@.+]] = private unnamed_addr constant [{{.+}} x i8] 
c";{{.*}}parallel_codegen.cpp;tmain;[[@LINE+19]];1;;\00"
 // IRBUILDER-DEBUG-DAG: %struct.ident_t = type { i32, i32, i32, i32, i8* }
-// IRBUILDER-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x 
i8] c";{{.*}}parallel_codegen.cpp;main;[[@LINE+19]];0;;\00"
-// IRBUILDER-DEBUG-DAG: [[LOC2:@.+]] = private unnamed_addr constant [{{.+}} x 
i8] c";{{.*}}parallel_codegen.cpp;tmain;[[@LINE+8]];0;;\00"
+// IRBUILDER-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x 
i8] c";{{.*}}parallel_codegen.cpp;main;[[@LINE+25]];0;;\00"
+// IRBUILDER-DEBUG-DAG: [[LOC2:@.+]] = private unnamed_addr constant [{{.+}} x 
i8] c";{{.*}}parallel_codegen.cpp;tmain;[[@LINE+9]];0;;\00"
+// IRBUILDER-DEBUG-DAG: [[LOC3:@.+]] = private unnamed_addr constant [{{.+}} x 
i8] c";{{.*}}parallel_codegen.cpp;tmain;[[@LINE+15]];0;;\00"
 
 template 
 void foo(T argc) {}
@@ -38,6 +40,11 @@
   foo(argc);
   chunk_t var;(void)var[0][0];
   }
+
+  if (argc[1])
+#pragma omp parallel
+   while(1);
+
   return 0;
 }
 
@@ -113,6 +120,8 @@
 // ALL:   store i8** %argc, i8*** [[ARGC_ADDR:%.+]],
 // CHECK:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void 
(i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***, i{{64|32}})* 
[[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], 
i{{64|32}} %{{.+}})
 // IRBUILDER:   call {{.*}}void (%struct.ident_t*, i32, void (i32*, i32*, 
...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 2, void 
(i32*, i32*, ...)* bitcast (void (i32*, i32*, i8***, i{{64|32}})* 
[[OMP_OUTLINED:@.+]] to void (i32*, i32*, ...)*), i8*** [[ARGC_ADDR]], 
i{{64|32}} %{{.+}})
+// CHECK-DAG:  call {{.*}}void (%struct.ident_t*, i32, void 
(i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 
0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OMP_OUTLINED1:@.+]] to 
void (i32*, i32*, ...)*))
+// IRBUILDER-DAG:  call {{.*}}void (%struct.ident_t*, i32, void (i32*, 
i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* [[DEF_LOC_2]], i32 0, void 
(i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OMP_OUTLINED1:@.+]] to void 
(i32*, i32*, ...)*))
 // ALL:  ret i32 0
 // ALL-NEXT:  }
 // ALL-DEBUG:   define linkonce_odr i32 [[TMAIN]](i8** %argc)
@@ -128,6 +137,13 @@
 // ALL-DEBUG:  ret i32 0
 // ALL-DEBUG-NEXT:  }
 
+// IRBUILDER:   define internal {{.*}}void [[OMP_OUTLINED1]](i32* noalias 
%{{.*}}, i32* noalias %{{.*}})
+// IRBUILDER-SAME:  #[[FN_ATTRS:[0-9]+]]
+// IRBUILDER:  br label %while.body
+// IRBUILDER-NOT:  ret %{{.*}}
+// IRBUILDER:  br label %while.body
+// IRBUILDER-NOT:  ret %{{.*}}
+
 // CHECK:   define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias 
%.global_tid., i32* noalias %.bound_tid., i8*** dereferenceable({{4|8}}) %argc, 
i{{64|32}}{{.*}} %{{.+}})
 // IRBUILDER:   define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias 
%{{.*}}, i32* noalias %{{.*}}, i8*** [[ARGC_REF:%.*]], i{{64|32}}{{.*}} %{{.+}})
 // CHECK:   store i8*** %argc, i8 [[ARGC_PTR_ADDR:%.+]],
@@ -152,6 +168,12 @@
 // CHECK-DEBUG-NEXT:  }
 
 // ALL: define linkonce_odr {{.*}}void [[FOO1]](i8** %argc)
+// CHECK:   define internal {{.*}}void [[OMP_OUTLINED1]](i32* noalias 
%.global_tid., i32* noalias %.bound_tid.)
+// CHECK-SAME:  #[[FN_ATTRS:[0-9]+]]
+// CHECK:   

[PATCH] D73495: [CodeGen] Attach no-builtin attributes to function definitions with no Decl

2020-01-28 Thread Francis Visoiu Mistrih via Phabricator via cfe-commits
thegameg marked 2 inline comments as done.
thegameg added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:1917
 const auto *NBA = Fn->getAttr();
-bool HasWildcard = NBA && llvm::is_contained(NBA->builtinNames(), "*");
-if (getLangOpts().NoBuiltin || HasWildcard)
-  FuncAttrs.addAttribute("no-builtins");
-else {
-  auto AddNoBuiltinAttr = [&FuncAttrs](StringRef BuiltinName) {
-SmallString<32> AttributeName;
-AttributeName += "no-builtin-";
-AttributeName += BuiltinName;
-FuncAttrs.addAttribute(AttributeName);
-  };
-  llvm::for_each(getLangOpts().NoBuiltinFuncs, AddNoBuiltinAttr);
-  if (NBA)
-llvm::for_each(NBA->builtinNames(), AddNoBuiltinAttr);
-}
+addNonCallSiteNoBuiltinAttributes(FuncAttrs, getLangOpts(), NBA);
   }

efriedma wrote:
> thegameg wrote:
> > efriedma wrote:
> > > What happens if we have a TargetDecl that isn't a FunctionDecl?  (I think 
> > > this happens in some cases, but not completely sure which, exactly.)
> > It looks like that can be triggered by indirect calls:
> > 
> > ```
> > typedef void T(void);
> > void test3(T f) {
> >   f();
> > }
> > ```
> > 
> > Since this adds the attribute to definitions and not to call sites, we 
> > should never need that.
> > 
> > This patch is for the case where `CreateGlobalInitOrDestructFunction` ends 
> > up re-using the same function to attach the attributes.
> > 
> > I'll update the description to make it more clear.
> Are you sure that's the only case where the TargetDecl isn't a FunctionDecl?  
> I'm afraid there might be some weird case where the TargetDecl defines 
> something like a function, but isn't technically a FunctionDecl. Maybe an 
> ObjC method or something like that.  And then we end up in a situation where 
> addNonCallSiteNoBuiltinAttributes is never called.
Right, it looks like in the test suite this triggers on:

* BlockDecl
* ObjCMethodDecl
* CapturedDecl

I think we should call `addNonCallSiteNoBuiltinAttributes` for these too.


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

https://reviews.llvm.org/D73495



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


[PATCH] D73538: [clangd] Make bin/llvm-lit run standalone clangd tests

2020-01-28 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcb74d2e1bdec: [clangd] Make bin/llvm-lit run standalone 
clangd tests (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73538

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


Index: clang-tools-extra/clangd/test/CMakeLists.txt
===
--- clang-tools-extra/clangd/test/CMakeLists.txt
+++ clang-tools-extra/clangd/test/CMakeLists.txt
@@ -29,7 +29,10 @@
 
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py)
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
+  MAIN_CONFIG
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
+  )
 
 add_lit_testsuite(check-clangd "Running the Clangd regression tests"
   ${CMAKE_CURRENT_BINARY_DIR}/../unittests;${CMAKE_CURRENT_BINARY_DIR}


Index: clang-tools-extra/clangd/test/CMakeLists.txt
===
--- clang-tools-extra/clangd/test/CMakeLists.txt
+++ clang-tools-extra/clangd/test/CMakeLists.txt
@@ -29,7 +29,10 @@
 
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py)
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
+  MAIN_CONFIG
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
+  )
 
 add_lit_testsuite(check-clangd "Running the Clangd regression tests"
   ${CMAKE_CURRENT_BINARY_DIR}/../unittests;${CMAKE_CURRENT_BINARY_DIR}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] cb74d2e - [clangd] Make bin/llvm-lit run standalone clangd tests

2020-01-28 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-01-28T16:17:58+01:00
New Revision: cb74d2e1bdec8510f4ddd41e1ec879d745f40597

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

LOG: [clangd] Make bin/llvm-lit run standalone clangd tests

Summary:
Currently clangd lit tests can't be run in isolation because we don't
set some of the config parameters. This enables running

./bin/llvm-lit ../clang-tools-extra/clangd/test/

or any other test in that subdirectory.

Reviewers: sammccall

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

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/test/CMakeLists.txt 
b/clang-tools-extra/clangd/test/CMakeLists.txt
index bbb582f1aa8e..1054fd593bfa 100644
--- a/clang-tools-extra/clangd/test/CMakeLists.txt
+++ b/clang-tools-extra/clangd/test/CMakeLists.txt
@@ -29,7 +29,10 @@ endforeach()
 
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py)
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
+  MAIN_CONFIG
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
+  )
 
 add_lit_testsuite(check-clangd "Running the Clangd regression tests"
   ${CMAKE_CURRENT_BINARY_DIR}/../unittests;${CMAKE_CURRENT_BINARY_DIR}



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


[PATCH] D73354: clang-format: insert trailing commas into containers.

2020-01-28 Thread Martin Probst via Phabricator via cfe-commits
mprobst marked 6 inline comments as done.
mprobst added a comment.

PTAL.




Comment at: clang/include/clang/Format/Format.h:552
+/// Insert trailing commas in container literals that were wrapped over
+/// multiple lines.
+TCS_Wrapped,

mprobst wrote:
> sammccall wrote:
> > Hadn't occurred to me that this will interact with bin-packing. That seems 
> > to increase the chances of going over the column limit :(
> Uh. Turns out we don't have a separate option for bin packing containers, 
> only for bin packing arguments and parameters.
> 
> Should we add that option to make this setting work?
> Should we have this setting imply bin packing containers (as opposed to 
> parameters) is disabled?
OK, so I added a bit of validation logic to reject bin packing arguments 
together with TSC_Wrapped. We can figure out in a next step whether we want to 
expose an option for bin packing containers, or whether we can just disable bin 
packing for those people who want trailing commas.



Comment at: clang/unittests/Format/FormatTestJS.cpp:1229
"  (param): param is {\n"
-   "a: SomeType\n"
+   "a: SomeType;\n"
"  }&ABC => 1)\n"

MyDeveloperDay wrote:
> mprobst wrote:
> > MyDeveloperDay wrote:
> > > is this correct?
> > Yes, type definitions should use `;`
> if you hadn't added this to the test would it have added a "," ?
More precisely:
you can  use either `;` or `,` to separate entries in object literal types. So 
using `;` is correct here, but c-f with this option would insert a `,`, which 
is correct as well. I've added a test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73354



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


[PATCH] D73354: clang-format: insert trailing commas into containers.

2020-01-28 Thread Martin Probst via Phabricator via cfe-commits
mprobst updated this revision to Diff 240873.
mprobst marked an inline comment as done.
mprobst added a comment.

- - only run comma insertion for JavaScript.
- review fixes
- Fix col limit
- test for comma insertion
- - validate options, reject bin packing + trailing commas


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73354

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/FormatTestJS.cpp

Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -878,6 +878,45 @@
"]);");
 }
 
+TEST_F(FormatTestJS, TrailingCommaInsertion) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
+  Style.InsertTrailingCommas = FormatStyle::TCS_Wrapped;
+  // Insert comma in wrapped array.
+  verifyFormat("const x = [\n"
+   "  1,  //\n"
+   "  2,\n"
+   "];",
+   "const x = [\n"
+   "  1,  //\n"
+   "  2];",
+   Style);
+  // Insert comma in newly wrapped array.
+  Style.ColumnLimit = 30;
+  verifyFormat("const x = [\n"
+   "  a,\n"
+   "];",
+   "const x = [a];", Style);
+  // Do not insert trailing commas if they'd exceed the colum limit
+  verifyFormat("const x = [\n"
+   "  \n"
+   "];",
+   "const x = [];", Style);
+  // Object literals.
+  verifyFormat("const x = {\n"
+   "  a: a,\n"
+   "};",
+   "const x = {a: a};", Style);
+  verifyFormat("const x = {\n"
+   "  a: a\n"
+   "};",
+   "const x = {a: a};", Style);
+  // Object literal types.
+  verifyFormat("let x: {\n"
+   "  a: a,\n"
+   "};",
+   "let x: {a: a};", Style);
+}
+
 TEST_F(FormatTestJS, FunctionLiterals) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
   Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13031,6 +13031,12 @@
"IndentWidth: 34",
&Style),
 ParseError::Unsuitable);
+  FormatStyle BinPackedTCS = {};
+  BinPackedTCS.Language = FormatStyle::LK_JavaScript;
+  EXPECT_EQ(parseConfiguration("BinPackArguments: true\n"
+   "InsertTrailingCommas: Wrapped",
+   &BinPackedTCS),
+ParseError::BinBackTrailingCommaConflict);
   EXPECT_EQ(12u, Style.IndentWidth);
   CHECK_PARSE("IndentWidth: 56", IndentWidth, 56u);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style.Language);
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -157,6 +157,13 @@
   }
 };
 
+template <> struct ScalarEnumerationTraits {
+  static void enumeration(IO &IO, FormatStyle::TrailingCommaStyle &Value) {
+IO.enumCase(Value, "None", FormatStyle::TCS_None);
+IO.enumCase(Value, "Wrapped", FormatStyle::TCS_Wrapped);
+  }
+};
+
 template <> struct ScalarEnumerationTraits {
   static void enumeration(IO &IO, FormatStyle::BinaryOperatorStyle &Value) {
 IO.enumCase(Value, "All", FormatStyle::BOS_All);
@@ -486,6 +493,7 @@
 IO.mapOptional("IndentWidth", Style.IndentWidth);
 IO.mapOptional("IndentWrappedFunctionNames",
Style.IndentWrappedFunctionNames);
+IO.mapOptional("InsertTrailingCommas", Style.InsertTrailingCommas);
 IO.mapOptional("JavaImportGroups", Style.JavaImportGroups);
 IO.mapOptional("JavaScriptQuotes", Style.JavaScriptQuotes);
 IO.mapOptional("JavaScriptWrapImports", Style.JavaScriptWrapImports);
@@ -644,6 +652,8 @@
 return "Invalid argument";
   case ParseError::Unsuitable:
 return "Unsuitable";
+  case ParseError::BinBackTrailingCommaConflict:
+return "trailing comma insertion cannot be used with bin packing";
   }
   llvm_unreachable("unexpected parse error");
 }
@@ -788,6 +798,7 @@
   LLVMStyle.IndentPPDirectives = FormatStyle::PPDIS_None;
   LLVMStyle.IndentWrappedFunctionNames = false;
   LLVMStyle.IndentWidth = 2;
+  LLVMStyle.InsertTrailingCommas = FormatStyle::TCS_None;
   LLVMStyle.JavaScriptQuotes = FormatStyle::JSQS_Leave;
   LLVMStyle.JavaScriptWrapImports = true;
   LLVMStyle.TabWidth = 8;
@@ -9

[PATCH] D73548: [clang-tidy] Added option for disabling const qualifiers in readability-qualified-auto

2020-01-28 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst:41
+   auto *const Bar = cast(Baz2);
+   auto *volatile FooBar = cast(Baz3);
+

Is it worth adding an example of a double pointer?

auto BarN = cast(FooN);

Does that become `auto*` or `auto**` (and why)? My wild guess is that it 
becomes `auto*` (and because nobody cares about double pointers), but I could 
be wrong.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst:64
+
+   Otherwise it will get be transformed into:
+

s/Will be/will be/
s/will get be/will be/

In the preceding section you give an example with `volatile`. How about here? 
What happens with

auto *volatile Foo3 = cast(Bar3);
auto *Foo4 = cast(Bar4);

Do they become

const auto *volatile Foo3 = cast(Bar3);
volatile auto *Foo4 = cast(Bar4);

as I would expect?



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst:69
+   const auto *Foo1 = cast(Bar1);
+   const auto &Foo2 = cast(Bar2);
+

How does this option interact with

const int range[10];
for (auto&& elt : range)

Does it (incorrectly IMHO) make that `const auto&& elt`, or (correctly IMHO) 
`const auto& elt`, or (also correctly) leave it as [`auto&&`, which Always 
Works](https://quuxplusone.github.io/blog/2018/12/15/autorefref-always-works/)?



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/llvm-qualified-auto.cpp:20
+  auto &NakedRef = *getIntPtr();
+  auto &NakedConstRef = *getCIntPtr();
+}

It is worth adding one test case to show that the LLVM alias does not 
gratuitously //remove// `const` from declarations:

auto const &ExtendedConstPtr = getCIntPtr();
// becomes
auto *const &ExtendedConstPtr = getCIntPtr();


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73548



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


[PATCH] D73548: [clang-tidy] Added option for disabling const qualifiers in readability-qualified-auto

2020-01-28 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62260 tests passed, 0 failed 
and 827 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73548



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


[PATCH] D73437: [mlir][spirv] Convert linalg.generic for reduction to SPIR-V ops

2020-01-28 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62199 tests passed, 0 failed 
and 815 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73437



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


[PATCH] D73492: [clang-format] Handle quotes and escaped braces in C# interpolated strings

2020-01-28 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9d212e83e920: [clang-format] Handle quotes and escaped 
braces in C# interpolated strings (authored by Jonathan Coe 
).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73492

Files:
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/FormatTokenLexer.h
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -417,5 +417,13 @@
   verifyFormat(R"(string str = $@"""Hello {friend}""")", Style);
 }
 
+TEST_F(FormatTestCSharp, CSharpQuotesInInterpolatedStrings) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  verifyFormat(R"(string str1 = $"{null ?? "null"}";)", Style);
+  verifyFormat(R"(string str2 = $"{{{braceCount} braces";)", Style);
+  verifyFormat(R"(string str3 = $"{braceCount}}} braces";)", Style);
+}
+
 } // namespace format
 } // end namespace clang
Index: clang/lib/Format/FormatTokenLexer.h
===
--- clang/lib/Format/FormatTokenLexer.h
+++ clang/lib/Format/FormatTokenLexer.h
@@ -49,7 +49,7 @@
   bool tryMergeLessLess();
   bool tryMergeNSStringLiteral();
   bool tryMergeJSPrivateIdentifier();
-  bool tryMergeCSharpVerbatimStringLiteral();
+  bool tryMergeCSharpStringLiteral();
   bool tryMergeCSharpKeywordVariables();
   bool tryMergeCSharpNullConditionals();
   bool tryMergeCSharpDoubleQuestion();
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -74,7 +74,7 @@
   if (Style.isCSharp()) {
 if (tryMergeCSharpKeywordVariables())
   return;
-if (tryMergeCSharpVerbatimStringLiteral())
+if (tryMergeCSharpStringLiteral())
   return;
 if (tryMergeCSharpDoubleQuestion())
   return;
@@ -181,18 +181,68 @@
 // Search for verbatim or interpolated string literals @"ABC" or
 // $"a{abc}a" i and mark the token as TT_CSharpStringLiteral, and to
 // prevent splitting of @, $ and ".
-bool FormatTokenLexer::tryMergeCSharpVerbatimStringLiteral() {
+bool FormatTokenLexer::tryMergeCSharpStringLiteral() {
   if (Tokens.size() < 2)
 return false;
 
-  auto &String = *(Tokens.end() - 1);
-  if (!String->is(tok::string_literal))
-return false;
+  auto &CSharpStringLiteral = *(Tokens.end() - 2);
+
+  // Interpolated strings could contain { } with " characters inside.
+  // $"{x ?? "null"}"
+  // should not be split into $"{x ?? ", null, "}" but should treated as a
+  // single string-literal.
+  //
+  // We opt not to try and format expressions inside {} within a C#
+  // interpolated string. Formatting expressions within an interpolated string
+  // would require similar work as that done for JavaScript template strings
+  // in `handleTemplateStrings()`.
+  auto &CSharpInterpolatedString = *(Tokens.end() - 2);
+  if (CSharpInterpolatedString->Type == TT_CSharpStringLiteral &&
+  (CSharpInterpolatedString->TokenText.startswith(R"($")") ||
+   CSharpInterpolatedString->TokenText.startswith(R"($@")"))) {
+int UnmatchedOpeningBraceCount = 0;
+
+auto TokenTextSize = CSharpInterpolatedString->TokenText.size();
+for (size_t Index = 0; Index < TokenTextSize; ++Index) {
+  char C = CSharpInterpolatedString->TokenText[Index];
+  if (C == '{') {
+// "{{"  inside an interpolated string is an escaped '{' so skip it.
+if (Index + 1 < TokenTextSize &&
+CSharpInterpolatedString->TokenText[Index + 1] == '{') {
+  ++Index;
+  continue;
+}
+++UnmatchedOpeningBraceCount;
+  } else if (C == '}') {
+// "}}"  inside an interpolated string is an escaped '}' so skip it.
+if (Index + 1 < TokenTextSize &&
+CSharpInterpolatedString->TokenText[Index + 1] == '}') {
+  ++Index;
+  continue;
+}
+--UnmatchedOpeningBraceCount;
+  }
+}
+
+if (UnmatchedOpeningBraceCount > 0) {
+  auto &NextToken = *(Tokens.end() - 1);
+  CSharpInterpolatedString->TokenText =
+  StringRef(CSharpInterpolatedString->TokenText.begin(),
+NextToken->TokenText.end() -
+CSharpInterpolatedString->TokenText.begin());
+  CSharpInterpolatedString->ColumnWidth += NextToken->ColumnWidth;
+  Tokens.erase(Tokens.end() - 1);
+  return true;
+}
+  }
 
   // verbatim strings could contain "" which C# sees as an escaped ".
   // @"""Hello""" will have been tokenized as @"" "Hello" "" and needs
   // merging into a sin

[PATCH] D73437: [mlir][spirv] Convert linalg.generic for reduction to SPIR-V ops

2020-01-28 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon question-circle color=gray} clang-format: unknown.

Build artifacts 
: 
diff.json 
,
 console-log.txt 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73437



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


[clang] 9d212e8 - [clang-format] Handle quotes and escaped braces in C# interpolated strings

2020-01-28 Thread Jonathan Coe via cfe-commits

Author: Jonathan Coe
Date: 2020-01-28T14:46:27Z
New Revision: 9d212e83e920363762eb265293adf0bd6fda5a13

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

LOG: [clang-format] Handle quotes and escaped braces in C# interpolated strings

Summary:
This addresses issues raised in https://bugs.llvm.org/show_bug.cgi?id=44454.

There are outstanding issues with multi-line verbatim strings in C# that will 
be addressed in a follow-up PR.

Reviewers: krasimir, MyDeveloperDay

Reviewed By: krasimir, MyDeveloperDay

Subscribers: MyDeveloperDay

Tags: #clang-format

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

Added: 


Modified: 
clang/lib/Format/FormatTokenLexer.cpp
clang/lib/Format/FormatTokenLexer.h
clang/unittests/Format/FormatTestCSharp.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatTokenLexer.cpp 
b/clang/lib/Format/FormatTokenLexer.cpp
index d8dfe17fb89c..ba0bbf68f12f 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -74,7 +74,7 @@ void FormatTokenLexer::tryMergePreviousTokens() {
   if (Style.isCSharp()) {
 if (tryMergeCSharpKeywordVariables())
   return;
-if (tryMergeCSharpVerbatimStringLiteral())
+if (tryMergeCSharpStringLiteral())
   return;
 if (tryMergeCSharpDoubleQuestion())
   return;
@@ -181,18 +181,68 @@ bool FormatTokenLexer::tryMergeJSPrivateIdentifier() {
 // Search for verbatim or interpolated string literals @"ABC" or
 // $"a{abc}a" i and mark the token as TT_CSharpStringLiteral, and to
 // prevent splitting of @, $ and ".
-bool FormatTokenLexer::tryMergeCSharpVerbatimStringLiteral() {
+bool FormatTokenLexer::tryMergeCSharpStringLiteral() {
   if (Tokens.size() < 2)
 return false;
 
-  auto &String = *(Tokens.end() - 1);
-  if (!String->is(tok::string_literal))
-return false;
+  auto &CSharpStringLiteral = *(Tokens.end() - 2);
+
+  // Interpolated strings could contain { } with " characters inside.
+  // $"{x ?? "null"}"
+  // should not be split into $"{x ?? ", null, "}" but should treated as a
+  // single string-literal.
+  //
+  // We opt not to try and format expressions inside {} within a C#
+  // interpolated string. Formatting expressions within an interpolated string
+  // would require similar work as that done for JavaScript template strings
+  // in `handleTemplateStrings()`.
+  auto &CSharpInterpolatedString = *(Tokens.end() - 2);
+  if (CSharpInterpolatedString->Type == TT_CSharpStringLiteral &&
+  (CSharpInterpolatedString->TokenText.startswith(R"($")") ||
+   CSharpInterpolatedString->TokenText.startswith(R"($@")"))) {
+int UnmatchedOpeningBraceCount = 0;
+
+auto TokenTextSize = CSharpInterpolatedString->TokenText.size();
+for (size_t Index = 0; Index < TokenTextSize; ++Index) {
+  char C = CSharpInterpolatedString->TokenText[Index];
+  if (C == '{') {
+// "{{"  inside an interpolated string is an escaped '{' so skip it.
+if (Index + 1 < TokenTextSize &&
+CSharpInterpolatedString->TokenText[Index + 1] == '{') {
+  ++Index;
+  continue;
+}
+++UnmatchedOpeningBraceCount;
+  } else if (C == '}') {
+// "}}"  inside an interpolated string is an escaped '}' so skip it.
+if (Index + 1 < TokenTextSize &&
+CSharpInterpolatedString->TokenText[Index + 1] == '}') {
+  ++Index;
+  continue;
+}
+--UnmatchedOpeningBraceCount;
+  }
+}
+
+if (UnmatchedOpeningBraceCount > 0) {
+  auto &NextToken = *(Tokens.end() - 1);
+  CSharpInterpolatedString->TokenText =
+  StringRef(CSharpInterpolatedString->TokenText.begin(),
+NextToken->TokenText.end() -
+CSharpInterpolatedString->TokenText.begin());
+  CSharpInterpolatedString->ColumnWidth += NextToken->ColumnWidth;
+  Tokens.erase(Tokens.end() - 1);
+  return true;
+}
+  }
 
   // verbatim strings could contain "" which C# sees as an escaped ".
   // @"""Hello""" will have been tokenized as @"" "Hello" "" and needs
   // merging into a single string literal.
-  auto &CSharpStringLiteral = *(Tokens.end() - 2);
+  auto &String = *(Tokens.end() - 1);
+  if (!String->is(tok::string_literal))
+return false;
+
   if (CSharpStringLiteral->Type == TT_CSharpStringLiteral &&
   (CSharpStringLiteral->TokenText.startswith(R"(@")") ||
CSharpStringLiteral->TokenText.startswith(R"($@")"))) {

diff  --git a/clang/lib/Format/FormatTokenLexer.h 
b/clang/lib/Format/FormatTokenLexer.h
index 611211be055a..053b759d2440 100644
--- a/clang/lib/Format/FormatTokenLexer.h
+++ b/clang/lib/Format/FormatTokenLexer.h
@@ -49,7 +49,7 @@ class FormatTokenLexer {
   bool tryMergeLessLess();
   

[PATCH] D73551: [AArch64][SVE] Add remaining SVE2 intrinsics for uniform DSP operations

2020-01-28 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin created this revision.
kmclaughlin added reviewers: efriedma, sdesmalen, dancgr, cameron.mcinally, 
c-rhodes.
Herald added subscribers: psnobl, rkruppe, hiraditya, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: LLVM.
kmclaughlin added a parent revision: D73493: [AArch64][SVE] Add SVE2 intrinsics 
for uniform DSP operations.

Implements the following intrinsics:

- @llvm.aarch64.sve.[s|u]qadd
- @llvm.aarch64.sve.[s|u]qsub
- @llvm.aarch64.sve.suqadd
- @llvm.aarch64.sve.usqadd
- @llvm.aarch64.sve.[s|u]qsubr
- @llvm.aarch64.sve.[s|u]rshl
- @llvm.aarch64.sve.[s|u]qshl
- @llvm.aarch64.sve.[s|u]qrshl
- @llvm.aarch64.sve.[s|u]rshr
- @llvm.aarch64.sve.sqshlu
- @llvm.aarch64.sve.sri
- @llvm.aarch64.sve.sli
- @llvm.aarch64.sve.[s|u]sra
- @llvm.aarch64.sve.[s|u]rsra
- @llvm.aarch64.sve.[s|u]aba


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73551

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve2-intrinsics-uniform-dsp.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-uniform-dsp.ll
===
--- llvm/test/CodeGen/AArch64/sve2-intrinsics-uniform-dsp.ll
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-uniform-dsp.ll
@@ -1,6 +1,50 @@
 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 -asm-verbose=0 < %s | FileCheck %s
 
 ;
+; SABA
+;
+
+define  @saba_i8( %a,  %b,  %c) {
+; CHECK-LABEL: saba_i8:
+; CHECK: saba z0.b, z1.b, z2.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saba.nxv16i8( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+define  @saba_i16( %a,  %b,  %c) {
+; CHECK-LABEL: saba_i16:
+; CHECK: saba z0.h, z1.h, z2.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saba.nxv8i16( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+define  @saba_i32( %a,  %b,  %c) {
+; CHECK-LABEL: saba_i32:
+; CHECK: saba z0.s, z1.s, z2.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saba.nxv4i32( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+define  @saba_i64( %a,  %b,  %c) {
+; CHECK-LABEL: saba_i64:
+; CHECK: saba z0.d, z1.d, z2.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saba.nxv2i64( %a,
+ %b,
+ %c)
+  ret  %out
+}
+
+;
 ; SHADD
 ;
 
@@ -133,6 +177,50 @@
 }
 
 ;
+; SLI
+;
+
+define  @sli_i8( %a,  %b) {
+; CHECK-LABEL: sli_i8:
+; CHECK: sli z0.b, z1.b, #0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sli.nxv16i8( %a,
+%b,
+   i32 0)
+  ret  %out
+}
+
+define  @sli_i16( %a,  %b) {
+; CHECK-LABEL: sli_i16:
+; CHECK: sli z0.h, z1.h, #1
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sli.nxv8i16( %a,
+%b,
+   i32 1)
+  ret  %out
+}
+
+define  @sli_i32( %a,  %b) {
+; CHECK-LABEL: sli_i32:
+; CHECK: sli z0.s, z1.s, #30
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sli.nxv4i32( %a,
+%b,
+   i32 30);
+  ret  %out
+}
+
+define  @sli_i64( %a,  %b) {
+; CHECK-LABEL: sli_i64:
+; CHECK: sli z0.d, z1.d, #63
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sli.nxv2i64( %a,
+%b,
+   i32 63)
+  ret  %out
+}
+
+;
 ; SQABS
 ;
 
@@ -177,6 +265,50 @@
 }
 
 ;
+; SQADD
+;
+
+define  @sqadd_i8( %pg,  %a,  %b) {
+; CHECK-LABEL: sqadd_i8:
+; CHECK: sqadd z0.b, p0/m, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sqadd.nxv16i8( %pg,
+  %a,
+  %b)
+  ret  %out
+}
+
+define  @sqadd_i16( %pg,  %a,  %b) {
+; CHECK-LABEL: sqadd_i16:
+; CHECK: sqadd z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sqadd.nxv8i16( %pg,
+  %a,
+  %b)
+  ret  %out
+}
+
+define  @sqadd_i32( %pg,  %a,  %b) {
+; CHECK-LABEL: sqadd_i32:
+; CHECK: sqadd z0.s, p0/m, z0.s, z1.s
+; CHECK-NEXT: re

[PATCH] D73450: [clangd] Add a symbol-name-based blacklist for rename.

2020-01-28 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62202 tests passed, 0 failed 
and 815 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73450



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


[PATCH] D73457: [Clang] Warn about 'z' printf modifier in old MSVC.

2020-01-28 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added a comment.

I wanted this to go in because I'm actually using it – pre-2015 C libraries are 
useful to link against if you need an application to run on very old versions 
of Windows, and that means you need the compiler to warn you if you do 
something those libraries don't support.

I see that auto-detecting the default MS compatibility version is not very 
compatible with keeping the test suite independent of the environment, but 
surely that's a general problem with the autodetection policy, nothing to do 
with this particular patch?

Would you be happy with just removing the RUN line in this test that doesn't 
specify a default compatibility version, so that every remaining RUN line 
specifies an explicit default?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73457



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


[PATCH] D73437: [mlir][spirv] Convert linalg.generic for reduction to SPIR-V ops

2020-01-28 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62199 tests passed, 0 failed 
and 815 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73437



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


[PATCH] D73450: [clangd] Add a symbol-name-based blacklist for rename.

2020-01-28 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:225
 TargetIDs.insert(SymbolID(USR));
-
   std::vector Results;

nit: maybe revert this one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73450



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


[PATCH] D73548: [clang-tidy] Added option for disabling const qualifiers in readability-qualified-auto

2020-01-28 Thread Nathan James via Phabricator via cfe-commits
njames93 marked an inline comment as done.
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp:209
+  llvm::StringRef PtrConst =
+  (AddConstQualifier && isPointerConst(Var->getType())) ? "const " : 
"";
   llvm::StringRef LocalConst = IsLocalConst ? "const " : "";

If a variables is typed as `auto x = cast(y)`, should the behaviour 
be `const auto*x = ...` even if AddConstQualifier is turned off. Thereby making 
the AddConstQualifier check only there to ensure that variables already typed 
as `auto *` and `auto &` get const qualifier if necessary


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73548



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


[PATCH] D73548: [clang-tidy] Added option for disabling const qualifiers in readability-qualified-auto

2020-01-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

SGTM, but please wait for the reviewers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73548



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


[PATCH] D72217: [clang-tidy] Added readability-qualified-auto check

2020-01-28 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

https://reviews.llvm.org/D73548
Next step is to fire off an email to llvm-dev about adding it to the coding 
standard :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72217



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


[PATCH] D73437: [mlir][spirv] Convert linalg.generic for reduction to SPIR-V ops

2020-01-28 Thread Lei Zhang via Phabricator via cfe-commits
antiagainst added a comment.

Messed up the revision history with Arc... Please show the diff between "Diff 
1" and "Diff 4" to check the modifications.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73437



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


[PATCH] D73437: [mlir][spirv] Convert linalg.generic for reduction to SPIR-V ops

2020-01-28 Thread Lei Zhang via Phabricator via cfe-commits
antiagainst updated this revision to Diff 240861.
antiagainst added a comment.

Clean up unrelated commits again


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73437

Files:
  mlir/include/mlir/Conversion/LinalgToSPIRV/LinalgToSPIRV.h
  mlir/include/mlir/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.h
  mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td
  mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td
  mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h
  mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h
  mlir/lib/Conversion/CMakeLists.txt
  mlir/lib/Conversion/LinalgToSPIRV/CMakeLists.txt
  mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp
  mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp
  mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
  mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
  mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
  mlir/lib/Dialect/SPIRV/TargetAndABI.cpp
  mlir/test/Conversion/LinalgToSPIRV/linalg-to-spirv.mlir
  mlir/tools/mlir-opt/CMakeLists.txt

Index: mlir/tools/mlir-opt/CMakeLists.txt
===
--- mlir/tools/mlir-opt/CMakeLists.txt
+++ mlir/tools/mlir-opt/CMakeLists.txt
@@ -40,6 +40,7 @@
   MLIRQuantOps
   MLIRROCDLIR
   MLIRSPIRV
+  MLIRLinalgToSPIRVTransforms
   MLIRStandardToSPIRVTransforms
   MLIRSPIRVTestPasses
   MLIRSPIRVTransforms
Index: mlir/test/Conversion/LinalgToSPIRV/linalg-to-spirv.mlir
===
--- /dev/null
+++ mlir/test/Conversion/LinalgToSPIRV/linalg-to-spirv.mlir
@@ -0,0 +1,162 @@
+// RUN: mlir-opt -split-input-file -convert-linalg-to-spirv -canonicalize -verify-diagnostics %s -o - | FileCheck %s
+
+//===--===//
+// Single workgroup reduction
+//===--===//
+
+#single_workgroup_reduction_trait = {
+  args_in = 1,
+  args_out = 1,
+  iterator_types = ["reduction"],
+  indexing_maps = [
+affine_map<(i) -> (i)>,
+affine_map<(i) -> (0)>
+  ]
+}
+
+module attributes {
+  spv.target_env = {
+version = 3 : i32,
+extensions = [],
+capabilities = [1: i32, 63: i32] // Shader, GroupNonUniformArithmetic
+  }
+} {
+
+// CHECK:  spv.globalVariable
+// CHECK-SAME: built_in("LocalInvocationId")
+
+// CHECK:  func @single_workgroup_reduction
+// CHECK-SAME: (%[[INPUT:.+]]: !spv.ptr{{.+}}, %[[OUTPUT:.+]]: !spv.ptr{{.+}})
+
+// CHECK:%[[ZERO:.+]] = spv.constant 0 : i32
+// CHECK:%[[ID:.+]] = spv.Load "Input" %{{.+}} : vector<3xi32>
+// CHECK:%[[X:.+]] = spv.CompositeExtract %[[ID]][0 : i32]
+
+// CHECK:%[[INPTR:.+]] = spv.AccessChain %[[INPUT]][%[[ZERO]], %[[X]]]
+// CHECK:%[[VAL:.+]] = spv.Load "StorageBuffer" %[[INPTR]] : i32
+// CHECK:%[[ADD:.+]] = spv.GroupNonUniformIAdd "Subgroup" "Reduce" %[[VAL]] : i32
+
+// CHECK:%[[OUTPTR:.+]] = spv.AccessChain %[[OUTPUT]][%[[ZERO]], %[[ZERO]]]
+// CHECK:%[[ELECT:.+]] = spv.GroupNonUniformElect "Subgroup" : i1
+
+// CHECK:spv.selection {
+// CHECK:  spv.BranchConditional %[[ELECT]], ^bb1, ^bb2
+// CHECK:^bb1:
+// CHECK:  spv.AtomicIAdd "Device" "AcquireRelease" %[[OUTPTR]], %[[ADD]]
+// CHECK:  spv.Branch ^bb2
+// CHECK:^bb2:
+// CHECK:  spv._merge
+// CHECK:}
+// CHECK:spv.Return
+
+func @single_workgroup_reduction(%input: memref<16xi32>, %output: memref<1xi32>) attributes {
+  spv.entry_point_abi = {local_size = dense<[16, 1, 1]>: vector<3xi32>}
+} {
+  linalg.generic #single_workgroup_reduction_trait %input, %output {
+^bb(%in: i32, %out: i32):
+  %sum = addi %in, %out : i32
+  linalg.yield %sum : i32
+  } : memref<16xi32>, memref<1xi32>
+  spv.Return
+}
+}
+
+// -
+
+// Missing shader entry point ABI
+
+#single_workgroup_reduction_trait = {
+  args_in = 1,
+  args_out = 1,
+  iterator_types = ["reduction"],
+  indexing_maps = [
+affine_map<(i) -> (i)>,
+affine_map<(i) -> (0)>
+  ]
+}
+
+module attributes {
+  spv.target_env = {
+version = 3 : i32,
+extensions = [],
+capabilities = [1: i32, 63: i32] // Shader, GroupNonUniformArithmetic
+  }
+} {
+func @single_workgroup_reduction(%input: memref<16xi32>, %output: memref<1xi32>) {
+  // expected-error @+1 {{failed to legalize operation 'linalg.generic'}}
+  linalg.generic #single_workgroup_reduction_trait %input, %output {
+^bb(%in: i32, %out: i32):
+  %sum = addi %in, %out : i32
+  linalg.yield %sum : i32
+  } : memref<16xi32>, memref<1xi32>
+  return
+}
+}
+
+// -
+
+// Mismatch between shader entry point ABI and input memref shape
+
+#single_workgroup_reduction_trait = {
+  args_in = 1,
+  args_out = 1,
+  iterator_types = ["reduction"],
+  indexing_maps = [
+affine_map<(i) -> (i)>,
+affine_map<(i) -> (0)>
+  ]
+}
+
+module a

[PATCH] D73457: [Clang] Warn about 'z' printf modifier in old MSVC.

2020-01-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This breaks tests on Windows: http://45.33.8.238/win/6812/step_7.txt

Since we auto-detect -fmsc-version if it's not explicitly installed and since 
this warning is on by default, it makes the test suite depend on the 
environment a good bit. Given how old 2015 is by now, I'm not sure this 
complexity and subtlety is worth the benefit?

In any case, I'll revert this for now to heal the bots.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73457



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


[clang] e916c8d - Revert "[Clang] Warn about 'z' printf modifier in old MSVC."

2020-01-28 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-01-28T09:27:54-05:00
New Revision: e916c8dfe461e272aa7ea115851db7ddda36b971

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

LOG: Revert "[Clang] Warn about 'z' printf modifier in old MSVC."

This reverts commit fe0d1b6a8ac5048b8007e5e7cc2aeb4e3291bda0.
Makes Analysis/taint-generic.c fail on some Windows systems.

Added: 


Modified: 
clang/lib/AST/FormatString.cpp
clang/test/Sema/format-strings-ms.c

Removed: 




diff  --git a/clang/lib/AST/FormatString.cpp b/clang/lib/AST/FormatString.cpp
index 2ca8fee67bf0..fcc0b3b11e25 100644
--- a/clang/lib/AST/FormatString.cpp
+++ b/clang/lib/AST/FormatString.cpp
@@ -748,15 +748,6 @@ bool FormatSpecifier::hasValidLengthModifier(const 
TargetInfo &Target,
 case LengthModifier::AsIntMax:
 case LengthModifier::AsSizeT:
 case LengthModifier::AsPtrDiff:
-  if (LM.getKind() == LengthModifier::AsSizeT &&
-  Target.getTriple().isOSMSVCRT() &&
-  !LO.isCompatibleWithMSVC(LangOptions::MSVC2015)) {
-// The standard libraries before MSVC2015 didn't support the 'z' length
-// modifier for size_t. So if the MS compatibility version is less than
-// that, reject.
-return false;
-  }
-
   switch (CS.getKind()) {
 case ConversionSpecifier::dArg:
 case ConversionSpecifier::DArg:

diff  --git a/clang/test/Sema/format-strings-ms.c 
b/clang/test/Sema/format-strings-ms.c
index c4d3e5664db0..56a349051d42 100644
--- a/clang/test/Sema/format-strings-ms.c
+++ b/clang/test/Sema/format-strings-ms.c
@@ -1,6 +1,4 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility 
-triple=i386-pc-win32 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility 
-triple=i386-pc-win32 -fms-compatibility-version=18 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility 
-triple=i386-pc-win32 -fms-compatibility-version=19 -DSIZE_T_OK %s
 // RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility 
-triple=i386-pc-win32 -Wformat-non-iso -DNON_ISO_WARNING %s
 
 int printf(const char *format, ...) __attribute__((format(printf, 1, 2)));
@@ -87,11 +85,4 @@ void z_test(void *p) {
   scanf("%Z", p); // expected-warning{{invalid conversion specifier 'Z'}}
 }
 
-void size_t_test(size_t s) {
-  printf("%zu", s);
-#ifndef SIZE_T_OK
-  // expected-warning@-2 {{length modifier 'z' results in undefined behavior 
or no effect with 'u' conversion specifier}}
-#endif
-}
-
 #endif



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


[PATCH] D68720: Support -fstack-clash-protection for x86

2020-01-28 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62269 tests passed, 0 failed 
and 827 were skipped.

{icon times-circle color=red} clang-tidy: fail. clang-tidy found 0 errors and 
16 warnings 
.
 0 of them are added as review comments below (why? 
).

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720



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


[PATCH] D73548: [clang-tidy] Added option for disabling const qualifiers in readability-qualified-auto

2020-01-28 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

Adds an option called `AddConstQualifier` to readability-qualified-auto to 
toggle adding const to the auto typed pointers and references. By default its 
enabled but in the LLVM module its disabled.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73548

Files:
  clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
  clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
  clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
  clang-tools-extra/test/clang-tidy/checkers/llvm-qualified-auto.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/llvm-qualified-auto.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/llvm-qualified-auto.cpp
@@ -0,0 +1,21 @@
+// RUN: %check_clang_tidy %s llvm-qualified-auto %t
+
+// This check just ensures by default the llvm alias doesn't add const
+// qualifiers to decls, so no need to copy the entire test file from
+// readability-qualified-auto.
+
+int *getIntPtr();
+const int *getCIntPtr();
+
+void foo() {
+  auto NakedPtr = getIntPtr();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'auto NakedPtr' can be declared as 'auto *NakedPtr'
+  // CHECK-FIXES: {{^}}  auto *NakedPtr = getIntPtr();
+  auto NakedConstPtr = getCIntPtr();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'auto NakedConstPtr' can be declared as 'auto *NakedConstPtr'
+  // CHECK-FIXES: {{^}}  auto *NakedConstPtr = getCIntPtr();
+  auto *Ptr = getIntPtr();
+  auto *ConstPtr = getCIntPtr();
+  auto &NakedRef = *getIntPtr();
+  auto &NakedConstRef = *getCIntPtr();
+}
Index: clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
@@ -3,62 +3,72 @@
 readability-qualified-auto
 ==
 
-Adds pointer and ``const`` qualifications to ``auto``-typed variables that are deduced
-to pointers and ``const`` pointers.
+Adds pointer qualifications to ``auto``-typed variables that are deduced to 
+pointers.
 
 `LLVM Coding Standards `_ advises to
-make it obvious if a ``auto`` typed variable is a pointer, constant pointer or 
-constant reference. This check will transform ``auto`` to ``auto *`` when the 
-type is deduced to be a pointer, as well as adding ``const`` when applicable to
-``auto`` pointers or references
+make it obvious if a ``auto`` typed variable is a pointer. This check will
+transform ``auto`` to ``auto *`` when the type is deduced to be a pointer.
 
 .. code-block:: c++
 
-  for (auto &Data : MutatableContainer) {
-change(Data);
-  }
-  for (auto &Data : ConstantContainer) {
-observe(Data);
-  }
   for (auto Data : MutatablePtrContainer) {
 change(*Data);
   }
-  for (auto Data : ConstantPtrContainer) {
-observe(*Data);
-  }
 
 Would be transformed into:
 
 .. code-block:: c++
 
-  for (auto &Data : MutatableContainer) {
-change(Data);
-  }
-  for (const auto &Data : ConstantContainer) {
-observe(Data);
-  }
   for (auto *Data : MutatablePtrContainer) {
 change(*Data);
   }
-  for (const auto *Data : ConstantPtrContainer) {
-observe(*Data);
-  }
 
 Note const volatile qualified types will retain their const and volatile qualifiers.
 
 .. code-block:: c++
 
-  const auto Foo = cast(Baz1);
-  const auto Bar = cast(Baz2);
-  volatile auto FooBar = cast(Baz3);
+   const auto Foo = cast(Baz1);
+   const auto Bar = cast(Baz2);
+   volatile auto FooBar = cast(Baz3);
 
 Would be transformed into:
 
 .. code-block:: c++
 
-  auto *const Foo = cast(Baz1);
-  const auto *const Bar = cast(Baz2);
-  auto *volatile FooBar = cast(Baz3);
+   auto *const Foo = cast(Baz1);
+   auto *const Bar = cast(Baz2);
+   auto *volatile FooBar = cast(Baz3);
+
+Options
+---
+
+.. option:: AddConstQualifier
+   
+   When set to `1` the check will add const qualifiers to auto typed pointers
+   or references.
+   Default value is '1'.
+
+.. code-block:: c++
+
+   auto Foo1 = cast(Bar1);
+   auto &Foo2 = cast(Bar2);
+
+   If AddConstQualifier is set to `0`, Will be transformed into:
+
+.. code-block:: c++
+
+   auto *Foo1 = cast(Bar1);
+   auto &Foo2 = cast(Bar2);
+
+   Otherwise it will get be transformed into:
+
+.. code-block:: c++
+
+   const auto *Foo1 = cast(Bar1);
+   const auto &Foo2 = cast(Bar2);
+
+   Note in the LLVM alias, the default value is `0`.
 
 This check helps to enforce this `LLVM Coding Standards recommendation
 `_.
Index: clang-tools-extra/docs/ReleaseNotes.rst
=

[PATCH] D73354: clang-format: insert trailing commas into containers.

2020-01-28 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Nit: Could you add an entry for ReleaseNotes.rst and regenerate the 
ClangFormatStyleOption.rst with the docs/tools/dump_style.py




Comment at: clang/unittests/Format/FormatTestJS.cpp:1229
"  (param): param is {\n"
-   "a: SomeType\n"
+   "a: SomeType;\n"
"  }&ABC => 1)\n"

mprobst wrote:
> MyDeveloperDay wrote:
> > is this correct?
> Yes, type definitions should use `;`
if you hadn't added this to the test would it have added a "," ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73354



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


[PATCH] D73437: [mlir][spirv] Convert linalg.generic for reduction to SPIR-V ops

2020-01-28 Thread Lei Zhang via Phabricator via cfe-commits
antiagainst marked 2 inline comments as done.
antiagainst added inline comments.
Herald added a reviewer: mclow.lists.



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:27
+/// types.
+static inline bool areAllValuesMemref(Operation *op) {
+  auto isOfMemrefType = [](Value val) {

rriddle wrote:
> Why the inline keyword?
Added initially because this function was trivial enough. I guess right now 
it's better to let the compiler decide.



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:60
+  auto ®ion = op.region();
+  if (region.empty() || region.getBlocks().size() != 1)
+return false;

rriddle wrote:
> Don't use size, it is O(N). Use 'has_single_element' instead.
Oh, good to know! Thanks!



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:70
+  auto &ops = block.getOperations();
+  if (ops.size() != 2)
+return false;

rriddle wrote:
> Same here, size() is O(N): `!has_single_element(block.without_terminator())`
Nice, thanks!



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:73
+
+  using mlir::matchers::m_Val;
+  auto a = m_Val(block.getArgument(0));

mravishankar wrote:
> I feel like this is not required. If the linalg.generic operation says this 
> is a reduction, we should not be checking the region to verify that it is. 
> linalg as a contract is guaranteeing this is a reduction.
I'm not sure I get your idea correctly; but this is checking we are doing the 
expected kind of reduction (`BinaryOp`). 



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:103
+linalg::GenericOp genericOp, ArrayRef operands,
+ConversionPatternRewriter &rewriter) const {
+  Operation *op = genericOp.getOperation();

rriddle wrote:
> This function is huge, is there any way to split it up a bit?
Good point. Split out two helper functions.



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:182
+  // Perform the group reduction operation.
+  Value groupOperation = rewriter.create(
+  loc, originalInputType.getElementType(), spirv::Scope::Subgroup,

mravishankar wrote:
> This is hard-wiring to IAdd. We probably need to structure this differently. 
> We need to have a pattern to lower the linalg.generic with reduction iterator 
> into the kernel generated here, and then lower the operations within the 
> region separately.
It was intentional to only support IAdd. I've re-structured this a bit so it's 
extensible to other binary op kinds.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73437



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


[PATCH] D73450: [clangd] Add a symbol-name-based blacklist for rename.

2020-01-28 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:466
 
   auto DeclsUnderCursor = locateDeclAt(AST, IdentifierToken->location());
   if (DeclsUnderCursor.empty())

kadircet wrote:
> hokein wrote:
> > kadircet wrote:
> > > hokein wrote:
> > > > kadircet wrote:
> > > > > `locateDeclAt` is already working on `NamedDecl`s but returning a set 
> > > > > of `Decl`s could you rather update that helper to return a set of 
> > > > > `NamedDecl`s instead?
> > > > I think the main problem is that `NamedDecl->getCanonicalDecl()` 
> > > > returns a `Decl*`, which we need to do a `dyn_cast`.
> > > ah right, but still it should be safe to perform just an `llvm:cast` 
> > > here, as a `NamedDecl` shouldn't have an `unnamed` decl as its canonical 
> > > declaration.
> > >  a NamedDecl shouldn't have an unnamed decl as its canonical declaration.
> > yeah, this is true for most cases, but it is not safe, we have corn cases, 
> > see the comment in SymbolCollector about ObjCPropertyDecl.
> I don't think that's relevant in here though, it is performing the cast on a 
> `Decl`. It is the `ASTNode.OrigD` that has been populated by `libIndex`. 
> So it doesn't need to be related with whatever nameddecl is being processed.
> 
> Am I missing something?
ah, you are right. I thought ASTNode.OrigD was the decl getting from 
`getCanonicalDecl`, but it turns out not.

I also checked with the `Decl::getCanonicalDecl` default implementation, if the 
Decl subclass doesn't override this method, it just returns itself. so it is 
safe for `NamedDecl`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73450



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


[PATCH] D73450: [clangd] Add a symbol-name-based blacklist for rename.

2020-01-28 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 240853.
hokein marked an inline comment as done.
hokein added a comment.

address comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73450

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  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
@@ -383,12 +383,12 @@
 
   // Typedef.
   R"cpp(
-namespace std {
+namespace ns {
 class basic_string {};
 typedef basic_string [[s^tring]];
-} // namespace std
+} // namespace ns
 
-std::[[s^tring]] foo();
+ns::[[s^tring]] foo();
   )cpp",
 
   // Variable.
@@ -539,6 +539,13 @@
  void fo^o() {})cpp",
"used outside main file", !HeaderFile, nullptr /*no index*/},
 
+  {R"cpp(// disallow rename on blacklisted symbols (e.g. std symbols)
+ namespace std {
+ class str^ing {};
+ }
+   )cpp",
+   "not a supported kind", !HeaderFile, Index},
+
   {R"cpp(
  void foo(int);
  void foo(char);
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -75,8 +75,8 @@
   return OtherFile;
 }
 
-llvm::DenseSet locateDeclAt(ParsedAST &AST,
-  SourceLocation TokenStartLoc) {
+llvm::DenseSet locateDeclAt(ParsedAST &AST,
+   SourceLocation TokenStartLoc) {
   unsigned Offset =
   AST.getSourceManager().getDecomposedSpellingLoc(TokenStartLoc).second;
 
@@ -85,7 +85,7 @@
   if (!SelectedNode)
 return {};
 
-  llvm::DenseSet Result;
+  llvm::DenseSet Result;
   for (const NamedDecl *D :
targetDecl(SelectedNode->ASTNode,
   DeclRelation::Alias | DeclRelation::TemplatePattern)) {
@@ -96,6 +96,15 @@
   return Result;
 }
 
+bool isBlacklisted(const NamedDecl &RenameDecl) {
+  static const auto *StdSymbols = new llvm::DenseSet({
+#define SYMBOL(Name, NameSpace, Header) {#NameSpace #Name},
+#include "StdSymbolMap.inc"
+#undef SYMBOL
+  });
+  return StdSymbols->count(RenameDecl.getQualifiedNameAsString());
+}
+
 enum ReasonToReject {
   NoSymbolFound,
   NoIndexProvided,
@@ -105,7 +114,7 @@
   AmbiguousSymbol,
 };
 
-llvm::Optional renameable(const Decl &RenameDecl,
+llvm::Optional renameable(const NamedDecl &RenameDecl,
   StringRef MainFilePath,
   const SymbolIndex *Index,
   bool CrossFile) {
@@ -120,6 +129,9 @@
   if (RenameDecl.getParentFunctionOrMethod())
 return None;
 
+  if (isBlacklisted(RenameDecl))
+return ReasonToReject::UnsupportedSymbol;
+
   // Check whether the symbol being rename is indexable.
   auto &ASTCtx = RenameDecl.getASTContext();
   bool MainFileIsHeader = isHeaderFile(MainFilePath, ASTCtx.getLangOpts());
@@ -131,12 +143,10 @@
 IsMainFileOnly = false;
   else if (!DeclaredInMainFile)
 IsMainFileOnly = false;
-  bool IsIndexable =
-  isa(RenameDecl) &&
-  SymbolCollector::shouldCollectSymbol(
-  cast(RenameDecl), RenameDecl.getASTContext(),
-  SymbolCollector::Options(), IsMainFileOnly);
-  if (!IsIndexable) // If the symbol is not indexable, we disallow rename.
+  // If the symbol is not indexable, we disallow rename.
+  if (!SymbolCollector::shouldCollectSymbol(
+  RenameDecl, RenameDecl.getASTContext(), SymbolCollector::Options(),
+  IsMainFileOnly))
 return ReasonToReject::NonIndexable;
 
   if (!CrossFile) {
@@ -222,7 +232,6 @@
   llvm::DenseSet TargetIDs;
   for (auto &USR : RenameUSRs)
 TargetIDs.insert(SymbolID(USR));
-
   std::vector Results;
   for (Decl *TopLevelDecl : AST.getLocalTopLevelDecls()) {
 findExplicitReferences(TopLevelDecl, [&](ReferenceLoc Ref) {
@@ -467,13 +476,10 @@
   if (DeclsUnderCursor.size() > 1)
 return makeError(ReasonToReject::AmbiguousSymbol);
 
-  const auto *RenameDecl = llvm::dyn_cast(*DeclsUnderCursor.begin());
-  if (!RenameDecl)
-return makeError(ReasonToReject::UnsupportedSymbol);
-
-  auto Reject =
-  renameable(*RenameDecl->getCanonicalDecl(), RInputs.MainFilePath,
- RInputs.Index, RInputs.AllowCrossFile);
+  const auto &RenameDecl =
+  llvm::cast(*(*DeclsUnderCursor.begin())->getCanonicalDecl());
+  auto Reject = renameable(RenameDecl, RInputs.MainFilePath, RInputs.Index,
+   RInputs.AllowCrossFile);
   if (Reject)
 return makeError(*Reject);
 
@@ -486,7 +492,7 @@
   // To make cross-file rename wo

[PATCH] D73464: [clang] Add TagDecl AST matcher

2020-01-28 Thread Karasev Nikita via Phabricator via cfe-commits
f00kat marked an inline comment as done.
f00kat added a comment.

In D73464#1844310 , @aaron.ballman 
wrote:

> LGTM! Do you need someone to commit on your behalf?


Yes, please. I don`t know how :)




Comment at: clang/lib/ASTMatchers/Dynamic/Registry.cpp:212
+  REGISTER_MATCHER(tagDecl);
+  REGISTER_MATCHER(tagType);
   REGISTER_MATCHER(enumConstantDecl);

alexfh wrote:
> There's already `tagType` registration on the line 497. And yes, should the 
> list be sorted, that would be obvious.
Fixed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73464



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


Re: [clang] af80b8c - PR44684: Look through parens and similar constructs when determining

2020-01-28 Thread Nico Weber via cfe-commits
I reverted this for now in aaae6b1b617378362462c1685e754813ed82b394 . The
commit message of the revert has a link to a bot on the official waterfall
as well (but it's the same error as on my bots).

On Mon, Jan 27, 2020 at 10:05 PM Nico Weber  wrote:

> This seems to break check-clang-tools on non-Linux:
> http://45.33.8.238/mac/6529/step_8.txt
> http://45.33.8.238/win/6770/step_8.txt
>
> On Mon, Jan 27, 2020 at 9:21 PM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>> Author: Richard Smith
>> Date: 2020-01-27T18:20:57-08:00
>> New Revision: af80b8ccc5772c14920d4554b7ca7e15f2fad1c4
>>
>> URL:
>> https://github.com/llvm/llvm-project/commit/af80b8ccc5772c14920d4554b7ca7e15f2fad1c4
>> DIFF:
>> https://github.com/llvm/llvm-project/commit/af80b8ccc5772c14920d4554b7ca7e15f2fad1c4.diff
>>
>> LOG: PR44684: Look through parens and similar constructs when determining
>> whether a call is to a builtin.
>>
>> We already had a general mechanism to do this but for some reason
>> weren't using it. In passing, check for the other unary operators that
>> can intervene in a reasonably-direct function call (we already handled
>> '&' but missed '*' and '+').
>>
>> Added:
>>
>>
>> Modified:
>> clang/lib/AST/Expr.cpp
>> clang/lib/AST/ExprConstant.cpp
>> clang/test/Parser/builtin_classify_type.c
>> clang/test/Sema/constant-builtins.c
>>
>> Removed:
>>
>>
>>
>>
>> 
>> diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
>> index 20505b21b15c..c2f73c2dc9d5 100644
>> --- a/clang/lib/AST/Expr.cpp
>> +++ b/clang/lib/AST/Expr.cpp
>> @@ -1443,19 +1443,28 @@ void CallExpr::updateDependenciesFromArg(Expr
>> *Arg) {
>>  Decl *Expr::getReferencedDeclOfCallee() {
>>Expr *CEE = IgnoreParenImpCasts();
>>
>> -  while (SubstNonTypeTemplateParmExpr *NTTP
>> -=
>> dyn_cast(CEE)) {
>> -CEE = NTTP->getReplacement()->IgnoreParenCasts();
>> +  while (SubstNonTypeTemplateParmExpr *NTTP =
>> + dyn_cast(CEE)) {
>> +CEE = NTTP->getReplacement()->IgnoreParenImpCasts();
>>}
>>
>>// If we're calling a dereference, look at the pointer instead.
>> -  if (BinaryOperator *BO = dyn_cast(CEE)) {
>> -if (BO->isPtrMemOp())
>> -  CEE = BO->getRHS()->IgnoreParenCasts();
>> -  } else if (UnaryOperator *UO = dyn_cast(CEE)) {
>> -if (UO->getOpcode() == UO_Deref)
>> -  CEE = UO->getSubExpr()->IgnoreParenCasts();
>> +  while (true) {
>> +if (BinaryOperator *BO = dyn_cast(CEE)) {
>> +  if (BO->isPtrMemOp()) {
>> +CEE = BO->getRHS()->IgnoreParenImpCasts();
>> +continue;
>> +  }
>> +} else if (UnaryOperator *UO = dyn_cast(CEE)) {
>> +  if (UO->getOpcode() == UO_Deref || UO->getOpcode() == UO_AddrOf ||
>> +  UO->getOpcode() == UO_Plus) {
>> +CEE = UO->getSubExpr()->IgnoreParenImpCasts();
>> +continue;
>> +  }
>> +}
>> +break;
>>}
>> +
>>if (DeclRefExpr *DRE = dyn_cast(CEE))
>>  return DRE->getDecl();
>>if (MemberExpr *ME = dyn_cast(CEE))
>> @@ -1466,28 +1475,11 @@ Decl *Expr::getReferencedDeclOfCallee() {
>>return nullptr;
>>  }
>>
>> -/// getBuiltinCallee - If this is a call to a builtin, return the
>> builtin ID. If
>> -/// not, return 0.
>> +/// If this is a call to a builtin, return the builtin ID. If not,
>> return 0.
>>  unsigned CallExpr::getBuiltinCallee() const {
>> -  // All simple function calls (e.g. func()) are implicitly cast to
>> pointer to
>> -  // function. As a result, we try and obtain the DeclRefExpr from the
>> -  // ImplicitCastExpr.
>> -  const ImplicitCastExpr *ICE = dyn_cast(getCallee());
>> -  if (!ICE) // FIXME: deal with more complex calls (e.g. (func)(),
>> (*func)()).
>> -return 0;
>> -
>> -  const DeclRefExpr *DRE = dyn_cast(ICE->getSubExpr());
>> -  if (!DRE)
>> -return 0;
>> -
>> -  const FunctionDecl *FDecl = dyn_cast(DRE->getDecl());
>> -  if (!FDecl)
>> -return 0;
>> -
>> -  if (!FDecl->getIdentifier())
>> -return 0;
>> -
>> -  return FDecl->getBuiltinID();
>> +  auto *FDecl =
>> +
>> dyn_cast_or_null(getCallee()->getReferencedDeclOfCallee());
>> +  return FDecl ? FDecl->getBuiltinID() : 0;
>>  }
>>
>>  bool CallExpr::isUnevaluatedBuiltinCall(const ASTContext &Ctx) const {
>>
>> diff  --git a/clang/lib/AST/ExprConstant.cpp
>> b/clang/lib/AST/ExprConstant.cpp
>> index c79973507323..75554c4692e9 100644
>> --- a/clang/lib/AST/ExprConstant.cpp
>> +++ b/clang/lib/AST/ExprConstant.cpp
>> @@ -10660,7 +10660,7 @@ static bool getBuiltinAlignArguments(const
>> CallExpr *E, EvalInfo &Info,
>>
>>  bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
>>  unsigned BuiltinOp) {
>> -  switch (unsigned BuiltinOp = E->getBuiltinCallee()) {
>> +  switch (BuiltinOp) {
>>default:
>>  return ExprEvaluatorBaseTy::VisitCallExpr(E);
>>
>>
>> diff  --git a/clang/test/Parser/builtin_classify

[PATCH] D73335: clang-format: [JS] options for arrow functions.

2020-01-28 Thread Martin Probst via Phabricator via cfe-commits
mprobst marked 2 inline comments as done.
mprobst added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:3165
+  }
+}
+

RKSimon wrote:
> @mprobst - this is breaking buildbots: 
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/builds/27196/steps/bootstrap%20clang/logs/stdio
> 
> Please can you remove the default case and add a suitable llvm_unreachable() 
> after the switch statement ?
Sorry for the breakage, and thanks to Jinsong Ji for fixing while I was OOO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73335



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


[clang] aaae6b1 - Revert "PR44684: Look through parens and similar constructs when determining"

2020-01-28 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-01-28T09:03:27-05:00
New Revision: aaae6b1b617378362462c1685e754813ed82b394

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

LOG: Revert "PR44684: Look through parens and similar constructs when 
determining"

This reverts commit af80b8ccc5772c14920d4554b7ca7e15f2fad1c4.
It broke clang-tidy/checkers/modernize-use-uncaught-exceptions.cpp in
check-clang-tools on macOS and Windows, see e.g.
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/13976/steps/stage%201%20check/logs/stdio

Added: 


Modified: 
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprConstant.cpp
clang/test/Parser/builtin_classify_type.c
clang/test/Sema/constant-builtins.c

Removed: 




diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index c2f73c2dc9d5..20505b21b15c 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1443,28 +1443,19 @@ void CallExpr::updateDependenciesFromArg(Expr *Arg) {
 Decl *Expr::getReferencedDeclOfCallee() {
   Expr *CEE = IgnoreParenImpCasts();
 
-  while (SubstNonTypeTemplateParmExpr *NTTP =
- dyn_cast(CEE)) {
-CEE = NTTP->getReplacement()->IgnoreParenImpCasts();
+  while (SubstNonTypeTemplateParmExpr *NTTP
+= dyn_cast(CEE)) 
{
+CEE = NTTP->getReplacement()->IgnoreParenCasts();
   }
 
   // If we're calling a dereference, look at the pointer instead.
-  while (true) {
-if (BinaryOperator *BO = dyn_cast(CEE)) {
-  if (BO->isPtrMemOp()) {
-CEE = BO->getRHS()->IgnoreParenImpCasts();
-continue;
-  }
-} else if (UnaryOperator *UO = dyn_cast(CEE)) {
-  if (UO->getOpcode() == UO_Deref || UO->getOpcode() == UO_AddrOf ||
-  UO->getOpcode() == UO_Plus) {
-CEE = UO->getSubExpr()->IgnoreParenImpCasts();
-continue;
-  }
-}
-break;
+  if (BinaryOperator *BO = dyn_cast(CEE)) {
+if (BO->isPtrMemOp())
+  CEE = BO->getRHS()->IgnoreParenCasts();
+  } else if (UnaryOperator *UO = dyn_cast(CEE)) {
+if (UO->getOpcode() == UO_Deref)
+  CEE = UO->getSubExpr()->IgnoreParenCasts();
   }
-
   if (DeclRefExpr *DRE = dyn_cast(CEE))
 return DRE->getDecl();
   if (MemberExpr *ME = dyn_cast(CEE))
@@ -1475,11 +1466,28 @@ Decl *Expr::getReferencedDeclOfCallee() {
   return nullptr;
 }
 
-/// If this is a call to a builtin, return the builtin ID. If not, return 0.
+/// getBuiltinCallee - If this is a call to a builtin, return the builtin ID. 
If
+/// not, return 0.
 unsigned CallExpr::getBuiltinCallee() const {
-  auto *FDecl =
-  dyn_cast_or_null(getCallee()->getReferencedDeclOfCallee());
-  return FDecl ? FDecl->getBuiltinID() : 0;
+  // All simple function calls (e.g. func()) are implicitly cast to pointer to
+  // function. As a result, we try and obtain the DeclRefExpr from the
+  // ImplicitCastExpr.
+  const ImplicitCastExpr *ICE = dyn_cast(getCallee());
+  if (!ICE) // FIXME: deal with more complex calls (e.g. (func)(), (*func)()).
+return 0;
+
+  const DeclRefExpr *DRE = dyn_cast(ICE->getSubExpr());
+  if (!DRE)
+return 0;
+
+  const FunctionDecl *FDecl = dyn_cast(DRE->getDecl());
+  if (!FDecl)
+return 0;
+
+  if (!FDecl->getIdentifier())
+return 0;
+
+  return FDecl->getBuiltinID();
 }
 
 bool CallExpr::isUnevaluatedBuiltinCall(const ASTContext &Ctx) const {

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 75554c4692e9..c79973507323 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -10660,7 +10660,7 @@ static bool getBuiltinAlignArguments(const CallExpr *E, 
EvalInfo &Info,
 
 bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
 unsigned BuiltinOp) {
-  switch (BuiltinOp) {
+  switch (unsigned BuiltinOp = E->getBuiltinCallee()) {
   default:
 return ExprEvaluatorBaseTy::VisitCallExpr(E);
 

diff  --git a/clang/test/Parser/builtin_classify_type.c 
b/clang/test/Parser/builtin_classify_type.c
index 94434e9f2ee4..63fd8e28045a 100644
--- a/clang/test/Parser/builtin_classify_type.c
+++ b/clang/test/Parser/builtin_classify_type.c
@@ -9,7 +9,7 @@ int main() {
   struct foo s;
 
   static int ary[__builtin_classify_type(a)];
-  static int ary2[(__builtin_classify_type)(a)];
+  static int ary2[(__builtin_classify_type)(a)]; // expected-error{{variable 
length array declaration cannot have 'static' storage duration}}
   static int ary3[(*__builtin_classify_type)(a)]; // expected-error{{builtin 
functions must be directly called}}
 
   int result;

diff  --git a/clang/test/Sema/constant-builtins.c 
b/clang/test/Sema/constant-builtins.c
index ae3b9135c965..c98f62dfc5a2 100644
--- a/clang/test/Sema/constant-builtins.c
+++ b/clang/test/Sema/constant-builtins.c

[PATCH] D72820: [FPEnv] Add pragma FP_CONTRACT support under strict FP.

2020-01-28 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei marked an inline comment as done.
pengfei added inline comments.



Comment at: llvm/docs/LangRef.rst:16145
+'``llvm.experimental.constrained.fmuladd``' Intrinsic
+^^^
+

jhenderson wrote:
> This underline isn't long enough and is breaking the sphinx build bot. Please 
> fix.
Thanks! I'll fix it soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72820



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


[PATCH] D52136: [clang-tidy] Add modernize-concat-nested-namespaces check

2020-01-28 Thread Noel Grandin via Phabricator via cfe-commits
grandinj added a comment.
Herald added a project: LLVM.

Hi

Thanks a lot for this checker - would it be possible to enhance it to also 
update stuff in associated header files?

Thanks


Repository:
  rL LLVM

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

https://reviews.llvm.org/D52136



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


[PATCH] D73354: clang-format: insert trailing commas into containers.

2020-01-28 Thread Martin Probst via Phabricator via cfe-commits
mprobst marked 3 inline comments as done.
mprobst added inline comments.



Comment at: clang/include/clang/Format/Format.h:552
+/// Insert trailing commas in container literals that were wrapped over
+/// multiple lines.
+TCS_Wrapped,

sammccall wrote:
> Hadn't occurred to me that this will interact with bin-packing. That seems to 
> increase the chances of going over the column limit :(
Uh. Turns out we don't have a separate option for bin packing containers, only 
for bin packing arguments and parameters.

Should we add that option to make this setting work?
Should we have this setting imply bin packing containers (as opposed to 
parameters) is disabled?



Comment at: clang/lib/Format/Format.cpp:956
 GoogleStyle.CommentPragmas = "(taze:|^/[ \t]*<|tslint:|@see)";
+GoogleStyle.InsertTrailingCommas = FormatStyle::TCS_Wrapped;
 GoogleStyle.MaxEmptyLinesToKeep = 3;

MyDeveloperDay wrote:
> Are you sure the right decision is to make this on by default for something 
> that's going to insert the comma? is this in google's javascript style guide?
> 
> I think this could cause clang-format to suddenly start adding lost of commas 
> (as we see  with the tests)
It matches the style guide: 
https://google.github.io/styleguide/jsguide.html#features-arrays-trailing-comma

But it's indeed not entirely clear re bin packing, and certainly a good idea to 
split adding the option vs landing it.



Comment at: clang/lib/Format/Format.cpp:1477
 
+/// TrailingCommaInserter inserts trailing commas into container literals.
+/// E.g.:

MyDeveloperDay wrote:
> sammccall wrote:
> > Inlining this in format.cpp seems worse than having passes in their own 
> > files, but is the pattern so far. Ugh, up to you.
> Actually I think there is precedent to put TokenAnalyzers in their own class, 
> I don't think it should be in Format.cpp
Re inlining vs separate file, idk. On one hand, this file is on the large side, 
otoh these ~60 LOC don't carry their own weight in a separate file. Maybe in a 
follow up we should extract all passes into a separate file (maybe all passes 
except the actual indenter?).



Comment at: clang/lib/Format/Format.cpp:1482
+/// ];
+class TrailingCommaInserter : public TokenAnalyzer {
+public:

krasimir wrote:
> sammccall wrote:
> > Worth a comment (somewhere) about the fact that this never rewraps, in 
> > particular if the line is long, for simplicity.
> > 
> > Another policy that occurred to me: don't insert the comma if you're 
> > exactly at the line limit.
> +1 for "Another policy that occurred to me: don't insert the comma if you're 
> exactly at the line limit." (or //over// the column limit). Seems like that 
> would be enough to keep it idempotent.
Done re comment, and also done re policy, good idea.

I've also added a comment that this doesn't work together with bin packing.



Comment at: clang/lib/Format/Format.cpp:1511
+FormatToken *Matching = FormatTok->MatchingParen;
+if (!Matching || !FormatTok->Previous)
+  continue;

sammccall wrote:
> You're checking for the existence of a previous token, and below you use 
> getPreviousNonComment() without a null-check.
> 
> I think you want to either assume that the existence of a match means there's 
> a prev token (and remove the check here), or you want to verify in which case 
> I think you also need to guard against it being a comment (by checking Prev 
> below instead)
Good catch. I think the right fix is to check if there is a previous non 
comment token, as that's what I'm using below.



Comment at: clang/unittests/Format/FormatTestJS.cpp:343
"  for: 'for',\n"
-   "  x: 'x'\n"
+   "  x: 'x',\n"
"};",

sammccall wrote:
> AFAICT one-arg verifyFormat doesn't actually test this change - the new tests 
> with commas should pass both before/after this change. 
> So there's just one testcase, I think.
Ha, I just adjusted the test cases to my change, but forgot uploading the patch 
with the tests.

I've reverted all these changes (because I'm splitting flipping the default 
from this), but added an explicit test.



Comment at: clang/unittests/Format/FormatTestJS.cpp:1229
"  (param): param is {\n"
-   "a: SomeType\n"
+   "a: SomeType;\n"
"  }&ABC => 1)\n"

MyDeveloperDay wrote:
> is this correct?
Yes, type definitions should use `;`



Comment at: clang/unittests/Format/FormatTestJS.cpp:1701
   verifyFormat("type X = {\n"
-   "  y: number\n"
+   "  y: number;\n"
"};\n"

MyDeveloperDay wrote:
> is this correct?
Yes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
 

[PATCH] D73354: clang-format: insert trailing commas into containers.

2020-01-28 Thread Martin Probst via Phabricator via cfe-commits
mprobst updated this revision to Diff 240847.
mprobst marked 16 inline comments as done.
mprobst added a comment.

- - only run comma insertion for JavaScript.
- review fixes
- Fix col limit
- test for comma insertion


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73354

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTestJS.cpp

Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -878,6 +878,41 @@
"]);");
 }
 
+TEST_F(FormatTestJS, TrailingCommaInsertion) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
+  Style.InsertTrailingCommas = FormatStyle::TCS_Wrapped;
+  // Insert comma in wrapped array.
+  verifyFormat("const x = [\n"
+   "  1,  //\n"
+   "  2,\n"
+   "];",
+   "const x = [\n"
+   "  1,  //\n"
+   "  2];",
+   Style);
+  // Insert comma in newly wrapped array.
+  Style.ColumnLimit = 30;
+  verifyFormat("const x = [\n"
+   "  a,\n"
+   "];",
+   "const x = [a];", Style);
+  // Do not insert trailing commas if they'd exceed the colum limit
+  verifyFormat("const x = [\n"
+   "  \n"
+   "];",
+   "const x = [];", Style);
+  // Object literals.
+  verifyFormat("const x = {\n"
+   "  a: a,\n"
+   "};",
+   "const x = {a: a};", Style);
+  verifyFormat("const x = {\n"
+   "  a: a\n"
+   "};",
+   "const x = {a: a};", Style);
+
+}
+
 TEST_F(FormatTestJS, FunctionLiterals) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
   Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -157,6 +157,13 @@
   }
 };
 
+template <> struct ScalarEnumerationTraits {
+  static void enumeration(IO &IO, FormatStyle::TrailingCommaStyle &Value) {
+IO.enumCase(Value, "None", FormatStyle::TCS_None);
+IO.enumCase(Value, "Wrapped", FormatStyle::TCS_Wrapped);
+  }
+};
+
 template <> struct ScalarEnumerationTraits {
   static void enumeration(IO &IO, FormatStyle::BinaryOperatorStyle &Value) {
 IO.enumCase(Value, "All", FormatStyle::BOS_All);
@@ -486,6 +493,7 @@
 IO.mapOptional("IndentWidth", Style.IndentWidth);
 IO.mapOptional("IndentWrappedFunctionNames",
Style.IndentWrappedFunctionNames);
+IO.mapOptional("InsertTrailingCommas", Style.InsertTrailingCommas);
 IO.mapOptional("JavaImportGroups", Style.JavaImportGroups);
 IO.mapOptional("JavaScriptQuotes", Style.JavaScriptQuotes);
 IO.mapOptional("JavaScriptWrapImports", Style.JavaScriptWrapImports);
@@ -788,6 +796,7 @@
   LLVMStyle.IndentPPDirectives = FormatStyle::PPDIS_None;
   LLVMStyle.IndentWrappedFunctionNames = false;
   LLVMStyle.IndentWidth = 2;
+  LLVMStyle.InsertTrailingCommas = FormatStyle::TCS_None;
   LLVMStyle.JavaScriptQuotes = FormatStyle::JSQS_Leave;
   LLVMStyle.JavaScriptWrapImports = true;
   LLVMStyle.TabWidth = 8;
@@ -946,6 +955,9 @@
 // taze:, triple slash directives (`/// <...`), tslint:, and @see, which is
 // commonly followed by overlong URLs.
 GoogleStyle.CommentPragmas = "(taze:|^/[ \t]*<|tslint:|@see)";
+// TODO: enable once decided, in particular re disabling bin packing.
+// https://google.github.io/styleguide/jsguide.html#features-arrays-trailing-comma
+// GoogleStyle.InsertTrailingCommas = FormatStyle::TCS_Wrapped;
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
 GoogleStyle.SpacesInContainerLiterals = false;
@@ -1466,6 +1478,75 @@
   FormattingAttemptStatus *Status;
 };
 
+/// TrailingCommaInserter inserts trailing commas into container literals.
+/// E.g.:
+/// const x = [
+///   1,
+/// ];
+/// TrailingCommaInserter runs after formatting. To avoid causing a required
+/// reformatting (and thus reflow), it never inserts a comma that'd exceed the
+/// ColumnLimit.
+///
+/// Because trailing commas disable binpacking of arrays, TrailingCommaInserter
+/// is conceptually incompatible with bin packing.
+class TrailingCommaInserter : public TokenAnalyzer {
+public:
+  TrailingCommaInserter(const Environment &Env, const FormatStyle &Style)
+  : TokenAnalyzer(Env, Style) {}
+
+  std::pair
+  analyze(TokenAnnotator &Annotator,
+  SmallVectorImpl &AnnotatedLines,
+ 

[PATCH] D73356: [ARM,MVE] Add intrinsics for vdupq.

2020-01-28 Thread Dave Green via Phabricator via cfe-commits
dmgreen accepted this revision.
dmgreen 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/D73356/new/

https://reviews.llvm.org/D73356



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


[PATCH] D72820: [FPEnv] Add pragma FP_CONTRACT support under strict FP.

2020-01-28 Thread James Henderson via Phabricator via cfe-commits
jhenderson added inline comments.



Comment at: llvm/docs/LangRef.rst:16145
+'``llvm.experimental.constrained.fmuladd``' Intrinsic
+^^^
+

This underline isn't long enough and is breaking the sphinx build bot. Please 
fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72820



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


[PATCH] D68720: Support -fstack-clash-protection for x86

2020-01-28 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 240844.
serge-sans-paille added a comment.

Make some tests more portable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/stack-clash-protection.c
  clang/test/Driver/stack-clash-protection.c
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/Target/X86/X86CallFrameOptimization.cpp
  llvm/lib/Target/X86/X86FrameLowering.cpp
  llvm/lib/Target/X86/X86FrameLowering.h
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/lib/Target/X86/X86InstrCompiler.td
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll
  llvm/test/CodeGen/X86/stack-clash-large.ll
  llvm/test/CodeGen/X86/stack-clash-medium-natural-probes-mutliple-objects.ll
  llvm/test/CodeGen/X86/stack-clash-medium-natural-probes.ll
  llvm/test/CodeGen/X86/stack-clash-medium.ll
  llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
  llvm/test/CodeGen/X86/stack-clash-small.ll
  llvm/test/CodeGen/X86/stack-clash-unknown-call.ll

Index: llvm/test/CodeGen/X86/stack-clash-unknown-call.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-unknown-call.ll
@@ -0,0 +1,31 @@
+; RUN: llc < %s | FileCheck %s
+
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg);
+
+define void @foo() local_unnamed_addr #0 {
+
+;CHECK-LABEL: foo:
+;CHECK: # %bb.0:
+;CHECK-NEXT:	subq	$4096, %rsp # imm = 0x1000
+; it's important that we don't use the call as a probe here
+;CHECK-NEXT:	movq	$0, (%rsp)
+;CHECK-NEXT:	subq	$3912, %rsp # imm = 0xF48
+;CHECK-NEXT:	.cfi_def_cfa_offset 8016
+;CHECK-NEXT:	movq	%rsp, %rdi
+;CHECK-NEXT:	movl	$8000, %edx # imm = 0x1F40
+;CHECK-NEXT:	xorl	%esi, %esi
+;CHECK-NEXT:	callq	memset
+;CHECK-NEXT:	addq	$8008, %rsp # imm = 0x1F48
+;CHECK-NEXT:	.cfi_def_cfa_offset 8
+;CHECK-NEXT:	retq
+
+  %a = alloca i8, i64 8000, align 16
+  call void @llvm.memset.p0i8.i64(i8* align 16 %a, i8 0, i64 8000, i1 false)
+  ret void
+}
+
+attributes #0 =  {"probe-stack"="inline-asm"}
Index: llvm/test/CodeGen/X86/stack-clash-small.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-small.ll
@@ -0,0 +1,25 @@
+; RUN: llc < %s | FileCheck %s
+
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo() local_unnamed_addr #0 {
+; CHECK-LABEL: foo:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:  subq	$280, %rsp # imm = 0x118
+; CHECK-NEXT:  .cfi_def_cfa_offset 288
+; CHECK-NEXT:  movl	$1, 264(%rsp)
+; CHECK-NEXT:  movl	-128(%rsp), %eax
+; CHECK-NEXT:  addq	$280, %rsp # imm = 0x118
+; CHECK-NEXT:  .cfi_def_cfa_offset 8
+; CHECK-NEXT:  retq
+
+  %a = alloca i32, i64 100, align 16
+  %b = getelementptr inbounds i32, i32* %a, i64 98
+  store volatile i32 1, i32* %b
+  %c = load volatile i32, i32* %a
+  ret i32 %c
+}
+
+attributes #0 =  {"probe-stack"="inline-asm"}
Index: llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
@@ -0,0 +1,27 @@
+; RUN: llc < %s | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo(i64 %i) local_unnamed_addr #0 {
+; CHECK-LABEL: foo:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:  subq	$4096, %rsp # imm = 0x1000
+; CHECK-NEXT:  movq	$0, (%rsp)
+; CHECK-NEXT:  subq	$3784, %rsp # imm = 0xEC8
+; CHECK-NEXT:  .cfi_def_cfa_offset 7888
+; CHECK-NEXT:  movl	$1, -128(%rsp,%rdi,4)
+; CHECK-NEXT:  movl	-128(%rsp), %eax
+; CHECK-NEXT:  addq	$7880, %rsp # imm = 0x1EC8
+; CHECK-NEXT:  .cfi_def_cfa_offset 8
+; CHECK-NEXT:  retq
+
+  %a = alloca i32, i32 2000, align 16
+  %b = getelementptr inbounds i32, i32* %a, i64 %i
+  store volatile i32 1, i32* %b
+  %c = load volatile i32, i32* %a
+  ret i32 %c
+}
+
+attributes #0 =  {"probe-stack"="inline-asm"}
+
Index: llvm/test/CodeGen/X86/stack-clash-medium.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-medium.ll
@@ -0,0 +1,30 @@
+; RUN: llc < %s | FileCheck %s
+
+

[PATCH] D72282: [clang-tidy] Add `bugprone-unintended-adl`

2020-01-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/UnintendedADLCheck.h:27
+  const bool IgnoreOverloadedOperators;
+  const std::vector Whitelist;
+

I'd prefer a more descriptive name for this (and the user-facing option + 
documentation). How about `AllowedIdentifiers` or `ADLEnabledIdentifiers` or 
some such?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72282



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


[PATCH] D73545: Fix a crash when casting _Complex and ignoring the results

2020-01-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rjmccall, jyknight, lebedev.ri.

Performing a cast where the result is ignored causes Clang to crash when 
performing codegen for the conversion:

  _Complex int a;
  void fn1() { (_Complex double) a; }

This patch addresses the crash by not trying to emit the scalar conversions, 
causing it to be a noop. Fixes PR44624.


https://reviews.llvm.org/D73545

Files:
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/test/CodeGen/complex-convert.c


Index: clang/test/CodeGen/complex-convert.c
===
--- clang/test/CodeGen/complex-convert.c
+++ clang/test/CodeGen/complex-convert.c
@@ -722,3 +722,8 @@
   // CHECK-NEXT: store i[[LLSIZE]] %[[VAR441]], i[[LLSIZE]]* %[[VAR443]]
 }
 
+// This code used to cause a crash; test that it no longer does so.
+_Complex int a;
+void pr44624(void) {
+  (_Complex double) a;
+}
Index: clang/lib/CodeGen/CGExprComplex.cpp
===
--- clang/lib/CodeGen/CGExprComplex.cpp
+++ clang/lib/CodeGen/CGExprComplex.cpp
@@ -431,8 +431,10 @@
   // C99 6.3.1.6: When a value of complex type is converted to another
   // complex type, both the real and imaginary parts follow the conversion
   // rules for the corresponding real types.
-  Val.first = CGF.EmitScalarConversion(Val.first, SrcType, DestType, Loc);
-  Val.second = CGF.EmitScalarConversion(Val.second, SrcType, DestType, Loc);
+  if (Val.first)
+Val.first = CGF.EmitScalarConversion(Val.first, SrcType, DestType, Loc);
+  if (Val.second)
+Val.second = CGF.EmitScalarConversion(Val.second, SrcType, DestType, Loc);
   return Val;
 }
 


Index: clang/test/CodeGen/complex-convert.c
===
--- clang/test/CodeGen/complex-convert.c
+++ clang/test/CodeGen/complex-convert.c
@@ -722,3 +722,8 @@
   // CHECK-NEXT: store i[[LLSIZE]] %[[VAR441]], i[[LLSIZE]]* %[[VAR443]]
 }
 
+// This code used to cause a crash; test that it no longer does so.
+_Complex int a;
+void pr44624(void) {
+  (_Complex double) a;
+}
Index: clang/lib/CodeGen/CGExprComplex.cpp
===
--- clang/lib/CodeGen/CGExprComplex.cpp
+++ clang/lib/CodeGen/CGExprComplex.cpp
@@ -431,8 +431,10 @@
   // C99 6.3.1.6: When a value of complex type is converted to another
   // complex type, both the real and imaginary parts follow the conversion
   // rules for the corresponding real types.
-  Val.first = CGF.EmitScalarConversion(Val.first, SrcType, DestType, Loc);
-  Val.second = CGF.EmitScalarConversion(Val.second, SrcType, DestType, Loc);
+  if (Val.first)
+Val.first = CGF.EmitScalarConversion(Val.first, SrcType, DestType, Loc);
+  if (Val.second)
+Val.second = CGF.EmitScalarConversion(Val.second, SrcType, DestType, Loc);
   return Val;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72448: [clang-tidy] readability-redundant-string-init now flags redundant initialisation in Field Decls and Constructor Initialisers

2020-01-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D72448#1844320 , @njames93 wrote:

> In D72448#1844309 , @aaron.ballman 
> wrote:
>
> > In D72448#1844032 , @njames93 
> > wrote:
> >
> > > Hmm a lot of the code in the redundant-string-init check is designed to 
> > > be macro unsafe. Not sure the best way to follow up, discard the old 
> > > macro behaviour or keep it
> >
> >
> > Designed to be macro unsafe, or just didn't consider macros in the first 
> > place? I'm not seeing anything that makes me think macros were taken into 
> > account, but maybe you're looking at something different from me. Do you 
> > have an example of where you think something was designed to be macro 
> > unsafe?
>
>
> This is one of the test cases
>
>   #define M(x) x
>   #define N { std::string s = ""; }
>   // CHECK-FIXES: #define N { std::string s = ""; }
>  
>   void h() {
> templ();
> templ();
>  
> M({ std::string s = ""; })
> // CHECK-MESSAGES: [[@LINE-1]]:19: warning: redundant string 
> initialization
> // CHECK-FIXES: M({ std::string s; })
>  
> N
> // CHECK-MESSAGES: [[@LINE-1]]:3: warning: redundant string initialization
> // CHECK-FIXES: N
> N
> // CHECK-MESSAGES: [[@LINE-1]]:3: warning: redundant string initialization
> // CHECK-FIXES: N
>   }
>   // further down
>   #define EMPTY_STR ""
>   void j() {
> std::string a(EMPTY_STR);
> // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string 
> initialization
> // CHECK-FIXES: std::string a;
> std::string b = (EMPTY_STR);
> // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string 
> initialization
> // CHECK-FIXES: std::string b;
>
>
> Looks like they knew the behaviour they wanted back then


Looking at the source code for the check, this looks more like they were 
documenting the existing behavior rather than making a design choice. I 
definitely disagree with some of those fixits. It's your call whether you want 
to do work in this area or not, but I'm not convinced the original design is 
what we want today (but finding out more from the code reviews that added the 
test cases may bring up other information we're not considering right now).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72448



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


[PATCH] D73439: [ASTMatchers] Add cxxNoexceptExpr AST matcher

2020-01-28 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaec6210367de: [ASTMatchers] Add cxxNoexceptExpr AST matcher 
(authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73439

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/lib/Analysis/ExprMutationAnalyzer.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -679,6 +679,16 @@
   cxxDeleteExpr()));
 }
 
+TEST(Matcher, NoexceptExpression) {
+  StatementMatcher NoExcept = cxxNoexceptExpr();
+  EXPECT_TRUE(matches("void foo(); bool bar = noexcept(foo());", NoExcept));
+  EXPECT_TRUE(
+  matches("void foo() noexcept; bool bar = noexcept(foo());", NoExcept));
+  EXPECT_TRUE(notMatches("void foo() noexcept;", NoExcept));
+  EXPECT_TRUE(notMatches("void foo() noexcept(1+1);", NoExcept));
+  EXPECT_TRUE(matches("void foo() noexcept(noexcept(1+1));", NoExcept));
+}
+
 TEST(Matcher, DefaultArgument) {
   StatementMatcher Arg = cxxDefaultArgExpr();
 
Index: clang/lib/Analysis/ExprMutationAnalyzer.cpp
===
--- clang/lib/Analysis/ExprMutationAnalyzer.cpp
+++ clang/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -43,9 +43,6 @@
   return Node.isPotentiallyEvaluated();
 }
 
-const ast_matchers::internal::VariadicDynCastAllOfMatcher
-cxxNoexceptExpr;
-
 const ast_matchers::internal::VariadicDynCastAllOfMatcher
 genericSelectionExpr;
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -183,6 +183,7 @@
   REGISTER_MATCHER(cxxMemberCallExpr);
   REGISTER_MATCHER(cxxMethodDecl);
   REGISTER_MATCHER(cxxNewExpr);
+  REGISTER_MATCHER(cxxNoexceptExpr);
   REGISTER_MATCHER(cxxNullPtrLiteralExpr);
   REGISTER_MATCHER(cxxOperatorCallExpr);
   REGISTER_MATCHER(cxxRecordDecl);
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -730,6 +730,8 @@
 materializeTemporaryExpr;
 const internal::VariadicDynCastAllOfMatcher cxxNewExpr;
 const internal::VariadicDynCastAllOfMatcher cxxDeleteExpr;
+const internal::VariadicDynCastAllOfMatcher
+cxxNoexceptExpr;
 const internal::VariadicDynCastAllOfMatcher
 arraySubscriptExpr;
 const internal::VariadicDynCastAllOfMatcher
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -1824,6 +1824,22 @@
 extern const internal::VariadicDynCastAllOfMatcher
 cxxDeleteExpr;
 
+/// Matches noexcept expressions.
+///
+/// Given
+/// \code
+///   bool a() noexcept;
+///   bool b() noexcept(true);
+///   bool c() noexcept(false);
+///   bool d() noexcept(noexcept(a()));
+///   bool e = noexcept(b()) || noexcept(c());
+/// \endcode
+/// cxxNoexceptExpr()
+///   matches `noexcept(a())`, `noexcept(b())` and `noexcept(c())`.
+///   doesn't match the noexcept specifier in the declarations a, b, c or d.
+extern const internal::VariadicDynCastAllOfMatcher
+cxxNoexceptExpr;
+
 /// Matches array subscript expressions.
 ///
 /// Given
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -1003,6 +1003,21 @@
 
 
 
+MatcherStmt>cxxNoexceptExprMatcherCXXNoexceptExpr>...
+Matches noexcept expressions.
+
+Given
+  bool a() noexcept;
+  bool b() noexcept(true);
+  bool c() noexcept(false);
+  bool d() noexcept(noexcept(a()));
+  bool e = noexcept(b()) || noexcept(c());
+cxxNoexceptExpr()
+  matches `noexcept(a())`, `noexcept(b())` and `noexcept(c())`.
+  doesn't match the noexcept specifier in the declarations a, b, c or d.
+
+
+
 MatcherStmt>cxxNullPtrLiteralExprMatcherCXXNullPtrLiteralExpr>...
 Matches nullptr literal.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bi

[PATCH] D72217: [clang-tidy] Added readability-qualified-auto check

2020-01-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D72217#1844262 , @sammccall wrote:

> In D72217#1844204 , @njames93 wrote:
>
> > https://llvm.org/docs/CodingStandards.html#beware-unnecessary-copies-with-auto
> >
> >   // Copy pointers, but make it clear that they're pointers.
> >   for (const auto *Ptr : Container) { observe(*Ptr); }
> >   for (auto *Ptr : Container) { Ptr->change(); }
> >
> >
> > This is the reasoning behind putting the const qualifier in the check. If 
> > people feel that this isn't quite enough to justify the const qualifier 
> > I'll submit a follow up. The general consensus though is that you should 
> > mark auto pointers as const if they don't need to change to express intent
>
>
> The text/rule there is explicitly about avoiding/clarifying copies - the 
> examples indeed use 'const' but AFAICT the "don't copy" reasoning only 
> applies to including *&.
>
> FWIW I think const here is often noise, particularly in AST-walking code 
> where you're traversing an edge from an X* to a Y* - the latter will be const 
> if the former is, and I care at API boundaries but not in between. (It's 
> usually a meaningless distinction - e.g. we're just reading but it's a 
> non-const pointer because RecursiveASTVisitor isn't const-friendly).
>
> So while spelling const is often helpful, we shouldn't (and don't) require 
> it, and the current config of this check is too intrusive.


Oddly enough, there were several long-time reviewers (including myself) who 
firmly believed we did document this requirement at one point in time, but we 
couldn't find evidence of it when we started digging harder. We've been giving 
this review feedback consistently for many years, so "we don't require it" may 
not be entirely accurate. We may not have written down a requirement for it, 
but I've *definitely* heard that we should not be deducing qualifiers and I 
agree with that sentiment. It makes the code harder to understand as a reviewer 
because there's no way to tell whether code is mutating the pointer/reference 
or not without further digging (and it changes where code dispatches to, so 
it's important information for readers of the code to have).

I'm fine making this into an option, but my preference be that the option is on 
by default for the readability checker. For the LLVM checker, maybe we default 
the option to off and argue about changing the coding standard.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72217



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


[clang] aec6210 - [ASTMatchers] Add cxxNoexceptExpr AST matcher

2020-01-28 Thread via cfe-commits

Author: Nathan
Date: 2020-01-28T13:12:28Z
New Revision: aec6210367de714caf876fe19c4b475889890e21

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

LOG: [ASTMatchers] Add cxxNoexceptExpr AST matcher

Summary: Adds a cxxNoexceptExpr matcher that matches the [[ 
https://en.cppreference.com/w/cpp/language/noexcept |  noexcept operator ]].

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: merge_guards_bot, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/docs/LibASTMatchersReference.html
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/lib/ASTMatchers/ASTMatchersInternal.cpp
clang/lib/ASTMatchers/Dynamic/Registry.cpp
clang/lib/Analysis/ExprMutationAnalyzer.cpp
clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Removed: 




diff  --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index bc6501c767ef..837f74ea0d41 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -1003,6 +1003,21 @@ Node Matchers
 
 
 
+MatcherStmt>cxxNoexceptExprMatcherCXXNoexceptExpr>...
+Matches noexcept 
expressions.
+
+Given
+  bool a() noexcept;
+  bool b() noexcept(true);
+  bool c() noexcept(false);
+  bool d() noexcept(noexcept(a()));
+  bool e = noexcept(b()) || noexcept(c());
+cxxNoexceptExpr()
+  matches `noexcept(a())`, `noexcept(b())` and `noexcept(c())`.
+  doesn't match the noexcept specifier in the declarations a, b, c or d.
+
+
+
 MatcherStmt>cxxNullPtrLiteralExprMatcherCXXNullPtrLiteralExpr>...
 Matches 
nullptr literal.
 

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 538babc569e9..2e932dbf3daa 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -1824,6 +1824,22 @@ extern const internal::VariadicDynCastAllOfMatcher cxxNewExpr;
 extern const internal::VariadicDynCastAllOfMatcher
 cxxDeleteExpr;
 
+/// Matches noexcept expressions.
+///
+/// Given
+/// \code
+///   bool a() noexcept;
+///   bool b() noexcept(true);
+///   bool c() noexcept(false);
+///   bool d() noexcept(noexcept(a()));
+///   bool e = noexcept(b()) || noexcept(c());
+/// \endcode
+/// cxxNoexceptExpr()
+///   matches `noexcept(a())`, `noexcept(b())` and `noexcept(c())`.
+///   doesn't match the noexcept specifier in the declarations a, b, c or d.
+extern const internal::VariadicDynCastAllOfMatcher
+cxxNoexceptExpr;
+
 /// Matches array subscript expressions.
 ///
 /// Given

diff  --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp 
b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index e08765b75665..3631922a5abf 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -730,6 +730,8 @@ const internal::VariadicDynCastAllOfMatcher
 materializeTemporaryExpr;
 const internal::VariadicDynCastAllOfMatcher cxxNewExpr;
 const internal::VariadicDynCastAllOfMatcher cxxDeleteExpr;
+const internal::VariadicDynCastAllOfMatcher
+cxxNoexceptExpr;
 const internal::VariadicDynCastAllOfMatcher
 arraySubscriptExpr;
 const internal::VariadicDynCastAllOfMatcher

diff  --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp 
b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index 1c0930c5983a..67b61d064cb4 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -183,6 +183,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(cxxMemberCallExpr);
   REGISTER_MATCHER(cxxMethodDecl);
   REGISTER_MATCHER(cxxNewExpr);
+  REGISTER_MATCHER(cxxNoexceptExpr);
   REGISTER_MATCHER(cxxNullPtrLiteralExpr);
   REGISTER_MATCHER(cxxOperatorCallExpr);
   REGISTER_MATCHER(cxxRecordDecl);

diff  --git a/clang/lib/Analysis/ExprMutationAnalyzer.cpp 
b/clang/lib/Analysis/ExprMutationAnalyzer.cpp
index fb5a139e82ab..b09be4317851 100644
--- a/clang/lib/Analysis/ExprMutationAnalyzer.cpp
+++ b/clang/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -43,9 +43,6 @@ AST_MATCHER(CXXTypeidExpr, isPotentiallyEvaluated) {
   return Node.isPotentiallyEvaluated();
 }
 
-const ast_matchers::internal::VariadicDynCastAllOfMatcher
-cxxNoexceptExpr;
-
 const ast_matchers::internal::VariadicDynCastAllOfMatcher
 genericSelectionExpr;

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index 02514f77afd3..b37ec2705406 100644
--- a/c

[PATCH] D72217: [clang-tidy] Added readability-qualified-auto check

2020-01-28 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D72217#1844262 , @sammccall wrote:

> The text/rule there is explicitly about avoiding/clarifying copies - the 
> examples indeed use 'const' but AFAICT the "don't copy" reasoning only 
> applies to including *&.
>
> FWIW I think const here is often noise, particularly in AST-walking code 
> where you're traversing an edge from an X* to a Y* - the latter will be const 
> if the former is, and I care at API boundaries but not in between. (It's 
> usually a meaningless distinction - e.g. we're just reading but it's a 
> non-const pointer because RecursiveASTVisitor isn't const-friendly).
>
> So while spelling const is often helpful, we shouldn't (and don't) require 
> it, and the current config of this check is too intrusive.


I have always been a little unsure, a few of the patches I have submitted 
reviewers have said to add `const` to `auto *` or turn `auto` into `const auto 
*` which gave the impression its a guideline. Could add an option to the check 
to forgo the const qualifier checks though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72217



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


[PATCH] D72448: [clang-tidy] readability-redundant-string-init now flags redundant initialisation in Field Decls and Constructor Initialisers

2020-01-28 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D72448#1844309 , @aaron.ballman 
wrote:

> In D72448#1844032 , @njames93 wrote:
>
> > Hmm a lot of the code in the redundant-string-init check is designed to be 
> > macro unsafe. Not sure the best way to follow up, discard the old macro 
> > behaviour or keep it
>
>
> Designed to be macro unsafe, or just didn't consider macros in the first 
> place? I'm not seeing anything that makes me think macros were taken into 
> account, but maybe you're looking at something different from me. Do you have 
> an example of where you think something was designed to be macro unsafe?


This is one of the test cases

  #define M(x) x
  #define N { std::string s = ""; }
  // CHECK-FIXES: #define N { std::string s = ""; }
  
  void h() {
templ();
templ();
  
M({ std::string s = ""; })
// CHECK-MESSAGES: [[@LINE-1]]:19: warning: redundant string initialization
// CHECK-FIXES: M({ std::string s; })
  
N
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: redundant string initialization
// CHECK-FIXES: N
N
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: redundant string initialization
// CHECK-FIXES: N
  }
  // further down
  #define EMPTY_STR ""
  void j() {
std::string a(EMPTY_STR);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
// CHECK-FIXES: std::string a;
std::string b = (EMPTY_STR);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization
// CHECK-FIXES: std::string b;

Looks like they knew the behaviour they wanted back then


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72448



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


[PATCH] D72531: Set traversal explicitly where needed in tests

2020-01-28 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 240841.
steveire added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72531

Files:
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/AST/SourceLocationTest.cpp
  clang/unittests/AST/StmtPrinterTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
  clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
  clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
  clang/unittests/Tooling/RangeSelectorTest.cpp
  clang/unittests/Tooling/RefactoringCallbacksTest.cpp
  clang/unittests/Tooling/StencilTest.cpp

Index: clang/unittests/Tooling/StencilTest.cpp
===
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -60,7 +60,8 @@
 return llvm::None;
   }
   ASTContext &Context = AstUnit->getASTContext();
-  auto Matches = ast_matchers::match(wrapMatcher(Matcher), Context);
+  auto Matches = ast_matchers::match(traverse(ast_type_traits::TK_AsIs,
+wrapMatcher(Matcher)), Context);
   // We expect a single, exact match for the statement.
   if (Matches.size() != 1) {
 ADD_FAILURE() << "Wrong number of matches: " << Matches.size();
@@ -331,8 +332,9 @@
 };
   )cc";
   auto StmtMatch =
-  matchStmt(Snippet, returnStmt(hasReturnValue(ignoringImplicit(memberExpr(
- hasObjectExpression(expr().bind("obj")));
+  matchStmt(Snippet, traverse(ast_type_traits::TK_AsIs,
+returnStmt(hasReturnValue(ignoringImplicit(memberExpr(
+ hasObjectExpression(expr().bind("obj";
   ASSERT_TRUE(StmtMatch);
   const Stencil Stencil = access("obj", "field");
   EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result),
Index: clang/unittests/Tooling/RefactoringCallbacksTest.cpp
===
--- clang/unittests/Tooling/RefactoringCallbacksTest.cpp
+++ clang/unittests/Tooling/RefactoringCallbacksTest.cpp
@@ -22,7 +22,7 @@
  const T &AMatcher, RefactoringCallback &Callback) {
   std::map FileToReplace;
   ASTMatchRefactorer Finder(FileToReplace);
-  Finder.addMatcher(AMatcher, &Callback);
+  Finder.addMatcher(traverse(ast_type_traits::TK_AsIs, AMatcher), &Callback);
   std::unique_ptr Factory(
   tooling::newFrontendActionFactory(&Finder));
   ASSERT_TRUE(tooling::runToolOnCode(Factory->create(), Code))
Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===
--- clang/unittests/Tooling/RangeSelectorTest.cpp
+++ clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -46,6 +46,7 @@
   ASTContext &Context = ASTUnit->getASTContext();
   assert(!Context.getDiagnostics().hasErrorOccurred() && "Compilation error");
 
+  TraversalKindScope RAII(Context, ast_type_traits::TK_AsIs);
   auto Matches = ast_matchers::match(Matcher, Context);
   // We expect a single, exact match.
   assert(Matches.size() != 0 && "no matches found");
Index: clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
===
--- clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
+++ clang/unittests/Analysis/ExprMutationAnalyzerTest.cpp
@@ -54,6 +54,7 @@
 bool isMutated(const SmallVectorImpl &Results, ASTUnit *AST) {
   const auto *const S = selectFirst("stmt", Results);
   const auto *const E = selectFirst("expr", Results);
+  TraversalKindScope RAII(AST->getASTContext(), ast_type_traits::TK_AsIs);
   return ExprMutationAnalyzer(*S, AST->getASTContext()).isMutated(E);
 }
 
Index: clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
===
--- clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -507,8 +507,10 @@
 
 TEST_F(RegistryTest, ParenExpr) {
   Matcher Value = constructMatcher("parenExpr").getTypedMatcher();
-  EXPECT_TRUE(matches("int i = (1);", Value));
-  EXPECT_FALSE(matches("int i = 1;", Value));
+  EXPECT_TRUE(matches("int i = (1);",
+traverse(ast_type_traits::TK_AsIs, Value)));
+  EXPECT_FALSE(matches("int i = 1;",
+traverse(ast_type_traits::TK_AsIs, Value)));
 }
 
 TEST_F(RegistryTest, EqualsMatcher) {
Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -373,7 +373,8 @@
   EXPECT_TRUE(matches("class Y { void x() { x(); } };", CallMethodX));
   EXPECT_TRUE(notMatches("class Y { void x() {} };", CallMethodX));
 
-  CallMethodX = callExpr(callee(cxxConversionDecl()));
+  CallMethodX = tra

[PATCH] D73464: [clang] Add TagDecl AST matcher

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

LGTM! Do you need someone to commit on your behalf?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73464



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


[PATCH] D72448: [clang-tidy] readability-redundant-string-init now flags redundant initialisation in Field Decls and Constructor Initialisers

2020-01-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D72448#1844032 , @njames93 wrote:

> Hmm a lot of the code in the redundant-string-init check is designed to be 
> macro unsafe. Not sure the best way to follow up, discard the old macro 
> behaviour or keep it


Designed to be macro unsafe, or just didn't consider macros in the first place? 
I'm not seeing anything that makes me think macros were taken into account, but 
maybe you're looking at something different from me. Do you have an example of 
where you think something was designed to be macro unsafe?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72448



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


[PATCH] D72820: [FPEnv] Add pragma FP_CONTRACT support under strict FP.

2020-01-28 Thread Pengfei Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3239b5034ee9: [FPEnv] Add pragma FP_CONTRACT support under 
strict FP. (authored by pengfei).

Changed prior to commit:
  https://reviews.llvm.org/D72820?vs=240474&id=240840#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72820

Files:
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/CodeGen/constrained-math-builtins.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/IR/ConstrainedOps.def
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/test/CodeGen/X86/fp-intrinsics-fma.ll

Index: llvm/test/CodeGen/X86/fp-intrinsics-fma.ll
===
--- llvm/test/CodeGen/X86/fp-intrinsics-fma.ll
+++ llvm/test/CodeGen/X86/fp-intrinsics-fma.ll
@@ -322,6 +322,128 @@
   ret double %result
 }
 
+; Verify constrained fmul and fadd aren't fused.
+define float @f11(float %0, float %1, float %2) #0 {
+; NOFMA-LABEL: f11:
+; NOFMA:   # %bb.0: # %entry
+; NOFMA-NEXT:mulss %xmm1, %xmm0
+; NOFMA-NEXT:addss %xmm2, %xmm0
+; NOFMA-NEXT:retq
+;
+; FMA-LABEL: f11:
+; FMA:   # %bb.0: # %entry
+; FMA-NEXT:vmulss %xmm1, %xmm0, %xmm0
+; FMA-NEXT:vaddss %xmm2, %xmm0, %xmm0
+; FMA-NEXT:retq
+;
+; FMA4-LABEL: f11:
+; FMA4:   # %bb.0: # %entry
+; FMA4-NEXT:vmulss %xmm1, %xmm0, %xmm0
+; FMA4-NEXT:vaddss %xmm2, %xmm0, %xmm0
+; FMA4-NEXT:retq
+entry:
+  %3 = call float @llvm.experimental.constrained.fmul.f32(float %0, float %1,
+  metadata !"round.dynamic",
+  metadata !"fpexcept.strict") #0
+  %4 = call float @llvm.experimental.constrained.fadd.f32(float %3, float %2,
+  metadata !"round.dynamic",
+  metadata !"fpexcept.strict") #0
+  ret float %4
+}
+
+; Verify constrained fmul and fadd aren't fused.
+define double @f12(double %0, double %1, double %2) #0 {
+; NOFMA-LABEL: f12:
+; NOFMA:   # %bb.0: # %entry
+; NOFMA-NEXT:mulsd %xmm1, %xmm0
+; NOFMA-NEXT:addsd %xmm2, %xmm0
+; NOFMA-NEXT:retq
+;
+; FMA-LABEL: f12:
+; FMA:   # %bb.0: # %entry
+; FMA-NEXT:vmulsd %xmm1, %xmm0, %xmm0
+; FMA-NEXT:vaddsd %xmm2, %xmm0, %xmm0
+; FMA-NEXT:retq
+;
+; FMA4-LABEL: f12:
+; FMA4:   # %bb.0: # %entry
+; FMA4-NEXT:vmulsd %xmm1, %xmm0, %xmm0
+; FMA4-NEXT:vaddsd %xmm2, %xmm0, %xmm0
+; FMA4-NEXT:retq
+entry:
+  %3 = call double @llvm.experimental.constrained.fmul.f64(double %0, double %1,
+   metadata !"round.dynamic",
+   metadata !"fpexcept.strict") #0
+  %4 = call double @llvm.experimental.constrained.fadd.f64(double %3, double %2,
+   metadata !"round.dynamic",
+   metadata !"fpexcept.strict") #0
+  ret double %4
+}
+
+; Verify that fmuladd(3.5) isn't simplified when the rounding mode is
+; unknown.
+define float @f15() #0 {
+; NOFMA-LABEL: f15:
+; NOFMA:   # %bb.0: # %entry
+; NOFMA-NEXT:movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
+; NOFMA-NEXT:movaps %xmm1, %xmm0
+; NOFMA-NEXT:mulss %xmm1, %xmm0
+; NOFMA-NEXT:addss %xmm1, %xmm0
+; NOFMA-NEXT:retq
+;
+; FMA-LABEL: f15:
+; FMA:   # %bb.0: # %entry
+; FMA-NEXT:vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; FMA-NEXT:vfmadd213ss {{.*#+}} xmm0 = (xmm0 * xmm0) + xmm0
+; FMA-NEXT:retq
+;
+; FMA4-LABEL: f15:
+; FMA4:   # %bb.0: # %entry
+; FMA4-NEXT:vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; FMA4-NEXT:vfmaddss %xmm0, %xmm0, %xmm0, %xmm0
+; FMA4-NEXT:retq
+entry:
+  %result = call float @llvm.experimental.constrained.fmuladd.f32(
+   float 3.5,
+   float 3.5,
+   float 3.5,
+   metadata !"round.dynamic",
+   metadata !"fpexcept.strict") #0
+  ret float %result
+}
+
+; Verify that fmuladd(42.1) isn't simplified when the rounding mode is
+; unknown.
+define double @f16() #0 {
+; NOFMA-LABEL: f16:
+; NOFMA:   # %bb.0: # %entry
+; NOFMA-NEXT:movsd {{.*#+}} xmm1 = mem[0],zero
+; NOFMA-NEXT:movapd %xmm1, %xmm0
+; NOFMA-NEXT:mulsd %xmm1, %xmm0
+; NOFMA-NEXT:addsd %xmm1, %xmm0
+; NOFMA-NEXT:retq
+;
+; FMA-LABEL: f16:
+; FMA:   # %bb.0: # %entry
+; FMA-NEXT:vmovsd {{.*#+}} xmm0 = mem[0],zero
+; FMA-NEXT:vfmadd213sd {{.*#+}} xmm0 = (xmm0 * xmm0) + xmm0
+; FMA-NEXT:

[clang] 3239b50 - [FPEnv] Add pragma FP_CONTRACT support under strict FP.

2020-01-28 Thread via cfe-commits

Author: Wang, Pengfei
Date: 2020-01-28T20:43:43+08:00
New Revision: 3239b5034ee97b63572e61713b15be8444eeab25

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

LOG: [FPEnv] Add pragma FP_CONTRACT support under strict FP.

Summary: Support pragma FP_CONTRACT under strict FP.

Reviewers: craig.topper, andrew.w.kaylor, uweigand, RKSimon, LiuChen3

Subscribers: hiraditya, jdoerfert, cfe-commits, llvm-commits, LuoYuanke

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/lib/CodeGen/CGExprScalar.cpp
clang/test/CodeGen/constrained-math-builtins.c
llvm/docs/LangRef.rst
llvm/include/llvm/CodeGen/BasicTTIImpl.h
llvm/include/llvm/IR/ConstrainedOps.def
llvm/include/llvm/IR/Intrinsics.td
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/test/CodeGen/X86/fp-intrinsics-fma.ll

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index de5c3a03fb68..1f3f4e7b894d 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -3365,7 +3365,7 @@ static Value *emitPointerArithmetic(CodeGenFunction &CGF,
 // the add operand respectively. This allows fmuladd to represent a*b-c, or
 // c-a*b. Patterns in LLVM should catch the negated forms and translate them to
 // efficient operations.
-static Value* buildFMulAdd(llvm::BinaryOperator *MulOp, Value *Addend,
+static Value* buildFMulAdd(llvm::Instruction *MulOp, Value *Addend,
const CodeGenFunction &CGF, CGBuilderTy &Builder,
bool negMul, bool negAdd) {
   assert(!(negMul && negAdd) && "Only one of negMul and negAdd should be 
set.");
@@ -3377,12 +3377,23 @@ static Value* buildFMulAdd(llvm::BinaryOperator *MulOp, 
Value *Addend,
   if (negAdd)
 Addend = Builder.CreateFNeg(Addend, "neg");
 
-  Value *FMulAdd = Builder.CreateCall(
-  CGF.CGM.getIntrinsic(llvm::Intrinsic::fmuladd, Addend->getType()),
-  {MulOp0, MulOp1, Addend});
-   MulOp->eraseFromParent();
+  Value *FMulAdd = nullptr;
+  if (Builder.getIsFPConstrained()) {
+assert(isa(MulOp) &&
+   "Only constrained operation should be created when Builder is in FP 
"
+   "constrained mode");
+FMulAdd = Builder.CreateConstrainedFPCall(
+CGF.CGM.getIntrinsic(llvm::Intrinsic::experimental_constrained_fmuladd,
+ Addend->getType()),
+{MulOp0, MulOp1, Addend});
+  } else {
+FMulAdd = Builder.CreateCall(
+CGF.CGM.getIntrinsic(llvm::Intrinsic::fmuladd, Addend->getType()),
+{MulOp0, MulOp1, Addend});
+  }
+  MulOp->eraseFromParent();
 
-   return FMulAdd;
+  return FMulAdd;
 }
 
 // Check whether it would be legal to emit an fmuladd intrinsic call to
@@ -3417,6 +3428,19 @@ static Value* tryEmitFMulAdd(const BinOpInfo &op,
   return buildFMulAdd(RHSBinOp, op.LHS, CGF, Builder, isSub, false);
   }
 
+  if (auto *LHSBinOp = dyn_cast(op.LHS)) {
+if (LHSBinOp->getIntrinsicID() ==
+llvm::Intrinsic::experimental_constrained_fmul &&
+LHSBinOp->use_empty())
+  return buildFMulAdd(LHSBinOp, op.RHS, CGF, Builder, false, isSub);
+  }
+  if (auto *RHSBinOp = dyn_cast(op.RHS)) {
+if (RHSBinOp->getIntrinsicID() ==
+llvm::Intrinsic::experimental_constrained_fmul &&
+RHSBinOp->use_empty())
+  return buildFMulAdd(RHSBinOp, op.LHS, CGF, Builder, isSub, false);
+  }
+
   return nullptr;
 }
 

diff  --git a/clang/test/CodeGen/constrained-math-builtins.c 
b/clang/test/CodeGen/constrained-math-builtins.c
index 72c2918dca96..b22cfe61d313 100644
--- a/clang/test/CodeGen/constrained-math-builtins.c
+++ b/clang/test/CodeGen/constrained-math-builtins.c
@@ -148,3 +148,15 @@ void foo(double *d, float f, float *fp, long double *l, 
int *i, const char *c) {
 // CHECK: declare x86_fp80 @llvm.experimental.constrained.trunc.f80(x86_fp80, 
metadata)
 };
 
+#pragma STDC FP_CONTRACT ON
+void bar(float f) {
+  f * f + f;
+  (double)f * f - f;
+  (long double)-f * f + f;
+
+// CHECK: call float @llvm.experimental.constrained.fmuladd.f32
+// CHECK: fneg
+// CHECK: call double @llvm.experimental.constrained.fmuladd.f64
+// CHECK: fneg
+// CHECK: call x86_fp80 @llvm.experimental.constrained.fmuladd.f80
+};

diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 315a1212c868..a3460a25a8a8 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -16141,6 +16141,69 @@ if either operand is a SNAN.  The signaling comparison 
operation
 performed by '``llvm.experimental.constrained.fcmps``' will raise an
 exception if either operand is a NAN (QNAN or SNAN).
 
+'``llvm.experimental.constrained.fmuladd``' Intrinsic
+^

[PATCH] D73367: [clangd] Go-to-definition on 'override' jumps to overridden method(s)

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

Thanks, LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73367



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


[PATCH] D73450: [clangd] Add a symbol-name-based blacklist for rename.

2020-01-28 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:466
 
   auto DeclsUnderCursor = locateDeclAt(AST, IdentifierToken->location());
   if (DeclsUnderCursor.empty())

hokein wrote:
> kadircet wrote:
> > hokein wrote:
> > > kadircet wrote:
> > > > `locateDeclAt` is already working on `NamedDecl`s but returning a set 
> > > > of `Decl`s could you rather update that helper to return a set of 
> > > > `NamedDecl`s instead?
> > > I think the main problem is that `NamedDecl->getCanonicalDecl()` returns 
> > > a `Decl*`, which we need to do a `dyn_cast`.
> > ah right, but still it should be safe to perform just an `llvm:cast` here, 
> > as a `NamedDecl` shouldn't have an `unnamed` decl as its canonical 
> > declaration.
> >  a NamedDecl shouldn't have an unnamed decl as its canonical declaration.
> yeah, this is true for most cases, but it is not safe, we have corn cases, 
> see the comment in SymbolCollector about ObjCPropertyDecl.
I don't think that's relevant in here though, it is performing the cast on a 
`Decl`. It is the `ASTNode.OrigD` that has been populated by `libIndex`. 
So it doesn't need to be related with whatever nameddecl is being processed.

Am I missing something?



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:148
+  RenameDecl, RenameDecl.getASTContext(), SymbolCollector::Options(),
+  IsMainFileOnly)) // If the symbol is not indexable, we disallow rename.
 return ReasonToReject::NonIndexable;

kadircet wrote:
> maybe move comment to be above if statement, and clang-format
looks like it is still not clang-formatted


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73450



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


[PATCH] D73541: [Clang] Added method getTokenLocations to StringLiteral

2020-01-28 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62255 tests passed, 0 failed 
and 827 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73541



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


[PATCH] D72824: [X86] Add combination for fma and fneg on X86 under strict FP.

2020-01-28 Thread Pengfei Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3d1f0ce3b9f8: [X86] Add combination for fma and fneg on X86 
under strict FP. (authored by pengfei).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72824

Files:
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/lib/Target/X86/X86InstrAVX512.td
  llvm/lib/Target/X86/X86InstrFMA.td
  llvm/lib/Target/X86/X86InstrFragmentsSIMD.td
  llvm/test/CodeGen/X86/fp-intrinsics-fma.ll

Index: llvm/test/CodeGen/X86/fp-intrinsics-fma.ll
===
--- llvm/test/CodeGen/X86/fp-intrinsics-fma.ll
+++ llvm/test/CodeGen/X86/fp-intrinsics-fma.ll
@@ -1,7 +1,326 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -O3 -mtriple=x86_64-pc-linux < %s | FileCheck %s --check-prefixes=COMMON,NOFMA
-; RUN: llc -O3 -mtriple=x86_64-pc-linux -mattr=+fma < %s | FileCheck %s --check-prefixes=COMMON,FMA
-; RUN: llc -O3 -mtriple=x86_64-pc-linux -mattr=+avx512f < %s | FileCheck %s --check-prefixes=COMMON,FMA
+; RUN: llc -O3 -mtriple=x86_64-pc-linux -mattr=+fma < %s | FileCheck %s --check-prefixes=COMMON,FMA,FMA-AVX1
+; RUN: llc -O3 -mtriple=x86_64-pc-linux -mattr=+fma4 < %s | FileCheck %s --check-prefixes=COMMON,FMA4
+; RUN: llc -O3 -mtriple=x86_64-pc-linux -mattr=+avx512f < %s | FileCheck %s --check-prefixes=COMMON,FMA,FMA-AVX512
+
+define float @f1(float %0, float %1, float %2) #0 {
+; NOFMA-LABEL: f1:
+; NOFMA:   # %bb.0: # %entry
+; NOFMA-NEXT:pushq %rax
+; NOFMA-NEXT:.cfi_def_cfa_offset 16
+; NOFMA-NEXT:xorps {{.*}}(%rip), %xmm0
+; NOFMA-NEXT:callq fmaf
+; NOFMA-NEXT:popq %rax
+; NOFMA-NEXT:.cfi_def_cfa_offset 8
+; NOFMA-NEXT:retq
+;
+; FMA-LABEL: f1:
+; FMA:   # %bb.0: # %entry
+; FMA-NEXT:vfnmadd213ss {{.*#+}} xmm0 = -(xmm1 * xmm0) + xmm2
+; FMA-NEXT:retq
+;
+; FMA4-LABEL: f1:
+; FMA4:   # %bb.0: # %entry
+; FMA4-NEXT:vfnmaddss %xmm2, %xmm1, %xmm0, %xmm0
+; FMA4-NEXT:retq
+entry:
+  %3 = fneg float %0
+  %result = call float @llvm.experimental.constrained.fma.f32(float %3, float %1, float %2,
+  metadata !"round.dynamic",
+  metadata !"fpexcept.strict") #0
+  ret float %result
+}
+
+define double @f2(double %0, double %1, double %2) #0 {
+; NOFMA-LABEL: f2:
+; NOFMA:   # %bb.0: # %entry
+; NOFMA-NEXT:pushq %rax
+; NOFMA-NEXT:.cfi_def_cfa_offset 16
+; NOFMA-NEXT:xorps {{.*}}(%rip), %xmm0
+; NOFMA-NEXT:callq fma
+; NOFMA-NEXT:popq %rax
+; NOFMA-NEXT:.cfi_def_cfa_offset 8
+; NOFMA-NEXT:retq
+;
+; FMA-LABEL: f2:
+; FMA:   # %bb.0: # %entry
+; FMA-NEXT:vfnmadd213sd {{.*#+}} xmm0 = -(xmm1 * xmm0) + xmm2
+; FMA-NEXT:retq
+;
+; FMA4-LABEL: f2:
+; FMA4:   # %bb.0: # %entry
+; FMA4-NEXT:vfnmaddsd %xmm2, %xmm1, %xmm0, %xmm0
+; FMA4-NEXT:retq
+entry:
+  %3 = fneg double %0
+  %result = call double @llvm.experimental.constrained.fma.f64(double %3, double %1, double %2,
+   metadata !"round.dynamic",
+   metadata !"fpexcept.strict") #0
+  ret double %result
+}
+
+define float @f3(float %0, float %1, float %2) #0 {
+; NOFMA-LABEL: f3:
+; NOFMA:   # %bb.0: # %entry
+; NOFMA-NEXT:pushq %rax
+; NOFMA-NEXT:.cfi_def_cfa_offset 16
+; NOFMA-NEXT:xorps {{.*}}(%rip), %xmm2
+; NOFMA-NEXT:callq fmaf
+; NOFMA-NEXT:popq %rax
+; NOFMA-NEXT:.cfi_def_cfa_offset 8
+; NOFMA-NEXT:retq
+;
+; FMA-LABEL: f3:
+; FMA:   # %bb.0: # %entry
+; FMA-NEXT:vfmsub213ss {{.*#+}} xmm0 = (xmm1 * xmm0) - xmm2
+; FMA-NEXT:retq
+;
+; FMA4-LABEL: f3:
+; FMA4:   # %bb.0: # %entry
+; FMA4-NEXT:vfmsubss %xmm2, %xmm1, %xmm0, %xmm0
+; FMA4-NEXT:retq
+entry:
+  %3 = fneg float %2
+  %result = call float @llvm.experimental.constrained.fma.f32(float %0, float %1, float %3,
+  metadata !"round.dynamic",
+  metadata !"fpexcept.strict") #0
+  ret float %result
+}
+
+define double @f4(double %0, double %1, double %2) #0 {
+; NOFMA-LABEL: f4:
+; NOFMA:   # %bb.0: # %entry
+; NOFMA-NEXT:pushq %rax
+; NOFMA-NEXT:.cfi_def_cfa_offset 16
+; NOFMA-NEXT:xorps {{.*}}(%rip), %xmm2
+; NOFMA-NEXT:callq fma
+; NOFMA-NEXT:popq %rax
+; NOFMA-NEXT:.cfi_def_cfa_offset 8
+; NOFMA-NEXT:retq
+;
+; FMA-LABEL: f4:
+; FMA:   # %bb.0: # %entry
+; FMA-NEXT:vfmsub213sd {{.*#+}} xmm0 = (xmm1 * xmm0) - xmm2
+; FMA-NEXT:retq
+;
+; FMA4-LABEL: f4:
+; FMA4:   # %bb.0: # %entry
+; FMA4-NEXT:vfmsubsd %xmm2, %xmm1, %xmm0, %xmm0
+; FMA4-NEXT:retq
+entry:

[PATCH] D73450: [clangd] Add a symbol-name-based blacklist for rename.

2020-01-28 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62202 tests passed, 0 failed 
and 815 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73450



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


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

2020-01-28 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet created this revision.
gchatelet added reviewers: efriedma, courbet, tejohnson.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

This is a follow up on D61634  and the last 
step to implement 
http://lists.llvm.org/pipermail/llvm-dev/2019-April/131973.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73543

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-memcpy-inline.c
  clang/test/Sema/builtins-memcpy-inline.c
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/IR/IRBuilder.cpp

Index: llvm/lib/IR/IRBuilder.cpp
===
--- llvm/lib/IR/IRBuilder.cpp
+++ llvm/lib/IR/IRBuilder.cpp
@@ -200,6 +200,30 @@
   return CI;
 }
 
+CallInst *IRBuilderBase::CreateMemCpyInline(Value *Dst, MaybeAlign DstAlign,
+Value *Src, MaybeAlign SrcAlign,
+Value *Size) {
+  Dst = getCastedInt8PtrValue(Dst);
+  Src = getCastedInt8PtrValue(Src);
+  Value *IsVolatile = getInt1(false);
+
+  Value *Ops[] = {Dst, Src, Size, IsVolatile};
+  Type *Tys[] = {Dst->getType(), Src->getType(), Size->getType()};
+  Function *F = BB->getParent();
+  Module *M = F->getParent();
+  Function *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memcpy_inline, Tys);
+
+  CallInst *CI = createCallHelper(TheFn, Ops, this);
+
+  auto *MCI = cast(CI);
+  if (DstAlign)
+MCI->setDestAlignment(*DstAlign);
+  if (SrcAlign)
+MCI->setSourceAlignment(*SrcAlign);
+
+  return CI;
+}
+
 CallInst *IRBuilderBase::CreateElementUnorderedAtomicMemCpy(
 Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size,
 uint32_t ElementSize, MDNode *TBAATag, MDNode *TBAAStructTag,
Index: llvm/include/llvm/IR/IRBuilder.h
===
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -560,6 +560,9 @@
  MDNode *ScopeTag = nullptr,
  MDNode *NoAliasTag = nullptr);
 
+  CallInst *CreateMemCpyInline(Value *Dst, MaybeAlign DstAlign, Value *Src,
+   MaybeAlign SrcAlign, Value *Size);
+
   /// Create and insert an element unordered-atomic memcpy between the
   /// specified pointers.
   ///
Index: clang/test/Sema/builtins-memcpy-inline.c
===
--- /dev/null
+++ clang/test/Sema/builtins-memcpy-inline.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#define NULL ((char *)0)
+
+#if __has_feature(__builtin_memcpy_inline)
+#warning defined as expected
+// expected-warning@-1 {{defined as expected}}
+#endif
+
+void test_memcpy_inline_null_src(void *ptr) {
+  __builtin_memcpy_inline(ptr, NULL, 4); // expected-warning {{null passed to a callee that requires a non-null argument}}
+}
+
+void test_memcpy_inline_null_dst(void *ptr) {
+  __builtin_memcpy_inline(NULL, ptr, 4); // expected-warning {{null passed to a callee that requires a non-null argument}}
+}
+
+void test_memcpy_inline_null_buffers() {
+  __builtin_memcpy_inline(NULL, NULL, 4);
+  // expected-warning@-1 {{null passed to a callee that requires a non-null argument}}
+  // expected-warning@-2 {{null passed to a callee that requires a non-null argument}}
+}
+
+void test_memcpy_inline_null_buffer_is_ok_if_size_is_zero(void *ptr) {
+  __builtin_memcpy_inline(ptr, NULL, /*size */ 0);
+  __builtin_memcpy_inline(NULL, ptr, /*size */ 0);
+  __builtin_memcpy_inline(NULL, NULL, /*size */ 0);
+}
Index: clang/test/CodeGen/builtins-memcpy-inline.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-memcpy-inline.c
@@ -0,0 +1,26 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s
+
+// CHECK-LABEL: define void @test_memcpy_inline_0(i8* %dst, i8* %src)
+void test_memcpy_inline_0(void *dst, const void *src) {
+  // CHECK:   call void @llvm.memcpy.inline.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 %1, i64 0, i1 false)
+  __builtin_memcpy_inline(dst, src, 0);
+}
+
+// CHECK-LABEL: define void @test_memcpy_inline_1(i8* %dst, i8* %src)
+void test_memcpy_inline_1(void *dst, const void *src) {
+  // CHECK:   call void @llvm.memcpy.inline.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 %1, i64 1, i1 false)
+  __builtin_memcpy_inline(dst, src, 1);
+}
+
+// CHECK-LABEL: define void @test_memcpy_inline_4(i8* %dst, i8* %src)
+void test_memcpy_inline_4(void *dst, const void *src) {
+  // CHECK:   call void @llvm.memcpy.inline.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 %1, i64 4, i1 false)
+  __builtin_memcpy_inline(dst, src, 4);
+}
+
+// CHECK-LABEL: define void @test_memc

[PATCH] D72217: [clang-tidy] Added readability-qualified-auto check

2020-01-28 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D72217#1844204 , @njames93 wrote:

> https://llvm.org/docs/CodingStandards.html#beware-unnecessary-copies-with-auto
>
>   // Copy pointers, but make it clear that they're pointers.
>   for (const auto *Ptr : Container) { observe(*Ptr); }
>   for (auto *Ptr : Container) { Ptr->change(); }
>
>
> This is the reasoning behind putting the const qualifier in the check. If 
> people feel that this isn't quite enough to justify the const qualifier I'll 
> submit a follow up. The general consensus though is that you should mark auto 
> pointers as const if they don't need to change to express intent


The text/rule there is explicitly about avoiding/clarifying copies - the 
examples indeed use 'const' but AFAICT the "don't copy" reasoning only applies 
to including *&.

FWIW I think const here is often noise, particularly in AST-walking code where 
you're traversing an edge from an X* to a Y* - the latter will be const if the 
former is, and I care at API boundaries but not in between. (It's usually a 
meaningless distinction - e.g. we're just reading but it's a non-const pointer 
because RecursiveASTVisitor isn't const-friendly).

So while spelling const is often helpful, we shouldn't (and don't) require it, 
and the current config of this check is too intrusive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72217



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


[PATCH] D73538: [clangd] Make bin/llvm-lit run standalone clangd tests

2020-01-28 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62255 tests passed, 0 failed 
and 827 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73538



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


[PATCH] D73541: [Clang] Added method getTokenLocations to StringLiteral

2020-01-28 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
njames93 edited the summary of this revision.
njames93 edited the summary of this revision.
njames93 added a reviewer: rsmith.

Adds a helper method `ArrayRef getTokenLocations() const` to 
`clang::StringLiteral` for easier analysis on the pieces that make up a string.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73541

Files:
  clang/include/clang/AST/Expr.h


Index: clang/include/clang/AST/Expr.h
===
--- clang/include/clang/AST/Expr.h
+++ clang/include/clang/AST/Expr.h
@@ -1883,6 +1883,11 @@
 return getTrailingObjects() + getNumConcatenated();
   }
 
+  /// Gets the source location of each piece that makes up this string literal.
+  ArrayRef getTokenLocations() const {
+return {getTrailingObjects(), getNumConcatenated()};
+  }
+
   SourceLocation getBeginLoc() const LLVM_READONLY { return *tokloc_begin(); }
   SourceLocation getEndLoc() const LLVM_READONLY { return *(tokloc_end() - 1); 
}
 


Index: clang/include/clang/AST/Expr.h
===
--- clang/include/clang/AST/Expr.h
+++ clang/include/clang/AST/Expr.h
@@ -1883,6 +1883,11 @@
 return getTrailingObjects() + getNumConcatenated();
   }
 
+  /// Gets the source location of each piece that makes up this string literal.
+  ArrayRef getTokenLocations() const {
+return {getTrailingObjects(), getNumConcatenated()};
+  }
+
   SourceLocation getBeginLoc() const LLVM_READONLY { return *tokloc_begin(); }
   SourceLocation getEndLoc() const LLVM_READONLY { return *(tokloc_end() - 1); }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73453: Preserve -nostdinc and --sysroot when calling query driver

2020-01-28 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/QueryDriverDatabase.cpp:144
+  });
+  if (Found != std::end(ArgsToPreserve)) {
+Arg.consume_front(*Found);

nit: early exit with
```
if(Found == std::end(ArgsToPreserve))
  continue;
```



Comment at: clang-tools-extra/clangd/QueryDriverDatabase.cpp:148
+  Args.push_back(CommandLine[I]);
+  Args.push_back(CommandLine[I + 1]);
+} else if (Arg.startswith("=")) {

nit: also increment `I`



Comment at: clang-tools-extra/clangd/test/system-include-extractor.test:10
 # RUN: echo '[ "$0" = "%t.dir/my_driver.sh" ] || exit' >> %t.dir/my_driver.sh
+# RUN: echo '[ -z "${args##"-nostdinc"}" ]  || exit' >> %t.dir/my_driver.sh
+# RUN: echo '[ -z "${args##"-isysroot=/isysroot"}" ] || exit' >> 
%t.dir/my_driver.sh

sorry I forgot to include `*`s, it should've been `[ -z 
"${args##*"-nostdinc"*}" ]`.

Also you need to populate `args` with `$*` or `$@` first.


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

https://reviews.llvm.org/D73453



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


[PATCH] D72217: [clang-tidy] Added readability-qualified-auto check

2020-01-28 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D72217#1844112 , @sammccall wrote:

> This check as configured for LLVM itself is pretty noisy, generating warnings 
> like:
>
> > warning: 'auto *CTSD' can be declared as 'const auto *CTSD' 
> > [llvm-qualified-auto]
>
> which the LLVM dev guide doesn't have an opinion about.
>
> AFAICS there's no option to disable just the const behavior, and no proposal 
> to change the dev guidelines - is someone working on something here?
>  Otherwise I'd like to turn this off at least for clang-tools-extra.


https://llvm.org/docs/CodingStandards.html#beware-unnecessary-copies-with-auto

  // Copy pointers, but make it clear that they're pointers.
  for (const auto *Ptr : Container) { observe(*Ptr); }
  for (auto *Ptr : Container) { Ptr->change(); }

This is the reasoning behind putting the const qualifier in the check. If 
people feel that this isn't quite enough to justify the const qualifier I'll 
submit a follow up. The general consensus though is that you should mark auto 
pointers as const if they don't need to change to express intent


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72217



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


[PATCH] D72527: [clang-tidy] adjust scripts to subsubsections in Release Notes

2020-01-28 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In D72527#1843475 , @Eugene.Zelenko 
wrote:

> As I wrote, I don't have GitHub commit access, so I need help with commit.


Sorry, missed that part of the patch description. As per Nathan's comment, 
please rebase the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72527



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


[PATCH] D73537: [clangd] add CODE_OWNERS

2020-01-28 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62195 tests passed, 0 failed 
and 815 were skipped.

{icon check-circle color=green} clang-tidy: pass.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73537



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


[PATCH] D73450: [clangd] Add a symbol-name-based blacklist for rename.

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



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:466
 
   auto DeclsUnderCursor = locateDeclAt(AST, IdentifierToken->location());
   if (DeclsUnderCursor.empty())

kadircet wrote:
> hokein wrote:
> > kadircet wrote:
> > > `locateDeclAt` is already working on `NamedDecl`s but returning a set of 
> > > `Decl`s could you rather update that helper to return a set of 
> > > `NamedDecl`s instead?
> > I think the main problem is that `NamedDecl->getCanonicalDecl()` returns a 
> > `Decl*`, which we need to do a `dyn_cast`.
> ah right, but still it should be safe to perform just an `llvm:cast` here, as 
> a `NamedDecl` shouldn't have an `unnamed` decl as its canonical declaration.
>  a NamedDecl shouldn't have an unnamed decl as its canonical declaration.
yeah, this is true for most cases, but it is not safe, we have corn cases, see 
the comment in SymbolCollector about ObjCPropertyDecl.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73450



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


[PATCH] D73538: [clangd] Make bin/llvm-lit run standalone clangd tests

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

Currently clangd lit tests can't be run in isolation because we don't
set some of the config parameters. This enables running

./bin/llvm-lit ../clang-tools-extra/clangd/test/

or any other test in that subdirectory.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73538

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


Index: clang-tools-extra/clangd/test/CMakeLists.txt
===
--- clang-tools-extra/clangd/test/CMakeLists.txt
+++ clang-tools-extra/clangd/test/CMakeLists.txt
@@ -29,7 +29,10 @@
 
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py)
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
+  MAIN_CONFIG
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
+  )
 
 add_lit_testsuite(check-clangd "Running the Clangd regression tests"
   ${CMAKE_CURRENT_BINARY_DIR}/../unittests;${CMAKE_CURRENT_BINARY_DIR}


Index: clang-tools-extra/clangd/test/CMakeLists.txt
===
--- clang-tools-extra/clangd/test/CMakeLists.txt
+++ clang-tools-extra/clangd/test/CMakeLists.txt
@@ -29,7 +29,10 @@
 
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py)
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
+  MAIN_CONFIG
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
+  )
 
 add_lit_testsuite(check-clangd "Running the Clangd regression tests"
   ${CMAKE_CURRENT_BINARY_DIR}/../unittests;${CMAKE_CURRENT_BINARY_DIR}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73450: [clangd] Add a symbol-name-based blacklist for rename.

2020-01-28 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 240822.
hokein marked an inline comment as done.
hokein added a comment.

move the comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73450

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  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
@@ -383,12 +383,12 @@
 
   // Typedef.
   R"cpp(
-namespace std {
+namespace ns {
 class basic_string {};
 typedef basic_string [[s^tring]];
-} // namespace std
+} // namespace ns
 
-std::[[s^tring]] foo();
+ns::[[s^tring]] foo();
   )cpp",
 
   // Variable.
@@ -539,6 +539,13 @@
  void fo^o() {})cpp",
"used outside main file", !HeaderFile, nullptr /*no index*/},
 
+  {R"cpp(// disallow rename on blacklisted symbols (e.g. std symbols)
+ namespace std {
+ class str^ing {};
+ }
+   )cpp",
+   "not a supported kind", !HeaderFile, Index},
+
   {R"cpp(
  void foo(int);
  void foo(char);
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -96,6 +96,15 @@
   return Result;
 }
 
+bool isBlacklisted(const NamedDecl &RenameDecl) {
+  static const auto *StdSymbols = new llvm::DenseSet({
+#define SYMBOL(Name, NameSpace, Header) {#NameSpace #Name},
+#include "StdSymbolMap.inc"
+#undef SYMBOL
+  });
+  return StdSymbols->count(RenameDecl.getQualifiedNameAsString());
+}
+
 enum ReasonToReject {
   NoSymbolFound,
   NoIndexProvided,
@@ -105,7 +114,7 @@
   AmbiguousSymbol,
 };
 
-llvm::Optional renameable(const Decl &RenameDecl,
+llvm::Optional renameable(const NamedDecl &RenameDecl,
   StringRef MainFilePath,
   const SymbolIndex *Index,
   bool CrossFile) {
@@ -120,6 +129,9 @@
   if (RenameDecl.getParentFunctionOrMethod())
 return None;
 
+  if (isBlacklisted(RenameDecl))
+return ReasonToReject::UnsupportedSymbol;
+
   // Check whether the symbol being rename is indexable.
   auto &ASTCtx = RenameDecl.getASTContext();
   bool MainFileIsHeader = isHeaderFile(MainFilePath, ASTCtx.getLangOpts());
@@ -131,12 +143,10 @@
 IsMainFileOnly = false;
   else if (!DeclaredInMainFile)
 IsMainFileOnly = false;
-  bool IsIndexable =
-  isa(RenameDecl) &&
-  SymbolCollector::shouldCollectSymbol(
-  cast(RenameDecl), RenameDecl.getASTContext(),
-  SymbolCollector::Options(), IsMainFileOnly);
-  if (!IsIndexable) // If the symbol is not indexable, we disallow rename.
+  // If the symbol is not indexable, we disallow rename.
+  if (!SymbolCollector::shouldCollectSymbol(
+  RenameDecl, RenameDecl.getASTContext(), SymbolCollector::Options(),
+  IsMainFileOnly))
 return ReasonToReject::NonIndexable;
 
   if (!CrossFile) {
@@ -222,7 +232,6 @@
   llvm::DenseSet TargetIDs;
   for (auto &USR : RenameUSRs)
 TargetIDs.insert(SymbolID(USR));
-
   std::vector Results;
   for (Decl *TopLevelDecl : AST.getLocalTopLevelDecls()) {
 findExplicitReferences(TopLevelDecl, [&](ReferenceLoc Ref) {
@@ -467,13 +476,13 @@
   if (DeclsUnderCursor.size() > 1)
 return makeError(ReasonToReject::AmbiguousSymbol);
 
-  const auto *RenameDecl = llvm::dyn_cast(*DeclsUnderCursor.begin());
+  const auto *RenameDecl = llvm::dyn_cast(
+  (*DeclsUnderCursor.begin())->getCanonicalDecl());
   if (!RenameDecl)
 return makeError(ReasonToReject::UnsupportedSymbol);
 
-  auto Reject =
-  renameable(*RenameDecl->getCanonicalDecl(), RInputs.MainFilePath,
- RInputs.Index, RInputs.AllowCrossFile);
+  auto Reject = renameable(*RenameDecl, RInputs.MainFilePath, RInputs.Index,
+   RInputs.AllowCrossFile);
   if (Reject)
 return makeError(*Reject);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73463: [clangd] use SCOPED_TRACE to better trace the testcase in test failure, NFC

2020-01-28 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdea11473db38: [clangd] use SCOPED_TRACE to better trace the 
testcase in test failure, NFC (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73463

Files:
  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
@@ -442,6 +442,7 @@
   )cpp",
   };
   for (llvm::StringRef T : Tests) {
+SCOPED_TRACE(T);
 Annotations Code(T);
 auto TU = TestTU::withCode(Code.code());
 TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
@@ -560,6 +561,7 @@
   };
 
   for (const auto& Case : Cases) {
+SCOPED_TRACE(Case.Code);
 Annotations T(Case.Code);
 TestTU TU = TestTU::withCode(T.code());
 TU.HeaderCode = CommonHeader;
@@ -886,6 +888,7 @@
   };
 
   for (const auto& T : Cases) {
+SCOPED_TRACE(T.FooH);
 Annotations FooH(T.FooH);
 Annotations FooCC(T.FooCC);
 std::string FooHPath = testPath("foo.h");
@@ -1012,6 +1015,7 @@
   LangOptions LangOpts;
   LangOpts.CPlusPlus = true;
   for (const auto &T : Tests) {
+SCOPED_TRACE(T.DraftCode);
 Annotations Draft(T.DraftCode);
 auto ActualRanges = adjustRenameRanges(
 Draft.code(), "x", Annotations(T.IndexedCode).ranges(), LangOpts);
@@ -1019,8 +1023,7 @@
EXPECT_THAT(Draft.ranges(), testing::IsEmpty());
 else
   EXPECT_THAT(Draft.ranges(),
-  testing::UnorderedElementsAreArray(*ActualRanges))
-  << T.DraftCode;
+  testing::UnorderedElementsAreArray(*ActualRanges));
   }
 }
 
@@ -1127,6 +1130,7 @@
 }
   };
   for (const auto &T : Tests) {
+SCOPED_TRACE(T.IndexedCode);
 auto Lexed = Annotations(T.LexedCode);
 auto LexedRanges = Lexed.ranges();
 std::vector ExpectedMatches;
@@ -1143,8 +1147,7 @@
 if (!Mapped)
   EXPECT_THAT(ExpectedMatches, IsEmpty());
 else
-  EXPECT_THAT(ExpectedMatches, UnorderedElementsAreArray(*Mapped))
-  << T.IndexedCode;
+  EXPECT_THAT(ExpectedMatches, UnorderedElementsAreArray(*Mapped));
   }
 }
 
@@ -1247,13 +1250,14 @@
 },
   };
   for (const auto &T : Tests) {
+SCOPED_TRACE(T.RangeCode);
 Annotations C(T.RangeCode);
 std::vector MappedIndex;
 for (size_t I = 0; I < C.ranges("lex").size(); ++I)
   MappedIndex.push_back(I);
 EXPECT_EQ(renameRangeAdjustmentCost(C.ranges("idx"), C.ranges("lex"),
 MappedIndex),
-  T.ExpectedCost) << T.RangeCode;
+  T.ExpectedCost);
   }
 }
 


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -442,6 +442,7 @@
   )cpp",
   };
   for (llvm::StringRef T : Tests) {
+SCOPED_TRACE(T);
 Annotations Code(T);
 auto TU = TestTU::withCode(Code.code());
 TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
@@ -560,6 +561,7 @@
   };
 
   for (const auto& Case : Cases) {
+SCOPED_TRACE(Case.Code);
 Annotations T(Case.Code);
 TestTU TU = TestTU::withCode(T.code());
 TU.HeaderCode = CommonHeader;
@@ -886,6 +888,7 @@
   };
 
   for (const auto& T : Cases) {
+SCOPED_TRACE(T.FooH);
 Annotations FooH(T.FooH);
 Annotations FooCC(T.FooCC);
 std::string FooHPath = testPath("foo.h");
@@ -1012,6 +1015,7 @@
   LangOptions LangOpts;
   LangOpts.CPlusPlus = true;
   for (const auto &T : Tests) {
+SCOPED_TRACE(T.DraftCode);
 Annotations Draft(T.DraftCode);
 auto ActualRanges = adjustRenameRanges(
 Draft.code(), "x", Annotations(T.IndexedCode).ranges(), LangOpts);
@@ -1019,8 +1023,7 @@
EXPECT_THAT(Draft.ranges(), testing::IsEmpty());
 else
   EXPECT_THAT(Draft.ranges(),
-  testing::UnorderedElementsAreArray(*ActualRanges))
-  << T.DraftCode;
+  testing::UnorderedElementsAreArray(*ActualRanges));
   }
 }
 
@@ -1127,6 +1130,7 @@
 }
   };
   for (const auto &T : Tests) {
+SCOPED_TRACE(T.IndexedCode);
 auto Lexed = Annotations(T.LexedCode);
 auto LexedRanges = Lexed.ranges();
 std::vector ExpectedMatches;
@@ -1143,8 +1147,7 @@
 if (!Mapped)
   EXPECT_THAT(ExpectedMatches, IsEmpty());
 else
-  EXPECT_THAT(ExpectedMatches, UnorderedElementsAreArray(*Mapped))
-  << T.IndexedCode;
+  EXPECT_THAT(ExpectedMatches, UnorderedElementsAreArray(*Mapped));
   }
 }
 
@@ -1247,13 +1250,14 @@
 },
   };
   for (const auto &T : Tests) {
+SCOPED_TRACE(T.RangeCode);
 Annotations C(T.RangeCode);
 std::vector MappedIn

[PATCH] D73537: [clangd] add CODE_OWNERS

2020-01-28 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73537



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


[PATCH] D73367: [clangd] Go-to-definition on 'override' jumps to overridden method(s)

2020-01-28 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62255 tests passed, 0 failed 
and 827 were skipped.

{icon times-circle color=red} clang-tidy: fail. clang-tidy found 0 errors and 1 
warnings 
.
 1 of them are added as review comments below (why? 
).

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73367



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


[clang-tools-extra] dea1147 - [clangd] use SCOPED_TRACE to better trace the testcase in test failure, NFC

2020-01-28 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-01-28T12:23:26+01:00
New Revision: dea11473db38d03cbfd77f0d46e92dceb202a24a

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

LOG: [clangd] use SCOPED_TRACE to better trace the testcase in test failure, NFC

Reviewers: kadircet

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/unittests/RenameTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp 
b/clang-tools-extra/clangd/unittests/RenameTests.cpp
index 6d62d1ee944b..620cdd0f483e 100644
--- a/clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -442,6 +442,7 @@ TEST(RenameTest, WithinFileRename) {
   )cpp",
   };
   for (llvm::StringRef T : Tests) {
+SCOPED_TRACE(T);
 Annotations Code(T);
 auto TU = TestTU::withCode(Code.code());
 TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
@@ -560,6 +561,7 @@ TEST(RenameTest, Renameable) {
   };
 
   for (const auto& Case : Cases) {
+SCOPED_TRACE(Case.Code);
 Annotations T(Case.Code);
 TestTU TU = TestTU::withCode(T.code());
 TU.HeaderCode = CommonHeader;
@@ -886,6 +888,7 @@ TEST(CrossFileRenameTests, WithUpToDateIndex) {
   };
 
   for (const auto& T : Cases) {
+SCOPED_TRACE(T.FooH);
 Annotations FooH(T.FooH);
 Annotations FooCC(T.FooCC);
 std::string FooHPath = testPath("foo.h");
@@ -1012,6 +1015,7 @@ TEST(CrossFileRenameTests, adjustRenameRanges) {
   LangOptions LangOpts;
   LangOpts.CPlusPlus = true;
   for (const auto &T : Tests) {
+SCOPED_TRACE(T.DraftCode);
 Annotations Draft(T.DraftCode);
 auto ActualRanges = adjustRenameRanges(
 Draft.code(), "x", Annotations(T.IndexedCode).ranges(), LangOpts);
@@ -1019,8 +1023,7 @@ TEST(CrossFileRenameTests, adjustRenameRanges) {
EXPECT_THAT(Draft.ranges(), testing::IsEmpty());
 else
   EXPECT_THAT(Draft.ranges(),
-  testing::UnorderedElementsAreArray(*ActualRanges))
-  << T.DraftCode;
+  testing::UnorderedElementsAreArray(*ActualRanges));
   }
 }
 
@@ -1127,6 +1130,7 @@ TEST(RangePatchingHeuristic, GetMappedRanges) {
 }
   };
   for (const auto &T : Tests) {
+SCOPED_TRACE(T.IndexedCode);
 auto Lexed = Annotations(T.LexedCode);
 auto LexedRanges = Lexed.ranges();
 std::vector ExpectedMatches;
@@ -1143,8 +1147,7 @@ TEST(RangePatchingHeuristic, GetMappedRanges) {
 if (!Mapped)
   EXPECT_THAT(ExpectedMatches, IsEmpty());
 else
-  EXPECT_THAT(ExpectedMatches, UnorderedElementsAreArray(*Mapped))
-  << T.IndexedCode;
+  EXPECT_THAT(ExpectedMatches, UnorderedElementsAreArray(*Mapped));
   }
 }
 
@@ -1247,13 +1250,14 @@ TEST(CrossFileRenameTests, adjustmentCost) {
 },
   };
   for (const auto &T : Tests) {
+SCOPED_TRACE(T.RangeCode);
 Annotations C(T.RangeCode);
 std::vector MappedIndex;
 for (size_t I = 0; I < C.ranges("lex").size(); ++I)
   MappedIndex.push_back(I);
 EXPECT_EQ(renameRangeAdjustmentCost(C.ranges("idx"), C.ranges("lex"),
 MappedIndex),
-  T.ExpectedCost) << T.RangeCode;
+  T.ExpectedCost);
   }
 }
 



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


[PATCH] D73537: [clangd] add CODE_OWNERS

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73537

Files:
  clang-tools-extra/CODE_OWNERS.TXT


Index: clang-tools-extra/CODE_OWNERS.TXT
===
--- clang-tools-extra/CODE_OWNERS.TXT
+++ clang-tools-extra/CODE_OWNERS.TXT
@@ -23,3 +23,7 @@
 N: Julie Hockett
 E: juliehock...@google.com
 D: clang-doc
+
+N: Sam McCall
+E: sammcc...@google.com
+D: clangd


Index: clang-tools-extra/CODE_OWNERS.TXT
===
--- clang-tools-extra/CODE_OWNERS.TXT
+++ clang-tools-extra/CODE_OWNERS.TXT
@@ -23,3 +23,7 @@
 N: Julie Hockett
 E: juliehock...@google.com
 D: clang-doc
+
+N: Sam McCall
+E: sammcc...@google.com
+D: clangd
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73367: [clangd] Go-to-definition on 'override' jumps to overridden method(s)

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

address comment and clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73367

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
@@ -447,6 +447,11 @@
 struct Fo^o {};
   )cpp",
 
+  R"cpp(// Override specifier jumps to overridden method
+class Y { virtual void $decl[[a]]() = 0; };
+class X : Y { void a() ^override {} };
+  )cpp",
+
   R"cpp(// Heuristic resolution of dependent method
 template 
 struct S {
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -21,6 +21,7 @@
 #include "index/Relation.h"
 #include "index/SymbolLocation.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/Attr.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
@@ -249,31 +250,17 @@
 return Result;
   }
 
-  // Emit all symbol locations (declaration or definition) from AST.
-  DeclRelationSet Relations =
-  DeclRelation::TemplatePattern | DeclRelation::Alias;
-  for (const NamedDecl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
+  auto AddResultDecl = [&](const NamedDecl *D) {
 const NamedDecl *Def = getDefinition(D);
 const NamedDecl *Preferred = Def ? Def : D;
 
-// If we're at the point of declaration of a template specialization,
-// it's more useful to navigate to the template declaration.
-if (SM.getMacroArgExpandedLocation(Preferred->getLocation()) ==
-IdentStartLoc) {
-  if (auto *CTSD = dyn_cast(Preferred)) {
-D = CTSD->getSpecializedTemplate();
-Def = getDefinition(D);
-Preferred = Def ? Def : D;
-  }
-}
-
 auto Loc = makeLocation(AST.getASTContext(), nameLocation(*Preferred, SM),
 *MainFilePath);
 if (!Loc)
-  continue;
+  return;
 
 Result.emplace_back();
-Result.back().Name = printName(AST.getASTContext(), *D);
+Result.back().Name = printName(AST.getASTContext(), *Preferred);
 Result.back().PreferredDeclaration = *Loc;
 // Preferred is always a definition if possible, so this check works.
 if (Def == Preferred)
@@ -282,6 +269,37 @@
 // Record SymbolID for index lookup later.
 if (auto ID = getSymbolID(Preferred))
   ResultIndex[*ID] = Result.size() - 1;
+  };
+
+  // Emit all symbol locations (declaration or definition) from AST.
+  DeclRelationSet Relations =
+  DeclRelation::TemplatePattern | DeclRelation::Alias;
+  for (const NamedDecl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
+// Special case: void foo() ^override: jump to the overridden method.
+if (const auto *CMD = llvm::dyn_cast(D)) {
+  const auto *Attr = D->getAttr();
+  const syntax::Token *Tok =
+  spelledIdentifierTouching(SourceLoc, AST.getTokens());
+  if (Attr && Tok &&
+  SM.getSpellingLoc(Attr->getLocation()) == Tok->location()) {
+// We may be overridding multiple methods - offer them all.
+for (const NamedDecl *ND : CMD->overridden_methods())
+  AddResultDecl(ND);
+continue;
+  }
+}
+
+// Special case: the point of declaration of a template specialization,
+// it's more useful to navigate to the template declaration.
+if (SM.getMacroArgExpandedLocation(D->getLocation()) == IdentStartLoc) {
+  if (auto *CTSD = dyn_cast(D)) {
+AddResultDecl(CTSD->getSpecializedTemplate());
+continue;
+  }
+}
+
+// Otherwise the target declaration is the right one.
+AddResultDecl(D);
   }
 
   // Now query the index for all Symbol IDs we found in the AST.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


<    1   2   3   >