[PATCH] D50534: [libc++] Fix handling of negated character classes in regex

2018-09-06 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added subscribers: hans, xbolva00.
xbolva00 added a comment.

is this fixed in 7.0 release branch too?

@hans


Repository:
  rCXX libc++

https://reviews.llvm.org/D50534



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


[PATCH] D32906: [Analyzer] Iterator Checker - Part 10: Support for iterators passed as parameter

2018-09-06 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 164152.
baloghadamsoftware added a comment.

Modification of the checker not needed anymore. Only tests added.


https://reviews.llvm.org/D32906

Files:
  test/Analysis/iterator-range.cpp
  test/Analysis/mismatched-iterator.cpp


Index: test/Analysis/mismatched-iterator.cpp
===
--- test/Analysis/mismatched-iterator.cpp
+++ test/Analysis/mismatched-iterator.cpp
@@ -144,6 +144,19 @@
   v1.insert(i, n); // expected-warning{{Container accessed using foreign 
iterator argument}}
 }
 
+template
+bool is_cend(Container cont, Iterator it) {
+  return it == cont.cend();
+}
+
+void good_empty(std::vector &v) {
+  is_cend(v, v.cbegin()); // no-warning
+}
+
+void bad_empty(std::vector &v1, std::vector &v2) {
+  is_cend(v1, v2.cbegin()); // expected-warning@149{{Iterators of different 
containers used where the same container is expected}}
+}
+
 void good_move(std::vector &v1, std::vector &v2) {
   const auto i0 = ++v2.cbegin();
   v1 = std::move(v2);
Index: test/Analysis/iterator-range.cpp
===
--- test/Analysis/iterator-range.cpp
+++ test/Analysis/iterator-range.cpp
@@ -216,6 +216,11 @@
 *first; // no-warning
 }
 
+void bad_non_std_find(std::vector &V, int e) {
+  auto first = nonStdFind(V.begin(), V.end(), e);
+  *first; // expected-warning{{Iterator accessed outside of its range}}
+}
+
 void tricky(std::vector &V, int e) {
   const auto first = V.begin();
   const auto comp1 = (first != V.end()), comp2 = (first == V.end());


Index: test/Analysis/mismatched-iterator.cpp
===
--- test/Analysis/mismatched-iterator.cpp
+++ test/Analysis/mismatched-iterator.cpp
@@ -144,6 +144,19 @@
   v1.insert(i, n); // expected-warning{{Container accessed using foreign iterator argument}}
 }
 
+template
+bool is_cend(Container cont, Iterator it) {
+  return it == cont.cend();
+}
+
+void good_empty(std::vector &v) {
+  is_cend(v, v.cbegin()); // no-warning
+}
+
+void bad_empty(std::vector &v1, std::vector &v2) {
+  is_cend(v1, v2.cbegin()); // expected-warning@149{{Iterators of different containers used where the same container is expected}}
+}
+
 void good_move(std::vector &v1, std::vector &v2) {
   const auto i0 = ++v2.cbegin();
   v1 = std::move(v2);
Index: test/Analysis/iterator-range.cpp
===
--- test/Analysis/iterator-range.cpp
+++ test/Analysis/iterator-range.cpp
@@ -216,6 +216,11 @@
 *first; // no-warning
 }
 
+void bad_non_std_find(std::vector &V, int e) {
+  auto first = nonStdFind(V.begin(), V.end(), e);
+  *first; // expected-warning{{Iterator accessed outside of its range}}
+}
+
 void tricky(std::vector &V, int e) {
   const auto first = V.begin();
   const auto comp1 = (first != V.end()), comp2 = (first == V.end());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32906: [Analyzer] Iterator Checker - Part 10: Support for iterators passed as parameter

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

Your are right, it is not necessary anymore. Should I keep this patch to add 
the tests only or should I abandon it completely?


https://reviews.llvm.org/D32906



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


[PATCH] D51719: Wrapped block after case label should not be merged into a single line (Bug 38854)

2018-09-06 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added a project: clang.
Herald added a subscriber: cfe-commits.

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


Repository:
  rC Clang

https://reviews.llvm.org/D51719

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


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -1064,6 +1064,32 @@
"  return;\n"
"}",
getLLVMStyleWithColumns(34));
+
+  FormatStyle Style = getLLVMStyle();
+  Style.IndentCaseLabels = true;
+  Style.AllowShortBlocksOnASingleLine = false;
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterControlStatement = true;
+  EXPECT_EQ("switch (n)\n"
+"{\n"
+"  case 0:\n"
+"  {\n"
+"return false;\n"
+"  }\n"
+"  default:\n"
+"  {\n"
+"return true;\n"
+"  }\n"
+"}",
+format("switch (n) {\n"
+   "  case 0: {\n"
+   "return false;\n"
+   "  }\n"
+   "  default: {\n"
+   "return true;\n"
+   "  }\n"
+   "}",
+   Style));
 }
 
 TEST_F(FormatTest, CaseRanges) {
Index: lib/Format/UnwrappedLineFormatter.cpp
===
--- lib/Format/UnwrappedLineFormatter.cpp
+++ lib/Format/UnwrappedLineFormatter.cpp
@@ -323,6 +323,10 @@
   kwId == clang::tok::objc_synchronized)
 return 0;
 }
+// Don't merge block with left brace wrapped after case labels
+if (TheLine->First->is(tok::l_brace) && I != AnnotatedLines.begin() &&
+I[-1]->First->isOneOf(tok::kw_case, tok::kw_default))
+  return 0;
 // Try to merge a block with left brace wrapped that wasn't yet covered
 if (TheLine->Last->is(tok::l_brace)) {
   return !Style.BraceWrapping.AfterFunction ||


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -1064,6 +1064,32 @@
"  return;\n"
"}",
getLLVMStyleWithColumns(34));
+
+  FormatStyle Style = getLLVMStyle();
+  Style.IndentCaseLabels = true;
+  Style.AllowShortBlocksOnASingleLine = false;
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterControlStatement = true;
+  EXPECT_EQ("switch (n)\n"
+"{\n"
+"  case 0:\n"
+"  {\n"
+"return false;\n"
+"  }\n"
+"  default:\n"
+"  {\n"
+"return true;\n"
+"  }\n"
+"}",
+format("switch (n) {\n"
+   "  case 0: {\n"
+   "return false;\n"
+   "  }\n"
+   "  default: {\n"
+   "return true;\n"
+   "  }\n"
+   "}",
+   Style));
 }
 
 TEST_F(FormatTest, CaseRanges) {
Index: lib/Format/UnwrappedLineFormatter.cpp
===
--- lib/Format/UnwrappedLineFormatter.cpp
+++ lib/Format/UnwrappedLineFormatter.cpp
@@ -323,6 +323,10 @@
   kwId == clang::tok::objc_synchronized)
 return 0;
 }
+// Don't merge block with left brace wrapped after case labels
+if (TheLine->First->is(tok::l_brace) && I != AnnotatedLines.begin() &&
+I[-1]->First->isOneOf(tok::kw_case, tok::kw_default))
+  return 0;
 // Try to merge a block with left brace wrapped that wasn't yet covered
 if (TheLine->Last->is(tok::l_brace)) {
   return !Style.BraceWrapping.AfterFunction ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51402: [OpenCL] Adding cl_intel_planar_yuv extension

2018-09-06 Thread Dmitry Sidorov via Phabricator via cfe-commits
sidorovd updated this revision to Diff 164157.
sidorovd added a comment.

I'm not sure if I put pragmas in an appropriate place (I mean in the very 
beginning of the header).


https://reviews.llvm.org/D51402

Files:
  lib/Headers/opencl-c.h
  test/SemaOpenCL/extension-version.cl


Index: test/SemaOpenCL/extension-version.cl
===
--- test/SemaOpenCL/extension-version.cl
+++ test/SemaOpenCL/extension-version.cl
@@ -1,11 +1,11 @@
-// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple spir-unknown-unknown
-// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown
-// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown
-// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown
-// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple spir-unknown-unknown 
-Wpedantic-core-features -DTEST_CORE_FEATURES
-// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown 
-Wpedantic-core-features -DTEST_CORE_FEATURES
-// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown 
-Wpedantic-core-features -DTEST_CORE_FEATURES
-// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown 
-Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -finclude-default-header -cl-std=CL %s -verify 
-triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -finclude-default-header -cl-std=CL1.1 %s -verify 
-triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -finclude-default-header -cl-std=CL1.2 %s -verify 
-triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -finclude-default-header -cl-std=CL2.0 %s -verify 
-triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -finclude-default-header -cl-std=CL %s -verify 
-triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -finclude-default-header -cl-std=CL1.1 %s -verify 
-triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -finclude-default-header -cl-std=CL1.2 %s -verify 
-triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -finclude-default-header -cl-std=CL2.0 %s -verify 
-triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 
 #if __OPENCL_C_VERSION__ >= 200 && ! defined TEST_CORE_FEATURES
 // expected-no-diagnostics
@@ -300,3 +300,11 @@
 #endif
 #pragma OPENCL EXTENSION cl_intel_subgroups_short : enable
 
+#if (__OPENCL_C_VERSION__ >= 120)
+#ifndef cl_intel_planar_yuv
+#error "Missing cl_intel_planar_yuv define"
+#endif
+#else
+// expected-warning@+2{{unknown OpenCL extension 'cl_intel_planar_yuv' - 
ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_intel_planar_yuv : enable
Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -22,6 +22,14 @@
 #endif //cl_khr_3d_image_writes
 #endif //__OPENCL_C_VERSION__ < CL_VERSION_2_0
 
+#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
+#ifndef cl_intel_planar_yuv
+#define cl_intel_planar_yuv
+#endif // cl_intel_planar_yuv
+#pragma OPENCL EXTENSION cl_intel_planar_yuv : begin
+#pragma OPENCL EXTENSION cl_intel_planar_yuv : end
+#endif // __OPENCL_C_VERSION__ >= CL_VERSION_1_2
+
 #define __ovld __attribute__((overloadable))
 #define __conv __attribute__((convergent))
 


Index: test/SemaOpenCL/extension-version.cl
===
--- test/SemaOpenCL/extension-version.cl
+++ test/SemaOpenCL/extension-version.cl
@@ -1,11 +1,11 @@
-// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple spir-unknown-unknown
-// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown
-// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown
-// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown
-// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
-// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
-// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
-// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -finclude-default-header -cl-std=CL %s -verify -triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -finclude-default-header -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -finclude-default-header -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -finclude-default-header -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown
+// RUN: %clang_cc1 -x cl -finclude-default-header -cl-std=CL %s -verify -triple spir-unknown-unknown -Wpedanti

[PATCH] D49722: [CStringSyntaxChecker] Check strlcat sizeof check

2018-09-06 Thread David CARLIER via Phabricator via cfe-commits
devnexen added a comment.

ping @george.karpenkov after that I won t bother you for a long time :)


https://reviews.llvm.org/D49722



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


[PATCH] D51722: [OpenCL] Allow blocks to capture arrays in OpenCL

2018-09-06 Thread Dmitry Sidorov via Phabricator via cfe-commits
sidorovd created this revision.
sidorovd added reviewers: Anastasia, yaxunl.
Herald added a subscriber: cfe-commits.
sidorovd added a comment.

Previously this patch was reviewed here: https://reviews.llvm.org/D26794 . I 
wasn't able to update it, so I created a new one with the comments applied.


Patch by Egor Churaev


Repository:
  rC Clang

https://reviews.llvm.org/D51722

Files:
  lib/Sema/SemaExpr.cpp
  test/SemaOpenCL/block-array-capturing.cl


Index: test/SemaOpenCL/block-array-capturing.cl
===
--- /dev/null
+++ test/SemaOpenCL/block-array-capturing.cl
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple spir64-unkown-unkown -emit-llvm 
%s -o -| FileCheck %s
+// expected-no-diagnostics
+
+typedef int (^block_t)();
+
+int block_typedef_kernel(global int* res) {
+  // CHECK: %{{.*}} = alloca <{ i32, i32, [3 x i32] }>
+  int a[3] = {1, 2, 3};
+  // CHECK: call void @llvm.memcpy{{.*}}
+  block_t b = ^() { return a[0]; };
+  return b();
+}
+
+// CHECK: define {{.*}} @__block_typedef_kernel_block_invoke
+// CHECK: %{{.*}} = getelementptr inbounds [3 x i32], [3 x i32] addrspace(4)* 
%{{.*}}, i64 0, i64 0
+// CHECK-NOT: call void @llvm.memcpy{{.*}}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14624,8 +14624,8 @@
   Expr *CopyExpr = nullptr;
   bool ByRef = false;
 
-  // Blocks are not allowed to capture arrays.
-  if (CaptureType->isArrayType()) {
+  // Blocks are not allowed to capture arrays, excepting OpenCL.
+  if (!S.getLangOpts().OpenCL && CaptureType->isArrayType()) {
 if (BuildAndDiagnose) {
   S.Diag(Loc, diag::err_ref_array_type);
   S.Diag(Var->getLocation(), diag::note_previous_decl)


Index: test/SemaOpenCL/block-array-capturing.cl
===
--- /dev/null
+++ test/SemaOpenCL/block-array-capturing.cl
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple spir64-unkown-unkown -emit-llvm %s -o -| FileCheck %s
+// expected-no-diagnostics
+
+typedef int (^block_t)();
+
+int block_typedef_kernel(global int* res) {
+  // CHECK: %{{.*}} = alloca <{ i32, i32, [3 x i32] }>
+  int a[3] = {1, 2, 3};
+  // CHECK: call void @llvm.memcpy{{.*}}
+  block_t b = ^() { return a[0]; };
+  return b();
+}
+
+// CHECK: define {{.*}} @__block_typedef_kernel_block_invoke
+// CHECK: %{{.*}} = getelementptr inbounds [3 x i32], [3 x i32] addrspace(4)* %{{.*}}, i64 0, i64 0
+// CHECK-NOT: call void @llvm.memcpy{{.*}}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14624,8 +14624,8 @@
   Expr *CopyExpr = nullptr;
   bool ByRef = false;
 
-  // Blocks are not allowed to capture arrays.
-  if (CaptureType->isArrayType()) {
+  // Blocks are not allowed to capture arrays, excepting OpenCL.
+  if (!S.getLangOpts().OpenCL && CaptureType->isArrayType()) {
 if (BuildAndDiagnose) {
   S.Diag(Loc, diag::err_ref_array_type);
   S.Diag(Var->getLocation(), diag::note_previous_decl)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51722: [OpenCL] Allow blocks to capture arrays in OpenCL

2018-09-06 Thread Dmitry Sidorov via Phabricator via cfe-commits
sidorovd added a comment.

Previously this patch was reviewed here: https://reviews.llvm.org/D26794 . I 
wasn't able to update it, so I created a new one with the comments applied.


Repository:
  rC Clang

https://reviews.llvm.org/D51722



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


[PATCH] D51411: [OpenCL] Improve diagnostic of argument in address space conversion builtins

2018-09-06 Thread Alistair Davies via Phabricator via cfe-commits
AlistairD updated this revision to Diff 164162.
AlistairD added a comment.

Reworded warning message, switched warning off by default, and added it to a 
group: generic-address-conversion.


https://reviews.llvm.org/D51411

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/SemaOpenCL/to_addr_builtin.cl


Index: test/SemaOpenCL/to_addr_builtin.cl
===
--- test/SemaOpenCL/to_addr_builtin.cl
+++ test/SemaOpenCL/to_addr_builtin.cl
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -verify -fsyntax-only %s
-// RUN: %clang_cc1 -verify -fsyntax-only -cl-std=CL2.0 %s
+// RUN: %clang_cc1 -Wgeneric-address-conversion -verify -fsyntax-only 
-cl-std=CL2.0 %s
 
 void test(void) {
   global int *glob;
@@ -43,13 +43,15 @@
   // expected-warning@-2{{incompatible integer to pointer conversion assigning 
to '__local int *' from 'int'}}
 #else
   // expected-error@-4{{assigning '__global int *' to '__local int *' changes 
address space of pointer}}
+  // expected-warning@-5{{passing non-generic address space pointer to 
to_global may cause dynamic conversion affecting performance}}
 #endif
 
   global char *glob_c = to_global(loc);
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
   // expected-warning@-2{{incompatible integer to pointer conversion 
initializing '__global char *' with an expression of type 'int'}}
 #else
   // expected-warning@-4{{incompatible pointer types initializing '__global 
char *' with an expression of type '__global int *'}}
+  // expected-warning@-5{{passing non-generic address space pointer to 
to_global may cause dynamic conversion affecting performance}}
 #endif
 
 }
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -839,6 +839,13 @@
 return true;
   }
 
+  if (RT->getPointeeType().getAddressSpace() != LangAS::opencl_generic) {
+S.Diag(Call->getArg(0)->getLocStart(),
+   diag::warn_opencl_generic_address_space_arg)
+<< Call->getDirectCallee()->getNameInfo().getAsString()
+<< Call->getArg(0)->getSourceRange();
+  }
+
   RT = RT->getPointeeType();
   auto Qual = RT.getQualifiers();
   switch (BuiltinID) {
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8590,6 +8590,10 @@
   "invalid prototype, variadic arguments are not allowed in OpenCL">;
 def err_opencl_requires_extension : Error<
   "use of %select{type|declaration}0 %1 requires %2 extension to be enabled">;
+def warn_opencl_generic_address_space_arg : Warning<
+  "passing non-generic address space pointer to %0"
+  " may cause dynamic conversion affecting performance">,
+  InGroup>, DefaultIgnore;
 
 // OpenCL v2.0 s6.13.6 -- Builtin Pipe Functions
 def err_opencl_builtin_pipe_first_arg : Error<


Index: test/SemaOpenCL/to_addr_builtin.cl
===
--- test/SemaOpenCL/to_addr_builtin.cl
+++ test/SemaOpenCL/to_addr_builtin.cl
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -verify -fsyntax-only %s
-// RUN: %clang_cc1 -verify -fsyntax-only -cl-std=CL2.0 %s
+// RUN: %clang_cc1 -Wgeneric-address-conversion -verify -fsyntax-only -cl-std=CL2.0 %s
 
 void test(void) {
   global int *glob;
@@ -43,13 +43,15 @@
   // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__local int *' from 'int'}}
 #else
   // expected-error@-4{{assigning '__global int *' to '__local int *' changes address space of pointer}}
+  // expected-warning@-5{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}}
 #endif
 
   global char *glob_c = to_global(loc);
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
   // expected-warning@-2{{incompatible integer to pointer conversion initializing '__global char *' with an expression of type 'int'}}
 #else
   // expected-warning@-4{{incompatible pointer types initializing '__global char *' with an expression of type '__global int *'}}
+  // expected-warning@-5{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}}
 #endif
 
 }
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -839,6 +839,13 @@
 return true;
   }
 
+  if (RT->getPointeeType().getAddressSpace() != LangAS::opencl_generic) {
+S.Diag(Call->getArg(0)->getLocStart(),
+   diag::warn_opencl_generic_address_space_arg)
+<< Call->getDirectCallee()->getNameInfo().getAsString()
+<< Call->getArg(0)->getSourceRange();
+  }
+
   RT = RT->getPointeeType();
   auto Qual = RT.getQualifiers();
   switch (BuiltinID) {
Index: include/clang/Basic/DiagnosticSemaKinds.td
===

[PATCH] D51484: [OpenCL] Add support of cl_intel_device_side_avc_motion_estimation extension

2018-09-06 Thread Alexey Sachkov via Phabricator via cfe-commits
AlexeySachkov added inline comments.



Comment at: include/clang/Basic/OpenCLExtensionTypes.def:1
+//===-- OpenCLExtensionTypes.def - Metadata about BuiltinTypes --*- C++ 
-*-===//
+//

Anastasia wrote:
> I am confused about the purpose of this file. Is it supposed to contain intel 
> extension specific types or generally OpenCL types?
It is supposed to contain any opaque types from any OpenCL extension



Comment at: include/clang/Basic/OpenCLExtensionTypes.def:27
+
+INTEL_SGAVC_TYPE(mce_payload_t, McePayload)
+INTEL_SGAVC_TYPE(ime_payload_t, ImePayload)

Anastasia wrote:
> From the specification of this extension I can't quite see if these types 
> have to be in Clang instead of the header. Can you please elaborate on any 
> example where it wouldn't be possible for this type to be declared in the 
> header using the technique explained in:
> https://clang.llvm.org/docs/UsersManual.html#opencl-extensions 
We cannot define these types in header because their layout is not defined in 
specification, i.e. all of these types are opaque


Repository:
  rC Clang

https://reviews.llvm.org/D51484



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


[PATCH] D51724: [clangd] Add "Deprecated" field to Symbol and CodeCompletion.

2018-09-06 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added reviewers: sammccall, kadircet.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, 
ilya-biryukov.

Also set "deprecated" field in LSP CompletionItem.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51724

Files:
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/Quality.cpp
  clangd/index/Index.h
  clangd/index/SymbolCollector.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/QualityTests.cpp

Index: unittests/clangd/QualityTests.cpp
===
--- unittests/clangd/QualityTests.cpp
+++ unittests/clangd/QualityTests.cpp
@@ -59,7 +59,7 @@
   F.References = 24; // TestTU doesn't count references, so fake it.
   Quality = {};
   Quality.merge(F);
-  EXPECT_FALSE(Quality.Deprecated); // FIXME: Include deprecated bit in index.
+  EXPECT_TRUE(Quality.Deprecated);
   EXPECT_FALSE(Quality.ReservedName);
   EXPECT_EQ(Quality.References, 24u);
   EXPECT_EQ(Quality.Category, SymbolQualitySignals::Function);
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -77,6 +77,7 @@
   return Contains(AllOf(Named(std::move(Name)), Kind(K)));
 }
 MATCHER(IsDocumented, "") { return !arg.Documentation.empty(); }
+MATCHER(Deprecated, "") { return arg.Deprecated; }
 
 std::unique_ptr memIndex(std::vector Symbols) {
   SymbolSlab::Builder Slab;
@@ -1355,6 +1356,7 @@
   C.Kind = CompletionItemKind::Method;
   C.Score.Total = 1.0;
   C.Origin = SymbolOrigin::AST | SymbolOrigin::Static;
+  C.Deprecated = true;
 
   CodeCompleteOptions Opts;
   Opts.IncludeIndicator.Insert = "^";
@@ -1370,6 +1372,7 @@
   EXPECT_EQ(R.documentation, "This is x().");
   EXPECT_THAT(R.additionalTextEdits, IsEmpty());
   EXPECT_EQ(R.sortText, sortText(1.0, "x"));
+  EXPECT_TRUE(R.deprecated);
 
   Opts.EnableSnippets = true;
   R = C.render(Opts);
@@ -1882,6 +1885,18 @@
   AllOf(Named("Func"), HasInclude("\"foo.h\""), Not(InsertInclude();
 }
 
+TEST(CompletionTest, DeprecatedResults) {
+  std::string Body = R"cpp(
+void TestClangd();
+void TestClangc() __attribute__((deprecated("", "")));
+  )cpp";
+
+  EXPECT_THAT(
+  completions(Body + "int main() { TestClang^ }").Completions,
+  UnorderedElementsAre(AllOf(Named("TestClangd"), Not(Deprecated())),
+   AllOf(Named("TestClangc"), Deprecated(;
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -535,6 +535,7 @@
 S.IncludeHeaders.emplace_back(Include, 1);
 
   S.Origin = Opts.Origin;
+  S.Deprecated = ND.getAvailability() == AR_Deprecated;
   Symbols.insert(S);
   return Symbols.find(S.ID);
 }
Index: clangd/index/Index.h
===
--- clangd/index/Index.h
+++ clangd/index/Index.h
@@ -244,7 +244,9 @@
   ///   any definition.
   llvm::SmallVector IncludeHeaders;
 
-  // FIXME: add extra fields for index scoring signals.
+  /// Indicates if the symbol is deprecated.
+  /// FIXME: also add deprecation message and fixit?
+  bool Deprecated = false;
 };
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Symbol &S);
 
Index: clangd/Quality.cpp
===
--- clangd/Quality.cpp
+++ clangd/Quality.cpp
@@ -167,9 +167,7 @@
 }
 
 void SymbolQualitySignals::merge(const CodeCompletionResult &SemaCCResult) {
-  if (SemaCCResult.Availability == CXAvailability_Deprecated)
-Deprecated = true;
-
+  Deprecated |= (SemaCCResult.Availability == CXAvailability_Deprecated);
   Category = categorize(SemaCCResult);
 
   if (SemaCCResult.Declaration) {
@@ -180,6 +178,7 @@
 }
 
 void SymbolQualitySignals::merge(const Symbol &IndexResult) {
+  Deprecated |= IndexResult.Deprecated;
   References = std::max(IndexResult.References, References);
   Category = categorize(IndexResult.SymInfo);
   ReservedName = ReservedName || isReserved(IndexResult.Name);
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -768,6 +768,9 @@
   /// themselves.
   std::vector additionalTextEdits;
 
+  /// Indicates if this item is deprecated.
+  bool deprecated = false;
+
   // TODO(krasimir): The following optional fields defined by the language
   // server protocol are unsupported:
   //
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -517,6 +517,8 @@
 Result["textEdit"] = *CI.textEdit;
   if (!CI.additionalTextEdits.empty())
 Result["additionalText

[PATCH] D51341: [HEADER] Overloadable function candidates for half/double types

2018-09-06 Thread Dmitry Sidorov via Phabricator via cfe-commits
sidorovd marked an inline comment as done.
sidorovd added inline comments.



Comment at: lib/Sema/SemaOverload.cpp:6063
+  // OpenCL: A candidate function that uses extentions that are not enabled or
+  // supported is not viable.
+  if (getLangOpts().OpenCL) {

Anastasia wrote:
> I would imagine if extension isn't supported the candidate function with data 
> type defined by extension shouldn't be available at all during compilation?
> 
> Also is there any good way to generalize this for all types and extensions 
> including vendor ones that are added with the pragmas?
> https://clang.llvm.org/docs/UsersManual.html#opencl-extensions
> I would imagine if extension isn't supported the candidate function with data 
> type defined by extension shouldn't be available at all during compilation?

Yes, you are right.

> Also is there any good way to generalize this for all types and extensions 
> including vendor ones that are added with the pragmas?
https://clang.llvm.org/docs/UsersManual.html#opencl-extensions

There might be a way but I can't properly answer this question right now. By 
default types and extensions aren't associated to each other.



Comment at: test/SemaOpenCL/half-double-overload.cl:18
+float __attribute__((overloadable)) foo_err(half in1, half in2);
+// expected-note@-1 {{candidate disabled due to OpenCL extension}}
+float __attribute__((overloadable)) foo_err(half in1, int in2);

Anastasia wrote:
> Wondering if better message could be:
>   candidate unavailable as it requires OpenCL extension to be disabled
> 
> Could it also print the extension name?
Sounds good. And I'd prefer to split it into another patch, because it would 
affect unrelated to the change tests and also require changes in Sema to allow 
extension name printing. 


https://reviews.llvm.org/D51341



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


[PATCH] D51341: [HEADER] Overloadable function candidates for half/double types

2018-09-06 Thread Dmitry Sidorov via Phabricator via cfe-commits
sidorovd updated this revision to Diff 164169.
sidorovd edited the summary of this revision.

https://reviews.llvm.org/D51341

Files:
  include/clang/AST/Type.h
  lib/AST/Type.cpp
  lib/Sema/SemaOverload.cpp
  test/SemaOpenCL/half-double-overload.cl


Index: test/SemaOpenCL/half-double-overload.cl
===
--- /dev/null
+++ test/SemaOpenCL/half-double-overload.cl
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
+
+float __attribute__((overloadable)) foo(float in1, float in2);
+int __attribute__((overloadable)) goo(float in1, float in2);
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+float __attribute__((overloadable)) foo(half in1, half in2);
+half __attribute__((overloadable)) goo(double in1, double in2);
+#pragma OPENCL EXTENSION cl_khr_fp16 : disable
+
+__kernel void vi(int x, int y) {
+  foo(x, y);
+  goo(x, y);
+}
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+float __attribute__((overloadable)) foo_err(half in1, half in2);
+// expected-note@-1 {{candidate disabled due to OpenCL extension}}
+float __attribute__((overloadable)) foo_err(half in1, int in2);
+// expected-note@-1 {{candidate disabled due to OpenCL extension}}
+#pragma OPENCL EXTENSION cl_khr_fp16 : disable
+
+__kernel void vi_err(int x, int y) {
+  foo_err(x, y);
+  // expected-error@-1 {{no matching function for call to 'foo_err'}}
+}
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -6059,6 +6059,33 @@
 return;
   }
 
+  // OpenCL: A candidate function that uses extentions that are not enabled or
+  // supported is not viable.
+  if (getLangOpts().OpenCL) {
+bool HasHalf =
+  getOpenCLOptions().isSupported("cl_khr_fp16", 
getLangOpts().OpenCLVersion)
+  && getOpenCLOptions().isEnabled("cl_khr_fp16");
+bool HasDouble =
+  getOpenCLOptions().isSupported("cl_khr_fp64", 
getLangOpts().OpenCLVersion)
+  && getOpenCLOptions().isEnabled("cl_khr_fp64");
+
+if ((!HasHalf && Function->getReturnType()->isHalfType()) ||
+(!HasDouble && Function->getReturnType()->isDoubleType())) {
+  Candidate.Viable = false;
+  Candidate.FailureKind = ovl_fail_ext_disabled;
+  return;
+}
+for (const auto *PI : Function->parameters()) {
+  QualType PTy = PI->getType();
+  if ((!HasHalf && PTy->isHalfType()) ||
+  (!HasDouble && PTy->isDoubleType())) {
+Candidate.Viable = false;
+Candidate.FailureKind = ovl_fail_ext_disabled;
+return;
+  }
+}
+  }
+
   // (CUDA B.1): Check for invalid calls between targets.
   if (getLangOpts().CUDA)
 if (const FunctionDecl *Caller = dyn_cast(CurContext))
Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -1919,6 +1919,13 @@
   return false;
 }
 
+bool Type::isDoubleType() const {
+  if (const BuiltinType *BT = dyn_cast(CanonicalType))
+return BT->getKind() >= BuiltinType::Double &&
+  BT->getKind() <= BuiltinType::LongDouble;
+  return false;
+}
+
 bool Type::hasFloatingRepresentation() const {
   if (const auto *VT = dyn_cast(CanonicalType))
 return VT->getElementType()->isFloatingType();
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -1924,6 +1924,7 @@
   bool isAggregateType() const;
   bool isFundamentalType() const;
   bool isCompoundType() const;
+  bool isDoubleType() const;   // (double + long double)
 
   // Type Predicates: Check to see if this type is structurally the specified
   // type, ignoring typedefs and qualifiers.


Index: test/SemaOpenCL/half-double-overload.cl
===
--- /dev/null
+++ test/SemaOpenCL/half-double-overload.cl
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
+
+float __attribute__((overloadable)) foo(float in1, float in2);
+int __attribute__((overloadable)) goo(float in1, float in2);
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+float __attribute__((overloadable)) foo(half in1, half in2);
+half __attribute__((overloadable)) goo(double in1, double in2);
+#pragma OPENCL EXTENSION cl_khr_fp16 : disable
+
+__kernel void vi(int x, int y) {
+  foo(x, y);
+  goo(x, y);
+}
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+float __attribute__((overloadable)) foo_err(half in1, half in2);
+// expected-note@-1 {{candidate disabled due to OpenCL extension}}
+float __attribute__((overloadable)) foo_err(half in1, int in2);
+// expected-note@-1 {{candidate disabled due to OpenCL extension}}
+#pragma OPENCL EXTENSION cl_khr_fp16 : disable
+
+__kernel void vi_err(int x, int y) {
+  foo_err(x, y);
+  // expected-error@-1 {{no matching function for call to 'foo_err'}}
+}
Index: lib/S

[libcxx] r341529 - Merging r340609:

2018-09-06 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Sep  6 01:54:44 2018
New Revision: 341529

URL: http://llvm.org/viewvc/llvm-project?rev=341529&view=rev
Log:
Merging r340609:

r340609 | ldionne | 2018-08-24 16:10:28 +0200 (Fri, 24 Aug 2018) | 13 lines

[libc++] Fix handling of negated character classes in regex

Summary:
This commit fixes a regression introduced in r316095, where we don't match
inverted character classes when there's no negated characrers in the []'s.

rdar://problem/43060054

Reviewers: mclow.lists, timshen, EricWF

Subscribers: christof, dexonsmith, cfe-commits

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


Added:

libcxx/branches/release_70/test/std/re/re.alg/re.alg.match/inverted_character_classes.pass.cpp
  - copied unchanged from r340609, 
libcxx/trunk/test/std/re/re.alg/re.alg.match/inverted_character_classes.pass.cpp
Modified:
libcxx/branches/release_70/   (props changed)
libcxx/branches/release_70/include/regex

libcxx/branches/release_70/test/std/re/re.alg/re.alg.search/invert_neg_word_search.pass.cpp

Propchange: libcxx/branches/release_70/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Sep  6 01:54:44 2018
@@ -1,2 +1,2 @@
 /libcxx/branches/apple:136569-137939
-/libcxx/trunk:339431,339675,339697,339702,339741-339743,339794,339804,339816,339874,340406,340544,340823
+/libcxx/trunk:339431,339675,339697,339702,339741-339743,339794,339804,339816,339874,340406,340544,340609,340823

Modified: libcxx/branches/release_70/include/regex
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_70/include/regex?rev=341529&r1=341528&r2=341529&view=diff
==
--- libcxx/branches/release_70/include/regex (original)
+++ libcxx/branches/release_70/include/regex Thu Sep  6 01:54:44 2018
@@ -2414,20 +2414,17 @@ __bracket_expression<_CharT, _Traits>::_
 goto __exit;
 }
 }
-// set of "__found" chars =
+// When there's at least one of __neg_chars_ and __neg_mask_, the set
+// of "__found" chars is
 //   union(complement(union(__neg_chars_, __neg_mask_)),
 // other cases...)
 //
-// __neg_chars_ and __neg_mask_'d better be handled together, as there
-// are no short circuit opportunities.
-//
-// In addition, when __neg_mask_/__neg_chars_ is empty, they should be
-// treated as all ones/all chars.
+// It doesn't make sense to check this when there are no __neg_chars_
+// and no __neg_mask_.
+if (!(__neg_mask_ == 0 && __neg_chars_.empty()))
 {
-  const bool __in_neg_mask = (__neg_mask_ == 0) ||
-  __traits_.isctype(__ch, __neg_mask_);
+const bool __in_neg_mask = __traits_.isctype(__ch, __neg_mask_);
   const bool __in_neg_chars =
-  __neg_chars_.empty() ||
   std::find(__neg_chars_.begin(), __neg_chars_.end(), __ch) !=
   __neg_chars_.end();
   if (!(__in_neg_mask || __in_neg_chars))

Modified: 
libcxx/branches/release_70/test/std/re/re.alg/re.alg.search/invert_neg_word_search.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_70/test/std/re/re.alg/re.alg.search/invert_neg_word_search.pass.cpp?rev=341529&r1=341528&r2=341529&view=diff
==
--- 
libcxx/branches/release_70/test/std/re/re.alg/re.alg.search/invert_neg_word_search.pass.cpp
 (original)
+++ 
libcxx/branches/release_70/test/std/re/re.alg/re.alg.search/invert_neg_word_search.pass.cpp
 Thu Sep  6 01:54:44 2018
@@ -18,7 +18,7 @@
 
 #include 
 #include 
-#include "test_macros.h"
+
 
 // PR34310
 int main()


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


Re: [libcxx] r340609 - [libc++] Fix handling of negated character classes in regex

2018-09-06 Thread Hans Wennborg via cfe-commits
Merged to 7.0 in r341529.

On Fri, Aug 24, 2018 at 4:10 PM, Louis Dionne via cfe-commits
 wrote:
> Author: ldionne
> Date: Fri Aug 24 07:10:28 2018
> New Revision: 340609
>
> URL: http://llvm.org/viewvc/llvm-project?rev=340609&view=rev
> Log:
> [libc++] Fix handling of negated character classes in regex
>
> Summary:
> This commit fixes a regression introduced in r316095, where we don't match
> inverted character classes when there's no negated characrers in the []'s.
>
> rdar://problem/43060054
>
> Reviewers: mclow.lists, timshen, EricWF
>
> Subscribers: christof, dexonsmith, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D50534
>
> Added:
> 
> libcxx/trunk/test/std/re/re.alg/re.alg.match/inverted_character_classes.pass.cpp
> Modified:
> libcxx/trunk/include/regex
> 
> libcxx/trunk/test/std/re/re.alg/re.alg.search/invert_neg_word_search.pass.cpp
>
> Modified: libcxx/trunk/include/regex
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=340609&r1=340608&r2=340609&view=diff
> ==
> --- libcxx/trunk/include/regex (original)
> +++ libcxx/trunk/include/regex Fri Aug 24 07:10:28 2018
> @@ -2414,20 +2414,17 @@ __bracket_expression<_CharT, _Traits>::_
>  goto __exit;
>  }
>  }
> -// set of "__found" chars =
> +// When there's at least one of __neg_chars_ and __neg_mask_, the set
> +// of "__found" chars is
>  //   union(complement(union(__neg_chars_, __neg_mask_)),
>  // other cases...)
>  //
> -// __neg_chars_ and __neg_mask_'d better be handled together, as 
> there
> -// are no short circuit opportunities.
> -//
> -// In addition, when __neg_mask_/__neg_chars_ is empty, they should 
> be
> -// treated as all ones/all chars.
> +// It doesn't make sense to check this when there are no __neg_chars_
> +// and no __neg_mask_.
> +if (!(__neg_mask_ == 0 && __neg_chars_.empty()))
>  {
> -  const bool __in_neg_mask = (__neg_mask_ == 0) ||
> -  __traits_.isctype(__ch, __neg_mask_);
> +const bool __in_neg_mask = __traits_.isctype(__ch, __neg_mask_);
>const bool __in_neg_chars =
> -  __neg_chars_.empty() ||
>std::find(__neg_chars_.begin(), __neg_chars_.end(), __ch) !=
>__neg_chars_.end();
>if (!(__in_neg_mask || __in_neg_chars))
>
> Added: 
> libcxx/trunk/test/std/re/re.alg/re.alg.match/inverted_character_classes.pass.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/inverted_character_classes.pass.cpp?rev=340609&view=auto
> ==
> --- 
> libcxx/trunk/test/std/re/re.alg/re.alg.match/inverted_character_classes.pass.cpp
>  (added)
> +++ 
> libcxx/trunk/test/std/re/re.alg/re.alg.match/inverted_character_classes.pass.cpp
>  Fri Aug 24 07:10:28 2018
> @@ -0,0 +1,44 @@
> +//===--===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is dual licensed under the MIT and the University of Illinois 
> Open
> +// Source Licenses. See LICENSE.TXT for details.
> +//
> +//===--===//
> +
> +// 
> +// UNSUPPORTED: c++98, c++03
> +
> +// Make sure that we correctly match inverted character classes.
> +
> +#include 
> +#include 
> +
> +
> +int main() {
> +assert(std::regex_match("X", std::regex("[X]")));
> +assert(std::regex_match("X", std::regex("[XY]")));
> +assert(!std::regex_match("X", std::regex("[^X]")));
> +assert(!std::regex_match("X", std::regex("[^XY]")));
> +
> +assert(std::regex_match("X", std::regex("[\\S]")));
> +assert(!std::regex_match("X", std::regex("[^\\S]")));
> +
> +assert(!std::regex_match("X", std::regex("[\\s]")));
> +assert(std::regex_match("X", std::regex("[^\\s]")));
> +
> +assert(std::regex_match("X", std::regex("[\\s\\S]")));
> +assert(std::regex_match("X", std::regex("[^Y\\s]")));
> +assert(!std::regex_match("X", std::regex("[^X\\s]")));
> +
> +assert(std::regex_match("X", std::regex("[\\w]")));
> +assert(std::regex_match("_", std::regex("[\\w]")));
> +assert(!std::regex_match("X", std::regex("[^\\w]")));
> +assert(!std::regex_match("_", std::regex("[^\\w]")));
> +
> +assert(!std::regex_match("X", std::regex("[\\W]")));
> +assert(!std::regex_match("_", std::regex("[\\W]")));
> +assert(std::regex_match("X", std::regex("[^\\W]")));
> +assert(std::regex_match("_", std::regex("[^\\W]")));
> +}
>
> Modified: 
> libcxx/trunk/test/std/re/re.alg/re.alg.search/invert_neg_word_search.pass.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.a

[PATCH] D50534: [libc++] Fix handling of negated character classes in regex

2018-09-06 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In https://reviews.llvm.org/D50534#1225591, @xbolva00 wrote:

> is this fixed in 7.0 release branch too?
>
> @hans


I've merged it in r341529 now. Thanks for letting me know.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50534



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


[PATCH] D51724: [clangd] Add "Deprecated" field to Symbol and CodeCompletion.

2018-09-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

I think you also need to update SymbolsYAML and Serialization.




Comment at: clangd/Protocol.cpp:520
 Result["additionalTextEdits"] = json::Array(CI.additionalTextEdits);
+  if (CI.deprecated)
+Result["deprecated"] = CI.deprecated;

do we actually want this in JSON?
(genuinely unsure - any clients aware of this extension?)



Comment at: clangd/Protocol.h:771
 
+  /// Indicates if this item is deprecated.
+  bool deprecated = false;

this is a clangd extension.
(right?)



Comment at: clangd/index/Index.h:249
+  /// FIXME: also add deprecation message and fixit?
+  bool Deprecated = false;
 };

would you mind packing this together with IsIndexedForCompletion, for memory 
size?
either as an actual bitfield `bool Deprecated : 1 = false` or as enum flags 
`enum Flags : uint8_t { IndexedForCompletion, Deprecated, }; Flags flags`

The latter will simplify life for serialization, but up to you.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51724



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


[PATCH] D51481: [clangd] Implement proximity path boosting for Dex

2018-09-06 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 164172.
kbobyrev marked 10 inline comments as done.
kbobyrev added a comment.

This should address the last round of comments.

There was still some hassle with the `SymbolSlab::Builder` in the unit tests 
and I decided to leave it as it is due to some weird ownership semantics 
introduced by `vector` of `Symbol`s.


https://reviews.llvm.org/D51481

Files:
  clang-tools-extra/clangd/FileDistance.h
  clang-tools-extra/clangd/URI.cpp
  clang-tools-extra/clangd/URI.h
  clang-tools-extra/clangd/index/SymbolYAML.cpp
  clang-tools-extra/clangd/index/SymbolYAML.h
  clang-tools-extra/clangd/index/dex/DexIndex.cpp
  clang-tools-extra/clangd/index/dex/DexIndex.h
  clang-tools-extra/clangd/index/dex/Token.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/unittests/clangd/DexIndexTests.cpp

Index: clang-tools-extra/unittests/clangd/DexIndexTests.cpp
===
--- clang-tools-extra/unittests/clangd/DexIndexTests.cpp
+++ clang-tools-extra/unittests/clangd/DexIndexTests.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+#include "FuzzyMatch.h"
+#include "TestFS.h"
 #include "TestIndex.h"
 #include "index/Index.h"
 #include "index/Merge.h"
@@ -30,6 +32,12 @@
 namespace dex {
 namespace {
 
+std::vector URISchemes = {"unittest"};
+
+//===--===//
+// Query iterator tests.
+//===--===//
+
 std::vector consumeIDs(Iterator &It) {
   auto IDAndScore = consume(It);
   std::vector IDs(IDAndScore.size());
@@ -325,15 +333,24 @@
   EXPECT_THAT(ElementBoost, 3);
 }
 
+//===--===//
+// Search token tests.
+//===--===//
+
 testing::Matcher>
-trigramsAre(std::initializer_list Trigrams) {
+tokensAre(std::initializer_list Strings, Token::Kind Kind) {
   std::vector Tokens;
-  for (const auto &Symbols : Trigrams) {
-Tokens.push_back(Token(Token::Kind::Trigram, Symbols));
+  for (const auto &TokenData : Strings) {
+Tokens.push_back(Token(Kind, TokenData));
   }
   return testing::UnorderedElementsAreArray(Tokens);
 }
 
+testing::Matcher>
+trigramsAre(std::initializer_list Trigrams) {
+  return tokensAre(Trigrams, Token::Kind::Trigram);
+}
+
 TEST(DexIndexTrigrams, IdentifierTrigrams) {
   EXPECT_THAT(generateIdentifierTrigrams("X86"),
   trigramsAre({"x86", "x$$", "x8$"}));
@@ -408,8 +425,25 @@
"hij", "ijk", "jkl", "klm"}));
 }
 
+TEST(DexSearchTokens, SymbolPath) {
+  EXPECT_THAT(generateProximityURIs(
+  "unittest:///clang-tools-extra/clangd/index/Token.h"),
+  ElementsAre("unittest:///clang-tools-extra/clangd/index/Token.h",
+  "unittest:///clang-tools-extra/clangd/index",
+  "unittest:///clang-tools-extra/clangd",
+  "unittest:///clang-tools-extra", "unittest:///"));
+
+  EXPECT_THAT(generateProximityURIs("unittest:///a/b/c.h"),
+  ElementsAre("unittest:///a/b/c.h", "unittest:///a/b",
+  "unittest:///a", "unittest:///"));
+}
+
+//===--===//
+// Index tests.
+//===--===//
+
 TEST(DexIndex, Lookup) {
-  auto I = DexIndex::build(generateSymbols({"ns::abc", "ns::xyz"}));
+  auto I = DexIndex::build(generateSymbols({"ns::abc", "ns::xyz"}), URISchemes);
   EXPECT_THAT(lookup(*I, SymbolID("ns::abc")), UnorderedElementsAre("ns::abc"));
   EXPECT_THAT(lookup(*I, {SymbolID("ns::abc"), SymbolID("ns::xyz")}),
   UnorderedElementsAre("ns::abc", "ns::xyz"));
@@ -421,7 +455,8 @@
 TEST(DexIndex, FuzzyFind) {
   auto Index = DexIndex::build(
   generateSymbols({"ns::ABC", "ns::BCD", "::ABC", "ns::nested::ABC",
-   "other::ABC", "other::A"}));
+   "other::ABC", "other::A"}),
+  URISchemes);
   FuzzyFindRequest Req;
   Req.Query = "ABC";
   Req.Scopes = {"ns::"};
@@ -443,7 +478,8 @@
 
 TEST(DexIndexTest, FuzzyMatchQ) {
   auto I = DexIndex::build(
-  generateSymbols({"LaughingOutLoud", "LionPopulation", "LittleOldLady"}));
+  generateSymbols({"LaughingOutLoud", "LionPopulation", "LittleOldLady"}),
+  URISchemes);
   FuzzyFindRequest Req;
   Req.Query = "lol";
   Req.MaxCandidateCount = 2;
@@ -461,12 +497,12 @@
  symbol("2") /* duplicate */};
   FuzzyFindRequest Req;
   Req.Query = "2";
-  DexIndex I(Symbols);
+  DexIndex I(Symbols, URISchemes);
   EXPECT_THAT(match(I, Req), ElementsAre("2", "2"));
 }
 
 TEST(DexIndexTest, DexIndexLimitedNumMatches) {
-  auto I = DexIndex::build(generateNumSymbols(0, 10

Re: [clang-tools-extra] r341459 - [clangd] Avoid enum class+enumValN to avoid GCC bug(?), and use consistent style.

2018-09-06 Thread Ilya Biryukov via cfe-commits
+1 for consistent style, but why not use enum class everywhere instead?

On Wed, Sep 5, 2018 at 12:41 PM Sam McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: sammccall
> Date: Wed Sep  5 03:39:58 2018
> New Revision: 341459
>
> URL: http://llvm.org/viewvc/llvm-project?rev=341459&view=rev
> Log:
> [clangd] Avoid enum class+enumValN to avoid GCC bug(?), and use consistent
> style.
>
> Modified:
>
> clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
> clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
>
> Modified:
> clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp?rev=341459&r1=341458&r2=341459&view=diff
>
> ==
> ---
> clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
> (original)
> +++
> clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
> Wed Sep  5 03:39:58 2018
> @@ -60,7 +60,7 @@ static llvm::cl::opt MergeOnTheFly
>  "MapReduce."),
>  llvm::cl::init(true), llvm::cl::Hidden);
>
> -enum class Format { YAML, Binary };
> +enum Format { YAML, Binary };
>  static llvm::cl::opt
>  Format("format", llvm::cl::desc("Format of the index to be written"),
> llvm::cl::values(
>
> Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp?rev=341459&r1=341458&r2=341459&view=diff
>
> ==
> --- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp (original)
> +++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Wed Sep  5 03:39:58
> 2018
> @@ -36,12 +36,6 @@ static llvm::cl::opt
> llvm::cl::desc("Use experimental Dex static index."),
> llvm::cl::init(true), llvm::cl::Hidden);
>
> -namespace {
> -
> -enum class PCHStorageFlag { Disk, Memory };
> -
> -} // namespace
> -
>  static llvm::cl::opt CompileCommandsDir(
>  "compile-commands-dir",
>  llvm::cl::desc("Specify a path to look for compile_commands.json. If
> path "
> @@ -54,10 +48,7 @@ static llvm::cl::opt
> llvm::cl::init(getDefaultAsyncThreadsCount()));
>
>  // FIXME: also support "plain" style where signatures are always omitted.
> -enum CompletionStyleFlag {
> -  Detailed,
> -  Bundled,
> -};
> +enum CompletionStyleFlag { Detailed, Bundled };
>  static llvm::cl::opt CompletionStyle(
>  "completion-style",
>  llvm::cl::desc("Granularity of code completion suggestions"),
> @@ -106,6 +97,7 @@ static llvm::cl::opt Test(
>  "Intended to simplify lit tests."),
>  llvm::cl::init(false), llvm::cl::Hidden);
>
> +enum PCHStorageFlag { Disk, Memory };
>  static llvm::cl::opt PCHStorage(
>  "pch-storage",
>  llvm::cl::desc("Storing PCHs in memory increases memory usages, but
> may "
> @@ -167,7 +159,6 @@ static llvm::cl::opt YamlSymbolFil
>  llvm::cl::init(""), llvm::cl::Hidden);
>
>  enum CompileArgsFrom { LSPCompileArgs, FilesystemCompileArgs };
> -
>  static llvm::cl::opt CompileArgsFrom(
>  "compile_args_from", llvm::cl::desc("The source of compile commands"),
>  llvm::cl::values(clEnumValN(LSPCompileArgs, "lsp",
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>


-- 
Regards,
Ilya Biryukov
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r341459 - [clangd] Avoid enum class+enumValN to avoid GCC bug(?), and use consistent style.

2018-09-06 Thread Ilya Biryukov via cfe-commits
Any pointers to the GCC bug/breakage mentioned?

On Thu, Sep 6, 2018 at 11:44 AM Ilya Biryukov  wrote:

> +1 for consistent style, but why not use enum class everywhere instead?
>
> On Wed, Sep 5, 2018 at 12:41 PM Sam McCall via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: sammccall
>> Date: Wed Sep  5 03:39:58 2018
>> New Revision: 341459
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=341459&view=rev
>> Log:
>> [clangd] Avoid enum class+enumValN to avoid GCC bug(?), and use
>> consistent style.
>>
>> Modified:
>>
>> clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
>> clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
>>
>> Modified:
>> clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp?rev=341459&r1=341458&r2=341459&view=diff
>>
>> ==
>> ---
>> clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
>> (original)
>> +++
>> clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
>> Wed Sep  5 03:39:58 2018
>> @@ -60,7 +60,7 @@ static llvm::cl::opt MergeOnTheFly
>>  "MapReduce."),
>>  llvm::cl::init(true), llvm::cl::Hidden);
>>
>> -enum class Format { YAML, Binary };
>> +enum Format { YAML, Binary };
>>  static llvm::cl::opt
>>  Format("format", llvm::cl::desc("Format of the index to be written"),
>> llvm::cl::values(
>>
>> Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp?rev=341459&r1=341458&r2=341459&view=diff
>>
>> ==
>> --- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp (original)
>> +++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Wed Sep  5
>> 03:39:58 2018
>> @@ -36,12 +36,6 @@ static llvm::cl::opt
>> llvm::cl::desc("Use experimental Dex static index."),
>> llvm::cl::init(true), llvm::cl::Hidden);
>>
>> -namespace {
>> -
>> -enum class PCHStorageFlag { Disk, Memory };
>> -
>> -} // namespace
>> -
>>  static llvm::cl::opt CompileCommandsDir(
>>  "compile-commands-dir",
>>  llvm::cl::desc("Specify a path to look for compile_commands.json. If
>> path "
>> @@ -54,10 +48,7 @@ static llvm::cl::opt
>> llvm::cl::init(getDefaultAsyncThreadsCount()));
>>
>>  // FIXME: also support "plain" style where signatures are always omitted.
>> -enum CompletionStyleFlag {
>> -  Detailed,
>> -  Bundled,
>> -};
>> +enum CompletionStyleFlag { Detailed, Bundled };
>>  static llvm::cl::opt CompletionStyle(
>>  "completion-style",
>>  llvm::cl::desc("Granularity of code completion suggestions"),
>> @@ -106,6 +97,7 @@ static llvm::cl::opt Test(
>>  "Intended to simplify lit tests."),
>>  llvm::cl::init(false), llvm::cl::Hidden);
>>
>> +enum PCHStorageFlag { Disk, Memory };
>>  static llvm::cl::opt PCHStorage(
>>  "pch-storage",
>>  llvm::cl::desc("Storing PCHs in memory increases memory usages, but
>> may "
>> @@ -167,7 +159,6 @@ static llvm::cl::opt YamlSymbolFil
>>  llvm::cl::init(""), llvm::cl::Hidden);
>>
>>  enum CompileArgsFrom { LSPCompileArgs, FilesystemCompileArgs };
>> -
>>  static llvm::cl::opt CompileArgsFrom(
>>  "compile_args_from", llvm::cl::desc("The source of compile
>> commands"),
>>  llvm::cl::values(clEnumValN(LSPCompileArgs, "lsp",
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
> --
> Regards,
> Ilya Biryukov
>


-- 
Regards,
Ilya Biryukov
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51674: [clangd] Fix async index loading (from r341376).

2018-09-06 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51674



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


[PATCH] D51481: [clangd] Implement proximity path boosting for Dex

2018-09-06 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 164176.
kbobyrev marked 3 inline comments as done.
kbobyrev added a comment.

Resolve the issue with `SymbolSlab::Builder` and make sure passed vector has 
correct lifetime.


https://reviews.llvm.org/D51481

Files:
  clang-tools-extra/clangd/FileDistance.h
  clang-tools-extra/clangd/URI.cpp
  clang-tools-extra/clangd/URI.h
  clang-tools-extra/clangd/index/SymbolYAML.cpp
  clang-tools-extra/clangd/index/SymbolYAML.h
  clang-tools-extra/clangd/index/dex/DexIndex.cpp
  clang-tools-extra/clangd/index/dex/DexIndex.h
  clang-tools-extra/clangd/index/dex/Token.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/unittests/clangd/DexIndexTests.cpp

Index: clang-tools-extra/unittests/clangd/DexIndexTests.cpp
===
--- clang-tools-extra/unittests/clangd/DexIndexTests.cpp
+++ clang-tools-extra/unittests/clangd/DexIndexTests.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+#include "FuzzyMatch.h"
+#include "TestFS.h"
 #include "TestIndex.h"
 #include "index/Index.h"
 #include "index/Merge.h"
@@ -30,6 +32,12 @@
 namespace dex {
 namespace {
 
+std::vector URISchemes = {"unittest"};
+
+//===--===//
+// Query iterator tests.
+//===--===//
+
 std::vector consumeIDs(Iterator &It) {
   auto IDAndScore = consume(It);
   std::vector IDs(IDAndScore.size());
@@ -325,15 +333,24 @@
   EXPECT_THAT(ElementBoost, 3);
 }
 
+//===--===//
+// Search token tests.
+//===--===//
+
 testing::Matcher>
-trigramsAre(std::initializer_list Trigrams) {
+tokensAre(std::initializer_list Strings, Token::Kind Kind) {
   std::vector Tokens;
-  for (const auto &Symbols : Trigrams) {
-Tokens.push_back(Token(Token::Kind::Trigram, Symbols));
+  for (const auto &TokenData : Strings) {
+Tokens.push_back(Token(Kind, TokenData));
   }
   return testing::UnorderedElementsAreArray(Tokens);
 }
 
+testing::Matcher>
+trigramsAre(std::initializer_list Trigrams) {
+  return tokensAre(Trigrams, Token::Kind::Trigram);
+}
+
 TEST(DexIndexTrigrams, IdentifierTrigrams) {
   EXPECT_THAT(generateIdentifierTrigrams("X86"),
   trigramsAre({"x86", "x$$", "x8$"}));
@@ -408,8 +425,25 @@
"hij", "ijk", "jkl", "klm"}));
 }
 
+TEST(DexSearchTokens, SymbolPath) {
+  EXPECT_THAT(generateProximityURIs(
+  "unittest:///clang-tools-extra/clangd/index/Token.h"),
+  ElementsAre("unittest:///clang-tools-extra/clangd/index/Token.h",
+  "unittest:///clang-tools-extra/clangd/index",
+  "unittest:///clang-tools-extra/clangd",
+  "unittest:///clang-tools-extra", "unittest:///"));
+
+  EXPECT_THAT(generateProximityURIs("unittest:///a/b/c.h"),
+  ElementsAre("unittest:///a/b/c.h", "unittest:///a/b",
+  "unittest:///a", "unittest:///"));
+}
+
+//===--===//
+// Index tests.
+//===--===//
+
 TEST(DexIndex, Lookup) {
-  auto I = DexIndex::build(generateSymbols({"ns::abc", "ns::xyz"}));
+  auto I = DexIndex::build(generateSymbols({"ns::abc", "ns::xyz"}), URISchemes);
   EXPECT_THAT(lookup(*I, SymbolID("ns::abc")), UnorderedElementsAre("ns::abc"));
   EXPECT_THAT(lookup(*I, {SymbolID("ns::abc"), SymbolID("ns::xyz")}),
   UnorderedElementsAre("ns::abc", "ns::xyz"));
@@ -421,7 +455,8 @@
 TEST(DexIndex, FuzzyFind) {
   auto Index = DexIndex::build(
   generateSymbols({"ns::ABC", "ns::BCD", "::ABC", "ns::nested::ABC",
-   "other::ABC", "other::A"}));
+   "other::ABC", "other::A"}),
+  URISchemes);
   FuzzyFindRequest Req;
   Req.Query = "ABC";
   Req.Scopes = {"ns::"};
@@ -443,7 +478,8 @@
 
 TEST(DexIndexTest, FuzzyMatchQ) {
   auto I = DexIndex::build(
-  generateSymbols({"LaughingOutLoud", "LionPopulation", "LittleOldLady"}));
+  generateSymbols({"LaughingOutLoud", "LionPopulation", "LittleOldLady"}),
+  URISchemes);
   FuzzyFindRequest Req;
   Req.Query = "lol";
   Req.MaxCandidateCount = 2;
@@ -461,12 +497,12 @@
  symbol("2") /* duplicate */};
   FuzzyFindRequest Req;
   Req.Query = "2";
-  DexIndex I(Symbols);
+  DexIndex I(Symbols, URISchemes);
   EXPECT_THAT(match(I, Req), ElementsAre("2", "2"));
 }
 
 TEST(DexIndexTest, DexIndexLimitedNumMatches) {
-  auto I = DexIndex::build(generateNumSymbols(0, 100));
+  auto I = DexIndex::build(generateNumSymbols(0, 100), URISchemes);
   FuzzyFindRequest Req;
   Req.Query = "5";
   Req.MaxCandidateCount

[PATCH] D51688: [clangd] Set SymbolID for sema macros so that they can be merged with index macros.

2018-09-06 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 164177.
ioeric marked 2 inline comments as done.
ioeric added a comment.

- improve comment; remove dead code.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51688

Files:
  clangd/AST.cpp
  clangd/AST.h
  clangd/CodeComplete.cpp
  clangd/index/SymbolCollector.cpp
  unittests/clangd/CodeCompleteTests.cpp

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -1882,6 +1882,17 @@
   AllOf(Named("Func"), HasInclude("\"foo.h\""), Not(InsertInclude();
 }
 
+TEST(CompletionTest, MergeMacrosFromIndexAndSema) {
+  Symbol Sym;
+  Sym.Name = "Clangd_Macro_Test";
+  Sym.ID = SymbolID("c:foo.cpp@8@macro@Clangd_Macro_Test");
+  Sym.SymInfo.Kind = index::SymbolKind::Macro;
+  Sym.IsIndexedForCodeCompletion = true;
+  EXPECT_THAT(completions("#define Clangd_Macro_Test\nClangd_Macro_T^", {Sym})
+  .Completions,
+  UnorderedElementsAre(Named("Clangd_Macro_Test")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -385,18 +385,16 @@
 Roles & static_cast(index::SymbolRole::Definition)))
 return true;
 
-  llvm::SmallString<128> USR;
-  if (index::generateUSRForMacro(Name->getName(), MI->getDefinitionLoc(), SM,
- USR))
+  auto ID = getSymbolID(*Name, MI, SM);
+  if (!ID)
 return true;
-  SymbolID ID(USR);
 
   // Only collect one instance in case there are multiple.
-  if (Symbols.find(ID) != nullptr)
+  if (Symbols.find(*ID) != nullptr)
 return true;
 
   Symbol S;
-  S.ID = std::move(ID);
+  S.ID = std::move(*ID);
   S.Name = Name->getName();
   S.IsIndexedForCodeCompletion = true;
   S.SymInfo = index::getSymbolInfoForMacro(*MI);
@@ -445,11 +443,9 @@
   if (Opts.CollectMacro) {
 assert(PP);
 for (const IdentifierInfo *II : ReferencedMacros) {
-  llvm::SmallString<128> USR;
   if (const auto *MI = PP->getMacroDefinition(II).getMacroInfo())
-if (!index::generateUSRForMacro(II->getName(), MI->getDefinitionLoc(),
-PP->getSourceManager(), USR))
-  IncRef(SymbolID(USR));
+if (auto ID = getSymbolID(*II, MI, PP->getSourceManager()))
+  IncRef(*ID);
 }
   }
 
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -505,14 +505,15 @@
 };
 
 // Determine the symbol ID for a Sema code completion result, if possible.
-llvm::Optional getSymbolID(const CodeCompletionResult &R) {
+llvm::Optional getSymbolID(const CodeCompletionResult &R,
+ const SourceManager &SM) {
   switch (R.Kind) {
   case CodeCompletionResult::RK_Declaration:
   case CodeCompletionResult::RK_Pattern: {
 return clang::clangd::getSymbolID(R.Declaration);
   }
   case CodeCompletionResult::RK_Macro:
-// FIXME: Macros do have USRs, but the CCR doesn't contain enough info.
+return clang::clangd::getSymbolID(*R.Macro, R.MacroDefInfo, SM);
   case CodeCompletionResult::RK_Keyword:
 return None;
   }
@@ -1435,7 +1436,8 @@
 llvm::DenseSet UsedIndexResults;
 auto CorrespondingIndexResult =
 [&](const CodeCompletionResult &SemaResult) -> const Symbol * {
-  if (auto SymID = getSymbolID(SemaResult)) {
+  if (auto SymID =
+  getSymbolID(SemaResult, Recorder->CCSema->getSourceManager())) {
 auto I = IndexResults.find(*SymID);
 if (I != IndexResults.end()) {
   UsedIndexResults.insert(&*I);
Index: clangd/AST.h
===
--- clangd/AST.h
+++ clangd/AST.h
@@ -37,6 +37,17 @@
 /// Gets the symbol ID for a declaration, if possible.
 llvm::Optional getSymbolID(const Decl *D);
 
+/// Gets the symbol ID for a macro, if possible.
+/// Currently, this is an encoded USR of the macro, which incorporates macro
+/// locations (e.g. file name, offset in file).
+/// FIXME: the USR semantics might not be stable enough as the ID for index
+/// macro (e.g. a change in definition offset can result in a different USR). We
+/// could change these semantics in the future by reimplementing this funcure
+/// (e.g. avoid USR for macros).
+llvm::Optional getSymbolID(const IdentifierInfo &II,
+ const MacroInfo *MI,
+ const SourceManager &SM);
+
 } // namespace clangd
 } // namespace clang
 
Index: clangd/AST.cpp
===
--- clangd/AST.cpp
+++ clangd/AST.cpp
@@ -61,5 +61,16 @@
   return SymbolID(USR);
 }
 
+llvm::Optional getSymbolID

[clang-tools-extra] r341534 - [clangd] Set SymbolID for sema macros so that they can be merged with index macros.

2018-09-06 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Sep  6 02:59:37 2018
New Revision: 341534

URL: http://llvm.org/viewvc/llvm-project?rev=341534&view=rev
Log:
[clangd] Set SymbolID for sema macros so that they can be merged with index 
macros.

Reviewers: sammccall

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

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

Modified:
clang-tools-extra/trunk/clangd/AST.cpp
clang-tools-extra/trunk/clangd/AST.h
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp

Modified: clang-tools-extra/trunk/clangd/AST.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/AST.cpp?rev=341534&r1=341533&r2=341534&view=diff
==
--- clang-tools-extra/trunk/clangd/AST.cpp (original)
+++ clang-tools-extra/trunk/clangd/AST.cpp Thu Sep  6 02:59:37 2018
@@ -61,5 +61,16 @@ llvm::Optional getSymbolID(con
   return SymbolID(USR);
 }
 
+llvm::Optional getSymbolID(const IdentifierInfo &II,
+ const MacroInfo *MI,
+ const SourceManager &SM) {
+  if (MI == nullptr)
+return None;
+  llvm::SmallString<128> USR;
+  if (index::generateUSRForMacro(II.getName(), MI->getDefinitionLoc(), SM, 
USR))
+return None;
+  return SymbolID(USR);
+}
+
 } // namespace clangd
 } // namespace clang

Modified: clang-tools-extra/trunk/clangd/AST.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/AST.h?rev=341534&r1=341533&r2=341534&view=diff
==
--- clang-tools-extra/trunk/clangd/AST.h (original)
+++ clang-tools-extra/trunk/clangd/AST.h Thu Sep  6 02:59:37 2018
@@ -37,6 +37,17 @@ std::string printQualifiedName(const Nam
 /// Gets the symbol ID for a declaration, if possible.
 llvm::Optional getSymbolID(const Decl *D);
 
+/// Gets the symbol ID for a macro, if possible.
+/// Currently, this is an encoded USR of the macro, which incorporates macro
+/// locations (e.g. file name, offset in file).
+/// FIXME: the USR semantics might not be stable enough as the ID for index
+/// macro (e.g. a change in definition offset can result in a different USR). 
We
+/// could change these semantics in the future by reimplementing this funcure
+/// (e.g. avoid USR for macros).
+llvm::Optional getSymbolID(const IdentifierInfo &II,
+ const MacroInfo *MI,
+ const SourceManager &SM);
+
 } // namespace clangd
 } // namespace clang
 

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=341534&r1=341533&r2=341534&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Thu Sep  6 02:59:37 2018
@@ -505,14 +505,15 @@ private:
 };
 
 // Determine the symbol ID for a Sema code completion result, if possible.
-llvm::Optional getSymbolID(const CodeCompletionResult &R) {
+llvm::Optional getSymbolID(const CodeCompletionResult &R,
+ const SourceManager &SM) {
   switch (R.Kind) {
   case CodeCompletionResult::RK_Declaration:
   case CodeCompletionResult::RK_Pattern: {
 return clang::clangd::getSymbolID(R.Declaration);
   }
   case CodeCompletionResult::RK_Macro:
-// FIXME: Macros do have USRs, but the CCR doesn't contain enough info.
+return clang::clangd::getSymbolID(*R.Macro, R.MacroDefInfo, SM);
   case CodeCompletionResult::RK_Keyword:
 return None;
   }
@@ -1435,7 +1436,8 @@ private:
 llvm::DenseSet UsedIndexResults;
 auto CorrespondingIndexResult =
 [&](const CodeCompletionResult &SemaResult) -> const Symbol * {
-  if (auto SymID = getSymbolID(SemaResult)) {
+  if (auto SymID =
+  getSymbolID(SemaResult, Recorder->CCSema->getSourceManager())) {
 auto I = IndexResults.find(*SymID);
 if (I != IndexResults.end()) {
   UsedIndexResults.insert(&*I);

Modified: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp?rev=341534&r1=341533&r2=341534&view=diff
==
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp Thu Sep  6 
02:59:37 2018
@@ -385,18 +385,16 @@ bool SymbolCollector::handleMacroOccuren
 Roles & static_cast(index::SymbolRole::Definition)))
 return true;
 
-  llvm::SmallString<128> USR;
-  if (index::generateUSRForMacro(Name->getName(), MI->

[PATCH] D51688: [clangd] Set SymbolID for sema macros so that they can be merged with index macros.

2018-09-06 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341534: [clangd] Set SymbolID for sema macros so that they 
can be merged with index… (authored by ioeric, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D51688

Files:
  clang-tools-extra/trunk/clangd/AST.cpp
  clang-tools-extra/trunk/clangd/AST.h
  clang-tools-extra/trunk/clangd/CodeComplete.cpp
  clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
  clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
@@ -1882,6 +1882,17 @@
   AllOf(Named("Func"), HasInclude("\"foo.h\""), Not(InsertInclude();
 }
 
+TEST(CompletionTest, MergeMacrosFromIndexAndSema) {
+  Symbol Sym;
+  Sym.Name = "Clangd_Macro_Test";
+  Sym.ID = SymbolID("c:foo.cpp@8@macro@Clangd_Macro_Test");
+  Sym.SymInfo.Kind = index::SymbolKind::Macro;
+  Sym.IsIndexedForCodeCompletion = true;
+  EXPECT_THAT(completions("#define Clangd_Macro_Test\nClangd_Macro_T^", {Sym})
+  .Completions,
+  UnorderedElementsAre(Named("Clangd_Macro_Test")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/trunk/clangd/CodeComplete.cpp
===
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp
@@ -505,14 +505,15 @@
 };
 
 // Determine the symbol ID for a Sema code completion result, if possible.
-llvm::Optional getSymbolID(const CodeCompletionResult &R) {
+llvm::Optional getSymbolID(const CodeCompletionResult &R,
+ const SourceManager &SM) {
   switch (R.Kind) {
   case CodeCompletionResult::RK_Declaration:
   case CodeCompletionResult::RK_Pattern: {
 return clang::clangd::getSymbolID(R.Declaration);
   }
   case CodeCompletionResult::RK_Macro:
-// FIXME: Macros do have USRs, but the CCR doesn't contain enough info.
+return clang::clangd::getSymbolID(*R.Macro, R.MacroDefInfo, SM);
   case CodeCompletionResult::RK_Keyword:
 return None;
   }
@@ -1435,7 +1436,8 @@
 llvm::DenseSet UsedIndexResults;
 auto CorrespondingIndexResult =
 [&](const CodeCompletionResult &SemaResult) -> const Symbol * {
-  if (auto SymID = getSymbolID(SemaResult)) {
+  if (auto SymID =
+  getSymbolID(SemaResult, Recorder->CCSema->getSourceManager())) {
 auto I = IndexResults.find(*SymID);
 if (I != IndexResults.end()) {
   UsedIndexResults.insert(&*I);
Index: clang-tools-extra/trunk/clangd/AST.cpp
===
--- clang-tools-extra/trunk/clangd/AST.cpp
+++ clang-tools-extra/trunk/clangd/AST.cpp
@@ -61,5 +61,16 @@
   return SymbolID(USR);
 }
 
+llvm::Optional getSymbolID(const IdentifierInfo &II,
+ const MacroInfo *MI,
+ const SourceManager &SM) {
+  if (MI == nullptr)
+return None;
+  llvm::SmallString<128> USR;
+  if (index::generateUSRForMacro(II.getName(), MI->getDefinitionLoc(), SM, USR))
+return None;
+  return SymbolID(USR);
+}
+
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
@@ -385,18 +385,16 @@
 Roles & static_cast(index::SymbolRole::Definition)))
 return true;
 
-  llvm::SmallString<128> USR;
-  if (index::generateUSRForMacro(Name->getName(), MI->getDefinitionLoc(), SM,
- USR))
+  auto ID = getSymbolID(*Name, MI, SM);
+  if (!ID)
 return true;
-  SymbolID ID(USR);
 
   // Only collect one instance in case there are multiple.
-  if (Symbols.find(ID) != nullptr)
+  if (Symbols.find(*ID) != nullptr)
 return true;
 
   Symbol S;
-  S.ID = std::move(ID);
+  S.ID = std::move(*ID);
   S.Name = Name->getName();
   S.IsIndexedForCodeCompletion = true;
   S.SymInfo = index::getSymbolInfoForMacro(*MI);
@@ -445,11 +443,9 @@
   if (Opts.CollectMacro) {
 assert(PP);
 for (const IdentifierInfo *II : ReferencedMacros) {
-  llvm::SmallString<128> USR;
   if (const auto *MI = PP->getMacroDefinition(II).getMacroInfo())
-if (!index::generateUSRForMacro(II->getName(), MI->getDefinitionLoc(),
-PP->getSourceManager(), USR))
-  IncRef(SymbolID(USR));
+if (auto ID = getSymbolID(*II, MI, PP->getSourceManager()))
+  IncRef(*ID);
 }
   }
 
Index: clang-tools-e

[PATCH] D51683: Fix arm_neon.h and arm_fp16.h generation for compiling with std=c89

2018-09-06 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio added inline comments.



Comment at: cfe/trunk/utils/TableGen/NeonEmitter.cpp:2412
 
-  OS << "#define __ai static inline __attribute__((__always_inline__, "
+  OS << "#define __ai static __inline __attribute__((__always_inline__, "
 "__nodebug__))\n\n";

joerg wrote:
> If you want to change it, at least change it properly to use __inline__.
Sorry, I don't get the suggestion. Do you mean test if it is C89 and use 
__inline, else, use inline?


Repository:
  rL LLVM

https://reviews.llvm.org/D51683



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


[PATCH] D51725: Allow un-setting the compilation database path

2018-09-06 Thread Simon Marchi via Phabricator via cfe-commits
simark created this revision.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, ioeric, 
ilya-biryukov.

It is currently possible to tell clangd where to find the
compile_commands.json file through the initializationOptions or the
didChangeConfiguration message.  However, it is not possible to tell
clangd to deselect any explicit compilation database path (i.e. go back
to the default).

This patch makes it possible by sending the value null:

  params: {
"settings": {
  "compilationDatabasePath": null
}
  }

Not including the compilationDatabasePath field doesn't change the value
(which means it doesn't deselect it if one is already set).  I chose to
do it this way because the other possible field,
compilationDatabaseChanges, just contains a delta.  So I think it makes
sense if compilationDatabasePath works the same way.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51725

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  test/clangd/compile-commands-path.test

Index: test/clangd/compile-commands-path.test
===
--- test/clangd/compile-commands-path.test
+++ test/clangd/compile-commands-path.test
@@ -39,4 +39,11 @@
 # CHECK-NEXT:   {
 # CHECK-NEXT: "message": "MACRO is two",
 ---
+{"jsonrpc":"2.0","id":0,"method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabasePath":null}}}
+# CHECK:   "method": "textDocument/publishDiagnostics",
+# CHECK-NEXT:   "params": {
+# CHECK-NEXT: "diagnostics": [
+# CHECK-NEXT:   {
+# CHECK-NEXT: "message": "MACRO is not defined",
+---
 {"jsonrpc":"2.0","id":1,"method":"shutdown"}
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -358,7 +358,14 @@
 /// "initialize" request and for the "workspace/didChangeConfiguration"
 /// notification since the data received is described as 'any' type in LSP.
 struct ClangdConfigurationParamsChange {
-  llvm::Optional compilationDatabasePath;
+  /// Path to the directory containing the compile_commands.json file to use.
+  /// The outer Optional is empty if the compilationDatabasePath field was not
+  /// present at all in the request.
+  /// The inner Optional is empty if the compilationDatabasePath field was
+  /// preset, but the value was null.
+  /// If the value of the compilationDatabasePath in the request is a string,
+  /// both Optionals are instantiated.
+  llvm::Optional> compilationDatabasePath;
 
   // The changes that happened to the compilation database.
   // The key of the map is a file name.
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -609,11 +609,22 @@
  O.map("compilationCommand", CDbUpdate.compilationCommand);
 }
 
-bool fromJSON(const json::Value &Params,
+bool fromJSON(const json::Value &Settings,
   ClangdConfigurationParamsChange &CCPC) {
-  json::ObjectMapper O(Params);
-  return O && O.map("compilationDatabasePath", CCPC.compilationDatabasePath) &&
- O.map("compilationDatabaseChanges", CCPC.compilationDatabaseChanges);
+  json::ObjectMapper O(Settings);
+  const json::Value *P = Settings.getAsObject()->get("compilationDatabasePath");
+
+  if (P) {
+// The field is present.
+CCPC.compilationDatabasePath.emplace();
+llvm::Optional S = P->getAsString();
+if (S) {
+  // The field has a string value.
+  CCPC.compilationDatabasePath->emplace(*S);
+}
+  }
+
+  return O && O.map("compilationDatabaseChanges", CCPC.compilationDatabaseChanges);
 }
 
 bool fromJSON(const json::Value &Params, ReferenceParams &R) {
Index: clangd/GlobalCompilationDatabase.h
===
--- clangd/GlobalCompilationDatabase.h
+++ clangd/GlobalCompilationDatabase.h
@@ -63,7 +63,7 @@
   tooling::CompileCommand getFallbackCommand(PathRef File) const override;
 
   /// Set the compile commands directory to \p P.
-  void setCompileCommandsDir(Path P);
+  void setCompileCommandsDir(llvm::Optional P);
 
   /// Sets the extra flags that should be added to a file.
   void setExtraFlagsForFile(PathRef File, std::vector ExtraFlags);
Index: clangd/GlobalCompilationDatabase.cpp
===
--- clangd/GlobalCompilationDatabase.cpp
+++ clangd/GlobalCompilationDatabase.cpp
@@ -60,7 +60,7 @@
   return C;
 }
 
-void DirectoryBasedGlobalCompilationDatabase::setCompileCommandsDir(Path P) {
+void DirectoryBasedGlobalCompilationDatabase::setCompileCommandsDir(llvm::Optional P) {
   std::lock_guard Lock(Mutex);
   CompileCommandsDir = P;
   CompilationDatabases.clear();
Index: clangd/ClangdLSPServer.h
==

[PATCH] D51725: Allow un-setting the compilation database path

2018-09-06 Thread Simon Marchi via Phabricator via cfe-commits
simark updated this revision to Diff 164183.
simark added a comment.

Fix formatting.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51725

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  test/clangd/compile-commands-path.test

Index: test/clangd/compile-commands-path.test
===
--- test/clangd/compile-commands-path.test
+++ test/clangd/compile-commands-path.test
@@ -39,4 +39,11 @@
 # CHECK-NEXT:   {
 # CHECK-NEXT: "message": "MACRO is two",
 ---
+{"jsonrpc":"2.0","id":0,"method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabasePath":null}}}
+# CHECK:   "method": "textDocument/publishDiagnostics",
+# CHECK-NEXT:   "params": {
+# CHECK-NEXT: "diagnostics": [
+# CHECK-NEXT:   {
+# CHECK-NEXT: "message": "MACRO is not defined",
+---
 {"jsonrpc":"2.0","id":1,"method":"shutdown"}
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -358,7 +358,14 @@
 /// "initialize" request and for the "workspace/didChangeConfiguration"
 /// notification since the data received is described as 'any' type in LSP.
 struct ClangdConfigurationParamsChange {
-  llvm::Optional compilationDatabasePath;
+  /// Path to the directory containing the compile_commands.json file to use.
+  /// The outer Optional is empty if the compilationDatabasePath field was not
+  /// present at all in the request.
+  /// The inner Optional is empty if the compilationDatabasePath field was
+  /// preset, but the value was null.
+  /// If the value of the compilationDatabasePath in the request is a string,
+  /// both Optionals are instantiated.
+  llvm::Optional> compilationDatabasePath;
 
   // The changes that happened to the compilation database.
   // The key of the map is a file name.
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -609,10 +609,22 @@
  O.map("compilationCommand", CDbUpdate.compilationCommand);
 }
 
-bool fromJSON(const json::Value &Params,
+bool fromJSON(const json::Value &Settings,
   ClangdConfigurationParamsChange &CCPC) {
-  json::ObjectMapper O(Params);
-  return O && O.map("compilationDatabasePath", CCPC.compilationDatabasePath) &&
+  json::ObjectMapper O(Settings);
+  const json::Value *P = Settings.getAsObject()->get("compilationDatabasePath");
+
+  if (P) {
+// The field is present.
+CCPC.compilationDatabasePath.emplace();
+llvm::Optional S = P->getAsString();
+if (S) {
+  // The field has a string value.
+  CCPC.compilationDatabasePath->emplace(*S);
+}
+  }
+
+  return O &&
  O.map("compilationDatabaseChanges", CCPC.compilationDatabaseChanges);
 }
 
Index: clangd/GlobalCompilationDatabase.h
===
--- clangd/GlobalCompilationDatabase.h
+++ clangd/GlobalCompilationDatabase.h
@@ -63,7 +63,7 @@
   tooling::CompileCommand getFallbackCommand(PathRef File) const override;
 
   /// Set the compile commands directory to \p P.
-  void setCompileCommandsDir(Path P);
+  void setCompileCommandsDir(llvm::Optional P);
 
   /// Sets the extra flags that should be added to a file.
   void setExtraFlagsForFile(PathRef File, std::vector ExtraFlags);
Index: clangd/GlobalCompilationDatabase.cpp
===
--- clangd/GlobalCompilationDatabase.cpp
+++ clangd/GlobalCompilationDatabase.cpp
@@ -60,7 +60,8 @@
   return C;
 }
 
-void DirectoryBasedGlobalCompilationDatabase::setCompileCommandsDir(Path P) {
+void DirectoryBasedGlobalCompilationDatabase::setCompileCommandsDir(
+llvm::Optional P) {
   std::lock_guard Lock(Mutex);
   CompileCommandsDir = P;
   CompilationDatabases.clear();
Index: clangd/ClangdLSPServer.h
===
--- clangd/ClangdLSPServer.h
+++ clangd/ClangdLSPServer.h
@@ -126,9 +126,10 @@
 void setExtraFlagsForFile(PathRef File,
   std::vector ExtraFlags);
 
-/// Set the compile commands directory to \p P.
+/// Set the compile commands directory to \p P.  An empty Optional value
+/// means to not use an explicit compile commands directory path.
 /// Only valid for directory-based CDB, no-op and error log on InMemoryCDB;
-void setCompileCommandsDir(Path P);
+void setCompileCommandsDir(llvm::Optional P);
 
 /// Returns a CDB that should be used to get compile commands for the
 /// current instance of ClangdLSPServer.
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -613,14 

[PATCH] D51038: [clang] Make sure codecompletion is called for calls even when inside a token.

2018-09-06 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: test/Index/complete-block-property-assignment.m:71
 
+// RUN: c-index-test -code-completion-at=%s:54:15 %s | FileCheck 
-check-prefix=CHECK-NO1 %s
+// CHECK-NO1: ObjCPropertyDecl:{ResultType int}{TypedText foo} (35)

Any idea why behavior changed in that case?


Repository:
  rC Clang

https://reviews.llvm.org/D51038



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


Re: r341475 - Fix arm_neon.h and arm_fp16.h generation for compiling with std=c89

2018-09-06 Thread Diogo Sampaio via cfe-commits

Sorry, but my patch is not reverted, and as for now it only reads:

Failing Tests (2):
   LLVM :: CodeGen/AMDGPU/mubuf-legalize-operands.ll
   LLVM :: CodeGen/AMDGPU/mubuf-legalize-operands.mir


So I'm considering it was a side-effect of some other test.

On 09/05/2018 10:00 PM, Galina Kistanova wrote:
Hello Diogo,

This commit added couple of broken tests to one of our builders:
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win

. . .
Failing Tests (5):
   Clang :: Headers/arm-fp16-header.c
   Clang :: Headers/arm-neon-header.c
. . .

Please have a look?
The builder was already red and did not send notifications on this.

Thanks

Galina

On Wed, Sep 5, 2018 at 7:59 AM Diogo N. Sampaio via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: dnsampaio
Date: Wed Sep  5 07:56:21 2018
New Revision: 341475

URL: http://llvm.org/viewvc/llvm-project?rev=341475&view=rev
Log:
Fix arm_neon.h and arm_fp16.h generation for compiling with std=c89


Summary:
The inline attribute is not valid for C standard 89. Replace the argument in 
the generation of header files with __inline, as well adding tests for both 
header files.

Reviewers: pbarrio, SjoerdMeijer, javed.absar, t.p.northover

Subscribers: t.p.northover, kristof.beyls, chrib, cfe-commits

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

test/Headers/arm-fp16-header.c
test/Headers/arm-neon-header.c
utils/TableGen/NeonEmitter.cpp

Added:
   cfe/trunk/test/Headers/arm-fp16-header.c
Modified:
   cfe/trunk/test/Headers/arm-neon-header.c
   cfe/trunk/utils/TableGen/NeonEmitter.cpp

Added: cfe/trunk/test/Headers/arm-fp16-header.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/arm-fp16-header.c?rev=341475&view=auto
==
--- cfe/trunk/test/Headers/arm-fp16-header.c (added)
+++ cfe/trunk/test/Headers/arm-fp16-header.c Wed Sep  5 07:56:21 2018
@@ -0,0 +1,19 @@
+// RUN: %clang -fsyntax-only  -ffreestanding --target=aarch64-arm-none-eabi 
-march=armv8.2-a+fp16 -std=c89 -xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c99 -xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c11 -xc %s
+
+// RUN: %clang -fsyntax-only -ffreestanding --target=aarch64-armeb-none-eabi 
-march=armv8.2-a+fp16 -std=c89 -xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c99 -xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c11 -xc %s
+
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c++98 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c++11 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c++14 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c++17 -xc++ %s
+
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c++98 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c++11 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c++14 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c++17 -xc++ %s
+
+#include 

Modified: cfe/trunk/test/Headers/arm-neon-header.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/arm-neon-header.c?rev=341475&r1=341474&r2=341475&view=diff
==
--- cfe/trunk/test/Headers/arm-neon-header.c (original)
+++ cfe/trunk/test/Headers/arm-neon-header.c Wed Sep  5 07:56:21 2018
@@ -2,4 +2,23 @@
// RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -fno-lax-vector-conversions -ffreestanding %s
// RUN: %clang_cc1 -x c++ -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -Wvector-conversions -ffreestanding %s

+// RUN: %clang -fsyntax-only -ffreestanding --target=aarch64-arm-none-eabi 
-march=armv8.2-a+fp16 -std=c89 -xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c99 -xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c11 -xc %s
+
+// RUN: %clang -fsyntax-only -ffreestanding --target=aarch64-armeb-none-eabi 
-march=armv8.2-a+fp16 -std=c89 -xc %s
+// RUN: %clang -fsyntax-only -Wall 

[clang-tools-extra] r341538 - [clangd] Fix data race in async fuzzyFind tests.

2018-09-06 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Thu Sep  6 04:04:56 2018
New Revision: 341538

URL: http://llvm.org/viewvc/llvm-project?rev=341538&view=rev
Log:
[clangd] Fix data race in async fuzzyFind tests.

Modified:
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp

Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=341538&r1=341537&r2=341538&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Thu Sep  6 
04:04:56 2018
@@ -966,6 +966,7 @@ public:
   bool
   fuzzyFind(const FuzzyFindRequest &Req,
 llvm::function_ref Callback) const override {
+std::lock_guard Lock(Mut);
 Requests.push_back(Req);
 return true;
   }
@@ -981,12 +982,15 @@ public:
   size_t estimateMemoryUsage() const override { return 0; }
 
   const std::vector consumeRequests() const {
+std::lock_guard Lock(Mut);
 auto Reqs = std::move(Requests);
 Requests = {};
 return Reqs;
   }
 
 private:
+  // We need a mutex to handle async fuzzy find requests.
+  mutable std::mutex Mut;
   mutable std::vector Requests;
 };
 


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


[PATCH] D51727: [OpenCL] Allow zero assignment and comparisons between queue_t type variables

2018-09-06 Thread Alistair Davies via Phabricator via cfe-commits
AlistairD created this revision.
AlistairD added reviewers: yaxunl, bader.

This change allows for zero assignment and comparison of queue_t type 
variables, and extends null_queue.cl to test this.


https://reviews.llvm.org/D51727

Files:
  lib/Sema/SemaExpr.cpp
  test/SemaOpenCL/null_queue.cl


Index: test/SemaOpenCL/null_queue.cl
===
--- test/SemaOpenCL/null_queue.cl
+++ test/SemaOpenCL/null_queue.cl
@@ -1,12 +1,30 @@
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
 extern queue_t get_default_queue();
 
-bool compare() {
-  return 1 == get_default_queue() && // expected-error{{invalid operands to 
binary expression ('int' and 'queue_t')}}
- get_default_queue() == 1; // expected-error{{invalid operands to 
binary expression ('queue_t' and 'int')}}
-}
+void queue_arg(queue_t); // expected-note {{passing argument to parameter 
here}}
 
 void init() {
   queue_t q1 = 1; // expected-error{{initializing 'queue_t' with an expression 
of incompatible type 'int'}}
   queue_t q = 0;
 }
+
+void assign() {
+  queue_t q2, q3;
+  q2 = 5; // expected-error{{assigning to 'queue_t' from incompatible type 
'int'}}
+  q3 = 0;
+  q2 = q3 = 0;
+}
+
+bool compare() {
+  queue_t q4, q5;
+  return 1 == get_default_queue() && // expected-error{{invalid operands to 
binary expression ('int' and 'queue_t')}}
+ get_default_queue() == 1 && // expected-error{{invalid operands to 
binary expression ('queue_t' and 'int')}}
+q4 == q5 &&
+q4 != 0 &&
+q4 != 0.0f; // expected-error{{invalid operands to binary 
expression ('queue_t' and 'float')}}
+}
+
+void call() {
+  queue_arg(5); // expected-error {{passing 'int' to parameter of incompatible 
type 'queue_t'}}
+  queue_arg(0);
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -8085,6 +8085,13 @@
 return Compatible;
   }
 
+  // OpenCL queue_t type assignment.
+  if (LHSType->isQueueT() && RHS.get()->isNullPointerConstant(
+ Context, Expr::NPC_ValueDependentIsNull)) {
+RHS = ImpCastExprToType(RHS.get(), LHSType, CK_NullToPointer);
+return Compatible;
+  }
+
   // This check seems unnatural, however it is necessary to ensure the proper
   // conversion of functions/arrays. If the conversion were done for all
   // DeclExpr's (created by ActOnIdExpression), it would mess up the unary
@@ -10422,6 +10429,10 @@
   }
 
   if (getLangOpts().OpenCLVersion >= 200) {
+if (LHSType->isQueueT() && RHSType->isQueueT()) {
+  return computeResultTy();
+}
+
 if (LHSIsNull && RHSType->isQueueT()) {
   LHS = ImpCastExprToType(LHS.get(), RHSType, CK_NullToPointer);
   return computeResultTy();


Index: test/SemaOpenCL/null_queue.cl
===
--- test/SemaOpenCL/null_queue.cl
+++ test/SemaOpenCL/null_queue.cl
@@ -1,12 +1,30 @@
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
 extern queue_t get_default_queue();
 
-bool compare() {
-  return 1 == get_default_queue() && // expected-error{{invalid operands to binary expression ('int' and 'queue_t')}}
- get_default_queue() == 1; // expected-error{{invalid operands to binary expression ('queue_t' and 'int')}}
-}
+void queue_arg(queue_t); // expected-note {{passing argument to parameter here}}
 
 void init() {
   queue_t q1 = 1; // expected-error{{initializing 'queue_t' with an expression of incompatible type 'int'}}
   queue_t q = 0;
 }
+
+void assign() {
+  queue_t q2, q3;
+  q2 = 5; // expected-error{{assigning to 'queue_t' from incompatible type 'int'}}
+  q3 = 0;
+  q2 = q3 = 0;
+}
+
+bool compare() {
+  queue_t q4, q5;
+  return 1 == get_default_queue() && // expected-error{{invalid operands to binary expression ('int' and 'queue_t')}}
+ get_default_queue() == 1 && // expected-error{{invalid operands to binary expression ('queue_t' and 'int')}}
+	 q4 == q5 &&
+	 q4 != 0 &&
+	 q4 != 0.0f; // expected-error{{invalid operands to binary expression ('queue_t' and 'float')}}
+}
+
+void call() {
+  queue_arg(5); // expected-error {{passing 'int' to parameter of incompatible type 'queue_t'}}
+  queue_arg(0);
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -8085,6 +8085,13 @@
 return Compatible;
   }
 
+  // OpenCL queue_t type assignment.
+  if (LHSType->isQueueT() && RHS.get()->isNullPointerConstant(
+ Context, Expr::NPC_ValueDependentIsNull)) {
+RHS = ImpCastExprToType(RHS.get(), LHSType, CK_NullToPointer);
+return Compatible;
+  }
+
   // This check seems unnatural, however it is necessary to ensure the proper
   // conversion of functions/arrays. If the conversion were done for all
   // DeclExpr's (create

[PATCH] D42370: Issue local statics in correct DWARF lexical scope

2018-09-06 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere accepted this revision as: JDevlieghere.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

This makes sense to me, LGTM.


https://reviews.llvm.org/D42370



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


[PATCH] D50259: [OpenCL] Disallow negative attribute arguments

2018-09-06 Thread Andrew Savonichev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC341539: [OpenCL] Disallow negative attribute arguments 
(authored by asavonic, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50259?vs=159022&id=164190#toc

Repository:
  rC Clang

https://reviews.llvm.org/D50259

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclAttr.cpp
  test/SemaOpenCL/invalid-kernel-attrs.cl


Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -227,9 +227,13 @@
 
 /// If Expr is a valid integer constant, get the value of the integer
 /// expression and return success or failure. May output an error.
+///
+/// Negative argument is implicitly converted to unsigned, unless
+/// \p StrictlyUnsigned is true.
 template 
 static bool checkUInt32Argument(Sema &S, const AttrInfo &AI, const Expr *Expr,
-uint32_t &Val, unsigned Idx = UINT_MAX) {
+uint32_t &Val, unsigned Idx = UINT_MAX,
+bool StrictlyUnsigned = false) {
   llvm::APSInt I(32);
   if (Expr->isTypeDependent() || Expr->isValueDependent() ||
   !Expr->isIntegerConstantExpr(I, S.Context)) {
@@ -249,6 +253,11 @@
 return false;
   }
 
+  if (StrictlyUnsigned && I.isSigned() && I.isNegative()) {
+S.Diag(getAttrLoc(AI), diag::err_attribute_argument_negative) << AI;
+return false;
+  }
+
   Val = (uint32_t)I.getZExtValue();
   return true;
 }
@@ -2766,7 +2775,8 @@
   uint32_t WGSize[3];
   for (unsigned i = 0; i < 3; ++i) {
 const Expr *E = AL.getArgAsExpr(i);
-if (!checkUInt32Argument(S, AL, E, WGSize[i], i))
+if (!checkUInt32Argument(S, AL, E, WGSize[i], i,
+ /*StrictlyUnsigned=*/true))
   return;
 if (WGSize[i] == 0) {
   S.Diag(AL.getLoc(), diag::err_attribute_argument_is_zero)
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2529,6 +2529,8 @@
   "constant|a string|an identifier}1">;
 def err_attribute_argument_outof_range : Error<
   "%0 attribute requires integer constant between %1 and %2 inclusive">;
+def err_attribute_argument_negative : Error<
+  "negative argument is not allowed for %0 attribute">;
 def err_init_priority_object_attr : Error<
   "can only use 'init_priority' attribute on file-scope definitions "
   "of objects of class type">;
Index: test/SemaOpenCL/invalid-kernel-attrs.cl
===
--- test/SemaOpenCL/invalid-kernel-attrs.cl
+++ test/SemaOpenCL/invalid-kernel-attrs.cl
@@ -37,3 +37,10 @@
 __attribute__((intel_reqd_sub_group_size(8))) void kernel14(){} // 
expected-error {{attribute 'intel_reqd_sub_group_size' can only be applied to 
an OpenCL kernel}}
 kernel __attribute__((intel_reqd_sub_group_size(0))) void kernel15(){} // 
expected-error {{'intel_reqd_sub_group_size' attribute must be greater than 0}}
 kernel __attribute__((intel_reqd_sub_group_size(8))) 
__attribute__((intel_reqd_sub_group_size(16))) void kernel16() {}  
//expected-warning{{attribute 'intel_reqd_sub_group_size' is already applied 
with different parameters}}
+
+__kernel __attribute__((work_group_size_hint(8,-16,32))) void neg1() {} 
//expected-error{{negative argument is not allowed for 'work_group_size_hint' 
attribute}}
+__kernel __attribute__((reqd_work_group_size(8,16,-32))) void neg2(){} // 
expected-error{{negative argument is not allowed for 'reqd_work_group_size' 
attribute}}
+
+// 4294967294 is a negative integer if treated as signed.
+// Should compile successfully, since we expect an unsigned.
+__kernel __attribute__((reqd_work_group_size(8,16,4294967294))) void ok1(){}


Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -227,9 +227,13 @@
 
 /// If Expr is a valid integer constant, get the value of the integer
 /// expression and return success or failure. May output an error.
+///
+/// Negative argument is implicitly converted to unsigned, unless
+/// \p StrictlyUnsigned is true.
 template 
 static bool checkUInt32Argument(Sema &S, const AttrInfo &AI, const Expr *Expr,
-uint32_t &Val, unsigned Idx = UINT_MAX) {
+uint32_t &Val, unsigned Idx = UINT_MAX,
+bool StrictlyUnsigned = false) {
   llvm::APSInt I(32);
   if (Expr->isTypeDependent() || Expr->isValueDependent() ||
   !Expr->isIntegerConstantExpr(I, S.Context)) {
@@ -249,6 +253,11 @@
 return false;
   }
 
+  if (StrictlyUnsigned && I.isSigned() && I.isNegative()) {
+S.Diag(getAttrLoc(AI), diag::err_attribute_argument_negative) << AI;

Re: [clang-tools-extra] r341459 - [clangd] Avoid enum class+enumValN to avoid GCC bug(?), and use consistent style.

2018-09-06 Thread Sam McCall via cfe-commits
It turned out to be a different bug: the problem was referring to
`Format::YAML` in the initializer for a variable also named `Format`.
This is legal but old versions of GCC get this wrong.
As usual with buildbot failures, I was throwing things at the wall to see
what sticks.

Regarding style - either would work, there were 2x enum and 2x enum class.
My reasons for leaning towards enum here is that for this command-line flag
pattern
 - it mainly leads to repeating the type name in a context where the type
is obvious
 - there's minimal risk/consequence to a namespace conflict as we're in an
anonymous namespace in a CC file
 - there's often not a second good name (need one for the flag + one for
the enum), so it's a bad name that ends up repeated
But if you feel strongly about it, feel free to flip it.

On Thu, Sep 6, 2018 at 11:45 AM Ilya Biryukov  wrote:

> Any pointers to the GCC bug/breakage mentioned?
>
> On Thu, Sep 6, 2018 at 11:44 AM Ilya Biryukov 
> wrote:
>
>> +1 for consistent style, but why not use enum class everywhere instead?
>>
>> On Wed, Sep 5, 2018 at 12:41 PM Sam McCall via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: sammccall
>>> Date: Wed Sep  5 03:39:58 2018
>>> New Revision: 341459
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=341459&view=rev
>>> Log:
>>> [clangd] Avoid enum class+enumValN to avoid GCC bug(?), and use
>>> consistent style.
>>>
>>> Modified:
>>>
>>> clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
>>> clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
>>>
>>> Modified:
>>> clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp?rev=341459&r1=341458&r2=341459&view=diff
>>>
>>> ==
>>> ---
>>> clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
>>> (original)
>>> +++
>>> clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
>>> Wed Sep  5 03:39:58 2018
>>> @@ -60,7 +60,7 @@ static llvm::cl::opt MergeOnTheFly
>>>  "MapReduce."),
>>>  llvm::cl::init(true), llvm::cl::Hidden);
>>>
>>> -enum class Format { YAML, Binary };
>>> +enum Format { YAML, Binary };
>>>  static llvm::cl::opt
>>>  Format("format", llvm::cl::desc("Format of the index to be
>>> written"),
>>> llvm::cl::values(
>>>
>>> Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp?rev=341459&r1=341458&r2=341459&view=diff
>>>
>>> ==
>>> --- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp (original)
>>> +++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Wed Sep  5
>>> 03:39:58 2018
>>> @@ -36,12 +36,6 @@ static llvm::cl::opt
>>> llvm::cl::desc("Use experimental Dex static index."),
>>> llvm::cl::init(true), llvm::cl::Hidden);
>>>
>>> -namespace {
>>> -
>>> -enum class PCHStorageFlag { Disk, Memory };
>>> -
>>> -} // namespace
>>> -
>>>  static llvm::cl::opt CompileCommandsDir(
>>>  "compile-commands-dir",
>>>  llvm::cl::desc("Specify a path to look for compile_commands.json.
>>> If path "
>>> @@ -54,10 +48,7 @@ static llvm::cl::opt
>>> llvm::cl::init(getDefaultAsyncThreadsCount()));
>>>
>>>  // FIXME: also support "plain" style where signatures are always
>>> omitted.
>>> -enum CompletionStyleFlag {
>>> -  Detailed,
>>> -  Bundled,
>>> -};
>>> +enum CompletionStyleFlag { Detailed, Bundled };
>>>  static llvm::cl::opt CompletionStyle(
>>>  "completion-style",
>>>  llvm::cl::desc("Granularity of code completion suggestions"),
>>> @@ -106,6 +97,7 @@ static llvm::cl::opt Test(
>>>  "Intended to simplify lit tests."),
>>>  llvm::cl::init(false), llvm::cl::Hidden);
>>>
>>> +enum PCHStorageFlag { Disk, Memory };
>>>  static llvm::cl::opt PCHStorage(
>>>  "pch-storage",
>>>  llvm::cl::desc("Storing PCHs in memory increases memory usages, but
>>> may "
>>> @@ -167,7 +159,6 @@ static llvm::cl::opt YamlSymbolFil
>>>  llvm::cl::init(""), llvm::cl::Hidden);
>>>
>>>  enum CompileArgsFrom { LSPCompileArgs, FilesystemCompileArgs };
>>> -
>>>  static llvm::cl::opt CompileArgsFrom(
>>>  "compile_args_from", llvm::cl::desc("The source of compile
>>> commands"),
>>>  llvm::cl::values(clEnumValN(LSPCompileArgs, "lsp",
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>
>>
>> --
>> Regards,
>> Ilya Biryukov
>>
>
>
> --
> Regards,
> Ilya Biryukov
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http:

r341539 - [OpenCL] Disallow negative attribute arguments

2018-09-06 Thread Andrew Savonichev via cfe-commits
Author: asavonic
Date: Thu Sep  6 04:54:09 2018
New Revision: 341539

URL: http://llvm.org/viewvc/llvm-project?rev=341539&view=rev
Log:
[OpenCL] Disallow negative attribute arguments

Summary:
Negative arguments in kernel attributes are silently bitcast'ed to
unsigned, for example:

__attribute__((reqd_work_group_size(1, -1, 1)))
__kernel void k() {}

is a complete equivalent of:

__attribute__((reqd_work_group_size(1, 4294967294, 1)))
__kernel void k() {}

This is likely an error, so the patch forbids negative arguments in
several OpenCL attributes. Users who really want 4294967294 can still
use it as an unsigned representation.

Reviewers: Anastasia, yaxunl, bader

Reviewed By: Anastasia, yaxunl, bader

Subscribers: bader, cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaOpenCL/invalid-kernel-attrs.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=341539&r1=341538&r2=341539&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Sep  6 04:54:09 
2018
@@ -2529,6 +2529,8 @@ def err_attribute_argument_type : Error<
   "constant|a string|an identifier}1">;
 def err_attribute_argument_outof_range : Error<
   "%0 attribute requires integer constant between %1 and %2 inclusive">;
+def err_attribute_argument_negative : Error<
+  "negative argument is not allowed for %0 attribute">;
 def err_init_priority_object_attr : Error<
   "can only use 'init_priority' attribute on file-scope definitions "
   "of objects of class type">;

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=341539&r1=341538&r2=341539&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Sep  6 04:54:09 2018
@@ -227,9 +227,13 @@ static SourceLocation getAttrLoc(const P
 
 /// If Expr is a valid integer constant, get the value of the integer
 /// expression and return success or failure. May output an error.
+///
+/// Negative argument is implicitly converted to unsigned, unless
+/// \p StrictlyUnsigned is true.
 template 
 static bool checkUInt32Argument(Sema &S, const AttrInfo &AI, const Expr *Expr,
-uint32_t &Val, unsigned Idx = UINT_MAX) {
+uint32_t &Val, unsigned Idx = UINT_MAX,
+bool StrictlyUnsigned = false) {
   llvm::APSInt I(32);
   if (Expr->isTypeDependent() || Expr->isValueDependent() ||
   !Expr->isIntegerConstantExpr(I, S.Context)) {
@@ -249,6 +253,11 @@ static bool checkUInt32Argument(Sema &S,
 return false;
   }
 
+  if (StrictlyUnsigned && I.isSigned() && I.isNegative()) {
+S.Diag(getAttrLoc(AI), diag::err_attribute_argument_negative) << AI;
+return false;
+  }
+
   Val = (uint32_t)I.getZExtValue();
   return true;
 }
@@ -2766,7 +2775,8 @@ static void handleWorkGroupSize(Sema &S,
   uint32_t WGSize[3];
   for (unsigned i = 0; i < 3; ++i) {
 const Expr *E = AL.getArgAsExpr(i);
-if (!checkUInt32Argument(S, AL, E, WGSize[i], i))
+if (!checkUInt32Argument(S, AL, E, WGSize[i], i,
+ /*StrictlyUnsigned=*/true))
   return;
 if (WGSize[i] == 0) {
   S.Diag(AL.getLoc(), diag::err_attribute_argument_is_zero)

Modified: cfe/trunk/test/SemaOpenCL/invalid-kernel-attrs.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid-kernel-attrs.cl?rev=341539&r1=341538&r2=341539&view=diff
==
--- cfe/trunk/test/SemaOpenCL/invalid-kernel-attrs.cl (original)
+++ cfe/trunk/test/SemaOpenCL/invalid-kernel-attrs.cl Thu Sep  6 04:54:09 2018
@@ -37,3 +37,10 @@ kernel __attribute__((reqd_work_group_si
 __attribute__((intel_reqd_sub_group_size(8))) void kernel14(){} // 
expected-error {{attribute 'intel_reqd_sub_group_size' can only be applied to 
an OpenCL kernel}}
 kernel __attribute__((intel_reqd_sub_group_size(0))) void kernel15(){} // 
expected-error {{'intel_reqd_sub_group_size' attribute must be greater than 0}}
 kernel __attribute__((intel_reqd_sub_group_size(8))) 
__attribute__((intel_reqd_sub_group_size(16))) void kernel16() {}  
//expected-warning{{attribute 'intel_reqd_sub_group_size' is already applied 
with different parameters}}
+
+__kernel __attribute__((work_group_size_hint(8,-16,32))) void neg1() {} 
//expected-error{{negative argument is not allowed for 'work_group_size_hint' 
attribute}}
+__kernel __attribute__((reqd_work_group_size(8,16,-32))) 

Re: r341539 - [OpenCL] Disallow negative attribute arguments

2018-09-06 Thread Aaron Ballman via cfe-commits
On Thu, Sep 6, 2018 at 7:54 AM, Andrew Savonichev via cfe-commits
 wrote:
> Author: asavonic
> Date: Thu Sep  6 04:54:09 2018
> New Revision: 341539
>
> URL: http://llvm.org/viewvc/llvm-project?rev=341539&view=rev
> Log:
> [OpenCL] Disallow negative attribute arguments
>
> Summary:
> Negative arguments in kernel attributes are silently bitcast'ed to
> unsigned, for example:
>
> __attribute__((reqd_work_group_size(1, -1, 1)))
> __kernel void k() {}
>
> is a complete equivalent of:
>
> __attribute__((reqd_work_group_size(1, 4294967294, 1)))
> __kernel void k() {}
>
> This is likely an error, so the patch forbids negative arguments in
> several OpenCL attributes. Users who really want 4294967294 can still
> use it as an unsigned representation.
>
> Reviewers: Anastasia, yaxunl, bader
>
> Reviewed By: Anastasia, yaxunl, bader
>
> Subscribers: bader, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D50259
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/test/SemaOpenCL/invalid-kernel-attrs.cl
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=341539&r1=341538&r2=341539&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Sep  6 04:54:09 
> 2018
> @@ -2529,6 +2529,8 @@ def err_attribute_argument_type : Error<
>"constant|a string|an identifier}1">;
>  def err_attribute_argument_outof_range : Error<
>"%0 attribute requires integer constant between %1 and %2 inclusive">;
> +def err_attribute_argument_negative : Error<
> +  "negative argument is not allowed for %0 attribute">;

I don't think we need a new diagnostic here as we already have
err_attribute_requires_positive_integer.

~Aaron

>  def err_init_priority_object_attr : Error<
>"can only use 'init_priority' attribute on file-scope definitions "
>"of objects of class type">;
>
> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=341539&r1=341538&r2=341539&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Sep  6 04:54:09 2018
> @@ -227,9 +227,13 @@ static SourceLocation getAttrLoc(const P
>
>  /// If Expr is a valid integer constant, get the value of the integer
>  /// expression and return success or failure. May output an error.
> +///
> +/// Negative argument is implicitly converted to unsigned, unless
> +/// \p StrictlyUnsigned is true.
>  template 
>  static bool checkUInt32Argument(Sema &S, const AttrInfo &AI, const Expr 
> *Expr,
> -uint32_t &Val, unsigned Idx = UINT_MAX) {
> +uint32_t &Val, unsigned Idx = UINT_MAX,
> +bool StrictlyUnsigned = false) {
>llvm::APSInt I(32);
>if (Expr->isTypeDependent() || Expr->isValueDependent() ||
>!Expr->isIntegerConstantExpr(I, S.Context)) {
> @@ -249,6 +253,11 @@ static bool checkUInt32Argument(Sema &S,
>  return false;
>}
>
> +  if (StrictlyUnsigned && I.isSigned() && I.isNegative()) {
> +S.Diag(getAttrLoc(AI), diag::err_attribute_argument_negative) << AI;
> +return false;
> +  }
> +
>Val = (uint32_t)I.getZExtValue();
>return true;
>  }
> @@ -2766,7 +2775,8 @@ static void handleWorkGroupSize(Sema &S,
>uint32_t WGSize[3];
>for (unsigned i = 0; i < 3; ++i) {
>  const Expr *E = AL.getArgAsExpr(i);
> -if (!checkUInt32Argument(S, AL, E, WGSize[i], i))
> +if (!checkUInt32Argument(S, AL, E, WGSize[i], i,
> + /*StrictlyUnsigned=*/true))
>return;
>  if (WGSize[i] == 0) {
>S.Diag(AL.getLoc(), diag::err_attribute_argument_is_zero)
>
> Modified: cfe/trunk/test/SemaOpenCL/invalid-kernel-attrs.cl
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid-kernel-attrs.cl?rev=341539&r1=341538&r2=341539&view=diff
> ==
> --- cfe/trunk/test/SemaOpenCL/invalid-kernel-attrs.cl (original)
> +++ cfe/trunk/test/SemaOpenCL/invalid-kernel-attrs.cl Thu Sep  6 04:54:09 2018
> @@ -37,3 +37,10 @@ kernel __attribute__((reqd_work_group_si
>  __attribute__((intel_reqd_sub_group_size(8))) void kernel14(){} // 
> expected-error {{attribute 'intel_reqd_sub_group_size' can only be applied to 
> an OpenCL kernel}}
>  kernel __attribute__((intel_reqd_sub_group_size(0))) void kernel15(){} // 
> expected-error {{'intel_reqd_sub_group_size' attribute must be greater than 
> 0}}
>  kernel __attribute__((intel_reqd_sub_group_size(8))) 
>

[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl

2018-09-06 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta added a comment.

I found that current ToT with original Nico's patch does not allow to link 
ui_base.dll

https://github.com/atetubou/llvm-project-20170507/tree/totwin_dbg_1236_nico
gives the following link error
https://pastebin.com/9LVRbRVn

I will do bisection to find when some inline functions are not inlined.


https://reviews.llvm.org/D51340



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


Re: [clang-tools-extra] r341459 - [clangd] Avoid enum class+enumValN to avoid GCC bug(?), and use consistent style.

2018-09-06 Thread Ilya Biryukov via cfe-commits
I would generally vouch for strongly typed enums, because there're nicer in
many aspects (no implicit integer conversions, no enumerators thrown into
the namespaces).
With regards to naming conventions, PCHStorage::Memory or
CompletionStyle::Bundled look pretty neat to me, the usual alternative for
enums is coming up with prefixes, e.g. PS_Memory CS_Bundled.
It's shorter, but it's hard to remember which prefix to use (without the
prefix, it's also hard to keep all enum values in your head), while the
type name is evident from signature help or completion results and
completing EnumType:: yields full list of enumerators right away.

The "Flag" suffix in the enum names seems redundant, though, I have removed
it from the examples on purpose.
WDYT?

PS BTW, we definitely need to make enumerator completions work in more
cases than switch-case at some point.




On Thu, Sep 6, 2018 at 2:11 PM Sam McCall  wrote:

> It turned out to be a different bug: the problem was referring to
> `Format::YAML` in the initializer for a variable also named `Format`.
> This is legal but old versions of GCC get this wrong.
> As usual with buildbot failures, I was throwing things at the wall to see
> what sticks.
>
> Regarding style - either would work, there were 2x enum and 2x enum class.
> My reasons for leaning towards enum here is that for this command-line
> flag pattern
>  - it mainly leads to repeating the type name in a context where the type
> is obvious
>  - there's minimal risk/consequence to a namespace conflict as we're in an
> anonymous namespace in a CC file
>  - there's often not a second good name (need one for the flag + one for
> the enum), so it's a bad name that ends up repeated
> But if you feel strongly about it, feel free to flip it.
>
> On Thu, Sep 6, 2018 at 11:45 AM Ilya Biryukov 
> wrote:
>
>> Any pointers to the GCC bug/breakage mentioned?
>>
>> On Thu, Sep 6, 2018 at 11:44 AM Ilya Biryukov 
>> wrote:
>>
>>> +1 for consistent style, but why not use enum class everywhere instead?
>>>
>>> On Wed, Sep 5, 2018 at 12:41 PM Sam McCall via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: sammccall
 Date: Wed Sep  5 03:39:58 2018
 New Revision: 341459

 URL: http://llvm.org/viewvc/llvm-project?rev=341459&view=rev
 Log:
 [clangd] Avoid enum class+enumValN to avoid GCC bug(?), and use
 consistent style.

 Modified:

 clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
 clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp

 Modified:
 clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp?rev=341459&r1=341458&r2=341459&view=diff

 ==
 ---
 clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
 (original)
 +++
 clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
 Wed Sep  5 03:39:58 2018
 @@ -60,7 +60,7 @@ static llvm::cl::opt MergeOnTheFly
  "MapReduce."),
  llvm::cl::init(true), llvm::cl::Hidden);

 -enum class Format { YAML, Binary };
 +enum Format { YAML, Binary };
  static llvm::cl::opt
  Format("format", llvm::cl::desc("Format of the index to be
 written"),
 llvm::cl::values(

 Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp?rev=341459&r1=341458&r2=341459&view=diff

 ==
 --- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp (original)
 +++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Wed Sep  5
 03:39:58 2018
 @@ -36,12 +36,6 @@ static llvm::cl::opt
 llvm::cl::desc("Use experimental Dex static index."),
 llvm::cl::init(true), llvm::cl::Hidden);

 -namespace {
 -
 -enum class PCHStorageFlag { Disk, Memory };
 -
 -} // namespace
 -
  static llvm::cl::opt CompileCommandsDir(
  "compile-commands-dir",
  llvm::cl::desc("Specify a path to look for compile_commands.json.
 If path "
 @@ -54,10 +48,7 @@ static llvm::cl::opt
 llvm::cl::init(getDefaultAsyncThreadsCount()));

  // FIXME: also support "plain" style where signatures are always
 omitted.
 -enum CompletionStyleFlag {
 -  Detailed,
 -  Bundled,
 -};
 +enum CompletionStyleFlag { Detailed, Bundled };
  static llvm::cl::opt CompletionStyle(
  "completion-style",
  llvm::cl::desc("Granularity of code completion suggestions"),
 @@ -106,6 +97,7 @@ static llvm::cl::opt Test(
>>>

[PATCH] D51689: [clangd] Dense posting lists proof-of-concept

2018-09-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 164191.
sammccall added a comment.

[Tooling] JSONCompilationDatabasePlugin infers compile commands for missing 
files

See the existing InterpolatingCompilationDatabase for details on how this works.
We've been using this in clangd for a while, the heuristics seem to work well.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51689

Files:
  clangd/index/dex/DexIndex.cpp
  clangd/index/dex/Iterator.cpp
  clangd/index/dex/Iterator.h

Index: clangd/index/dex/Iterator.h
===
--- clangd/index/dex/Iterator.h
+++ clangd/index/dex/Iterator.h
@@ -32,6 +32,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEX_ITERATOR_H
 
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/BitVector.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -44,20 +45,6 @@
 /// Symbol position in the list of all index symbols sorted by a pre-computed
 /// symbol quality.
 using DocID = uint32_t;
-/// Contains sorted sequence of DocIDs all of which belong to symbols matching
-/// certain criteria, i.e. containing a Search Token. PostingLists are values
-/// for the inverted index.
-// FIXME(kbobyrev): Posting lists for incomplete trigrams (one/two symbols) are
-// likely to be very dense and hence require special attention so that the index
-// doesn't use too much memory. Possible solution would be to construct
-// compressed posting lists which consist of ranges of DocIDs instead of
-// distinct DocIDs. A special case would be the empty query: for that case
-// TrueIterator should be implemented - an iterator which doesn't actually store
-// any PostingList within itself, but "contains" all DocIDs in range
-// [0, IndexSize).
-using PostingList = std::vector;
-/// Immutable reference to PostingList object.
-using PostingListRef = llvm::ArrayRef;
 
 /// Iterator is the interface for Query Tree node. The simplest type of Iterator
 /// is DocumentIterator which is simply a wrapper around PostingList iterator
@@ -131,11 +118,6 @@
 /// to acquire preliminary scores of requested items.
 std::vector> consume(Iterator &It);
 
-/// Returns a document iterator over given PostingList.
-///
-/// DocumentIterator returns DEFAULT_BOOST_SCORE for each processed item.
-std::unique_ptr create(PostingListRef Documents);
-
 /// Returns AND Iterator which performs the intersection of the PostingLists of
 /// its children.
 ///
@@ -200,6 +182,33 @@
   Children.push_back(move(Head));
 }
 
+/// Contains sorted sequence of DocIDs all of which belong to symbols matching
+/// certain criteria, i.e. containing a Search Token. PostingLists are values
+/// for the inverted index.
+class PostingList {
+public:
+  PostingList() : Representation(Null) {}
+  PostingList(std::vector Docs);
+  /// Returns a document iterator over given PostingList.
+  std::unique_ptr iterator() const;
+
+  PostingList(PostingList&&);
+  PostingList &operator=(PostingList&&);
+  ~PostingList();
+
+  size_t bytes() const;
+
+private:
+  enum Rep { Null, Dense, Sparse } Representation;
+  union {
+struct {
+  llvm::BitVector Bitmap;
+  size_t Count;
+} DenseRep;
+std::vector SparseRep;
+  };
+};
+
 } // namespace dex
 } // namespace clangd
 } // namespace clang
Index: clangd/index/dex/Iterator.cpp
===
--- clangd/index/dex/Iterator.cpp
+++ clangd/index/dex/Iterator.cpp
@@ -18,12 +18,11 @@
 
 namespace {
 
-/// Implements Iterator over a PostingList. DocumentIterator is the most basic
-/// iterator: it doesn't have any children (hence it is the leaf of iterator
-/// tree) and is simply a wrapper around PostingList::const_iterator.
-class DocumentIterator : public Iterator {
+/// Implements Iterator over a sparse PostingList.
+/// This is a leaf iterator which simply wraps a list of DocIDs.
+class SparseIterator : public Iterator {
 public:
-  DocumentIterator(PostingListRef Documents)
+  SparseIterator(llvm::ArrayRef Documents)
   : Documents(Documents), Index(std::begin(Documents)) {}
 
   bool reachedEnd() const override { return Index == std::end(Documents); }
@@ -74,8 +73,52 @@
 return OS;
   }
 
-  PostingListRef Documents;
-  PostingListRef::const_iterator Index;
+  llvm::ArrayRef Documents;
+  llvm::ArrayRef::iterator Index;
+};
+
+/// Implements Iterator over a dense PostingList.
+/// This is a leaf iterator over a BitVector with one bit per possible DocID.
+class DenseIterator : public Iterator {
+public:
+  DenseIterator(const llvm::BitVector &Bits, size_t Count)
+  : Bits(Bits), Index(Bits.find_first()), Count(Count) {}
+
+  bool reachedEnd() const override { return Index == -1; }
+
+  /// Advances cursor to the next item.
+  void advance() override {
+assert(!reachedEnd() && "DENSE iterator can't advance() at the end.");
+Index = Bits.find_next(Index);
+  }
+
+  /// Applies binary search to advance cursor to the next item with DocID equal
+  /// 

[PATCH] D51689: [clangd] Dense posting lists proof-of-concept

2018-09-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Uh, please ignore the last comment, arc/I got confused.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51689



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


[PATCH] D51729: [Tooling] JSONCompilationDatabasePlugin infers compile commands for missing files

2018-09-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: bkramer.
Herald added subscribers: cfe-commits, kadircet, ioeric, ilya-biryukov.

See the existing InterpolatingCompilationDatabase for details on how this works.
We've been using this in clangd for a while, the heuristics seem to work well.


Repository:
  rC Clang

https://reviews.llvm.org/D51729

Files:
  lib/Tooling/JSONCompilationDatabase.cpp
  test/Tooling/auto-detect-from-source.cpp


Index: test/Tooling/auto-detect-from-source.cpp
===
--- test/Tooling/auto-detect-from-source.cpp
+++ test/Tooling/auto-detect-from-source.cpp
@@ -1,8 +1,12 @@
 // RUN: rm -rf %t
 // RUN: mkdir %t
-// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c 
%/t/test.cpp\",\"file\":\"%/t/test.cpp\"}]" | sed -e 's/\\//g' > 
%t/compile_commands.json
+// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -DSECRET=XYZZY -c 
%/t/test.cpp\",\"file\":\"%/t/test.cpp\"}]" | sed -e 's/\\//g' > 
%t/compile_commands.json
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: not clang-check "%t/test.cpp" 2>&1 | FileCheck %s
 
-// CHECK: C++ requires
-invalid;
+// CHECK: XYZZY
+SECRET;
+
+// Copy to a different file, and rely on the command being inferred.
+// RUN: cp "%s" "%t/other.cpp"
+// RUN: not clang-check "%t/other.cpp" 2>&1 | FileCheck %s
Index: lib/Tooling/JSONCompilationDatabase.cpp
===
--- lib/Tooling/JSONCompilationDatabase.cpp
+++ lib/Tooling/JSONCompilationDatabase.cpp
@@ -157,13 +157,16 @@
   return parser.parse();
 }
 
+// This plugin locates a nearby compile_command.json file, and also infers
+// compile commands for files not present in the database.
 class JSONCompilationDatabasePlugin : public CompilationDatabasePlugin {
   std::unique_ptr
   loadFromDirectory(StringRef Directory, std::string &ErrorMessage) override {
 SmallString<1024> JSONDatabasePath(Directory);
 llvm::sys::path::append(JSONDatabasePath, "compile_commands.json");
-return JSONCompilationDatabase::loadFromFile(
+auto Base = JSONCompilationDatabase::loadFromFile(
 JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect);
+return Base ? inferMissingCompileCommands(std::move(Base)) : nullptr;
   }
 };
 


Index: test/Tooling/auto-detect-from-source.cpp
===
--- test/Tooling/auto-detect-from-source.cpp
+++ test/Tooling/auto-detect-from-source.cpp
@@ -1,8 +1,12 @@
 // RUN: rm -rf %t
 // RUN: mkdir %t
-// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c %/t/test.cpp\",\"file\":\"%/t/test.cpp\"}]" | sed -e 's/\\//g' > %t/compile_commands.json
+// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -DSECRET=XYZZY -c %/t/test.cpp\",\"file\":\"%/t/test.cpp\"}]" | sed -e 's/\\//g' > %t/compile_commands.json
 // RUN: cp "%s" "%t/test.cpp"
 // RUN: not clang-check "%t/test.cpp" 2>&1 | FileCheck %s
 
-// CHECK: C++ requires
-invalid;
+// CHECK: XYZZY
+SECRET;
+
+// Copy to a different file, and rely on the command being inferred.
+// RUN: cp "%s" "%t/other.cpp"
+// RUN: not clang-check "%t/other.cpp" 2>&1 | FileCheck %s
Index: lib/Tooling/JSONCompilationDatabase.cpp
===
--- lib/Tooling/JSONCompilationDatabase.cpp
+++ lib/Tooling/JSONCompilationDatabase.cpp
@@ -157,13 +157,16 @@
   return parser.parse();
 }
 
+// This plugin locates a nearby compile_command.json file, and also infers
+// compile commands for files not present in the database.
 class JSONCompilationDatabasePlugin : public CompilationDatabasePlugin {
   std::unique_ptr
   loadFromDirectory(StringRef Directory, std::string &ErrorMessage) override {
 SmallString<1024> JSONDatabasePath(Directory);
 llvm::sys::path::append(JSONDatabasePath, "compile_commands.json");
-return JSONCompilationDatabase::loadFromFile(
+auto Base = JSONCompilationDatabase::loadFromFile(
 JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect);
+return Base ? inferMissingCompileCommands(std::move(Base)) : nullptr;
   }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl

2018-09-06 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta added a comment.

In https://reviews.llvm.org/D51340#1225805, @takuto.ikuta wrote:

> I found that current ToT with original Nico's patch does not allow to link 
> ui_base.dll
>
> https://github.com/atetubou/llvm-project-20170507/tree/totwin_dbg_1236_nico
>  gives the following link error
>  https://pastebin.com/9LVRbRVn
>
> I will do bisection to find when some inline functions are not inlined.


Sorry, this is due to my local build config of chromium.


https://reviews.llvm.org/D51340



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


Re: [clang-tools-extra] r341459 - [clangd] Avoid enum class+enumValN to avoid GCC bug(?), and use consistent style.

2018-09-06 Thread Sam McCall via cfe-commits
On Thu, Sep 6, 2018 at 2:26 PM Ilya Biryukov  wrote:

> I would generally vouch for strongly typed enums, because there're nicer
> in many aspects (no implicit integer conversions, no enumerators thrown
> into the namespaces).
>
I mostly (generally!) agree.
In particular they have strong advantages when being exposed as part of a
widely-visible API.
The disadvantages are mostly verbosity (in cases where it doesn't aid
readability) and it being hard to use them in bitfields.


> With regards to naming conventions, PCHStorage::Memory or
> CompletionStyle::Bundled look pretty neat to me, the usual alternative for
> enums is coming up with prefixes, e.g. PS_Memory CS_Bundled.
>
It's shorter, but it's hard to remember which prefix to use (without the
> prefix, it's also hard to keep all enum values in your head)
>
I don't think this is the case here (within the scope of the main file).


> while the type name is evident from signature help or completion results
> and completing EnumType:: yields full list of enumerators right away.
>
(this is true of both scoped and unscoped enums)

The "Flag" suffix in the enum names seems redundant, though, I have removed
> it from the examples on purpose.
>
Yes, agree with this.


> WDYT?
>
I think plain enum is better for this case for the reasons above, but I
don't feel strongly, feel free to change it.


>
> PS BTW, we definitely need to make enumerator completions work in more
> cases than switch-case at some point.
>
>
>
>
> On Thu, Sep 6, 2018 at 2:11 PM Sam McCall  wrote:
>
>> It turned out to be a different bug: the problem was referring to
>> `Format::YAML` in the initializer for a variable also named `Format`.
>> This is legal but old versions of GCC get this wrong.
>> As usual with buildbot failures, I was throwing things at the wall to see
>> what sticks.
>>
>> Regarding style - either would work, there were 2x enum and 2x enum class.
>> My reasons for leaning towards enum here is that for this command-line
>> flag pattern
>>  - it mainly leads to repeating the type name in a context where the type
>> is obvious
>>  - there's minimal risk/consequence to a namespace conflict as we're in
>> an anonymous namespace in a CC file
>>  - there's often not a second good name (need one for the flag + one for
>> the enum), so it's a bad name that ends up repeated
>> But if you feel strongly about it, feel free to flip it.
>>
>> On Thu, Sep 6, 2018 at 11:45 AM Ilya Biryukov 
>> wrote:
>>
>>> Any pointers to the GCC bug/breakage mentioned?
>>>
>>> On Thu, Sep 6, 2018 at 11:44 AM Ilya Biryukov 
>>> wrote:
>>>
 +1 for consistent style, but why not use enum class everywhere instead?

 On Wed, Sep 5, 2018 at 12:41 PM Sam McCall via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

> Author: sammccall
> Date: Wed Sep  5 03:39:58 2018
> New Revision: 341459
>
> URL: http://llvm.org/viewvc/llvm-project?rev=341459&view=rev
> Log:
> [clangd] Avoid enum class+enumValN to avoid GCC bug(?), and use
> consistent style.
>
> Modified:
>
> clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
> clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
>
> Modified:
> clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp?rev=341459&r1=341458&r2=341459&view=diff
>
> ==
> ---
> clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
> (original)
> +++
> clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
> Wed Sep  5 03:39:58 2018
> @@ -60,7 +60,7 @@ static llvm::cl::opt MergeOnTheFly
>  "MapReduce."),
>  llvm::cl::init(true), llvm::cl::Hidden);
>
> -enum class Format { YAML, Binary };
> +enum Format { YAML, Binary };
>  static llvm::cl::opt
>  Format("format", llvm::cl::desc("Format of the index to be
> written"),
> llvm::cl::values(
>
> Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp?rev=341459&r1=341458&r2=341459&view=diff
>
> ==
> --- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp (original)
> +++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Wed Sep  5
> 03:39:58 2018
> @@ -36,12 +36,6 @@ static llvm::cl::opt
> llvm::cl::desc("Use experimental Dex static index."),
> llvm::cl::init(true), llvm::cl::Hidden);
>
> -namespace {
> -
> -enum class PCHStorageFlag { Disk, Memory };
> -
> -} // namespace
> -
>  stati

[clang-tools-extra] r341542 - [clangd] Implement proximity path boosting for Dex

2018-09-06 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Thu Sep  6 05:54:43 2018
New Revision: 341542

URL: http://llvm.org/viewvc/llvm-project?rev=341542&view=rev
Log:
[clangd] Implement proximity path boosting for Dex

This patch introduces `PathURI` Search Token kind and utilizes it to
uprank symbols which are defined in files with small distance to the
directory where the fuzzy find request is coming from (e.g. files user
is editing).

Reviewed By: ioeric

Reviewers: ioeric, sammccall

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

Modified:
clang-tools-extra/trunk/clangd/FileDistance.h
clang-tools-extra/trunk/clangd/URI.cpp
clang-tools-extra/trunk/clangd/URI.h
clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp
clang-tools-extra/trunk/clangd/index/SymbolYAML.h
clang-tools-extra/trunk/clangd/index/dex/DexIndex.cpp
clang-tools-extra/trunk/clangd/index/dex/DexIndex.h
clang-tools-extra/trunk/clangd/index/dex/Token.h
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
clang-tools-extra/trunk/unittests/clangd/DexIndexTests.cpp

Modified: clang-tools-extra/trunk/clangd/FileDistance.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FileDistance.h?rev=341542&r1=341541&r2=341542&view=diff
==
--- clang-tools-extra/trunk/clangd/FileDistance.h (original)
+++ clang-tools-extra/trunk/clangd/FileDistance.h Thu Sep  6 05:54:43 2018
@@ -37,6 +37,9 @@
 //
 
//===--===//
 
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FILEDISTANCE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FILEDISTANCE_H
+
 #include "URI.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseMapInfo.h"
@@ -107,3 +110,5 @@ private:
 
 } // namespace clangd
 } // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_FILEDISTANCE_H

Modified: clang-tools-extra/trunk/clangd/URI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/URI.cpp?rev=341542&r1=341541&r2=341542&view=diff
==
--- clang-tools-extra/trunk/clangd/URI.cpp (original)
+++ clang-tools-extra/trunk/clangd/URI.cpp Thu Sep  6 05:54:43 2018
@@ -181,6 +181,26 @@ llvm::Expected URI::create(llvm::St
   return S->get()->uriFromAbsolutePath(AbsolutePath);
 }
 
+llvm::Expected URI::create(llvm::StringRef AbsolutePath,
+const std::vector &Schemes) {
+  if (!llvm::sys::path::is_absolute(AbsolutePath))
+return make_string_error("Not a valid absolute path: " + AbsolutePath);
+  for (const auto &Scheme : Schemes) {
+auto URI = URI::create(AbsolutePath, Scheme);
+// For some paths, conversion to different URI schemes is impossible. These
+// should be just skipped.
+if (!URI) {
+  // Ignore the error.
+  llvm::consumeError(URI.takeError());
+  continue;
+}
+return URI;
+  }
+  return make_string_error(
+  "Couldn't convert " + AbsolutePath +
+  " to any given scheme: " + llvm::join(Schemes, ", "));
+}
+
 URI URI::createFile(llvm::StringRef AbsolutePath) {
   auto U = create(AbsolutePath, "file");
   if (!U)

Modified: clang-tools-extra/trunk/clangd/URI.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/URI.h?rev=341542&r1=341541&r2=341542&view=diff
==
--- clang-tools-extra/trunk/clangd/URI.h (original)
+++ clang-tools-extra/trunk/clangd/URI.h Thu Sep  6 05:54:43 2018
@@ -45,6 +45,11 @@ public:
   static llvm::Expected create(llvm::StringRef AbsolutePath,
 llvm::StringRef Scheme);
 
+  // Similar to above except this uses the first scheme in \p Schemes that
+  // works.
+  static llvm::Expected create(llvm::StringRef AbsolutePath,
+const std::vector &Schemes);
+
   /// This creates a file:// URI for \p AbsolutePath. The path must be 
absolute.
   static URI createFile(llvm::StringRef AbsolutePath);
 

Modified: clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp?rev=341542&r1=341541&r2=341542&view=diff
==
--- clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp Thu Sep  6 05:54:43 2018
@@ -185,6 +185,7 @@ std::string SymbolToYAML(Symbol Sym) {
 }
 
 std::unique_ptr loadIndex(llvm::StringRef SymbolFilename,
+   llvm::ArrayRef URISchemes,
bool UseDex) {
   trace::Span OverallTracer("LoadIndex");
   auto Buffer = llvm::MemoryBuffer::getFile(SymbolFilename);
@@ -209,7 +210,7 @@ std::unique_ptr loadIndex(l
   if (!Slab)
 return nullptr;
   trace::Span Tracer("BuildIndex");
-  retu

[PATCH] D51481: [clangd] Implement proximity path boosting for Dex

2018-09-06 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE341542: [clangd] Implement proximity path boosting for Dex 
(authored by omtcyfz, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D51481?vs=164176&id=164195#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51481

Files:
  clangd/FileDistance.h
  clangd/URI.cpp
  clangd/URI.h
  clangd/index/SymbolYAML.cpp
  clangd/index/SymbolYAML.h
  clangd/index/dex/DexIndex.cpp
  clangd/index/dex/DexIndex.h
  clangd/index/dex/Token.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/DexIndexTests.cpp

Index: unittests/clangd/DexIndexTests.cpp
===
--- unittests/clangd/DexIndexTests.cpp
+++ unittests/clangd/DexIndexTests.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+#include "FuzzyMatch.h"
+#include "TestFS.h"
 #include "TestIndex.h"
 #include "index/Index.h"
 #include "index/Merge.h"
@@ -30,6 +32,12 @@
 namespace dex {
 namespace {
 
+std::vector URISchemes = {"unittest"};
+
+//===--===//
+// Query iterator tests.
+//===--===//
+
 std::vector consumeIDs(Iterator &It) {
   auto IDAndScore = consume(It);
   std::vector IDs(IDAndScore.size());
@@ -325,15 +333,24 @@
   EXPECT_THAT(ElementBoost, 3);
 }
 
+//===--===//
+// Search token tests.
+//===--===//
+
 testing::Matcher>
-trigramsAre(std::initializer_list Trigrams) {
+tokensAre(std::initializer_list Strings, Token::Kind Kind) {
   std::vector Tokens;
-  for (const auto &Symbols : Trigrams) {
-Tokens.push_back(Token(Token::Kind::Trigram, Symbols));
+  for (const auto &TokenData : Strings) {
+Tokens.push_back(Token(Kind, TokenData));
   }
   return testing::UnorderedElementsAreArray(Tokens);
 }
 
+testing::Matcher>
+trigramsAre(std::initializer_list Trigrams) {
+  return tokensAre(Trigrams, Token::Kind::Trigram);
+}
+
 TEST(DexIndexTrigrams, IdentifierTrigrams) {
   EXPECT_THAT(generateIdentifierTrigrams("X86"),
   trigramsAre({"x86", "x$$", "x8$"}));
@@ -408,8 +425,25 @@
"hij", "ijk", "jkl", "klm"}));
 }
 
+TEST(DexSearchTokens, SymbolPath) {
+  EXPECT_THAT(generateProximityURIs(
+  "unittest:///clang-tools-extra/clangd/index/Token.h"),
+  ElementsAre("unittest:///clang-tools-extra/clangd/index/Token.h",
+  "unittest:///clang-tools-extra/clangd/index",
+  "unittest:///clang-tools-extra/clangd",
+  "unittest:///clang-tools-extra", "unittest:///"));
+
+  EXPECT_THAT(generateProximityURIs("unittest:///a/b/c.h"),
+  ElementsAre("unittest:///a/b/c.h", "unittest:///a/b",
+  "unittest:///a", "unittest:///"));
+}
+
+//===--===//
+// Index tests.
+//===--===//
+
 TEST(DexIndex, Lookup) {
-  auto I = DexIndex::build(generateSymbols({"ns::abc", "ns::xyz"}));
+  auto I = DexIndex::build(generateSymbols({"ns::abc", "ns::xyz"}), URISchemes);
   EXPECT_THAT(lookup(*I, SymbolID("ns::abc")), UnorderedElementsAre("ns::abc"));
   EXPECT_THAT(lookup(*I, {SymbolID("ns::abc"), SymbolID("ns::xyz")}),
   UnorderedElementsAre("ns::abc", "ns::xyz"));
@@ -421,7 +455,8 @@
 TEST(DexIndex, FuzzyFind) {
   auto Index = DexIndex::build(
   generateSymbols({"ns::ABC", "ns::BCD", "::ABC", "ns::nested::ABC",
-   "other::ABC", "other::A"}));
+   "other::ABC", "other::A"}),
+  URISchemes);
   FuzzyFindRequest Req;
   Req.Query = "ABC";
   Req.Scopes = {"ns::"};
@@ -443,7 +478,8 @@
 
 TEST(DexIndexTest, FuzzyMatchQ) {
   auto I = DexIndex::build(
-  generateSymbols({"LaughingOutLoud", "LionPopulation", "LittleOldLady"}));
+  generateSymbols({"LaughingOutLoud", "LionPopulation", "LittleOldLady"}),
+  URISchemes);
   FuzzyFindRequest Req;
   Req.Query = "lol";
   Req.MaxCandidateCount = 2;
@@ -461,12 +497,12 @@
  symbol("2") /* duplicate */};
   FuzzyFindRequest Req;
   Req.Query = "2";
-  DexIndex I(Symbols);
+  DexIndex I(Symbols, URISchemes);
   EXPECT_THAT(match(I, Req), ElementsAre("2", "2"));
 }
 
 TEST(DexIndexTest, DexIndexLimitedNumMatches) {
-  auto I = DexIndex::build(generateNumSymbols(0, 100));
+  auto I = DexIndex::build(generateNumSymbols(0, 100), URISchemes);
   FuzzyFindRequest Req;
   Req.Query = "5";
   Req.MaxCandidateCount = 3;
@@ -478,73 +514,101 @@
 
 TEST(DexIndexTest, FuzzyMatch) {
   auto I = DexIndex::build(
-  generateSymbols({"LaughingOutLou

[PATCH] D51683: Fix arm_neon.h and arm_fp16.h generation for compiling with std=c89

2018-09-06 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio updated this revision to Diff 164196.
dnsampaio added a comment.

Fix test march triple.


https://reviews.llvm.org/D51683

Files:
  test/Headers/arm-fp16-header.c
  test/Headers/arm-neon-header.c


Index: test/Headers/arm-neon-header.c
===
--- test/Headers/arm-neon-header.c
+++ test/Headers/arm-neon-header.c
@@ -2,23 +2,23 @@
 // RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -fno-lax-vector-conversions -ffreestanding %s
 // RUN: %clang_cc1 -x c++ -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -Wvector-conversions -ffreestanding %s
 
-// RUN: %clang -fsyntax-only -ffreestanding --target=aarch64-arm-none-eabi 
-march=armv8.2-a+fp16 -std=c89 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c99 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c11 -xc %s
+// RUN: %clang -fsyntax-only   -ffreestanding 
--target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c89 -xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c99 -xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c11 -xc %s
 
-// RUN: %clang -fsyntax-only -ffreestanding --target=aarch64-armeb-none-eabi 
-march=armv8.2-a+fp16 -std=c89 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c99 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c11 -xc %s
+// RUN: %clang -fsyntax-only   -ffreestanding 
--target=aarch64_be-none-eabi -march=armv8.2-a+fp16 -std=c89 -xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-eabi -march=armv8.2-a+fp16 -std=c99 -xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-eabi -march=armv8.2-a+fp16 -std=c11 -xc %s
 
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c++98 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c++11 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c++14 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c++17 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c++98 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c++11 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c++14 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c++17 -xc++ %s
 
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c++98 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c++11 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c++14 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c++17 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-eabi -march=armv8.2-a+fp16 -std=c++98 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-eabi -march=armv8.2-a+fp16 -std=c++11 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-eabi -march=armv8.2-a+fp16 -std=c++14 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-eabi -march=armv8.2-a+fp16 -std=c++17 -xc++ %s
 
 #include 
 
Index: test/Headers/arm-fp16-header.c
===
--- test/Headers/arm-fp16-header.c
+++ test/Headers/arm-fp16-header.c
@@ -1,19 +1,19 @@
-// RUN: %clang -fsyntax-only  -ffreestanding --target=aarch64-arm-none-eabi 
-march=armv8.2-a+fp16 -std=c89 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c99 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c11 -xc %s
+// RUN: %clang -fsyntax-only  -ffreestanding  
--target=aarch64-none-none-eabi -march=armv8.2-a+f

[PATCH] D51691: [clangd] NFC: Document URIDistance

2018-09-06 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 164197.

https://reviews.llvm.org/D51691

Files:
  clang-tools-extra/clangd/FileDistance.h


Index: clang-tools-extra/clangd/FileDistance.h
===
--- clang-tools-extra/clangd/FileDistance.h
+++ clang-tools-extra/clangd/FileDistance.h
@@ -89,6 +89,7 @@
 // comparison on the bodies.
 class URIDistance {
 public:
+  // \p Sources must contain absolute paths, not URIs.
   URIDistance(llvm::StringMap Sources,
   const FileDistanceOptions &Opts = {})
   : Sources(Sources), Opts(Opts) {}


Index: clang-tools-extra/clangd/FileDistance.h
===
--- clang-tools-extra/clangd/FileDistance.h
+++ clang-tools-extra/clangd/FileDistance.h
@@ -89,6 +89,7 @@
 // comparison on the bodies.
 class URIDistance {
 public:
+  // \p Sources must contain absolute paths, not URIs.
   URIDistance(llvm::StringMap Sources,
   const FileDistanceOptions &Opts = {})
   : Sources(Sources), Opts(Opts) {}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51691: [clangd] NFC: Document URIDistance

2018-09-06 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev marked an inline comment as done.
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/FileDistance.h:89
 public:
+  // Memorizes paths from \p Sources and builds efficient structure for URI
+  // distance computations. \p Sources must contain absolute paths, not URIs.

sammccall wrote:
> The constructor doesn't do any computation, thus there's nothing to memoize.
> 
> I'd suggest dropping the second sentence here, that's the only noteworthy 
> thing specific to this constructor.
Sorry, did you mean dropping the *first sentence* here? The second one seems to 
be the one you describe.


https://reviews.llvm.org/D51691



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


[clang-tools-extra] r341543 - [clangd] NFC: mark single-parameter constructors explicit

2018-09-06 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Thu Sep  6 06:06:04 2018
New Revision: 341543

URL: http://llvm.org/viewvc/llvm-project?rev=341543&view=rev
Log:
[clangd] NFC: mark single-parameter constructors explicit

Code health: prevent implicit conversions to user-defined types.

Reviewed By: sammccall

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

Modified:
clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp

Modified: clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp?rev=341543&r1=341542&r2=341543&view=diff
==
--- clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp Thu Sep  6 06:06:04 
2018
@@ -23,7 +23,7 @@ namespace {
 /// tree) and is simply a wrapper around PostingList::const_iterator.
 class DocumentIterator : public Iterator {
 public:
-  DocumentIterator(PostingListRef Documents)
+  explicit DocumentIterator(PostingListRef Documents)
   : Documents(Documents), Index(std::begin(Documents)) {}
 
   bool reachedEnd() const override { return Index == std::end(Documents); }
@@ -85,7 +85,7 @@ private:
 /// iterator restores the invariant: all children must point to the same item.
 class AndIterator : public Iterator {
 public:
-  AndIterator(std::vector> AllChildren)
+  explicit AndIterator(std::vector> AllChildren)
   : Children(std::move(AllChildren)) {
 assert(!Children.empty() && "AND iterator should have at least one 
child.");
 // Establish invariants.
@@ -193,7 +193,7 @@ private:
 /// soon as all of its children are exhausted.
 class OrIterator : public Iterator {
 public:
-  OrIterator(std::vector> AllChildren)
+  explicit OrIterator(std::vector> AllChildren)
   : Children(std::move(AllChildren)) {
 assert(Children.size() > 0 && "OR iterator must have at least one child.");
   }
@@ -279,7 +279,7 @@ private:
 /// in O(1).
 class TrueIterator : public Iterator {
 public:
-  TrueIterator(DocID Size) : Size(Size) {}
+  explicit TrueIterator(DocID Size) : Size(Size) {}
 
   bool reachedEnd() const override { return Index >= Size; }
 


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


[PATCH] D51690: [clangd] NFC: mark single-parameter constructors explicit

2018-09-06 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341543: [clangd] NFC: mark single-parameter constructors 
explicit (authored by omtcyfz, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51690?vs=164065&id=164198#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51690

Files:
  clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp


Index: clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp
===
--- clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp
+++ clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp
@@ -23,7 +23,7 @@
 /// tree) and is simply a wrapper around PostingList::const_iterator.
 class DocumentIterator : public Iterator {
 public:
-  DocumentIterator(PostingListRef Documents)
+  explicit DocumentIterator(PostingListRef Documents)
   : Documents(Documents), Index(std::begin(Documents)) {}
 
   bool reachedEnd() const override { return Index == std::end(Documents); }
@@ -85,7 +85,7 @@
 /// iterator restores the invariant: all children must point to the same item.
 class AndIterator : public Iterator {
 public:
-  AndIterator(std::vector> AllChildren)
+  explicit AndIterator(std::vector> AllChildren)
   : Children(std::move(AllChildren)) {
 assert(!Children.empty() && "AND iterator should have at least one 
child.");
 // Establish invariants.
@@ -193,7 +193,7 @@
 /// soon as all of its children are exhausted.
 class OrIterator : public Iterator {
 public:
-  OrIterator(std::vector> AllChildren)
+  explicit OrIterator(std::vector> AllChildren)
   : Children(std::move(AllChildren)) {
 assert(Children.size() > 0 && "OR iterator must have at least one child.");
   }
@@ -279,7 +279,7 @@
 /// in O(1).
 class TrueIterator : public Iterator {
 public:
-  TrueIterator(DocID Size) : Size(Size) {}
+  explicit TrueIterator(DocID Size) : Size(Size) {}
 
   bool reachedEnd() const override { return Index >= Size; }
 


Index: clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp
===
--- clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp
+++ clang-tools-extra/trunk/clangd/index/dex/Iterator.cpp
@@ -23,7 +23,7 @@
 /// tree) and is simply a wrapper around PostingList::const_iterator.
 class DocumentIterator : public Iterator {
 public:
-  DocumentIterator(PostingListRef Documents)
+  explicit DocumentIterator(PostingListRef Documents)
   : Documents(Documents), Index(std::begin(Documents)) {}
 
   bool reachedEnd() const override { return Index == std::end(Documents); }
@@ -85,7 +85,7 @@
 /// iterator restores the invariant: all children must point to the same item.
 class AndIterator : public Iterator {
 public:
-  AndIterator(std::vector> AllChildren)
+  explicit AndIterator(std::vector> AllChildren)
   : Children(std::move(AllChildren)) {
 assert(!Children.empty() && "AND iterator should have at least one child.");
 // Establish invariants.
@@ -193,7 +193,7 @@
 /// soon as all of its children are exhausted.
 class OrIterator : public Iterator {
 public:
-  OrIterator(std::vector> AllChildren)
+  explicit OrIterator(std::vector> AllChildren)
   : Children(std::move(AllChildren)) {
 assert(Children.size() > 0 && "OR iterator must have at least one child.");
   }
@@ -279,7 +279,7 @@
 /// in O(1).
 class TrueIterator : public Iterator {
 public:
-  TrueIterator(DocID Size) : Size(Size) {}
+  explicit TrueIterator(DocID Size) : Size(Size) {}
 
   bool reachedEnd() const override { return Index >= Size; }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51683: Fix arm_neon.h and arm_fp16.h generation for compiling with std=c89

2018-09-06 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio updated this revision to Diff 164199.

https://reviews.llvm.org/D51683

Files:
  test/Headers/arm-fp16-header.c
  test/Headers/arm-neon-header.c


Index: test/Headers/arm-neon-header.c
===
--- test/Headers/arm-neon-header.c
+++ test/Headers/arm-neon-header.c
@@ -2,23 +2,22 @@
 // RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -fno-lax-vector-conversions -ffreestanding %s
 // RUN: %clang_cc1 -x c++ -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -Wvector-conversions -ffreestanding %s
 
-// RUN: %clang -fsyntax-only -ffreestanding --target=aarch64-arm-none-eabi 
-march=armv8.2-a+fp16 -std=c89 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c99 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c11 -xc %s
+// RUN: %clang -fsyntax-only   -ffreestanding 
--target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c89 -xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c99 -xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c11 -xc %s
 
-// RUN: %clang -fsyntax-only -ffreestanding --target=aarch64-armeb-none-eabi 
-march=armv8.2-a+fp16 -std=c89 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c99 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c11 -xc %s
+// RUN: %clang -fsyntax-only   -ffreestanding 
--target=aarch64_be-none-eabi -march=armv8.2-a+fp16 -std=c89 -xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-eabi -march=armv8.2-a+fp16 -std=c99 -xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-eabi -march=armv8.2-a+fp16 -std=c11 -xc %s
 
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c++98 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c++11 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c++14 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c++17 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c++98 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c++11 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c++14 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c++17 -xc++ %s
 
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c++98 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c++11 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c++14 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c++17 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-eabi -march=armv8.2-a+fp16 -std=c++98 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-eabi -march=armv8.2-a+fp16 -std=c++11 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-eabi -march=armv8.2-a+fp16 -std=c++14 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-eabi -march=armv8.2-a+fp16 -std=c++17 -xc++ %s
 
 #include 
-
Index: test/Headers/arm-fp16-header.c
===
--- test/Headers/arm-fp16-header.c
+++ test/Headers/arm-fp16-header.c
@@ -1,19 +1,19 @@
-// RUN: %clang -fsyntax-only  -ffreestanding --target=aarch64-arm-none-eabi 
-march=armv8.2-a+fp16 -std=c89 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c99 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c11 -xc %s
+// RUN: %clang -fsyntax-only  -ffreestanding  
--target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c89 -xc %s
+// RUN: %clang -fsyntax-only -Wall -

[PATCH] D51038: [clang] Make sure codecompletion is called for calls even when inside a token.

2018-09-06 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: test/Index/complete-block-property-assignment.m:71
 
+// RUN: c-index-test -code-completion-at=%s:54:15 %s | FileCheck 
-check-prefix=CHECK-NO1 %s
+// CHECK-NO1: ObjCPropertyDecl:{ResultType int}{TypedText foo} (35)

ilya-biryukov wrote:
> Any idea why behavior changed in that case?
Looked at it more thoroughly now...
So we're now showing both the signature help and the completion, right?
If that the case, LG, but can we include the rest of completion items from 
CHECK-N0? 

Maybe also add a comment that the last item is from overload set completion, 
rather than the ordinary code completion? (To avoid confusion and make it clear 
why we need an extra check there)


Repository:
  rC Clang

https://reviews.llvm.org/D51038



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


[PATCH] D51676: [clangd] Use TopN instead of std::priority_queue

2018-09-06 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 164200.
kbobyrev marked an inline comment as done.

https://reviews.llvm.org/D51676

Files:
  clang-tools-extra/clangd/index/MemIndex.cpp


Index: clang-tools-extra/clangd/index/MemIndex.cpp
===
--- clang-tools-extra/clangd/index/MemIndex.cpp
+++ clang-tools-extra/clangd/index/MemIndex.cpp
@@ -10,7 +10,7 @@
 #include "MemIndex.h"
 #include "../FuzzyMatch.h"
 #include "../Logger.h"
-#include 
+#include "../Quality.h"
 
 namespace clang {
 namespace clangd {
@@ -26,7 +26,7 @@
   assert(!StringRef(Req.Query).contains("::") &&
  "There must be no :: in query.");
 
-  std::priority_queue> Top;
+  TopN> Top(Req.MaxCandidateCount);
   FuzzyMatcher Filter(Req.Query);
   bool More = false;
   for (const auto Pair : Index) {
@@ -38,16 +38,12 @@
 if (Req.RestrictForCodeCompletion && !Sym->IsIndexedForCodeCompletion)
   continue;
 
-if (auto Score = Filter.match(Sym->Name)) {
-  Top.emplace(-*Score * quality(*Sym), Sym);
-  if (Top.size() > Req.MaxCandidateCount) {
-More = true;
-Top.pop();
-  }
-}
+if (auto Score = Filter.match(Sym->Name))
+  if (Top.push({*Score * quality(*Sym), Sym}))
+More = true; // An element with smallest score was discarded.
   }
-  for (; !Top.empty(); Top.pop())
-Callback(*Top.top().second);
+  for (const auto &Item : std::move(Top).items())
+Callback(*Item.second);
   return More;
 }
 


Index: clang-tools-extra/clangd/index/MemIndex.cpp
===
--- clang-tools-extra/clangd/index/MemIndex.cpp
+++ clang-tools-extra/clangd/index/MemIndex.cpp
@@ -10,7 +10,7 @@
 #include "MemIndex.h"
 #include "../FuzzyMatch.h"
 #include "../Logger.h"
-#include 
+#include "../Quality.h"
 
 namespace clang {
 namespace clangd {
@@ -26,7 +26,7 @@
   assert(!StringRef(Req.Query).contains("::") &&
  "There must be no :: in query.");
 
-  std::priority_queue> Top;
+  TopN> Top(Req.MaxCandidateCount);
   FuzzyMatcher Filter(Req.Query);
   bool More = false;
   for (const auto Pair : Index) {
@@ -38,16 +38,12 @@
 if (Req.RestrictForCodeCompletion && !Sym->IsIndexedForCodeCompletion)
   continue;
 
-if (auto Score = Filter.match(Sym->Name)) {
-  Top.emplace(-*Score * quality(*Sym), Sym);
-  if (Top.size() > Req.MaxCandidateCount) {
-More = true;
-Top.pop();
-  }
-}
+if (auto Score = Filter.match(Sym->Name))
+  if (Top.push({*Score * quality(*Sym), Sym}))
+More = true; // An element with smallest score was discarded.
   }
-  for (; !Top.empty(); Top.pop())
-Callback(*Top.top().second);
+  for (const auto &Item : std::move(Top).items())
+Callback(*Item.second);
   return More;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51676: [clangd] Use TopN instead of std::priority_queue

2018-09-06 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

In https://reviews.llvm.org/D51676#1225215, @sammccall wrote:

> Thanks for cleaning this up!
>
> I believe this will result in the results from MemIndex being returned in 
> best -> worst order, rather than worst -> best.
>  The contract says callers shouldn't rely on the order so it should still be 
> NFC overall.
>  It's likely to make your index explorer more useful though :-)


Right. The index explorer would probably still have to re-order elements (so 
that it actually doesn't rely on implementation details and implicit 
assumptions). For the completion part, IIUC the complete ranking would 
rearrange items anyway.


https://reviews.llvm.org/D51676



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


[clang-tools-extra] r341544 - [clangd] NFC: Use TopN instead of std::priority_queue

2018-09-06 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Thu Sep  6 06:15:03 2018
New Revision: 341544

URL: http://llvm.org/viewvc/llvm-project?rev=341544&view=rev
Log:
[clangd] NFC: Use TopN instead of std::priority_queue

Quality.cpp defines a structure for convenient storage of Top N items,
it should be used instead of the `std::priority_queue` with slightly
obscure semantics.

This patch does not affect functionality.

Reviewed By: sammccall

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

Modified:
clang-tools-extra/trunk/clangd/index/MemIndex.cpp

Modified: clang-tools-extra/trunk/clangd/index/MemIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/MemIndex.cpp?rev=341544&r1=341543&r2=341544&view=diff
==
--- clang-tools-extra/trunk/clangd/index/MemIndex.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/MemIndex.cpp Thu Sep  6 06:15:03 2018
@@ -10,7 +10,7 @@
 #include "MemIndex.h"
 #include "../FuzzyMatch.h"
 #include "../Logger.h"
-#include 
+#include "../Quality.h"
 
 namespace clang {
 namespace clangd {
@@ -26,7 +26,7 @@ bool MemIndex::fuzzyFind(
   assert(!StringRef(Req.Query).contains("::") &&
  "There must be no :: in query.");
 
-  std::priority_queue> Top;
+  TopN> Top(Req.MaxCandidateCount);
   FuzzyMatcher Filter(Req.Query);
   bool More = false;
   for (const auto Pair : Index) {
@@ -38,16 +38,12 @@ bool MemIndex::fuzzyFind(
 if (Req.RestrictForCodeCompletion && !Sym->IsIndexedForCodeCompletion)
   continue;
 
-if (auto Score = Filter.match(Sym->Name)) {
-  Top.emplace(-*Score * quality(*Sym), Sym);
-  if (Top.size() > Req.MaxCandidateCount) {
-More = true;
-Top.pop();
-  }
-}
+if (auto Score = Filter.match(Sym->Name))
+  if (Top.push({*Score * quality(*Sym), Sym}))
+More = true; // An element with smallest score was discarded.
   }
-  for (; !Top.empty(); Top.pop())
-Callback(*Top.top().second);
+  for (const auto &Item : std::move(Top).items())
+Callback(*Item.second);
   return More;
 }
 


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


[PATCH] D51676: [clangd] NFC: Use TopN instead of std::priority_queue

2018-09-06 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341544: [clangd] NFC: Use TopN instead of 
std::priority_queue (authored by omtcyfz, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51676?vs=164200&id=164202#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51676

Files:
  clang-tools-extra/trunk/clangd/index/MemIndex.cpp


Index: clang-tools-extra/trunk/clangd/index/MemIndex.cpp
===
--- clang-tools-extra/trunk/clangd/index/MemIndex.cpp
+++ clang-tools-extra/trunk/clangd/index/MemIndex.cpp
@@ -10,7 +10,7 @@
 #include "MemIndex.h"
 #include "../FuzzyMatch.h"
 #include "../Logger.h"
-#include 
+#include "../Quality.h"
 
 namespace clang {
 namespace clangd {
@@ -26,7 +26,7 @@
   assert(!StringRef(Req.Query).contains("::") &&
  "There must be no :: in query.");
 
-  std::priority_queue> Top;
+  TopN> Top(Req.MaxCandidateCount);
   FuzzyMatcher Filter(Req.Query);
   bool More = false;
   for (const auto Pair : Index) {
@@ -38,16 +38,12 @@
 if (Req.RestrictForCodeCompletion && !Sym->IsIndexedForCodeCompletion)
   continue;
 
-if (auto Score = Filter.match(Sym->Name)) {
-  Top.emplace(-*Score * quality(*Sym), Sym);
-  if (Top.size() > Req.MaxCandidateCount) {
-More = true;
-Top.pop();
-  }
-}
+if (auto Score = Filter.match(Sym->Name))
+  if (Top.push({*Score * quality(*Sym), Sym}))
+More = true; // An element with smallest score was discarded.
   }
-  for (; !Top.empty(); Top.pop())
-Callback(*Top.top().second);
+  for (const auto &Item : std::move(Top).items())
+Callback(*Item.second);
   return More;
 }
 


Index: clang-tools-extra/trunk/clangd/index/MemIndex.cpp
===
--- clang-tools-extra/trunk/clangd/index/MemIndex.cpp
+++ clang-tools-extra/trunk/clangd/index/MemIndex.cpp
@@ -10,7 +10,7 @@
 #include "MemIndex.h"
 #include "../FuzzyMatch.h"
 #include "../Logger.h"
-#include 
+#include "../Quality.h"
 
 namespace clang {
 namespace clangd {
@@ -26,7 +26,7 @@
   assert(!StringRef(Req.Query).contains("::") &&
  "There must be no :: in query.");
 
-  std::priority_queue> Top;
+  TopN> Top(Req.MaxCandidateCount);
   FuzzyMatcher Filter(Req.Query);
   bool More = false;
   for (const auto Pair : Index) {
@@ -38,16 +38,12 @@
 if (Req.RestrictForCodeCompletion && !Sym->IsIndexedForCodeCompletion)
   continue;
 
-if (auto Score = Filter.match(Sym->Name)) {
-  Top.emplace(-*Score * quality(*Sym), Sym);
-  if (Top.size() > Req.MaxCandidateCount) {
-More = true;
-Top.pop();
-  }
-}
+if (auto Score = Filter.match(Sym->Name))
+  if (Top.push({*Score * quality(*Sym), Sym}))
+More = true; // An element with smallest score was discarded.
   }
-  for (; !Top.empty(); Top.pop())
-Callback(*Top.top().second);
+  for (const auto &Item : std::move(Top).items())
+Callback(*Item.second);
   return More;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51683: Fix arm_neon.h and arm_fp16.h generation for compiling with std=c89

2018-09-06 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

These new changes look good to me.

If you are updating things like this, it's often better to create a new Phab 
review so it's easier to see it's a new thing (or, in cases like this where the 
changes are simple and just test updates, they often don't need review). Either 
way, LGTM. Thanks for the test fix.


https://reviews.llvm.org/D51683



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


[PATCH] D45045: [DebugInfo] Generate debug information for labels.

2018-09-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

The latest reland of this patch triggers a segfault in clang (seemingly only on 
k8 and ppc).
I've bisected it to r341519 but don't understand the cause.
The stacktrace is:

  1. parser at end of file
  2.Code generation
  #0 0x5649754494d4 SignalHandler(int) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x10db4d4)
  #1 0x7f72c7f849a0 __restore_rt (/usr/grte/v4/lib64/libpthread.so.0+0xf9a0)
  #2 0x56497495f950 llvm::MCObjectStreamer::visitUsedSymbol(llvm::MCSymbol 
const&) (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x5f1950)
  #3 0x564974927858 llvm::MCELFStreamer::EmitValueImpl(llvm::MCExpr const*, 
unsigned int, llvm::SMLoc) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x5b9858)
  #4 0x564975bdb18c llvm::AddressPool::emit(llvm::AsmPrinter&, 
llvm::MCSection*) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x186d18c)
  #5 0x564975bb5525 llvm::DwarfDebug::endModule() 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x1847525)
  #6 0x5649748d185a llvm::AsmPrinter::doFinalization(llvm::Module&) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x56385a)
  #7 0x56497535f883 llvm::FPPassManager::doFinalization(llvm::Module&) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0xff1883)
  #8 0x56497535ff05 llvm::legacy::PassManagerImpl::run(llvm::Module&) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0xff1f05)
  #9 0x564974acff27 clang::EmitBackendOutput(clang::DiagnosticsEngine&, 
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, 
clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout 
const&, llvm::Module*, clang::BackendAction, 
std::unique_ptr >) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x761f27)
  #10 0x5649764c40cd 
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x21560cd)
  #11 0x564974cc4f78 clang::ParseAST(clang::Sema&, bool, bool) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x956f78)
  #12 0x56497649a3e7 clang::FrontendAction::Execute() 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x212c3e7)
  #13 0x5649764e1c02 
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x2173c02)
  #14 0x56497683e8b3 
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x24d08b3)
  #15 0x5649754110de cc1_main(llvm::ArrayRef, char const*, 
void*) (third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0x10a30de)
  #16 0x564974e4682a main 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0xad882a)
  #17 0x7f72c7cf2bbd __libc_start_main 
(/usr/grte/v4/lib64/libc.so.6+0x38bbd)
  #18 0x564974e51069 _start 
(third_party/crosstool/v18/llvm_unstable/toolchain/bin/clang+0xae3069)
  clang: error: unable to execute command: Segmentation fault
  clang: error: clang frontend command failed due to signal (use -v to see 
invocation)

I can try to isolate a reproducer if the buildbots don't pick this up.


Repository:
  rL LLVM

https://reviews.llvm.org/D45045



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


[PATCH] D51724: [clangd] Add "Deprecated" field to Symbol and CodeCompletion.

2018-09-06 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/Protocol.cpp:520
 Result["additionalTextEdits"] = json::Array(CI.additionalTextEdits);
+  if (CI.deprecated)
+Result["deprecated"] = CI.deprecated;

sammccall wrote:
> do we actually want this in JSON?
> (genuinely unsure - any clients aware of this extension?)
This is actually defined in LSP: 
https://github.com/Microsoft/language-server-protocol/blob/gh-pages/specification.md#completion-request-leftwards_arrow_with_hook



Comment at: clangd/index/Index.h:249
+  /// FIXME: also add deprecation message and fixit?
+  bool Deprecated = false;
 };

sammccall wrote:
> would you mind packing this together with IsIndexedForCompletion, for memory 
> size?
> either as an actual bitfield `bool Deprecated : 1 = false` or as enum flags 
> `enum Flags : uint8_t { IndexedForCompletion, Deprecated, }; Flags flags`
> 
> The latter will simplify life for serialization, but up to you.
Done. Pack them into flags.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51724



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


[PATCH] D51724: [clangd] Add "Deprecated" field to Symbol and CodeCompletion.

2018-09-06 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 164205.
ioeric marked an inline comment as done.
ioeric added a comment.

- Pack flags in Symbol.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51724

Files:
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/Quality.cpp
  clangd/index/Index.cpp
  clangd/index/Index.h
  clangd/index/MemIndex.cpp
  clangd/index/Serialization.cpp
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolYAML.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/QualityTests.cpp
  unittests/clangd/SerializationTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -80,8 +80,9 @@
 }
 MATCHER_P(RefCount, R, "") { return int(arg.References) == R; }
 MATCHER_P(ForCodeCompletion, IsIndexedForCodeCompletion, "") {
-  return arg.IsIndexedForCodeCompletion == IsIndexedForCodeCompletion;
+  return arg.IsIndexedForCodeCompletion() == IsIndexedForCodeCompletion;
 }
+MATCHER(Deprecated, "") { return arg.Deprecated(); }
 MATCHER(RefRange, "") {
   const Ref &Pos = testing::get<0>(arg);
   const Range &Range = testing::get<1>(arg);
@@ -1014,6 +1015,17 @@
  DeclRange(Header.range("used");
 }
 
+TEST_F(SymbolCollectorTest, DeprecatedSymbols) {
+  const std::string Header = R"(
+void TestClangc() __attribute__((deprecated("", "")));
+void TestClangd();
+  )";
+  runSymbolCollector(Header, /**/ "");
+  EXPECT_THAT(Symbols, UnorderedElementsAre(
+   AllOf(QName("TestClangc"), Deprecated()),
+   AllOf(QName("TestClangd"), Not(Deprecated();
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/SerializationTests.cpp
===
--- unittests/clangd/SerializationTests.cpp
+++ unittests/clangd/SerializationTests.cpp
@@ -35,7 +35,7 @@
   End:
 Line: 1
 Column: 1
-IsIndexedForCodeCompletion:true
+Flags:1
 Documentation:'Foo doc'
 ReturnType:'int'
 IncludeHeaders:
@@ -62,7 +62,7 @@
   End:
 Line: 1
 Column: 1
-IsIndexedForCodeCompletion:false
+Flags:2
 Signature:'-sig'
 CompletionSnippetSuffix:'-snippet'
 ...
@@ -82,7 +82,8 @@
   EXPECT_EQ(Sym1.Documentation, "Foo doc");
   EXPECT_EQ(Sym1.ReturnType, "int");
   EXPECT_EQ(Sym1.CanonicalDeclaration.FileURI, "file:///path/foo.h");
-  EXPECT_TRUE(Sym1.IsIndexedForCodeCompletion);
+  EXPECT_TRUE(Sym1.IsIndexedForCodeCompletion());
+  EXPECT_FALSE(Sym1.Deprecated());
   EXPECT_THAT(Sym1.IncludeHeaders,
   UnorderedElementsAre(IncludeHeaderWithRef("include1", 7u),
IncludeHeaderWithRef("include2", 3u)));
@@ -94,7 +95,8 @@
   EXPECT_EQ(Sym2.Signature, "-sig");
   EXPECT_EQ(Sym2.ReturnType, "");
   EXPECT_EQ(Sym2.CanonicalDeclaration.FileURI, "file:///path/bar.h");
-  EXPECT_FALSE(Sym2.IsIndexedForCodeCompletion);
+  EXPECT_FALSE(Sym2.IsIndexedForCodeCompletion());
+  EXPECT_TRUE(Sym2.Deprecated());
 
   std::string ConcatenatedYAML;
   {
Index: unittests/clangd/QualityTests.cpp
===
--- unittests/clangd/QualityTests.cpp
+++ unittests/clangd/QualityTests.cpp
@@ -59,7 +59,7 @@
   F.References = 24; // TestTU doesn't count references, so fake it.
   Quality = {};
   Quality.merge(F);
-  EXPECT_FALSE(Quality.Deprecated); // FIXME: Include deprecated bit in index.
+  EXPECT_TRUE(Quality.Deprecated);
   EXPECT_FALSE(Quality.ReservedName);
   EXPECT_EQ(Quality.References, 24u);
   EXPECT_EQ(Quality.Category, SymbolQualitySignals::Function);
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -77,6 +77,7 @@
   return Contains(AllOf(Named(std::move(Name)), Kind(K)));
 }
 MATCHER(IsDocumented, "") { return !arg.Documentation.empty(); }
+MATCHER(Deprecated, "") { return arg.Deprecated; }
 
 std::unique_ptr memIndex(std::vector Symbols) {
   SymbolSlab::Builder Slab;
@@ -161,7 +162,7 @@
   USR += Regex("^.*$").sub(USRFormat, Sym.Name); // e.g. func -> @F@func#
   Sym.ID = SymbolID(USR);
   Sym.SymInfo.Kind = Kind;
-  Sym.IsIndexedForCodeCompletion = true;
+  Sym.Flags |= SymbolFlag::IsIndexedForCodeCompletion;
   Sym.Origin = SymbolOrigin::Static;
   return Sym;
 }
@@ -720,9 +721,9 @@
 TEST(CompletionTest, GlobalCompletionFiltering) {
 
   Symbol Class = cls("XYZ");
-  Class.IsIndexedForCodeCompletion = false;
+  Class.Flags &= ~(SymbolFlag::IsIndexedForCodeCompletion);
   Symbol Func = func("XYZ::f");
-  Func.IsIndexedForCodeCompletion = false;
+  Func.Flags &= ~(SymbolFlag::IsIndexedForCodeCompletio

Re: r341539 - [OpenCL] Disallow negative attribute arguments

2018-09-06 Thread Andrew Savonichev via cfe-commits
Hi Aaron,

> On Thu, Sep 6, 2018 at 7:54 AM, Andrew Savonichev via cfe-commits
>  wrote:
>> Author: asavonic
>> Date: Thu Sep  6 04:54:09 2018
>> New Revision: 341539
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=341539&view=rev
>> Log:
>> [OpenCL] Disallow negative attribute arguments
>>
>> [...]
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=341539&r1=341538&r2=341539&view=diff
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Sep  6 04:54:09 
>> 2018
>> @@ -2529,6 +2529,8 @@ def err_attribute_argument_type : Error<
>>"constant|a string|an identifier}1">;
>>  def err_attribute_argument_outof_range : Error<
>>"%0 attribute requires integer constant between %1 and %2 inclusive">;
>> +def err_attribute_argument_negative : Error<
>> +  "negative argument is not allowed for %0 attribute">;
>
> I don't think we need a new diagnostic here as we already have
> err_attribute_requires_positive_integer.

`err_attribute_requires_positive_integer' implies that a zero argument
is not allowed, while `err_attribute_argument_negative' should fire only
on a strictly negative argument.

I can merge these diagnostics into one (using %select), but I'm not sure
if it is appropriate.

-- 
Andrew


Joint Stock Company Intel A/O
Registered legal address: Krylatsky Hills Business Park,
17 Krylatskaya Str., Bldg 4, Moscow 121614,
Russian Federation

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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


r341547 - Fix the -print-multi-directory flag to print the selected multilib.

2018-09-06 Thread Christian Bruel via cfe-commits
Author: chrib
Date: Thu Sep  6 07:03:44 2018
New Revision: 341547

URL: http://llvm.org/viewvc/llvm-project?rev=341547&view=rev
Log:
Fix the -print-multi-directory flag to print the selected multilib.

Summary: Fix -print-multi-directory to print the selected multilib

Reviewers: jroelofs

Reviewed By: jroelofs

Subscribers: jroelofs, timshen, thakis, srhines, cfe-commits

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

Added:
cfe/trunk/test/Driver/print-multi-directory.c
Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChains/Linux.cpp

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=341547&r1=341546&r2=341547&view=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Thu Sep  6 07:03:44 2018
@@ -149,6 +149,7 @@ private:
 
 protected:
   MultilibSet Multilibs;
+  Multilib SelectedMultilib;
 
   ToolChain(const Driver &D, const llvm::Triple &T,
 const llvm::opt::ArgList &Args);
@@ -227,6 +228,8 @@ public:
 
   const MultilibSet &getMultilibs() const { return Multilibs; }
 
+  const Multilib &getMultilib() const { return SelectedMultilib; }
+
   const SanitizerArgs& getSanitizerArgs() const;
 
   const XRayArgs& getXRayArgs() const;

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=341547&r1=341546&r2=341547&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Sep  6 07:03:44 2018
@@ -1661,14 +1661,13 @@ bool Driver::HandleImmediateArgs(const C
   }
 
   if (C.getArgs().hasArg(options::OPT_print_multi_directory)) {
-for (const Multilib &Multilib : TC.getMultilibs()) {
-  if (Multilib.gccSuffix().empty())
-llvm::outs() << ".\n";
-  else {
-StringRef Suffix(Multilib.gccSuffix());
-assert(Suffix.front() == '/');
-llvm::outs() << Suffix.substr(1) << "\n";
-  }
+const Multilib &Multilib = TC.getMultilib();
+if (Multilib.gccSuffix().empty())
+  llvm::outs() << ".\n";
+else {
+  StringRef Suffix(Multilib.gccSuffix());
+  assert(Suffix.front() == '/');
+  llvm::outs() << Suffix.substr(1) << "\n";
 }
 return false;
   }

Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Linux.cpp?rev=341547&r1=341546&r2=341547&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Thu Sep  6 07:03:44 2018
@@ -210,6 +210,7 @@ Linux::Linux(const Driver &D, const llvm
 : Generic_ELF(D, Triple, Args) {
   GCCInstallation.init(Triple, Args);
   Multilibs = GCCInstallation.getMultilibs();
+  SelectedMultilib = GCCInstallation.getMultilib();
   llvm::Triple::ArchType Arch = Triple.getArch();
   std::string SysRoot = computeSysRoot();
 
@@ -299,16 +300,14 @@ Linux::Linux(const Driver &D, const llvm
   if (GCCInstallation.isValid()) {
 const llvm::Triple &GCCTriple = GCCInstallation.getTriple();
 const std::string &LibPath = GCCInstallation.getParentLibPath();
-const Multilib &Multilib = GCCInstallation.getMultilib();
-const MultilibSet &Multilibs = GCCInstallation.getMultilibs();
 
 // Add toolchain / multilib specific file paths.
-addMultilibsFilePaths(D, Multilibs, Multilib,
+addMultilibsFilePaths(D, Multilibs, SelectedMultilib,
   GCCInstallation.getInstallPath(), Paths);
 
 // Sourcery CodeBench MIPS toolchain holds some libraries under
 // a biarch-like suffix of the GCC installation.
-addPathIfExists(D, GCCInstallation.getInstallPath() + Multilib.gccSuffix(),
+addPathIfExists(D, GCCInstallation.getInstallPath() + 
SelectedMultilib.gccSuffix(),
 Paths);
 
 // GCC cross compiling toolchains will install target libraries which ship
@@ -330,7 +329,7 @@ Linux::Linux(const Driver &D, const llvm
 // Note that this matches the GCC behavior. See the below comment for where
 // Clang diverges from GCC's behavior.
 addPathIfExists(D, LibPath + "/../" + GCCTriple.str() + "/lib/../" +
-   OSLibDir + Multilib.osSuffix(),
+   OSLibDir + SelectedMultilib.osSuffix(),
 Paths);
 
 // If the GCC installation we found is inside of the sysroot, we want to

Added: cfe/trunk/test/Driver/print-multi-directory.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/print-multi-directory.c?rev=341547&view=auto

[PATCH] D45179: [libc++] Add _LIBCPP_ENABLE_NODISCARD and _LIBCPP_NODISCARD_EXT to allow pre-C++2a [[nodiscard]]

2018-09-06 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

What's the status here? Did this land?


https://reviews.llvm.org/D45179



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


[PATCH] D51354: Fix the -print-multi-directory flag to print the selected multilib.

2018-09-06 Thread Christian Bruel via Phabricator via cfe-commits
chrib added a comment.

Re-commit patch at r341547 with modified test case to use an explicit root tree 
for libraries


Repository:
  rC Clang

https://reviews.llvm.org/D51354



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


Re: r341539 - [OpenCL] Disallow negative attribute arguments

2018-09-06 Thread Aaron Ballman via cfe-commits
On Thu, Sep 6, 2018 at 10:00 AM, Andrew Savonichev
 wrote:
> Hi Aaron,
>
>> On Thu, Sep 6, 2018 at 7:54 AM, Andrew Savonichev via cfe-commits
>>  wrote:
>>> Author: asavonic
>>> Date: Thu Sep  6 04:54:09 2018
>>> New Revision: 341539
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=341539&view=rev
>>> Log:
>>> [OpenCL] Disallow negative attribute arguments
>>>
>>> [...]
>>>
>>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=341539&r1=341538&r2=341539&view=diff
>>> ==
>>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Sep  6 
>>> 04:54:09 2018
>>> @@ -2529,6 +2529,8 @@ def err_attribute_argument_type : Error<
>>>"constant|a string|an identifier}1">;
>>>  def err_attribute_argument_outof_range : Error<
>>>"%0 attribute requires integer constant between %1 and %2 inclusive">;
>>> +def err_attribute_argument_negative : Error<
>>> +  "negative argument is not allowed for %0 attribute">;
>>
>> I don't think we need a new diagnostic here as we already have
>> err_attribute_requires_positive_integer.
>
> `err_attribute_requires_positive_integer' implies that a zero argument
> is not allowed, while `err_attribute_argument_negative' should fire only
> on a strictly negative argument.
>
> I can merge these diagnostics into one (using %select), but I'm not sure
> if it is appropriate.

That's a subtle distinction, but a good catch! I think it's fine to
change it to: "%0 attribute requires a %select{positive|non-negative}1
integral compile time constant expression" but if you think of wording
that makes the distinction less subtle, that'd be even better.

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


[PATCH] D45179: [libc++] Add _LIBCPP_ENABLE_NODISCARD and _LIBCPP_NODISCARD_EXT to allow pre-C++2a [[nodiscard]]

2018-09-06 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

I don't think it ever landed. I'll try to get it in this week.


https://reviews.llvm.org/D45179



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


[PATCH] D51722: [OpenCL] Allow blocks to capture arrays in OpenCL

2018-09-06 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! There is a small comment that can be addressed before the final commit. 
Thanks!




Comment at: lib/Sema/SemaExpr.cpp:14627
 
-  // Blocks are not allowed to capture arrays.
-  if (CaptureType->isArrayType()) {
+  // Blocks are not allowed to capture arrays, excepting OpenCL.
+  if (!S.getLangOpts().OpenCL && CaptureType->isArrayType()) {

It would be good to add spec reference here.


Repository:
  rC Clang

https://reviews.llvm.org/D51722



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


r341548 - Fix march triple used test from rL341475

2018-09-06 Thread Diogo N. Sampaio via cfe-commits
Author: dnsampaio
Date: Thu Sep  6 07:13:10 2018
New Revision: 341548

URL: http://llvm.org/viewvc/llvm-project?rev=341548&view=rev
Log:
Fix march triple used test from rL341475

Change the march triple of test files, possible fixing
test failures due rL341475


Modified:
cfe/trunk/test/Headers/arm-fp16-header.c
cfe/trunk/test/Headers/arm-neon-header.c

Modified: cfe/trunk/test/Headers/arm-fp16-header.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/arm-fp16-header.c?rev=341548&r1=341547&r2=341548&view=diff
==
--- cfe/trunk/test/Headers/arm-fp16-header.c (original)
+++ cfe/trunk/test/Headers/arm-fp16-header.c Thu Sep  6 07:13:10 2018
@@ -1,19 +1,19 @@
-// RUN: %clang -fsyntax-only  -ffreestanding --target=aarch64-arm-none-eabi 
-march=armv8.2-a+fp16 -std=c89 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c99 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c11 -xc %s
+// RUN: %clang -fsyntax-only  -ffreestanding  
--target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c89 -xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c99 -xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c11 -xc %s
 
-// RUN: %clang -fsyntax-only -ffreestanding --target=aarch64-armeb-none-eabi 
-march=armv8.2-a+fp16 -std=c89 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c99 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c11 -xc %s
+// RUN: %clang -fsyntax-only -ffreestanding   
--target=aarch64_be-none-eabi -march=armv8.2-a+fp16 -std=c89 -xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-eabi -march=armv8.2-a+fp16 -std=c99 -xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-eabi -march=armv8.2-a+fp16 -std=c11 -xc %s
 
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c++98 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c++11 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c++14 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16 -std=c++17 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c++98 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c++11 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c++14 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c++17 -xc++ %s
 
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c++98 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c++11 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c++14 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-armeb-none-eabi -march=armv8.2-a+fp16 -std=c++17 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-eabi -march=armv8.2-a+fp16 -std=c++98 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-eabi -march=armv8.2-a+fp16 -std=c++11 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-eabi -march=armv8.2-a+fp16 -std=c++14 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-eabi -march=armv8.2-a+fp16 -std=c++17 -xc++ %s
 
 #include 

Modified: cfe/trunk/test/Headers/arm-neon-header.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/arm-neon-header.c?rev=341548&r1=341547&r2=341548&view=diff
==
--- cfe/trunk/test/Headers/arm-neon-header.c (original)
+++ cfe/trunk/test/Headers/arm-neon-header.c Thu Sep  6 07:13:10 2018
@@ -2,23 +2,22 @@
 // RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -fno-lax-vector-conversions -ffreestanding %s
 // RUN: %clang_cc1 -x c++ -triple thumbv7-apple-darwin10

[PATCH] D51402: [OpenCL] Adding cl_intel_planar_yuv extension

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



Comment at: lib/Headers/opencl-c.h:26
+#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
+#ifndef cl_intel_planar_yuv
+#define cl_intel_planar_yuv

@yaxunl, do you think we need to add some kind of architecture guard for such 
things? Like it should only be added if the architecture supports the 
extension? But I guess `-cl-ext=+cl_intel_planar_yuv` trick might not work here 
because it's not a Clang known extension?

So may be the right solution here is to introduce a target specific header? For 
now it can be explicitly included but we could think of a target hook to 
preload a target specific header...


https://reviews.llvm.org/D51402



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


r341549 - Revert "[DebugInfo] Generate debug information for labels. (Fix PR37395)"

2018-09-06 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Sep  6 07:27:40 2018
New Revision: 341549

URL: http://llvm.org/viewvc/llvm-project?rev=341549&view=rev
Log:
Revert "[DebugInfo] Generate debug information for labels. (Fix PR37395)"

This reverts commit r341519, which generates debug info that causes
backend crashes. (with -split-dwarf-file)

Details in https://reviews.llvm.org/D50495

Removed:
cfe/trunk/test/CodeGen/debug-label-inline.c
cfe/trunk/test/CodeGen/debug-label.c
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CGStmt.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=341549&r1=341548&r2=341549&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Sep  6 07:27:40 2018
@@ -3769,32 +3769,6 @@ CGDebugInfo::EmitDeclareOfAutoVariable(c
   return EmitDeclare(VD, Storage, llvm::None, Builder);
 }
 
-void CGDebugInfo::EmitLabel(const LabelDecl *D, CGBuilderTy &Builder) {
-  assert(DebugKind >= codegenoptions::LimitedDebugInfo);
-  assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
-
-  if (D->hasAttr())
-return;
-
-  auto *Scope = cast(LexicalBlockStack.back());
-  llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
-
-  // Get location information.
-  unsigned Line = getLineNumber(D->getLocation());
-  unsigned Column = getColumnNumber(D->getLocation());
-
-  StringRef Name = D->getName();
-
-  // Create the descriptor for the label.
-  auto *L =
-  DBuilder.createLabel(Scope, Name, Unit, Line, 
CGM.getLangOpts().Optimize);
-
-  // Insert an llvm.dbg.label into the current block.
-  DBuilder.insertLabel(L,
-   llvm::DebugLoc::get(Line, Column, Scope, CurInlinedAt),
-   Builder.GetInsertBlock());
-}
-
 llvm::DIType *CGDebugInfo::CreateSelfType(const QualType &QualTy,
   llvm::DIType *Ty) {
   llvm::DIType *CachedTy = getTypeOrNull(QualTy);

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=341549&r1=341548&r2=341549&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Sep  6 07:27:40 2018
@@ -415,9 +415,6 @@ public:
llvm::Value *AI,
CGBuilderTy &Builder);
 
-  /// Emit call to \c llvm.dbg.label for an label.
-  void EmitLabel(const LabelDecl *D, CGBuilderTy &Builder);
-
   /// Emit call to \c llvm.dbg.declare for an imported variable
   /// declaration in a block.
   void EmitDeclareOfBlockDeclRefVariable(

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=341549&r1=341548&r2=341549&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Thu Sep  6 07:27:40 2018
@@ -531,16 +531,6 @@ void CodeGenFunction::EmitLabel(const La
   }
 
   EmitBlock(Dest.getBlock());
-
-  // Emit debug info for labels.
-  if (CGDebugInfo *DI = getDebugInfo()) {
-if (CGM.getCodeGenOpts().getDebugInfo() >=
-codegenoptions::LimitedDebugInfo) {
-  DI->setLocation(D->getLocation());
-  DI->EmitLabel(D, Builder);
-}
-  }
-
   incrementProfileCounter(D->getStmt());
 }
 

Removed: cfe/trunk/test/CodeGen/debug-label-inline.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-label-inline.c?rev=341548&view=auto
==
--- cfe/trunk/test/CodeGen/debug-label-inline.c (original)
+++ cfe/trunk/test/CodeGen/debug-label-inline.c (removed)
@@ -1,28 +0,0 @@
-// This test will test the correctness of generating DILabel and
-// llvm.dbg.label when the label is in inlined functions.
-//
-// RUN: %clang_cc1 -O2 %s -o - -emit-llvm -debug-info-kind=limited | FileCheck 
%s
-inline int f1(int a, int b) {
-  int sum;
-
-top:
-  sum = a + b;
-  return sum;
-}
-
-extern int ga, gb;
-
-int f2(void) {
-  int result;
-
-  result = f1(ga, gb);
-  // CHECK: call void @llvm.dbg.label(metadata [[LABEL_METADATA:!.*]]), !dbg 
[[LABEL_LOCATION:!.*]]
-
-  return result;
-}
-
-// CHECK: distinct !DISubprogram(name: "f1", {{.*}}, retainedNodes: 
[[ELEMENTS:!.*]])
-// CHECK: [[ELEMENTS]] = !{{{.*}}, [[LABEL_METADATA]]}
-// CHECK: [[LABEL_METADATA]] = !DILabel({{.*}}, name: "top", {{.*}}, line: 8)
-// CHECK: [[INLINEDAT:!.*]] = distinct !DILocation(line: 18,
-// CHECK: [[LABEL_LOCATION]] = !DILocation(line: 8, {{.*}}, inlinedAt: 
[[INLINEDAT]])

Removed: cfe/trunk/test/CodeGen/

[PATCH] D51484: [OpenCL] Add support of cl_intel_device_side_avc_motion_estimation extension

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



Comment at: include/clang/Basic/OpenCLExtensionTypes.def:27
+
+INTEL_SGAVC_TYPE(mce_payload_t, McePayload)
+INTEL_SGAVC_TYPE(ime_payload_t, ImePayload)

AlexeySachkov wrote:
> Anastasia wrote:
> > From the specification of this extension I can't quite see if these types 
> > have to be in Clang instead of the header. Can you please elaborate on any 
> > example where it wouldn't be possible for this type to be declared in the 
> > header using the technique explained in:
> > https://clang.llvm.org/docs/UsersManual.html#opencl-extensions 
> We cannot define these types in header because their layout is not defined in 
> specification, i.e. all of these types are opaque
This is not the reason to add functionality to Clang. You can easily sort such 
things with target specific headers or even general headers (see `ndrange_t` 
for example). Spec doesn't have to describe everything. The question is whether 
there is something about those types that can't be handled using standard 
include mechanisms. Usually it's prohibited behaviors that can't be represented 
with such mechanisms. Like if some operations have to be disallowed or allowed 
(since in OpenCL C you can't define user defined operators) with the types.

I think the trend is to avoid adding complexity into Clang, unless there is no 
other way to implement some feature correctly.


Repository:
  rC Clang

https://reviews.llvm.org/D51484



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


[PATCH] D51722: [OpenCL] Allow blocks to capture arrays in OpenCL

2018-09-06 Thread Dmitry Sidorov via Phabricator via cfe-commits
sidorovd updated this revision to Diff 164214.
sidorovd added a comment.

Reference to the Spec was added


https://reviews.llvm.org/D51722

Files:
  lib/Sema/SemaExpr.cpp
  test/SemaOpenCL/block-array-capturing.cl


Index: test/SemaOpenCL/block-array-capturing.cl
===
--- /dev/null
+++ test/SemaOpenCL/block-array-capturing.cl
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple spir64-unkown-unkown -emit-llvm 
%s -o -| FileCheck %s
+// expected-no-diagnostics
+
+typedef int (^block_t)();
+
+int block_typedef_kernel(global int* res) {
+  // CHECK: %{{.*}} = alloca <{ i32, i32, [3 x i32] }>
+  int a[3] = {1, 2, 3};
+  // CHECK: call void @llvm.memcpy{{.*}}
+  block_t b = ^() { return a[0]; };
+  return b();
+}
+
+// CHECK: define {{.*}} @__block_typedef_kernel_block_invoke
+// CHECK: %{{.*}} = getelementptr inbounds [3 x i32], [3 x i32] addrspace(4)* 
%{{.*}}, i64 0, i64 0
+// CHECK-NOT: call void @llvm.memcpy{{.*}}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14624,8 +14624,10 @@
   Expr *CopyExpr = nullptr;
   bool ByRef = false;
 
-  // Blocks are not allowed to capture arrays.
-  if (CaptureType->isArrayType()) {
+  // Blocks are not allowed to capture arrays, excepting OpenCL.
+  // OpenCL v2.0 s1.12.5 (revision 40): arrays are captured by reference
+  // (decayed to pointers).
+  if (!S.getLangOpts().OpenCL && CaptureType->isArrayType()) {
 if (BuildAndDiagnose) {
   S.Diag(Loc, diag::err_ref_array_type);
   S.Diag(Var->getLocation(), diag::note_previous_decl)


Index: test/SemaOpenCL/block-array-capturing.cl
===
--- /dev/null
+++ test/SemaOpenCL/block-array-capturing.cl
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple spir64-unkown-unkown -emit-llvm %s -o -| FileCheck %s
+// expected-no-diagnostics
+
+typedef int (^block_t)();
+
+int block_typedef_kernel(global int* res) {
+  // CHECK: %{{.*}} = alloca <{ i32, i32, [3 x i32] }>
+  int a[3] = {1, 2, 3};
+  // CHECK: call void @llvm.memcpy{{.*}}
+  block_t b = ^() { return a[0]; };
+  return b();
+}
+
+// CHECK: define {{.*}} @__block_typedef_kernel_block_invoke
+// CHECK: %{{.*}} = getelementptr inbounds [3 x i32], [3 x i32] addrspace(4)* %{{.*}}, i64 0, i64 0
+// CHECK-NOT: call void @llvm.memcpy{{.*}}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14624,8 +14624,10 @@
   Expr *CopyExpr = nullptr;
   bool ByRef = false;
 
-  // Blocks are not allowed to capture arrays.
-  if (CaptureType->isArrayType()) {
+  // Blocks are not allowed to capture arrays, excepting OpenCL.
+  // OpenCL v2.0 s1.12.5 (revision 40): arrays are captured by reference
+  // (decayed to pointers).
+  if (!S.getLangOpts().OpenCL && CaptureType->isArrayType()) {
 if (BuildAndDiagnose) {
   S.Diag(Loc, diag::err_ref_array_type);
   S.Diag(Var->getLocation(), diag::note_previous_decl)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42370: Issue local statics in correct DWARF lexical scope

2018-09-06 Thread Reid Kleckner via Phabricator via cfe-commits
rnk requested changes to this revision.
rnk added a comment.
This revision now requires changes to proceed.

Still needs a test.


https://reviews.llvm.org/D42370



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


[libcxx] r341550 - [libcxx] Add ReleaseNotes.rst file for release notes

2018-09-06 Thread Louis Dionne via cfe-commits
Author: ldionne
Date: Thu Sep  6 07:46:22 2018
New Revision: 341550

URL: http://llvm.org/viewvc/llvm-project?rev=341550&view=rev
Log:
[libcxx] Add ReleaseNotes.rst file for release notes

Added:
libcxx/trunk/docs/ReleaseNotes.rst

Added: libcxx/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/ReleaseNotes.rst?rev=341550&view=auto
==
--- libcxx/trunk/docs/ReleaseNotes.rst (added)
+++ libcxx/trunk/docs/ReleaseNotes.rst Thu Sep  6 07:46:22 2018
@@ -0,0 +1,43 @@
+
+Libc++ 8.0.0 (In-Progress) Release Notes
+
+
+.. contents::
+   :local:
+   :depth: 2
+
+Written by the `Libc++ Team `_
+
+.. warning::
+
+   These are in-progress notes for the upcoming libc++ 8 release.
+   Release notes for previous releases can be found on
+   `the Download Page `_.
+
+Introduction
+
+
+This document contains the release notes for the libc++ C++ Standard Library,
+part of the LLVM Compiler Infrastructure, release 8.0.0. Here we describe the
+status of libc++ in some detail, including major improvements from the previous
+release and new feature work. For the general LLVM release notes, see `the LLVM
+documentation `_. All LLVM releases may
+be downloaded from the `LLVM releases web site `_.
+
+For more information about libc++, please see the `Libc++ Web Site
+`_ or the `LLVM Web Site `_.
+
+Note that if you are reading this file from a Subversion checkout or the
+main Libc++ web page, this document applies to the *next* release, not
+the current one. To see the release notes for a specific release, please
+see the `releases page `_.
+
+What's New in Libc++ 8.0.0?
+===
+
+New Features
+
+
+API Changes
+---
+


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


[PATCH] D51683: Fix arm_neon.h and arm_fp16.h generation for compiling with std=c89

2018-09-06 Thread James Greenhalgh via Phabricator via cfe-commits
jgreenhalgh added inline comments.



Comment at: cfe/trunk/utils/TableGen/NeonEmitter.cpp:2412
 
-  OS << "#define __ai static inline __attribute__((__always_inline__, "
+  OS << "#define __ai static __inline __attribute__((__always_inline__, "
 "__nodebug__))\n\n";

dnsampaio wrote:
> joerg wrote:
> > If you want to change it, at least change it properly to use __inline__.
> Sorry, I don't get the suggestion. Do you mean test if it is C89 and use 
> __inline, else, use inline?
I think the suggestion was unintentionally rendered as an underline by phab; 
and was supposed to be 
```
__inline__
```


https://reviews.llvm.org/D51683



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


[libcxx] r341551 - [libc++] Add a link to the Release notes from the main libc++ documentation

2018-09-06 Thread Louis Dionne via cfe-commits
Author: ldionne
Date: Thu Sep  6 08:05:43 2018
New Revision: 341551

URL: http://llvm.org/viewvc/llvm-project?rev=341551&view=rev
Log:
[libc++] Add a link to the Release notes from the main libc++ documentation

Modified:
libcxx/trunk/docs/index.rst

Modified: libcxx/trunk/docs/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/index.rst?rev=341551&r1=341550&r2=341551&view=diff
==
--- libcxx/trunk/docs/index.rst (original)
+++ libcxx/trunk/docs/index.rst Thu Sep  6 08:05:43 2018
@@ -34,6 +34,7 @@ Getting Started with libc++
 .. toctree::
:maxdepth: 2
 
+   ReleaseNotes
UsingLibcxx
BuildingLibcxx
TestingLibcxx


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


[PATCH] D50488: [Analyzer] Checker for non-determinism caused by sorting of pointer-like elements

2018-09-06 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

In https://reviews.llvm.org/D50488#1225064, @george.karpenkov wrote:

> Why explicitly skip C  projects? We would not be able to match `std::X` 
> functions anyway.


Why spend time constructing matchers and running on the AST when we are sure 
that generating any result is impossible? Skipping the entire useless traversal 
of the tree can end up saving precious execution time that should not be 
overlooked.


https://reviews.llvm.org/D50488



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


[clang-tools-extra] r341552 - [clangd] Fix Dex initialization

2018-09-06 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Thu Sep  6 08:10:10 2018
New Revision: 341552

URL: http://llvm.org/viewvc/llvm-project?rev=341552&view=rev
Log:
[clangd] Fix Dex initialization

This patch sets URI schemes of Dex to SymbolCollector's default schemes
in case callers tried to pass empty list of schemes. This was the case
for initialization in Clangd main and was a reason of incorrect
behavior.

Also, it fixes a bug with missed `continue;` after spotting invalid URI
scheme conversion.

Modified:
clang-tools-extra/trunk/clangd/index/dex/DexIndex.cpp
clang-tools-extra/trunk/clangd/index/dex/DexIndex.h

Modified: clang-tools-extra/trunk/clangd/index/dex/DexIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/dex/DexIndex.cpp?rev=341552&r1=341551&r2=341552&view=diff
==
--- clang-tools-extra/trunk/clangd/index/dex/DexIndex.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/dex/DexIndex.cpp Thu Sep  6 08:10:10 
2018
@@ -59,6 +59,7 @@ std::vector> c
"scheme. fuzzyFind request will ignore it.",
Path);
   llvm::consumeError(PathURI.takeError());
+  continue;
 }
 const auto PathProximityURIs = generateProximityURIs(PathURI->toString());
 for (const auto &ProximityURI : PathProximityURIs)

Modified: clang-tools-extra/trunk/clangd/index/dex/DexIndex.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/dex/DexIndex.h?rev=341552&r1=341551&r2=341552&view=diff
==
--- clang-tools-extra/trunk/clangd/index/dex/DexIndex.h (original)
+++ clang-tools-extra/trunk/clangd/index/dex/DexIndex.h Thu Sep  6 08:10:10 2018
@@ -22,6 +22,7 @@
 
 #include "../Index.h"
 #include "../MemIndex.h"
+#include "../SymbolCollector.h"
 #include "Iterator.h"
 #include "Token.h"
 #include "Trigram.h"
@@ -40,8 +41,14 @@ class DexIndex : public SymbolIndex {
 public:
   // All symbols must outlive this index.
   template 
-  DexIndex(Range &&Symbols, llvm::ArrayRef URISchemes)
-  : URISchemes(URISchemes) {
+  DexIndex(Range &&Symbols, llvm::ArrayRef Schemes)
+  : URISchemes(Schemes) {
+// If Schemes don't contain any items, fall back to SymbolCollector's
+// default URI schemes.
+if (URISchemes.empty()) {
+  SymbolCollector::Options Opts;
+  URISchemes = Opts.URISchemes;
+}
 for (auto &&Sym : Symbols)
   this->Symbols.push_back(&Sym);
 buildIndex();
@@ -90,7 +97,7 @@ private:
   llvm::DenseMap InvertedIndex;
   std::shared_ptr KeepAlive; // poor man's move-only std::any
 
-  const std::vector URISchemes;
+  std::vector URISchemes;
 };
 
 /// Returns Search Token for a number of parent directories of given Path.


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


r341553 - [OpenCL] Relax diagnostics on OpenCL access qualifiers

2018-09-06 Thread Andrew Savonichev via cfe-commits
Author: asavonic
Date: Thu Sep  6 08:10:26 2018
New Revision: 341553

URL: http://llvm.org/viewvc/llvm-project?rev=341553&view=rev
Log:
[OpenCL] Relax diagnostics on OpenCL access qualifiers

Summary:
Emit warning for multiple access qualifiers if they do not conflict.

Patch by Alexey Bader

Reviewers: Anastasia, yaxunl

Reviewed By: Anastasia

Subscribers: asavonic, bader, cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaOpenCL/access-qualifier.cl

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=341553&r1=341552&r2=341553&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Sep  6 08:10:26 2018
@@ -5900,10 +5900,16 @@ static void handleOpenCLAccessAttr(Sema
 
   // Check if there is only one access qualifier.
   if (D->hasAttr()) {
-S.Diag(AL.getLoc(), diag::err_opencl_multiple_access_qualifiers)
-<< D->getSourceRange();
-D->setInvalidDecl(true);
-return;
+if (D->getAttr()->getSemanticSpelling() ==
+AL.getSemanticSpelling()) {
+  S.Diag(AL.getLoc(), diag::warn_duplicate_declspec)
+  << AL.getName()->getName() << AL.getRange();
+} else {
+  S.Diag(AL.getLoc(), diag::err_opencl_multiple_access_qualifiers)
+  << D->getSourceRange();
+  D->setInvalidDecl(true);
+  return;
+}
   }
 
   // OpenCL v2.0 s6.6 - read_write can be used for image types to specify that 
an

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=341553&r1=341552&r2=341553&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Thu Sep  6 08:10:26 2018
@@ -7105,23 +7105,43 @@ static void HandleOpenCLAccessAttr(QualT
   }
 
   if (const TypedefType* TypedefTy = CurType->getAs()) {
-QualType PointeeTy = TypedefTy->desugar();
-S.Diag(Attr.getLoc(), diag::err_opencl_multiple_access_qualifiers);
+QualType BaseTy = TypedefTy->desugar();
 
 std::string PrevAccessQual;
-switch (cast(PointeeTy.getTypePtr())->getKind()) {
-  #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
-case BuiltinType::Id:  \
-  PrevAccessQual = #Access;\
-  break;
-  #include "clang/Basic/OpenCLImageTypes.def"
-default:
-  assert(0 && "Unable to find corresponding image type.");
+if (BaseTy->isPipeType()) {
+  if (TypedefTy->getDecl()->hasAttr()) {
+OpenCLAccessAttr *Attr =
+TypedefTy->getDecl()->getAttr();
+PrevAccessQual = Attr->getSpelling();
+  } else {
+PrevAccessQual = "read_only";
+  }
+} else if (const BuiltinType* ImgType = BaseTy->getAs()) {
+
+  switch (ImgType->getKind()) {
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
+  case BuiltinType::Id:  \
+PrevAccessQual = #Access;\
+break;
+#include "clang/Basic/OpenCLImageTypes.def"
+  default:
+llvm_unreachable("Unable to find corresponding image type.");
+  }
+} else {
+  llvm_unreachable("unexpected type");
+}
+StringRef AttrName = Attr.getName()->getName();
+if (PrevAccessQual == AttrName.ltrim("_")) {
+  // Duplicated qualifiers
+  S.Diag(Attr.getLoc(), diag::warn_duplicate_declspec)
+ << AttrName << Attr.getRange();
+} else {
+  // Contradicting qualifiers
+  S.Diag(Attr.getLoc(), diag::err_opencl_multiple_access_qualifiers);
 }
 
 S.Diag(TypedefTy->getDecl()->getBeginLoc(),
-   diag::note_opencl_typedef_access_qualifier)
-<< PrevAccessQual;
+   diag::note_opencl_typedef_access_qualifier) << PrevAccessQual;
   } else if (CurType->isPipeType()) {
 if (Attr.getSemanticSpelling() == OpenCLAccessAttr::Keyword_write_only) {
   QualType ElemType = CurType->getAs()->getElementType();

Modified: cfe/trunk/test/SemaOpenCL/access-qualifier.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/access-qualifier.cl?rev=341553&r1=341552&r2=341553&view=diff
==
--- cfe/trunk/test/SemaOpenCL/access-qualifier.cl (original)
+++ cfe/trunk/test/SemaOpenCL/access-qualifier.cl Thu Sep  6 08:10:26 2018
@@ -60,7 +60,7 @@ kernel void k10(read_only Int img){} //
 
 kernel void k11(read_only write_only image1d_t i){} // 
expected-error{{multiple access qualifiers}}
 
-kernel void k12(read_only read_only image1d_t i){} // expected-error{{multi

[PATCH] D51302: [OpenCL] Relax diagnostics on OpenCL access qualifiers

2018-09-06 Thread Andrew Savonichev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC341553: [OpenCL] Relax diagnostics on OpenCL access 
qualifiers (authored by asavonic, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D51302

Files:
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaType.cpp
  test/SemaOpenCL/access-qualifier.cl

Index: test/SemaOpenCL/access-qualifier.cl
===
--- test/SemaOpenCL/access-qualifier.cl
+++ test/SemaOpenCL/access-qualifier.cl
@@ -60,7 +60,7 @@
 
 kernel void k11(read_only write_only image1d_t i){} // expected-error{{multiple access qualifiers}}
 
-kernel void k12(read_only read_only image1d_t i){} // expected-error{{multiple access qualifiers}}
+kernel void k12(read_only read_only image1d_t i){} // expected-warning {{duplicate 'read_only' declaration specifier}}
 
 #if __OPENCL_C_VERSION__ >= 200
 kernel void k13(read_write pipe int i){} // expected-error{{access qualifier 'read_write' can not be used for 'read_only pipe int'}}
@@ -78,3 +78,33 @@
 #if __OPENCL_C_VERSION__ < 200
 kernel void test_image3d_wo(write_only image3d_t img) {} // expected-error {{use of type '__write_only image3d_t' requires cl_khr_3d_image_writes extension to be enabled}}
 #endif
+
+#if __OPENCL_C_VERSION__ >= 200
+kernel void read_write_twice_typedef(read_write img1d_rw i){} // expected-warning {{duplicate 'read_write' declaration specifier}}
+// expected-note@-74 {{previously declared 'read_write' here}}
+
+kernel void pipe_ro_twice(read_only read_only pipe int i){} // expected-warning{{duplicate 'read_only' declaration specifier}}
+// Conflicting access qualifiers
+kernel void pipe_ro_twice_tw(read_write read_only read_only pipe int i){} // expected-error{{access qualifier 'read_write' can not be used for 'read_only pipe int'}}
+kernel void pipe_ro_wo(read_only write_only pipe int i){} // expected-error{{multiple access qualifiers}}
+
+typedef read_only pipe int ROPipeInt;
+kernel void pipe_ro_twice_typedef(read_only ROPipeInt i){} // expected-warning{{duplicate 'read_only' declaration specifier}}
+// expected-note@-2 {{previously declared 'read_only' here}}
+
+kernel void pass_ro_typedef_to_wo(ROPipeInt p) {
+  myPipeWrite(p); // expected-error {{passing 'ROPipeInt' (aka 'read_only pipe int') to parameter of incompatible type 'write_only pipe int'}}
+  // expected-note@-25 {{passing argument to parameter here}}
+}
+#endif
+
+kernel void read_only_twice_typedef(__read_only img1d_ro i){} // expected-warning {{duplicate '__read_only' declaration specifier}}
+// expected-note@-95 {{previously declared 'read_only' here}}
+
+kernel void read_only_twice_default(read_only img1d_ro_default img){} // expected-warning {{duplicate 'read_only' declaration specifier}}
+// expected-note@-101 {{previously declared 'read_only' here}}
+
+kernel void image_wo_twice(write_only __write_only image1d_t i){} // expected-warning {{duplicate '__write_only' declaration specifier}}
+kernel void image_wo_twice_typedef(write_only img1d_wo i){} // expected-warning {{duplicate 'write_only' declaration specifier}}
+// expected-note@-103 {{previously declared 'write_only' here}}
+
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7105,23 +7105,43 @@
   }
 
   if (const TypedefType* TypedefTy = CurType->getAs()) {
-QualType PointeeTy = TypedefTy->desugar();
-S.Diag(Attr.getLoc(), diag::err_opencl_multiple_access_qualifiers);
+QualType BaseTy = TypedefTy->desugar();
 
 std::string PrevAccessQual;
-switch (cast(PointeeTy.getTypePtr())->getKind()) {
-  #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
-case BuiltinType::Id:  \
-  PrevAccessQual = #Access;\
-  break;
-  #include "clang/Basic/OpenCLImageTypes.def"
-default:
-  assert(0 && "Unable to find corresponding image type.");
+if (BaseTy->isPipeType()) {
+  if (TypedefTy->getDecl()->hasAttr()) {
+OpenCLAccessAttr *Attr =
+TypedefTy->getDecl()->getAttr();
+PrevAccessQual = Attr->getSpelling();
+  } else {
+PrevAccessQual = "read_only";
+  }
+} else if (const BuiltinType* ImgType = BaseTy->getAs()) {
+
+  switch (ImgType->getKind()) {
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
+  case BuiltinType::Id:  \
+PrevAccessQual = #Access;\
+break;
+#include "clang/Basic/OpenCLImageTypes.def"
+  default:
+llvm_unreachable("Unable to find corresponding image type.");
+  }
+} else {
+  llvm_unreachable("unexpected type");
+}
+StringRef AttrName = Attr.getName()->getName();
+if (PrevAccessQual == AttrName.ltrim("_")) {
+  // Duplicated qualifiers
+

[PATCH] D51302: [OpenCL] Relax diagnostics on OpenCL access qualifiers

2018-09-06 Thread Andrew Savonichev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341553: [OpenCL] Relax diagnostics on OpenCL access 
qualifiers (authored by asavonic, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51302?vs=163086&id=164222#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51302

Files:
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/SemaOpenCL/access-qualifier.cl

Index: cfe/trunk/test/SemaOpenCL/access-qualifier.cl
===
--- cfe/trunk/test/SemaOpenCL/access-qualifier.cl
+++ cfe/trunk/test/SemaOpenCL/access-qualifier.cl
@@ -60,7 +60,7 @@
 
 kernel void k11(read_only write_only image1d_t i){} // expected-error{{multiple access qualifiers}}
 
-kernel void k12(read_only read_only image1d_t i){} // expected-error{{multiple access qualifiers}}
+kernel void k12(read_only read_only image1d_t i){} // expected-warning {{duplicate 'read_only' declaration specifier}}
 
 #if __OPENCL_C_VERSION__ >= 200
 kernel void k13(read_write pipe int i){} // expected-error{{access qualifier 'read_write' can not be used for 'read_only pipe int'}}
@@ -78,3 +78,33 @@
 #if __OPENCL_C_VERSION__ < 200
 kernel void test_image3d_wo(write_only image3d_t img) {} // expected-error {{use of type '__write_only image3d_t' requires cl_khr_3d_image_writes extension to be enabled}}
 #endif
+
+#if __OPENCL_C_VERSION__ >= 200
+kernel void read_write_twice_typedef(read_write img1d_rw i){} // expected-warning {{duplicate 'read_write' declaration specifier}}
+// expected-note@-74 {{previously declared 'read_write' here}}
+
+kernel void pipe_ro_twice(read_only read_only pipe int i){} // expected-warning{{duplicate 'read_only' declaration specifier}}
+// Conflicting access qualifiers
+kernel void pipe_ro_twice_tw(read_write read_only read_only pipe int i){} // expected-error{{access qualifier 'read_write' can not be used for 'read_only pipe int'}}
+kernel void pipe_ro_wo(read_only write_only pipe int i){} // expected-error{{multiple access qualifiers}}
+
+typedef read_only pipe int ROPipeInt;
+kernel void pipe_ro_twice_typedef(read_only ROPipeInt i){} // expected-warning{{duplicate 'read_only' declaration specifier}}
+// expected-note@-2 {{previously declared 'read_only' here}}
+
+kernel void pass_ro_typedef_to_wo(ROPipeInt p) {
+  myPipeWrite(p); // expected-error {{passing 'ROPipeInt' (aka 'read_only pipe int') to parameter of incompatible type 'write_only pipe int'}}
+  // expected-note@-25 {{passing argument to parameter here}}
+}
+#endif
+
+kernel void read_only_twice_typedef(__read_only img1d_ro i){} // expected-warning {{duplicate '__read_only' declaration specifier}}
+// expected-note@-95 {{previously declared 'read_only' here}}
+
+kernel void read_only_twice_default(read_only img1d_ro_default img){} // expected-warning {{duplicate 'read_only' declaration specifier}}
+// expected-note@-101 {{previously declared 'read_only' here}}
+
+kernel void image_wo_twice(write_only __write_only image1d_t i){} // expected-warning {{duplicate '__write_only' declaration specifier}}
+kernel void image_wo_twice_typedef(write_only img1d_wo i){} // expected-warning {{duplicate 'write_only' declaration specifier}}
+// expected-note@-103 {{previously declared 'write_only' here}}
+
Index: cfe/trunk/lib/Sema/SemaType.cpp
===
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -7105,23 +7105,43 @@
   }
 
   if (const TypedefType* TypedefTy = CurType->getAs()) {
-QualType PointeeTy = TypedefTy->desugar();
-S.Diag(Attr.getLoc(), diag::err_opencl_multiple_access_qualifiers);
+QualType BaseTy = TypedefTy->desugar();
 
 std::string PrevAccessQual;
-switch (cast(PointeeTy.getTypePtr())->getKind()) {
-  #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
-case BuiltinType::Id:  \
-  PrevAccessQual = #Access;\
-  break;
-  #include "clang/Basic/OpenCLImageTypes.def"
-default:
-  assert(0 && "Unable to find corresponding image type.");
+if (BaseTy->isPipeType()) {
+  if (TypedefTy->getDecl()->hasAttr()) {
+OpenCLAccessAttr *Attr =
+TypedefTy->getDecl()->getAttr();
+PrevAccessQual = Attr->getSpelling();
+  } else {
+PrevAccessQual = "read_only";
+  }
+} else if (const BuiltinType* ImgType = BaseTy->getAs()) {
+
+  switch (ImgType->getKind()) {
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
+  case BuiltinType::Id:  \
+PrevAccessQual = #Access;\
+break;
+#include "clang/Basic/OpenCLImageTypes.def"
+  default:
+llvm_unreachable("Unable to find corresponding image type.

r341556 - Remove unnecessary semicolon to silence -Wpedantic warning. NFCI.

2018-09-06 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Sep  6 08:16:17 2018
New Revision: 341556

URL: http://llvm.org/viewvc/llvm-project?rev=341556&view=rev
Log:
Remove unnecessary semicolon to silence -Wpedantic warning. NFCI.

Modified:
cfe/trunk/lib/Sema/SemaExceptionSpec.cpp

Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExceptionSpec.cpp?rev=341556&r1=341555&r2=341556&view=diff
==
--- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExceptionSpec.cpp Thu Sep  6 08:16:17 2018
@@ -238,7 +238,7 @@ static bool exceptionSpecNotKnownYet(con
   auto EST = 
MD->getType()->castAs()->getExceptionSpecType();
   return EST == EST_Unparsed ||
  (EST == EST_Unevaluated && MD->getParent()->isBeingDefined());
-};
+}
 
 static bool CheckEquivalentExceptionSpecImpl(
 Sema &S, const PartialDiagnostic &DiagID, const PartialDiagnostic &NoteID,


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


[PATCH] D51714: CMake: Deprecate using llvm-config to detect llvm installation

2018-09-06 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

In https://reviews.llvm.org/D51714#1225545, @mgorny wrote:

> Is LLVM_CONFIG dropped from cache here? I suspect the warning might fire for 
> everyone who has LLVM configured.


Yes, it is dropped from the cache, is it a problem to having the warning fire 
for people who have already configured LLVM?


Repository:
  rC Clang

https://reviews.llvm.org/D51714



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


r341560 - Reverting r 341390 because it is causing test failures on GreenDragon.

2018-09-06 Thread A Bergen via cfe-commits
Author: sudofortune
Date: Thu Sep  6 09:29:40 2018
New Revision: 341560

URL: http://llvm.org/viewvc/llvm-project?rev=341560&view=rev
Log:
Reverting r 341390 because it is causing test failures on GreenDragon.

http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental/52810/


Modified:
cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
cfe/trunk/test/Driver/msvc-link.c

Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.cpp?rev=341560&r1=341559&r2=341560&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp Thu Sep  6 09:29:40 2018
@@ -355,15 +355,6 @@ void visualstudio::Linker::ConstructJob(
   options::OPT__SLASH_Zd))
 CmdArgs.push_back("-debug");
 
-  // Pass on /Brepro if it was passed to the compiler.
-  // Note that /Brepro maps to -mno-incremental-linker-compatible.
-  bool DefaultIncrementalLinkerCompatible =
-  C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment();
-  if (!Args.hasFlag(options::OPT_mincremental_linker_compatible,
-options::OPT_mno_incremental_linker_compatible,
-DefaultIncrementalLinkerCompatible))
-CmdArgs.push_back("-Brepro");
-
   bool DLL = Args.hasArg(options::OPT__SLASH_LD, options::OPT__SLASH_LDd,
  options::OPT_shared);
   if (DLL) {

Modified: cfe/trunk/test/Driver/msvc-link.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/msvc-link.c?rev=341560&r1=341559&r2=341560&view=diff
==
--- cfe/trunk/test/Driver/msvc-link.c (original)
+++ cfe/trunk/test/Driver/msvc-link.c Thu Sep  6 09:29:40 2018
@@ -3,7 +3,6 @@
 // BASIC: "-out:a.exe"
 // BASIC: "-defaultlib:libcmt"
 // BASIC: "-nologo"
-// BASIC-NOT: "-Brepro"
 
 // RUN: %clang -target i686-pc-windows-msvc -shared -o a.dll -### %s 2>&1 | 
FileCheck --check-prefix=DLL %s
 // DLL: link.exe"
@@ -17,14 +16,3 @@
 // LIBPATH: "-libpath:/usr/lib"
 // LIBPATH: "-nologo"
 
-// RUN: %clang_cl /Brepro -### %s 2>&1 | FileCheck --check-prefix=REPRO %s
-// REPRO: link.exe"
-// REPRO: "-out:msvc-link.exe"
-// REPRO: "-nologo"
-// REPRO: "-Brepro"
-
-// RUN: %clang_cl /Brepro- -### %s 2>&1 | FileCheck --check-prefix=NOREPRO %s
-// NOREPRO: link.exe"
-// NOREPRO: "-out:msvc-link.exe"
-// NOREPRO: "-nologo"
-// NOREPRO-NOT: "-Brepro"


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


[PATCH] D51724: [clangd] Add "Deprecated" field to Symbol and CodeCompletion.

2018-09-06 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clangd/index/Index.h:171
+  /// See also isIndexedForCodeCompletion().
+  IsIndexedForCodeCompletion = 1 << 0,
+  /// Indicates if the symbol is deprecated.

nit: rename to IndexedForCodeCompletion, since it is more of an attribute 
having is in the name doesn't seem so cool. Instead of the attributes 
themselves maybe the checkers below should have "is" prefix.



Comment at: clangd/index/Index.h:172
+  IsIndexedForCodeCompletion = 1 << 0,
+  /// Indicates if the symbol is deprecated.
+  Deprecated = 1 << 1,

nit: Add a comment similar to above one leading to Deprecated()?



Comment at: clangd/index/Index.h:268
+  /// FIXME: also add deprecation message and fixit?
+  bool Deprecated() const {
+return static_cast(Flags & SymbolFlag::Deprecated);

nit: rename to isDeprecated ?



Comment at: unittests/clangd/CodeCompleteTests.cpp:1359
   C.Origin = SymbolOrigin::AST | SymbolOrigin::Static;
+  C.Deprecated = true;
 

Maybe do this on its own render so that we can have both code paths covered. 
Just before rendering with `Opts.EnableSnippets = true` below. We can simply 
set this one render again and check deprecated is set to true.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51724



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


[PATCH] D51697: [Sema] Clean up some __builtin_*_chk diagnostics

2018-09-06 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


Repository:
  rC Clang

https://reviews.llvm.org/D51697



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


[PATCH] D51724: [clangd] Add "Deprecated" field to Symbol and CodeCompletion.

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

Agree with Kadir's comments.
I'd just suggest reducing boilerplate a bit by taking some shortcuts.




Comment at: clangd/index/Index.h:167
 
+enum class SymbolFlag : uint8_t {
+  None = 0,

enum class is a pain for bitfields.
I'd just make this a plain enum nested inside symbol, then you don't need to 
define the operators and don't need to cast as often.



Comment at: clangd/index/Index.h:268
+  /// FIXME: also add deprecation message and fixit?
+  bool Deprecated() const {
+return static_cast(Flags & SymbolFlag::Deprecated);

kadircet wrote:
> nit: rename to isDeprecated ?
FWIW I don't think these accessors pull their weight: in calller code `if 
(Sym.Flags & Symbol::IsDeprecated)` is clear enough



Comment at: clangd/index/Serialization.cpp:309
 // data. Later we may want to support some backward compatibility.
 constexpr static uint32_t Version = 2;
 

3


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51724



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


[PATCH] D51510: Move AESNI generation to Skylake and Goldmont

2018-09-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Do you have commit access, or do you need someone to commit this for you?


Repository:
  rC Clang

https://reviews.llvm.org/D51510



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


[PATCH] D51714: CMake: Deprecate using llvm-config to detect llvm installation

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

I don't have a strong opinion here.


Repository:
  rC Clang

https://reviews.llvm.org/D51714



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


r341564 - Re-commit "Enable DWARF accelerator tables by default when tuning for lldb (-glldb => -gpubnames)""

2018-09-06 Thread Pavel Labath via cfe-commits
Author: labath
Date: Thu Sep  6 10:01:45 2018
New Revision: 341564

URL: http://llvm.org/viewvc/llvm-project?rev=341564&view=rev
Log:
Re-commit "Enable DWARF accelerator tables by default when tuning for lldb 
(-glldb => -gpubnames)""

This recommits r341472, which was reverted due to test failures on macos bots.

The issue was that a macos target implies -glldb which, together with
this patch added a -gpubnames switch where there previously wasn't one.
The intentions of those checks was to check that -gpubnames is not
emitted by default so I add an explicit -ggdb arg to those command lines
to get same behavior on all platforms (the fact that -glldb *does* set
-gpubnames is tested by a separate test).

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/debug-options.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=341564&r1=341563&r2=341564&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Sep  6 10:01:45 2018
@@ -3072,7 +3072,7 @@ static void RenderDebugOptions(const Too
   const auto *PubnamesArg =
   Args.getLastArg(options::OPT_ggnu_pubnames, 
options::OPT_gno_gnu_pubnames,
   options::OPT_gpubnames, options::OPT_gno_pubnames);
-  if (SplitDWARFArg ||
+  if (SplitDWARFArg || DebuggerTuning == llvm::DebuggerKind::LLDB ||
   (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC)))
 if (!PubnamesArg ||
 (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) &&

Modified: cfe/trunk/test/Driver/debug-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=341564&r1=341563&r2=341564&view=diff
==
--- cfe/trunk/test/Driver/debug-options.c (original)
+++ cfe/trunk/test/Driver/debug-options.c Thu Sep  6 10:01:45 2018
@@ -153,18 +153,21 @@
 // RUN:| FileCheck -check-prefix=GIGNORE %s
 //
 // RUN: %clang -### -c -ggnu-pubnames %s 2>&1 | FileCheck -check-prefix=GPUB %s
-// RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix=NOPUB %s
+// RUN: %clang -### -c -ggdb %s 2>&1 | FileCheck -check-prefix=NOPUB %s
 // RUN: %clang -### -c -ggnu-pubnames -gno-gnu-pubnames %s 2>&1 | FileCheck 
-check-prefix=NOPUB %s
 // RUN: %clang -### -c -ggnu-pubnames -gno-pubnames %s 2>&1 | FileCheck 
-check-prefix=NOPUB %s
 //
 // RUN: %clang -### -c -gpubnames %s 2>&1 | FileCheck -check-prefix=PUB %s
-// RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix=NOPUB %s
+// RUN: %clang -### -c -ggdb %s 2>&1 | FileCheck -check-prefix=NOPUB %s
 // RUN: %clang -### -c -gpubnames -gno-gnu-pubnames %s 2>&1 | FileCheck 
-check-prefix=NOPUB %s
 // RUN: %clang -### -c -gpubnames -gno-pubnames %s 2>&1 | FileCheck 
-check-prefix=NOPUB %s
 //
 // RUN: %clang -### -c -gsplit-dwarf %s 2>&1 | FileCheck -check-prefix=GPUB %s
 // RUN: %clang -### -c -gsplit-dwarf -gno-pubnames %s 2>&1 | FileCheck 
-check-prefix=NOPUB %s
 //
+// RUN: %clang -### -c -glldb %s 2>&1 | FileCheck -check-prefix=GPUB %s
+// RUN: %clang -### -c -glldb -gno-pubnames %s 2>&1 | FileCheck 
-check-prefix=NOPUB %s
+//
 // RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck 
-check-prefix=GARANGE %s
 //
 // RUN: %clang -### -fdebug-types-section -target x86_64-unknown-linux %s 2>&1 
\


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


[PATCH] D51084: Implement -Watomic-implicit-seq-cst

2018-09-06 Thread JF Bastien via Phabricator via cfe-commits
jfb updated this revision to Diff 164235.
jfb marked 4 inline comments as done.
jfb added a comment.

- Address comments.


Repository:
  rC Clang

https://reviews.llvm.org/D51084

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/Sema/atomic-implicit-seq_cst.c
  test/Sema/sync-implicit-seq_cst.c

Index: test/Sema/sync-implicit-seq_cst.c
===
--- /dev/null
+++ test/Sema/sync-implicit-seq_cst.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -verify -ffreestanding -fsyntax-only -triple=i686-linux-gnu -std=c11 -Watomic-implicit-seq-cst -Wno-sync-fetch-and-nand-semantics-changed
+
+// __sync_* operations are implicitly sequentially-consistent. Some codebases
+// want to force explicit usage of memory order instead.
+
+void fetch_and_add(int *ptr, int val) { __sync_fetch_and_add(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void fetch_and_sub(int *ptr, int val) { __sync_fetch_and_sub(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void fetch_and_or(int *ptr, int val) { __sync_fetch_and_or(ptr, val); } // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void fetch_and_and(int *ptr, int val) { __sync_fetch_and_and(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void fetch_and_xor(int *ptr, int val) { __sync_fetch_and_xor(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void fetch_and_nand(int *ptr, int val) { __sync_fetch_and_nand(ptr, val); } // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+
+void add_and_fetch(int *ptr, int val) { __sync_add_and_fetch(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void sub_and_fetch(int *ptr, int val) { __sync_sub_and_fetch(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void or_and_fetch(int *ptr, int val) { __sync_or_and_fetch(ptr, val); } // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void and_and_fetch(int *ptr, int val) { __sync_and_and_fetch(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void xor_and_fetch(int *ptr, int val) { __sync_xor_and_fetch(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void nand_and_fetch(int *ptr, int val) { __sync_nand_and_fetch(ptr, val); } // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+
+void bool_compare_and_swap(int *ptr, int oldval, int newval) { __sync_bool_compare_and_swap(ptr, oldval, newval); } // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void val_compare_and_swap(int *ptr, int oldval, int newval) { __sync_val_compare_and_swap(ptr, oldval, newval); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+
+void synchronize(void) { __sync_synchronize(); } // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+
+void lock_test_and_set(int *ptr, int val) { __sync_lock_test_and_set(ptr, val); } // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void lock_release(int *ptr) { __sync_lock_release(ptr); } // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
Index: test/Sema/atomic-implicit-seq_cst.c
===
--- /dev/null
+++ test/Sema/atomic-implicit-seq_cst.c
@@ -0,0 +1,325 @@
+// RUN: %clang_cc1 %s -verify -ffreestanding -fsyntax-only -triple=i686-linux-gnu -std=c11 -Watomic-implicit-seq-cst
+
+// _Atomic operations are implicitly sequentially-consistent. Some codebases
+// want to force explicit usage of memory order instead.
+
+_Atomic(int) atom;
+void gimme_int(int);
+
+void bad_pre_inc(void) {
+  ++atom; // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+}
+
+void bad_pre_dec(void) {
+  --atom; // expected-warning {{implicit use of sequentially-consiste

[PATCH] D51084: Implement -Watomic-implicit-seq-cst

2018-09-06 Thread JF Bastien via Phabricator via cfe-commits
jfb added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:10974
+  if (E->IgnoreParenImpCasts()->getType()->isAtomicType())
+return;
   CheckImplicitConversion(S, E->IgnoreParenImpCasts(), S.Context.BoolTy, CC);

rjmccall wrote:
> Can you explain this one?
It would produce duplicate warnings of `!`, `&&`, `||`, and condition for `? 
:`. Bool-like conversion is a special case of implicit conversion, which we 
already check elsewhere.


Repository:
  rC Clang

https://reviews.llvm.org/D51084



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


[PATCH] D51697: [Sema] Clean up some __builtin_*_chk diagnostics

2018-09-06 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341566: [Sema] Clean up some __builtin_*_chk diagnostics 
(authored by epilk, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51697?vs=164087&id=164237#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51697

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/Sema/builtin-object-size.c
  cfe/trunk/test/Sema/builtins.c

Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -238,7 +238,8 @@
 
 static void SemaBuiltinMemChkCall(Sema &S, FunctionDecl *FDecl,
   CallExpr *TheCall, unsigned SizeIdx,
-  unsigned DstSizeIdx) {
+  unsigned DstSizeIdx,
+  StringRef LikelyMacroName) {
   if (TheCall->getNumArgs() <= SizeIdx ||
   TheCall->getNumArgs() <= DstSizeIdx)
 return;
@@ -256,12 +257,21 @@
   if (Size.ule(DstSize))
 return;
 
-  // confirmed overflow so generate the diagnostic.
-  IdentifierInfo *FnName = FDecl->getIdentifier();
+  // Confirmed overflow, so generate the diagnostic.
+  StringRef FunctionName = FDecl->getName();
   SourceLocation SL = TheCall->getBeginLoc();
-  SourceRange SR = TheCall->getSourceRange();
+  SourceManager &SM = S.getSourceManager();
+  // If we're in an expansion of a macro whose name corresponds to this builtin,
+  // use the simple macro name and location.
+  if (SL.isMacroID() && Lexer::getImmediateMacroName(SL, SM, S.getLangOpts()) ==
+LikelyMacroName) {
+FunctionName = LikelyMacroName;
+SL = SM.getImmediateMacroCallerLoc(SL);
+  }
 
-  S.Diag(SL, diag::warn_memcpy_chk_overflow) << SR << FnName;
+  S.Diag(SL, diag::warn_memcpy_chk_overflow)
+  << FunctionName << DstSize.toString(/*Radix=*/10)
+  << Size.toString(/*Radix=*/10);
 }
 
 static bool SemaBuiltinCallWithStaticChain(Sema &S, CallExpr *BuiltinCall) {
@@ -1219,21 +1229,37 @@
   // check secure string manipulation functions where overflows
   // are detectable at compile time
   case Builtin::BI__builtin___memcpy_chk:
+SemaBuiltinMemChkCall(*this, FDecl, TheCall, 2, 3, "memcpy");
+break;
   case Builtin::BI__builtin___memmove_chk:
+SemaBuiltinMemChkCall(*this, FDecl, TheCall, 2, 3, "memmove");
+break;
   case Builtin::BI__builtin___memset_chk:
+SemaBuiltinMemChkCall(*this, FDecl, TheCall, 2, 3, "memset");
+break;
   case Builtin::BI__builtin___strlcat_chk:
+SemaBuiltinMemChkCall(*this, FDecl, TheCall, 2, 3, "strlcat");
+break;
   case Builtin::BI__builtin___strlcpy_chk:
+SemaBuiltinMemChkCall(*this, FDecl, TheCall, 2, 3, "strlcpy");
+break;
   case Builtin::BI__builtin___strncat_chk:
+SemaBuiltinMemChkCall(*this, FDecl, TheCall, 2, 3, "strncat");
+break;
   case Builtin::BI__builtin___strncpy_chk:
+SemaBuiltinMemChkCall(*this, FDecl, TheCall, 2, 3, "strncpy");
+break;
   case Builtin::BI__builtin___stpncpy_chk:
-SemaBuiltinMemChkCall(*this, FDecl, TheCall, 2, 3);
+SemaBuiltinMemChkCall(*this, FDecl, TheCall, 2, 3, "stpncpy");
 break;
   case Builtin::BI__builtin___memccpy_chk:
-SemaBuiltinMemChkCall(*this, FDecl, TheCall, 3, 4);
+SemaBuiltinMemChkCall(*this, FDecl, TheCall, 3, 4, "memccpy");
 break;
   case Builtin::BI__builtin___snprintf_chk:
+SemaBuiltinMemChkCall(*this, FDecl, TheCall, 1, 3, "snprintf");
+break;
   case Builtin::BI__builtin___vsnprintf_chk:
-SemaBuiltinMemChkCall(*this, FDecl, TheCall, 1, 3);
+SemaBuiltinMemChkCall(*this, FDecl, TheCall, 1, 3, "vsnprintf");
 break;
   case Builtin::BI__builtin_call_with_static_chain:
 if (SemaBuiltinCallWithStaticChain(*this, TheCall))
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -694,7 +694,8 @@
   InGroup>;
 
 def warn_memcpy_chk_overflow : Warning<
-  "%0 will always overflow destination buffer">,
+  "'%0' will always overflow; destination buffer has size %1,"
+  " but size argument is %2">,
   InGroup>;
 
 /// main()
Index: cfe/trunk/test/Sema/builtins.c
===
--- cfe/trunk/test/Sema/builtins.c
+++ cfe/trunk/test/Sema/builtins.c
@@ -221,30 +221,30 @@
 // expected-note {{change size argument to be the size of the destination}}
 __builtin___strlcpy_chk(buf, b, sizeof(b), __builtin_object_size(buf, 0)); // expected-warning {{size argument in '__builtin___strlcpy_chk' call appears to be size of the source; expected the size o

r341566 - [Sema] Clean up some __builtin_*_chk diagnostics

2018-09-06 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Thu Sep  6 10:19:33 2018
New Revision: 341566

URL: http://llvm.org/viewvc/llvm-project?rev=341566&view=rev
Log:
[Sema] Clean up some __builtin_*_chk diagnostics

Namely, print the likely macro name when it's used, and include the actual
computed sizes in the diagnostic message, which are sometimes not obvious.

rdar://43909200

Differential revision: https://reviews.llvm.org/D51697

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/builtin-object-size.c
cfe/trunk/test/Sema/builtins.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=341566&r1=341565&r2=341566&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Sep  6 10:19:33 
2018
@@ -694,7 +694,8 @@ def warn_assume_side_effects : Warning<
   InGroup>;
 
 def warn_memcpy_chk_overflow : Warning<
-  "%0 will always overflow destination buffer">,
+  "'%0' will always overflow; destination buffer has size %1,"
+  " but size argument is %2">,
   InGroup>;
 
 /// main()

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=341566&r1=341565&r2=341566&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Sep  6 10:19:33 2018
@@ -238,7 +238,8 @@ static bool SemaBuiltinOverflow(Sema &S,
 
 static void SemaBuiltinMemChkCall(Sema &S, FunctionDecl *FDecl,
   CallExpr *TheCall, unsigned SizeIdx,
-  unsigned DstSizeIdx) {
+  unsigned DstSizeIdx,
+  StringRef LikelyMacroName) {
   if (TheCall->getNumArgs() <= SizeIdx ||
   TheCall->getNumArgs() <= DstSizeIdx)
 return;
@@ -256,12 +257,21 @@ static void SemaBuiltinMemChkCall(Sema &
   if (Size.ule(DstSize))
 return;
 
-  // confirmed overflow so generate the diagnostic.
-  IdentifierInfo *FnName = FDecl->getIdentifier();
+  // Confirmed overflow, so generate the diagnostic.
+  StringRef FunctionName = FDecl->getName();
   SourceLocation SL = TheCall->getBeginLoc();
-  SourceRange SR = TheCall->getSourceRange();
+  SourceManager &SM = S.getSourceManager();
+  // If we're in an expansion of a macro whose name corresponds to this 
builtin,
+  // use the simple macro name and location.
+  if (SL.isMacroID() && Lexer::getImmediateMacroName(SL, SM, S.getLangOpts()) 
==
+LikelyMacroName) {
+FunctionName = LikelyMacroName;
+SL = SM.getImmediateMacroCallerLoc(SL);
+  }
 
-  S.Diag(SL, diag::warn_memcpy_chk_overflow) << SR << FnName;
+  S.Diag(SL, diag::warn_memcpy_chk_overflow)
+  << FunctionName << DstSize.toString(/*Radix=*/10)
+  << Size.toString(/*Radix=*/10);
 }
 
 static bool SemaBuiltinCallWithStaticChain(Sema &S, CallExpr *BuiltinCall) {
@@ -1219,21 +1229,37 @@ Sema::CheckBuiltinFunctionCall(FunctionD
   // check secure string manipulation functions where overflows
   // are detectable at compile time
   case Builtin::BI__builtin___memcpy_chk:
+SemaBuiltinMemChkCall(*this, FDecl, TheCall, 2, 3, "memcpy");
+break;
   case Builtin::BI__builtin___memmove_chk:
+SemaBuiltinMemChkCall(*this, FDecl, TheCall, 2, 3, "memmove");
+break;
   case Builtin::BI__builtin___memset_chk:
+SemaBuiltinMemChkCall(*this, FDecl, TheCall, 2, 3, "memset");
+break;
   case Builtin::BI__builtin___strlcat_chk:
+SemaBuiltinMemChkCall(*this, FDecl, TheCall, 2, 3, "strlcat");
+break;
   case Builtin::BI__builtin___strlcpy_chk:
+SemaBuiltinMemChkCall(*this, FDecl, TheCall, 2, 3, "strlcpy");
+break;
   case Builtin::BI__builtin___strncat_chk:
+SemaBuiltinMemChkCall(*this, FDecl, TheCall, 2, 3, "strncat");
+break;
   case Builtin::BI__builtin___strncpy_chk:
+SemaBuiltinMemChkCall(*this, FDecl, TheCall, 2, 3, "strncpy");
+break;
   case Builtin::BI__builtin___stpncpy_chk:
-SemaBuiltinMemChkCall(*this, FDecl, TheCall, 2, 3);
+SemaBuiltinMemChkCall(*this, FDecl, TheCall, 2, 3, "stpncpy");
 break;
   case Builtin::BI__builtin___memccpy_chk:
-SemaBuiltinMemChkCall(*this, FDecl, TheCall, 3, 4);
+SemaBuiltinMemChkCall(*this, FDecl, TheCall, 3, 4, "memccpy");
 break;
   case Builtin::BI__builtin___snprintf_chk:
+SemaBuiltinMemChkCall(*this, FDecl, TheCall, 1, 3, "snprintf");
+break;
   case Builtin::BI__builtin___vsnprintf_chk:
-SemaBuiltinMemChkCall(*this, FDecl, TheCall, 1, 3);
+SemaBuiltinMemChkCall(*this, FDecl, TheCall, 1, 3, "vsnprintf");
 break;
   case Builtin::BI__builtin_call_with_static_chain:

[PATCH] D51650: Implement target_clones multiversioning

2018-09-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: rsmith.
aaron.ballman added a comment.

Thank you for this! I have some cursory review comments, and possibly more 
later.




Comment at: include/clang/Basic/AttrDocs.td:1600
+  let Content = [{
+Clang supports the GNU style ``__attribute__((target_clones("OPTIONS")))``
+attribute. This attribute may be attached to a function definition and causes

It supports the C++ style as well, so perhaps "Clang supports the 
``target_clones("OPTIONS")`` attribute." instead?



Comment at: include/clang/Basic/AttrDocs.td:1601
+Clang supports the GNU style ``__attribute__((target_clones("OPTIONS")))``
+attribute. This attribute may be attached to a function definition and causes
+function multiversioning, where multiple versions  of the function will be

It can be on a declaration too, can't it?



Comment at: include/clang/Basic/AttrDocs.td:1602
+attribute. This attribute may be attached to a function definition and causes
+function multiversioning, where multiple versions  of the function will be
+emitted with different code generation options.  Additionally, these versions

Extraneous space between "versions of"



Comment at: include/clang/Basic/AttrDocs.td:1607
+
+All multiversioned functions must contain a ``default`` (fallback)
+implementation, otherwise usages of the function are considered invalid.

You should probably explain the options a bit more thoroughly around here; 
nothing explains that the options are architectures, for instance.



Comment at: include/clang/Basic/AttrDocs.td:1612
+Note that unlike the ``target`` syntax, every option listed creates a new
+version, desregarding whether it is split on a comma inside or outside a 
string.
+The following will emit 4 versions of the function.

typo: disregarding



Comment at: lib/CodeGen/CodeGenModule.cpp:2394
   const auto *F = cast(GD.getDecl());
+
   if (CodeGenOpts.OptimizationLevel == 0 && !F->hasAttr())

Spurious newline?



Comment at: lib/CodeGen/CodeGenModule.cpp:2559
+  assert(FD && "Not a FunctionDecl?");
+  auto *ClonesAttr = FD->getAttr();
+  assert(ClonesAttr && "Not a target_clones Function?");

`const auto *`



Comment at: lib/Sema/SemaDecl.cpp:9428
 S.Diag(OldFD->getLocation(), diag::err_multiversion_no_other_attrs)
-<< IsCPUSpecificCPUDispatchMVType;
+<< (MVType - 1);
 S.Diag(NewFD->getLocation(), diag::note_multiversioning_caused_here);

Rather than repeat this expression in multiple places, I prefer a named local 
variable.



Comment at: lib/Sema/SemaDeclAttr.cpp:3014
+  while (Str.size() != 0) {
+// remove the comma we found last time through.
+if (Str[0] == ',')

remove -> Remove


https://reviews.llvm.org/D51650



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


r341570 - [OPENMP] Fix PR38823: Do not emit vtable if it is not used in target

2018-09-06 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Sep  6 10:56:28 2018
New Revision: 341570

URL: http://llvm.org/viewvc/llvm-project?rev=341570&view=rev
Log:
[OPENMP] Fix PR38823: Do not emit vtable if it is not used in target
context.

If the explicit template instantiation definition defined outside of the
target context, its vtable should not be marked as used. This is true
for other situations where the compiler want to emit vtables
unconditionally.

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/OpenMP/declare_target_codegen.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=341570&r1=341569&r2=341570&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Sep  6 10:56:28 2018
@@ -14903,6 +14903,11 @@ void Sema::MarkVTableUsed(SourceLocation
   if (!Class->isDynamicClass() || Class->isDependentContext() ||
   CurContext->isDependentContext() || isUnevaluatedContext())
 return;
+  // Do not mark as used if compiling for the device outside of the target
+  // region.
+  if (LangOpts.OpenMP && LangOpts.OpenMPIsDevice &&
+  !isInOpenMPDeclareTargetContext() && !getCurFunctionDecl())
+return;
 
   // Try to insert this class into the map.
   LoadExternalVTableUses();

Modified: cfe/trunk/test/OpenMP/declare_target_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_target_codegen.cpp?rev=341570&r1=341569&r2=341570&view=diff
==
--- cfe/trunk/test/OpenMP/declare_target_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_target_codegen.cpp Thu Sep  6 10:56:28 2018
@@ -12,7 +12,8 @@
 
 // SIMD-ONLY-NOT: {{__kmpc|__tgt}}
 
-// CHECK-NOT: define {{.*}}{{baz1|baz4|maini1}}
+// CHECK-NOT: define {{.*}}{{baz1|baz4|maini1|Base}}
+// CHECK-DAG: Bake
 // CHECK-NOT: @{{hhh|ggg|fff|eee}} =
 // CHECK-DAG: @aaa = external global i32,
 // CHECK-DAG: @bbb = global i32 0,
@@ -140,9 +141,25 @@ int baz5() {
   return a;
 }
 
+template 
+struct Base {
+  virtual ~Base() {}
+};
+
+template class Base;
+
+template 
+struct Bake {
+  virtual ~Bake() {}
+};
+
+#pragma omp declare target
+template class Bake;
+#pragma omp end declare target
+
 // CHECK-DAG: declare extern_weak signext i32 @__create()
 
-// CHECK-NOT: define {{.*}}{{baz1|baz4|maini1}}
+// CHECK-NOT: define {{.*}}{{baz1|baz4|maini1|Base}}
 
 // CHECK-DAG: !{i32 1, !"aaa", i32 0, i32 {{[0-9]+}}}
 // CHECK-DAG: !{i32 1, !"ccc", i32 0, i32 {{[0-9]+}}}


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


[PATCH] D51741: [coro]Pass rvalue reference for named local variable to return_value

2018-09-06 Thread Tanoy Sinha via Phabricator via cfe-commits
tks2103 created this revision.
tks2103 added reviewers: modocache, GorNishanov.
Herald added a subscriber: cfe-commits.
tks2103 edited the summary of this revision.

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

Implements [class.copy]/33 of coroutines TS

When the criteria for elision of a copy/move operation are met, but not
for an exception-declaration, and the object to be copied is designated by an 
lvalue, or when the
expression in a return or co_return statement is a (possibly parenthesized) 
id-expression that
names an object with automatic storage duration declared in the body or
parameter-declaration-clause of the innermost enclosing function or 
lambda-expression, overload resolution to select
the constructor for the copy or the return_value overload to call is first 
performed as if the object
were designated by an rvalue.


Repository:
  rC Clang

https://reviews.llvm.org/D51741

Files:
  lib/Sema/SemaCoroutine.cpp
  test/SemaCXX/coroutine-rvo.cpp


Index: test/SemaCXX/coroutine-rvo.cpp
===
--- /dev/null
+++ test/SemaCXX/coroutine-rvo.cpp
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -stdlib=libc++ -std=c++1z 
-fcoroutines-ts -fsyntax-only
+
+namespace std::experimental {
+template  struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+
+template <> struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+};
+
+template 
+struct void_t_imp {
+  using type = void;
+};
+template 
+using void_t = typename void_t_imp::type;
+
+template 
+struct traits_sfinae_base {};
+
+template 
+struct traits_sfinae_base> {
+  using promise_type = typename T::promise_type;
+};
+
+template 
+struct coroutine_traits : public traits_sfinae_base {};
+}
+
+struct suspend_never {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+struct MoveOnly {
+  MoveOnly() {};
+  MoveOnly(const MoveOnly&) = delete;
+  MoveOnly(MoveOnly&&) noexcept {};
+  ~MoveOnly() {};
+};
+
+template 
+struct task {
+  struct promise_type {
+auto initial_suspend() { return suspend_never{}; }
+auto final_suspend() { return suspend_never{}; }
+auto get_return_object() { return task{}; }
+static void unhandled_exception() {}
+void return_value(T&& value) {}
+  };
+};
+
+task f() {
+  MoveOnly value;
+  co_return value;
+}
+
+int main() {
+  f();
+  return 0;
+}
+
+// expected-no-diagnostics
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -841,6 +841,16 @@
 E = R.get();
   }
 
+  // Move the return value if we can
+  if (E) {
+InitializedEntity Entity =
+InitializedEntity::InitializeResult(Loc, E->getType(), false);
+ExprResult MoveResult =
+this->PerformMoveOrCopyInitialization(Entity, nullptr, E->getType(), 
E);
+if (MoveResult.get())
+  E = MoveResult.get();
+  }
+
   // FIXME: If the operand is a reference to a variable that's about to go out
   // of scope, we should treat the operand as an xvalue for this overload
   // resolution.


Index: test/SemaCXX/coroutine-rvo.cpp
===
--- /dev/null
+++ test/SemaCXX/coroutine-rvo.cpp
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -stdlib=libc++ -std=c++1z -fcoroutines-ts -fsyntax-only
+
+namespace std::experimental {
+template  struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+
+template <> struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+};
+
+template 
+struct void_t_imp {
+  using type = void;
+};
+template 
+using void_t = typename void_t_imp::type;
+
+template 
+struct traits_sfinae_base {};
+
+template 
+struct traits_sfinae_base> {
+  using promise_type = typename T::promise_type;
+};
+
+template 
+struct coroutine_traits : public traits_sfinae_base {};
+}
+
+struct suspend_never {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+struct MoveOnly {
+  MoveOnly() {};
+  MoveOnly(const MoveOnly&) = delete;
+  MoveOnly(MoveOnly&&) noexcept {};
+  ~MoveOnly() {};
+};
+
+template 
+struct task {
+  struct promise_type {
+auto initial_suspend() { return suspend_never{}; }
+auto final_suspend() { return suspend_never{}; }
+auto get_return_object() { return task{}; }
+static void unhandled_exception() {}
+void return_value(T&& value) {}
+  };
+};
+
+task f() {
+  Mov

[PATCH] D51650: Implement target_clones multiversioning

2018-09-06 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 164251.
erichkeane marked 9 inline comments as done.
erichkeane added a comment.

fix aaron's comments.


https://reviews.llvm.org/D51650

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/Decl.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/attr-cpuspecific.c
  test/CodeGen/attr-target-clones.c
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/Sema/attr-target-clones.c

Index: test/Sema/attr-target-clones.c
===
--- /dev/null
+++ test/Sema/attr-target-clones.c
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu  -fsyntax-only -verify %s
+
+// expected-error@+1 {{'target_clones' multiversioning requires a default target}}
+void __attribute__((target_clones("sse4.2", "arch=sandybridge")))
+no_default(void);
+
+// expected-error@+2 {{'target_clones' and 'target' attributes are not compatible}}
+// expected-note@+1 {{conflicting attribute is here}}
+void __attribute__((target("sse4.2"), target_clones("arch=sandybridge")))
+ignored_attr(void);
+// expected-error@+2 {{'target' and 'target_clones' attributes are not compatible}}
+// expected-note@+1 {{conflicting attribute is here}}
+void __attribute__((target_clones("arch=sandybridge,default"), target("sse4.2")))
+ignored_attr2(void);
+
+int redecl(void);
+int __attribute__((target_clones("sse4.2", "default"))) redecl(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2", "default"))) redecl2(void);
+int __attribute__((target_clones("sse4.2", "default"))) redecl2(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2", "default"))) redecl3(void);
+int redecl3(void);
+
+int __attribute__((target_clones("sse4.2", "arch=atom", "default"))) redecl4(void);
+// expected-error@+3 {{'target_clones' attribute does not match previous declaration}}
+// expected-note@-2 {{previous declaration is here}}
+int __attribute__((target_clones("sse4.2", "arch=sandybridge", "default")))
+redecl4(void) { return 1; }
+
+int __attribute__((target("sse4.2"))) redef2(void) { return 1; }
+// expected-error@+2 {{multiversioning attributes cannot be combined}}
+// expected-note@-2 {{previous declaration is here}}
+int __attribute__((target_clones("sse4.2", "default"))) redef2(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2,default"))) redef3(void) { return 1; }
+// expected-error@+2 {{redefinition of 'redef3'}}
+// expected-note@-2 {{previous definition is here}}
+int __attribute__((target_clones("sse4.2,default"))) redef3(void) { return 1; }
+
+int __attribute__((target_clones("sse4.2,default"))) redef4(void) { return 1; }
+// expected-error@+2 {{redefinition of 'redef4'}}
+// expected-note@-2 {{previous definition is here}}
+int __attribute__((target_clones("sse4.2,default"))) redef4(void) { return 1; }
+
+// No error here... duplicates are allowed because they alter name mangling.
+int __attribute__((target_clones("arch=atom,arch=atom", "arch=atom,default")))
+dupes(void) { return 1; }
+
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones("")))
+empty_target_1(void);
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones(",default")))
+empty_target_2(void);
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones("default,")))
+empty_target_3(void);
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones("default, ,avx2")))
+empty_target_4(void);
+
+// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
+void __attribute__((target_clones("default,avx2", "")))
+empty_target_5(void);
+
+int mv_after_use(void);
+int useage() {
+  return mv_after_use();
+}
+// expected-error@+1 {{function declaration cannot become a multiversioned function after first usage}}
+int __attribute__((target_clones("sse4.2", "default"))) mv_after_use(void) { return 1; }
Index: test/Misc/pragma-attribute-supported-attributes-list.test
===
--- test/Misc/pragma-attribute-supported-attributes-list.test
+++ test/Misc/pragma-attribute-supported-attributes-list.test
@@ -2,7 +2,7 @@
 
 // The number of supported attributes should never go down!
 
-// CHECK: #pragma clang attribute supports 128 attributes:
+// CHECK: #pragma clang attribute supports 129 attributes:
 // CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_func

r341572 - Re-land r334417 "[MS] Use mangled names and comdats for string merging with ASan"

2018-09-06 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Sep  6 11:25:39 2018
New Revision: 341572

URL: http://llvm.org/viewvc/llvm-project?rev=341572&view=rev
Log:
Re-land r334417 "[MS] Use mangled names and comdats for string merging with 
ASan"

The issue with -fprofile-generate was fixed and the dependent CL
relanded in r340232.

Added:
cfe/trunk/test/CodeGen/asan-strings.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=341572&r1=341571&r2=341572&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Sep  6 11:25:39 2018
@@ -4305,15 +4305,13 @@ CodeGenModule::GetAddrOfConstantStringFr
   StringRef GlobalVariableName;
   llvm::GlobalValue::LinkageTypes LT;
 
-  // Mangle the string literal if the ABI allows for it.  However, we cannot
-  // do this if  we are compiling with ASan or -fwritable-strings because they
-  // rely on strings having normal linkage.
-  if (!LangOpts.WritableStrings &&
-  !LangOpts.Sanitize.has(SanitizerKind::Address) &&
-  getCXXABI().getMangleContext().shouldMangleStringLiteral(S)) {
+  // Mangle the string literal if that's how the ABI merges duplicate strings.
+  // Don't do it if they are writable, since we don't want writes in one TU to
+  // affect strings in another.
+  if (getCXXABI().getMangleContext().shouldMangleStringLiteral(S) &&
+  !LangOpts.WritableStrings) {
 llvm::raw_svector_ostream Out(MangledNameBuffer);
 getCXXABI().getMangleContext().mangleStringLiteral(S, Out);
-
 LT = llvm::GlobalValue::LinkOnceODRLinkage;
 GlobalVariableName = MangledNameBuffer;
   } else {

Added: cfe/trunk/test/CodeGen/asan-strings.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/asan-strings.c?rev=341572&view=auto
==
--- cfe/trunk/test/CodeGen/asan-strings.c (added)
+++ cfe/trunk/test/CodeGen/asan-strings.c Thu Sep  6 11:25:39 2018
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=address 
-disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefix=LINUX
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fsanitize=address 
-disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefix=WINDOWS
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fsanitize=address 
-fwritable-strings -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s 
--check-prefix=WINWRITE
+
+// On Linux (and basically every non-MS target) string literals are emitted 
with
+// private linkage, which means ASan can freely instrument them. On Windows,
+// they are emitted with comdats. ASan's global instrumentation code for COFF
+// knows how to make the metadata comdat associative, so the string literal
+// global is only registered if the instrumented global prevails during 
linking.
+
+const char *foo() { return "asdf"; }
+
+// LINUX: @.str = private unnamed_addr constant [5 x i8] c"asdf\00", align 1
+
+// WINDOWS: @"??_C@_04JIHMPGLA@asdf?$AA@" = linkonce_odr dso_local 
unnamed_addr constant [5 x i8] c"asdf\00", comdat, align 1
+
+// WINWRITE: @.str = private unnamed_addr global [5 x i8] c"asdf\00", align 1


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


  1   2   >