[PATCH] D62368: Add support for Hygon Dhyana processor

2019-05-24 Thread Jinke Fan via Phabricator via cfe-commits
fanjinke created this revision.
Herald added projects: clang, Sanitizers, LLVM.
Herald added subscribers: llvm-commits, Sanitizers, cfe-commits.

This patch adds vendor id detection for Hygon Dhyana CPUs.

More details can be found on:

  
http://lkml.kernel.org/r/5ce86123a7b9dad925ac583d88d2f921040e859b.1538583282.git.pu...@hygon.cn

Result of "make check":
[100%] Running the LLVM regression tests
Testing Time: 671.13s

  Expected Passes: 30229
  Expected Failures  : 149
  Unsupported Tests  : 673

[100%] Built target check-llvm
Scanning dependencies of target check
[100%] Built target check


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62368

Files:
  clang/lib/Headers/cpuid.h
  compiler-rt/lib/scudo/scudo_utils.cpp
  compiler-rt/lib/scudo/standalone/checksum.cc


Index: compiler-rt/lib/scudo/standalone/checksum.cc
===
--- compiler-rt/lib/scudo/standalone/checksum.cc
+++ compiler-rt/lib/scudo/standalone/checksum.cc
@@ -39,7 +39,9 @@
(Ecx == signature_INTEL_ecx);
   const bool IsAMD = (Ebx == signature_AMD_ebx) && (Edx == signature_AMD_edx) 
&&
  (Ecx == signature_AMD_ecx);
-  if (!IsIntel && !IsAMD)
+  const bool IsHygon = (Ebx == signature_HYGON_ebx) && (Edx == 
signature_HYGON_edx) &&
+   (Ecx == signature_HYGON_ecx);
+  if (!IsIntel && !IsAMD && !IsHygon)
 return false;
   __get_cpuid(1, &Eax, &Ebx, &Ecx, &Edx);
   return !!(Ecx & bit_SSE4_2);
Index: compiler-rt/lib/scudo/scudo_utils.cpp
===
--- compiler-rt/lib/scudo/scudo_utils.cpp
+++ compiler-rt/lib/scudo/scudo_utils.cpp
@@ -71,7 +71,10 @@
   const bool IsAMD = (Ebx == signature_AMD_ebx) &&
  (Edx == signature_AMD_edx) &&
  (Ecx == signature_AMD_ecx);
-  if (!IsIntel && !IsAMD)
+  const bool IsHygon = (Ebx == signature_HYGON_ebx) &&
+   (Edx == signature_HYGON_edx) &&
+   (Ecx == signature_HYGON_ecx);
+  if (!IsIntel && !IsAMD && !IsHygon)
 return false;
   __get_cpuid(1, &Eax, &Ebx, &Ecx, &Edx);
   return !!(Ecx & bit_SSE4_2);
Index: clang/lib/Headers/cpuid.h
===
--- clang/lib/Headers/cpuid.h
+++ clang/lib/Headers/cpuid.h
@@ -24,6 +24,10 @@
 #define signature_CYRIX_ebx 0x69727943
 #define signature_CYRIX_edx 0x736e4978
 #define signature_CYRIX_ecx 0x64616574
+/* HYGON:   "HygonGenuine" */
+#define signature_HYGON_ebx 0x6f677948
+#define signature_HYGON_edx 0x6e65476e
+#define signature_HYGON_ecx 0x656e6975
 /* INTEL:   "GenuineIntel" */
 #define signature_INTEL_ebx 0x756e6547
 #define signature_INTEL_edx 0x49656e69


Index: compiler-rt/lib/scudo/standalone/checksum.cc
===
--- compiler-rt/lib/scudo/standalone/checksum.cc
+++ compiler-rt/lib/scudo/standalone/checksum.cc
@@ -39,7 +39,9 @@
(Ecx == signature_INTEL_ecx);
   const bool IsAMD = (Ebx == signature_AMD_ebx) && (Edx == signature_AMD_edx) &&
  (Ecx == signature_AMD_ecx);
-  if (!IsIntel && !IsAMD)
+  const bool IsHygon = (Ebx == signature_HYGON_ebx) && (Edx == signature_HYGON_edx) &&
+   (Ecx == signature_HYGON_ecx);
+  if (!IsIntel && !IsAMD && !IsHygon)
 return false;
   __get_cpuid(1, &Eax, &Ebx, &Ecx, &Edx);
   return !!(Ecx & bit_SSE4_2);
Index: compiler-rt/lib/scudo/scudo_utils.cpp
===
--- compiler-rt/lib/scudo/scudo_utils.cpp
+++ compiler-rt/lib/scudo/scudo_utils.cpp
@@ -71,7 +71,10 @@
   const bool IsAMD = (Ebx == signature_AMD_ebx) &&
  (Edx == signature_AMD_edx) &&
  (Ecx == signature_AMD_ecx);
-  if (!IsIntel && !IsAMD)
+  const bool IsHygon = (Ebx == signature_HYGON_ebx) &&
+   (Edx == signature_HYGON_edx) &&
+   (Ecx == signature_HYGON_ecx);
+  if (!IsIntel && !IsAMD && !IsHygon)
 return false;
   __get_cpuid(1, &Eax, &Ebx, &Ecx, &Edx);
   return !!(Ecx & bit_SSE4_2);
Index: clang/lib/Headers/cpuid.h
===
--- clang/lib/Headers/cpuid.h
+++ clang/lib/Headers/cpuid.h
@@ -24,6 +24,10 @@
 #define signature_CYRIX_ebx 0x69727943
 #define signature_CYRIX_edx 0x736e4978
 #define signature_CYRIX_ecx 0x64616574
+/* HYGON:   "HygonGenuine" */
+#define signature_HYGON_ebx 0x6f677948
+#define signature_HYGON_edx 0x6e65476e
+#define signature_HYGON_ecx 0x656e6975
 /* INTEL:   "GenuineIntel" */
 #define signature_INTEL_ebx 0x756e6547
 #define signature_INTEL_edx 0x49656e69
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62312: [ASTImporter] Added visibility context check for CXXRecordDecl.

2019-05-24 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked an inline comment as done.
balazske added a comment.

Thanks for reviewing.

Similar additions are planned to follow with function and variable template, 
enum, scoped enum, typedef, type alias.




Comment at: unittests/AST/ASTImporterVisibilityTest.cpp:34
 };
+struct GetClassPattern {
+  using DeclTy = CXXRecordDecl;

shafik wrote:
> `GetCXXRecordPattern` feels more consistent.
The exact decl name is not repeated in these variable names like "FunPattern" 
for functions. Using "class" instead of "CXXRecord" can be acceptable. I do not 
like `ImportCXXRecordsVisibilityChain` (`GetRecPattern` and 
`ImportRecordsVisibilityChain` may be good too, but we do not say "C++ record" 
for thing that is a class).



Repository:
  rC Clang

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

https://reviews.llvm.org/D62312



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


[PATCH] D62367: [X86] VP2INTERSECT clang

2019-05-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: lib/Basic/Targets/X86.cpp:518
   case AVX512F:
 Features["avx512f"] = Features["avx512cd"] = Features["avx512er"] =
 Features["avx512pf"] = Features["avx512dq"] = Features["avx512bw"] =

This patch needs to be rebased. I modified the formatting here earlier to fix 
the weird indentation.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62367



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


[PATCH] D61472: [X86FixupLEAs] Turn optIncDec into a generic two address LEA optimizer. Support LEA64_32r properly.

2019-05-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Ping


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

https://reviews.llvm.org/D61472



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


[PATCH] D62340: [clang-tidy] In TransformerClangTidyCheck, require Explanation field.

2019-05-24 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, thanks!




Comment at: 
clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp:38
   " else ", statement(T;
+  Rule.Cases[0].Explanation = tooling::text("no explanation");
+  return Rule;

NIT: this might be the first place people look at when writing the check, so we 
might want to provide a real explanation here.
Something like `negate condition and revert then and else branches`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62340



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


[PATCH] D62312: [ASTImporter] Added visibility context check for CXXRecordDecl.

2019-05-24 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 201133.
balazske added a comment.

- Changed type of string constants to const.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62312

Files:
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterVisibilityTest.cpp

Index: unittests/AST/ASTImporterVisibilityTest.cpp
===
--- unittests/AST/ASTImporterVisibilityTest.cpp
+++ unittests/AST/ASTImporterVisibilityTest.cpp
@@ -31,6 +31,10 @@
   using DeclTy = VarDecl;
   BindableMatcher operator()() { return varDecl(hasName("v")); }
 };
+struct GetClassPattern {
+  using DeclTy = CXXRecordDecl;
+  BindableMatcher operator()() { return cxxRecordDecl(hasName("X")); }
+};
 
 // Values for the value-parameterized test fixtures.
 // FunctionDecl:
@@ -41,6 +45,9 @@
 const auto *ExternV = "extern int v;";
 const auto *StaticV = "static int v;";
 const auto *AnonV = "namespace { extern int v; }";
+// CXXRecordDecl:
+const auto *ExternC = "class X;";
+const auto *AnonC = "namespace { class X; }";
 
 // First value in tuple: Compile options.
 // Second value in tuple: Source code to be used in the test.
@@ -84,14 +91,19 @@
 // Manual instantiation of the fixture with each type.
 using ImportFunctionsVisibilityChain = ImportVisibilityChain;
 using ImportVariablesVisibilityChain = ImportVisibilityChain;
-// Value-parameterized test for the first type.
+using ImportClassesVisibilityChain = ImportVisibilityChain;
+// Value-parameterized test for functions.
 TEST_P(ImportFunctionsVisibilityChain, ImportChain) {
   TypedTest_ImportChain();
 }
-// Value-parameterized test for the second type.
+// Value-parameterized test for variables.
 TEST_P(ImportVariablesVisibilityChain, ImportChain) {
   TypedTest_ImportChain();
 }
+// Value-parameterized test for classes.
+TEST_P(ImportClassesVisibilityChain, ImportChain) {
+  TypedTest_ImportChain();
+}
 
 // Automatic instantiation of the value-parameterized tests.
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctionsVisibilityChain,
@@ -110,6 +122,11 @@
 // provided but they must have the same linkage.  See also the test
 // ImportVariableChainInC which test for this special C Lang case.
 ::testing::Values(ExternV, AnonV)), );
+INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, ImportClassesVisibilityChain,
+::testing::Combine(
+DefaultTestValuesForRunOptions,
+::testing::Values(ExternC, AnonC)), );
 
 // First value in tuple: Compile options.
 // Second value in tuple: Tuple with informations for the test.
@@ -169,6 +186,7 @@
 };
 using ImportFunctionsVisibility = ImportVisibility;
 using ImportVariablesVisibility = ImportVisibility;
+using ImportClassesVisibility = ImportVisibility;
 
 // FunctionDecl.
 TEST_P(ImportFunctionsVisibility, ImportAfter) {
@@ -184,6 +202,13 @@
 TEST_P(ImportVariablesVisibility, ImportAfterImport) {
   TypedTest_ImportAfterImport();
 }
+// CXXRecordDecl.
+TEST_P(ImportClassesVisibility, ImportAfter) {
+  TypedTest_ImportAfter();
+}
+TEST_P(ImportClassesVisibility, ImportAfterImport) {
+  TypedTest_ImportAfterImport();
+}
 
 const bool ExpectLink = true;
 const bool ExpectNotLink = false;
@@ -214,6 +239,14 @@
   std::make_tuple(AnonV, ExternV, ExpectNotLink),
   std::make_tuple(AnonV, StaticV, ExpectNotLink),
   std::make_tuple(AnonV, AnonV, ExpectNotLink))), );
+INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, ImportClassesVisibility,
+::testing::Combine(
+DefaultTestValuesForRunOptions,
+::testing::Values(std::make_tuple(ExternC, ExternC, ExpectLink),
+  std::make_tuple(ExternC, AnonC, ExpectNotLink),
+  std::make_tuple(AnonC, ExternC, ExpectNotLink),
+  std::make_tuple(AnonC, AnonC, ExpectNotLink))), );
 
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -2559,6 +2559,9 @@
   if (!IsStructuralMatch(D, FoundRecord, false))
 continue;
 
+if (!hasSameVisibilityContext(FoundRecord, D))
+  continue;
+
 if (IsStructuralMatch(D, FoundRecord)) {
   RecordDecl *FoundDef = FoundRecord->getDefinition();
   if (D->isThisDeclarationADefinition() && FoundDef) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62367: [X86] VP2INTERSECT clang

2019-05-24 Thread Xiang Zhang via Phabricator via cfe-commits
xiangzhangllvm updated this revision to Diff 201137.
xiangzhangllvm added a comment.

rebase


Repository:
  rC Clang

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

https://reviews.llvm.org/D62367

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Basic/BuiltinsX86.def
  include/clang/Driver/Options.td
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/avx512vlvp2intersectintrin.h
  lib/Headers/avx512vp2intersectintrin.h
  lib/Headers/immintrin.h
  test/CodeGen/attr-target-x86.c
  test/CodeGen/intel-avx512vlvp2intersect.c
  test/CodeGen/intel-avx512vp2intersect.c
  test/Driver/x86-target-features.c
  test/Preprocessor/x86_target_features.c

Index: test/Preprocessor/x86_target_features.c
===
--- test/Preprocessor/x86_target_features.c
+++ test/Preprocessor/x86_target_features.c
@@ -458,3 +458,13 @@
 
 // AVX512BF16_NOAVX512VL: #define __AVX512BF16__ 1
 
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mavx512vp2intersect -x c -E -dM -o - %s | FileCheck  -check-prefix=VP2INTERSECT %s
+
+// VP2INTERSECT: #define __AVX512F__ 1
+// VP2INTERSECT: #define __AVX512VP2INTERSECT__ 1
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-avx512vp2intersect -x c -E -dM -o - %s | FileCheck  -check-prefix=NOVP2INTERSECT %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mavx512vp2intersect -mno-avx512f -x c -E -dM -o - %s | FileCheck  -check-prefix=NOVP2INTERSECT %s
+
+// NOVP2INTERSECT-NOT: #define __AVX512VP2INTERSECT__ 1
+
Index: test/Driver/x86-target-features.c
===
--- test/Driver/x86-target-features.c
+++ test/Driver/x86-target-features.c
@@ -125,6 +125,11 @@
 // VBMI2: "-target-feature" "+avx512vbmi2"
 // NO-VBMI2: "-target-feature" "-avx512vbmi2"
 
+// RUN: %clang -target i386-linux-gnu -mavx512vp2intersect %s -### -o %t.o 2>&1 | FileCheck -check-prefix=VP2INTERSECT %s
+// RUN: %clang -target i386-linux-gnu -mno-avx512vp2intersect %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-VP2INTERSECT %s
+// VP2INTERSECT: "-target-feature" "+avx512vp2intersect"
+// NO-VP2INTERSECT: "-target-feature" "-avx512vp2intersect"
+
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mrdpid %s -### -o %t.o 2>&1 | FileCheck -check-prefix=RDPID %s
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-rdpid %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-RDPID %s
 // RDPID: "-target-feature" "+rdpid"
Index: test/CodeGen/intel-avx512vp2intersect.c
===
--- /dev/null
+++ test/CodeGen/intel-avx512vp2intersect.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-unknown-unknown -target-feature +avx512vp2intersect -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 %s -ffreestanding -triple=i386-unknown-unknown -target-feature +avx512vp2intersect -emit-llvm -o - -Wall -Werror | FileCheck %s
+
+#include 
+
+void test_mm512_2intersect_epi32(__m512i a, __m512i b, __mmask16 *m0, __mmask16 *m1) {
+// CHECK-LABEL: test_mm512_2intersect_epi32
+// CHECK: call { <16 x i1>, <16 x i1> } @llvm.x86.avx512.vp2intersect.d.512(<16 x i32> %{{.*}}, <16 x i32> %{{.*}})
+// CHECK: extractvalue { <16 x i1>, <16 x i1> } %{{.*}}, 0
+// CHECK: extractvalue { <16 x i1>, <16 x i1> } %{{.*}}, 1
+  _mm512_2intersect_epi32(a, b, m0, m1);
+}
+
+void test_mm512_2intersect_epi64(__m512i a, __m512i b, __mmask8 *m0, __mmask8 *m1) {
+// CHECK-LABEL: test_mm512_2intersect_epi64
+// CHECK: call { <8 x i1>, <8 x i1> } @llvm.x86.avx512.vp2intersect.q.512(<8 x i64> %{{.*}}, <8 x i64> %{{.*}})
+// CHECK: extractvalue { <8 x i1>, <8 x i1> } %{{.*}}, 0
+// CHECK: extractvalue { <8 x i1>, <8 x i1> } %{{.*}}, 1
+  _mm512_2intersect_epi64(a, b, m0, m1);
+}
Index: test/CodeGen/intel-avx512vlvp2intersect.c
===
--- /dev/null
+++ test/CodeGen/intel-avx512vlvp2intersect.c
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-unknown-unknown -target-feature +avx512vp2intersect -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 %s -ffreestanding -triple=i386-unknown-unknown -target-feature +avx512vp2intersect -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s
+
+#include 
+
+void test_mm256_2intersect_epi32(__m256i a, __m256i b, __mmask8 *m0, __mmask8 *m1) {
+// CHECK-LABEL: test_mm256_2intersect_epi32
+// CHECK: call { <8 x i1>, <8 x i1> } @llvm.x86.avx512.vp2intersect.d.256(<8 x i32> %{{.*}}, <8 x i32> %{{.*}})
+// CHECK: extractvalue { <8 x i1>, <8 x i1> } %{{.*}}, 0
+// CHECK: extractvalue { <8 x i1>, <8 x i1> } %{{.*}}, 1
+  _mm256_2intersect_epi32(a, b, m0, m1);
+}
+
+void test_mm256_2intersect_epi64(__m256i a, __m256i b, __mmask8 *m0, __mmask8 *m1) {
+// CHECK-LABEL: test_

[PATCH] D62372: [clangd] Limit the size of synthesized fix message

2019-05-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: kadircet.
Herald added subscribers: arphaman, jkorous, MaskRay.
Herald added a project: clang.

A temporary workaround until we figure out a better way to present fixes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62372

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

Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -120,7 +120,7 @@
  "use of undeclared identifier 'goo'; did you mean 'foo'?"),
 DiagSource(Diag::Clang), DiagName("undeclared_var_use_suggest"),
 WithFix(
-Fix(Test.range("typo"), "foo", "change 'go\\ o' to 'foo'")),
+Fix(Test.range("typo"), "foo", "change 'go\\…' to 'foo'")),
 // This is a pretty normal range.
 WithNote(Diag(Test.range("decl"), "'foo' declared here"))),
   // This range is zero-width and insertion. Therefore make sure we are
@@ -247,6 +247,36 @@
   DiagSeverity(DiagnosticsEngine::Error;
 }
 
+TEST(DiagnosticTest, LongFixMessages) {
+  // We limit the size of printed code.
+  Annotations Source(R"cpp(
+int main() {
+  int somereallyreallyreallyreallyreallyreallyreallyreallylongidentifier;
+  [[omereallyreallyreallyreallyreallyreallyreallyreallylongidentifier]]= 10;
+}
+  )cpp");
+  TestTU TU = TestTU::withCode(Source.code());
+  EXPECT_THAT(
+  TU.build().getDiagnostics(),
+  ElementsAre(WithFix(Fix(
+  Source.range(),
+  "somereallyreallyreallyreallyreallyreallyreallyreallylongidentifier",
+  "change 'omereallyreallyreallyreallyreallyreallyreallyreall…' to "
+  "'somereallyreallyreallyreallyreallyreallyreallyreal…'";
+  // Only show changes up to a first newline.
+  Source = Annotations(R"cpp(
+int main() {
+  int ident;
+  [[ide\
+n]] = 10;
+}
+  )cpp");
+  TU = TestTU::withCode(Source.code());
+  EXPECT_THAT(TU.build().getDiagnostics(),
+  ElementsAre(WithFix(
+  Fix(Source.range(), "ident", "change 'ide\\…' to 'ident'";
+}
+
 TEST(DiagnosticTest, ClangTidyWarningAsErrorTrumpsSuppressionComment) {
   Annotations Main(R"cpp(
 int main() {
Index: clang-tools-extra/clangd/Diagnostics.cpp
===
--- clang-tools-extra/clangd/Diagnostics.cpp
+++ clang-tools-extra/clangd/Diagnostics.cpp
@@ -25,7 +25,9 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -437,6 +439,24 @@
   LangOpts = None;
 }
 
+/// Sanitizes a piece for presenting it in a synthesized fix message. Ensures
+/// the result is not too large and does not contain newlines.
+static void writeCodeToFixMessage(llvm::raw_ostream &OS, llvm::StringRef Code) {
+  constexpr unsigned MaxLen = 50;
+
+  llvm::StringRef R = Code;
+
+  size_t FirstNewline = R.find('\n');
+  if (FirstNewline != llvm::StringRef::npos)
+R = R.take_front(FirstNewline);
+  if (R.size() > MaxLen)
+R = R.take_front(MaxLen);
+
+  OS << R;
+  if (R.size() != Code.size())
+OS << "…";
+}
+
 void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
   const clang::Diagnostic &Info) {
   DiagnosticConsumer::HandleDiagnostic(DiagLevel, Info);
@@ -494,12 +514,23 @@
   llvm::StringRef Insert = FixIt.CodeToInsert;
   if (!Invalid) {
 llvm::raw_svector_ostream M(Message);
-if (!Remove.empty() && !Insert.empty())
-  M << "change '" << Remove << "' to '" << Insert << "'";
-else if (!Remove.empty())
-  M << "remove '" << Remove << "'";
-else if (!Insert.empty())
-  M << "insert '" << Insert << "'";
+if (!Remove.empty() && !Insert.empty()) {
+  M << "change '";
+  writeCodeToFixMessage(M, Remove);
+  M << "' to '";
+  writeCodeToFixMessage(M, Insert);
+  M << "'";
+}
+else if (!Remove.empty()) {
+  M << "remove '";
+  writeCodeToFixMessage(M, Remove);
+  M << "'";
+}
+else if (!Insert.empty()) {
+  M << "insert '";
+  writeCodeToFixMessage(M, Insert);
+  M << "'";
+}
 // Don't allow source code to inject newlines into diagnostics.
 std::replace(Message.begin(), Message.end(), '\n', ' ');
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62298: [CodeComplete] Filter override completions by function name

2019-05-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

LGTM

Have one question though, does it improve behavior in vscode? Since label seems 
to be the same, it will most definitely improve clangd's ranking but vscode 
ignores it anyway.




Comment at: clang/lib/Sema/SemaCodeComplete.cpp:3165
+}
+if (!SeenTypedChunk && Chunk.Kind == CodeCompletionString::CK_TypedText)
+  SeenTypedChunk = true;

why not just put `SeenTypedChunk |= Chunk.Kind == 
CodeCompletionString::CK_TypedText`



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:3172
+// Add a space after return type.
+if (Chunk.Kind == CodeCompletionString::CK_ResultType) {
+  assert(!SeenTypedChunk);

do we expect anything but return type in the `BeforeName` or any case where we 
shouldn't put a space between `BeforeName` and `NameAndSignature` ?

why not let the user add a space while concatenating these two?



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:3191
+  printOverrideString(*CCS, BeforeName, NameAndSignature);
+  NameAndSignature += " override";
+

let's move this into `printOverrideString`



Comment at: clang/test/CodeCompletion/overrides.cpp:14
   void vfunc(bool param) override;
-  void
+  vfo
 };

nit: I suppose it should be `vfu`?(same thing for the comments below starting 
with `Runs completion...`



Comment at: clang/test/CodeCompletion/overrides.cpp:29
-//
-// Runs completion at void ^.
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:8 %s -o - | 
FileCheck -check-prefix=CHECK-CC3 %s

ilya-biryukov wrote:
> I've removed this to avoid dealing with the error return code (`vfo` is 
> unresolved, so clang produces error there).
> Happy to bring it back if you feel it's important
it was here to prevent a regression maybe trigger it on the 13th line instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62298



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


[PATCH] D62298: [CodeComplete] Filter override completions by function name

2019-05-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In D62298#1515399 , @kadircet wrote:

> LGTM
>
> Have one question though, does it improve behavior in vscode? Since label 
> seems to be the same, it will most definitely improve clangd's ranking but 
> vscode ignores it anyway.


It does, VSCode relies on `filterText` for ranking and since it now starts with 
the function name the ranking is much better.

Will fix the rest of the comments and land this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62298



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


[PATCH] D62298: [CodeComplete] Filter override completions by function name

2019-05-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:3172
+// Add a space after return type.
+if (Chunk.Kind == CodeCompletionString::CK_ResultType) {
+  assert(!SeenTypedChunk);

kadircet wrote:
> do we expect anything but return type in the `BeforeName` or any case where 
> we shouldn't put a space between `BeforeName` and `NameAndSignature` ?
> 
> why not let the user add a space while concatenating these two?
Maybe annotations? But not sure where they go (also not sure we should print 
them here).
I could move adding the space to the point where we concatenate `BeforeName` 
and `NameAndSignature` if that would make it clearer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62298



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


[PATCH] D62298: [CodeComplete] Filter override completions by function name

2019-05-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:3172
+// Add a space after return type.
+if (Chunk.Kind == CodeCompletionString::CK_ResultType) {
+  assert(!SeenTypedChunk);

ilya-biryukov wrote:
> kadircet wrote:
> > do we expect anything but return type in the `BeforeName` or any case where 
> > we shouldn't put a space between `BeforeName` and `NameAndSignature` ?
> > 
> > why not let the user add a space while concatenating these two?
> Maybe annotations? But not sure where they go (also not sure we should print 
> them here).
> I could move adding the space to the point where we concatenate `BeforeName` 
> and `NameAndSignature` if that would make it clearer.
I usually find it annoying when some helper function returns strings with 
trailing whitespaces, which is not useful in the general case. (Faced those a 
lot during `HoverInfo` patch.) I believe it would make the function more usable 
to others, so let's make it part of concat logic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62298



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


[PATCH] D62298: [CodeComplete] Filter override completions by function name

2019-05-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 201157.
ilya-biryukov marked 4 inline comments as done.
ilya-biryukov added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62298

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/overrides.cpp

Index: clang/test/CodeCompletion/overrides.cpp
===
--- clang/test/CodeCompletion/overrides.cpp
+++ clang/test/CodeCompletion/overrides.cpp
@@ -11,23 +11,23 @@
 class C : public B {
  public:
   void vfunc(bool param) override;
-  void
+  vfo
 };
 
-// Runs completion at ^void.
+// Runs completion at ^vfo
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:3 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
 // CHECK-CC1: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC1-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
 //
-// Runs completion at vo^id.
+// Runs completion at vf^o
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:5 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
-// CHECK-CC2: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC2-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
+// CHECK-CC2: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC2-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
 //
-// Runs completion at void ^.
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:8 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// Runs completion at void ^ on line 13.
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:13:8 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
 // CHECK-CC3-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
 // CHECK-CC3-NOT: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC3-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -37,6 +37,7 @@
 #include "llvm/Support/Path.h"
 #include 
 #include 
+#include 
 #include 
 
 using namespace clang;
@@ -1828,19 +1829,6 @@
   Results.AddResult(CodeCompletionResult(Builder.TakeString()));
 }
 
-static void printOverrideString(llvm::raw_ostream &OS,
-CodeCompletionString *CCS) {
-  for (const auto &C : *CCS) {
-if (C.Kind == CodeCompletionString::CK_Optional)
-  printOverrideString(OS, C.Optional);
-else
-  OS << C.Text;
-// Add a space after return type.
-if (C.Kind == CodeCompletionString::CK_ResultType)
-  OS << ' ';
-  }
-}
-
 static void AddOverrideResults(ResultBuilder &Results,
const CodeCompletionContext &CCContext,
CodeCompletionBuilder &Builder) {
@@ -3162,19 +3150,48 @@
   PP, Ctx, Result, IncludeBriefComments, CCContext, Policy);
 }
 
+static void printOverrideString(const CodeCompletionString &CCS,
+   std::string &BeforeName,
+   std::string &NameAndSignature) {
+  bool SeenTypedChunk = false;
+  for (auto &Chunk : CCS) {
+if (Chunk.Kind == CodeCompletionString::CK_Optional) {
+  assert(SeenTypedChunk && "optional parameter before name");
+  // Note that we put all chunks inside into NameAndSignature.
+  printOverrideString(*Chunk.Optional, NameAndSignature,
+ NameAndSignature);
+  continue;
+}
+SeenTypedChunk |= Chunk.Kind == CodeCompletionString::CK_TypedText;
+if (SeenTypedChunk)
+  NameAndSignature += Chunk.Text;
+else
+  BeforeName += Chunk.Text;
+// Add a space after return type.
+if (Chunk.Kind == CodeCompletionString::CK_ResultType) {
+  assert(!SeenTypedChunk);
+  BeforeName += " ";
+}
+  }
+  NameAndSignature += " override";
+}
+
 CodeCompletionString *
 CodeCompletionResult::createCodeCompletionStringForOverride(
 Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result,
 bool IncludeBriefComments, const CodeCompletionContext &CCContext,
 PrintingPolicy &Policy) {
-  std::string OverrideSignature;
-  llvm::raw_string_ostream OS(OverrideSignature);
   auto *CCS = createCodeCompletionStringForDecl(PP, Ctx, Result,
 /*IncludeBriefComments=*/false,
 CCContext, Policy);
-  printOverrideString(OS, CCS);
-  OS << " override";
-  Result.AddTypedTextChunk(Result.getAllocator().CopyString(OS.str()));
+  std::string Bef

[PATCH] D62298: [CodeComplete] Filter override completions by function name

2019-05-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang/test/CodeCompletion/overrides.cpp:14
   void vfunc(bool param) override;
-  void
+  vfo
 };

kadircet wrote:
> nit: I suppose it should be `vfu`?(same thing for the comments below starting 
> with `Runs completion...`
No, the idea was to test the `vfunc` item prefix-matching on `vfo` but still 
matches on `vf`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62298



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


[PATCH] D62298: [CodeComplete] Filter override completions by function name

2019-05-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 201161.
ilya-biryukov marked 4 inline comments as done.
ilya-biryukov added a comment.

- Add whitespace outside printOverrideString


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62298

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/overrides.cpp

Index: clang/test/CodeCompletion/overrides.cpp
===
--- clang/test/CodeCompletion/overrides.cpp
+++ clang/test/CodeCompletion/overrides.cpp
@@ -11,23 +11,23 @@
 class C : public B {
  public:
   void vfunc(bool param) override;
-  void
+  vfo
 };
 
-// Runs completion at ^void.
+// Runs completion at ^vfo
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:3 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
 // CHECK-CC1: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC1-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
 //
-// Runs completion at vo^id.
+// Runs completion at vf^o
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:5 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
-// CHECK-CC2: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC2-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
+// CHECK-CC2: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC2-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
 //
-// Runs completion at void ^.
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:8 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// Runs completion at void ^ on line 13.
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:13:8 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
 // CHECK-CC3-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
 // CHECK-CC3-NOT: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC3-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -37,6 +37,7 @@
 #include "llvm/Support/Path.h"
 #include 
 #include 
+#include 
 #include 
 
 using namespace clang;
@@ -1828,19 +1829,6 @@
   Results.AddResult(CodeCompletionResult(Builder.TakeString()));
 }
 
-static void printOverrideString(llvm::raw_ostream &OS,
-CodeCompletionString *CCS) {
-  for (const auto &C : *CCS) {
-if (C.Kind == CodeCompletionString::CK_Optional)
-  printOverrideString(OS, C.Optional);
-else
-  OS << C.Text;
-// Add a space after return type.
-if (C.Kind == CodeCompletionString::CK_ResultType)
-  OS << ' ';
-  }
-}
-
 static void AddOverrideResults(ResultBuilder &Results,
const CodeCompletionContext &CCContext,
CodeCompletionBuilder &Builder) {
@@ -3162,19 +3150,44 @@
   PP, Ctx, Result, IncludeBriefComments, CCContext, Policy);
 }
 
+static void printOverrideString(const CodeCompletionString &CCS,
+   std::string &BeforeName,
+   std::string &NameAndSignature) {
+  bool SeenTypedChunk = false;
+  for (auto &Chunk : CCS) {
+if (Chunk.Kind == CodeCompletionString::CK_Optional) {
+  assert(SeenTypedChunk && "optional parameter before name");
+  // Note that we put all chunks inside into NameAndSignature.
+  printOverrideString(*Chunk.Optional, NameAndSignature,
+ NameAndSignature);
+  continue;
+}
+SeenTypedChunk |= Chunk.Kind == CodeCompletionString::CK_TypedText;
+if (SeenTypedChunk)
+  NameAndSignature += Chunk.Text;
+else
+  BeforeName += Chunk.Text;
+  }
+  NameAndSignature += " override";
+}
+
 CodeCompletionString *
 CodeCompletionResult::createCodeCompletionStringForOverride(
 Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result,
 bool IncludeBriefComments, const CodeCompletionContext &CCContext,
 PrintingPolicy &Policy) {
-  std::string OverrideSignature;
-  llvm::raw_string_ostream OS(OverrideSignature);
   auto *CCS = createCodeCompletionStringForDecl(PP, Ctx, Result,
 /*IncludeBriefComments=*/false,
 CCContext, Policy);
-  printOverrideString(OS, CCS);
-  OS << " override";
-  Result.AddTypedTextChunk(Result.getAllocator().CopyString(OS.str()));
+  std::string BeforeName;
+  std::string NameAndSignature;
+  // For overrides all chunks go into the result, none are informative.
+  printOverrideString(*C

[PATCH] D62298: [CodeComplete] Filter override completions by function name

2019-05-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:3172
+// Add a space after return type.
+if (Chunk.Kind == CodeCompletionString::CK_ResultType) {
+  assert(!SeenTypedChunk);

kadircet wrote:
> ilya-biryukov wrote:
> > kadircet wrote:
> > > do we expect anything but return type in the `BeforeName` or any case 
> > > where we shouldn't put a space between `BeforeName` and 
> > > `NameAndSignature` ?
> > > 
> > > why not let the user add a space while concatenating these two?
> > Maybe annotations? But not sure where they go (also not sure we should 
> > print them here).
> > I could move adding the space to the point where we concatenate 
> > `BeforeName` and `NameAndSignature` if that would make it clearer.
> I usually find it annoying when some helper function returns strings with 
> trailing whitespaces, which is not useful in the general case. (Faced those a 
> lot during `HoverInfo` patch.) I believe it would make the function more 
> usable to others, so let's make it part of concat logic.
Agree, it's cleaner that way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62298



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


[clang-tools-extra] r361616 - Fix sphinx "Malformed option description" warning

2019-05-24 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Fri May 24 02:31:32 2019
New Revision: 361616

URL: http://llvm.org/viewvc/llvm-project?rev=361616&view=rev
Log:
Fix sphinx "Malformed option description" warning

Modified:

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst?rev=361616&r1=361615&r2=361616&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
 Fri May 24 02:31:32 2019
@@ -35,7 +35,7 @@ Options
 
 .. option:: UseAssignment
If set to non-zero, the check will provide fix-its with literal initializers
-   (``int i = 0;``) instead of curly braces (``int i{};``).
+   \( ``int i = 0;`` \) instead of curly braces \( ``int i{};`` \).
 
 This rule is part of the "Type safety" profile of the C++ Core
 Guidelines, corresponding to rule Type.6. See


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


[PATCH] D62373: [ASTImporter] Store import errors for Decls

2019-05-24 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added a reviewer: a_sidorin.
Herald added subscribers: cfe-commits, gamesh411, Szelethus, dkrupp, rnkovacs.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: clang.

We add a new member which is a mapping from the already-imported
declarations in the "from" context to the error status of the import of
that declaration.  This map contains only the declarations that were not
correctly imported. The same declaration may or may not be included in
ImportedDecls. This map is updated continuously during imports and never
cleared (like ImportedDecls).  In Import(Decl*) we use this mapping, so
if there was a previous failed import we return with the existing error.

We add/remove from the Lookuptable in consistency with ImportedFromDecls.
When we map a decl in the 'to' context to something in the 'from'
context then and only then we add it to the lookup table. When we
remove a mapping then and only then we remove it from the lookup table.

This patch is the first in a series of patches whose aim is to further
strengthen the error handling in ASTImporter.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62373

Files:
  clang/include/clang/AST/ASTImporter.h
  clang/lib/AST/ASTImporter.cpp
  clang/test/ASTMerge/class-template-partial-spec/test.cpp

Index: clang/test/ASTMerge/class-template-partial-spec/test.cpp
===
--- clang/test/ASTMerge/class-template-partial-spec/test.cpp
+++ clang/test/ASTMerge/class-template-partial-spec/test.cpp
@@ -1,5 +1,3 @@
-// FIXME: Crashes after r357394
-// XFAIL: *
 // RUN: %clang_cc1 -emit-pch -std=c++1z -o %t.1.ast %S/Inputs/class-template-partial-spec1.cpp
 // RUN: %clang_cc1 -emit-pch -std=c++1z -o %t.2.ast %S/Inputs/class-template-partial-spec2.cpp
 // RUN: %clang_cc1 -std=c++1z -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -253,11 +253,10 @@
 LLVM_NODISCARD bool
 GetImportedOrCreateSpecialDecl(ToDeclT *&ToD, CreateFunT CreateFun,
FromDeclT *FromD, Args &&... args) {
-  // FIXME: This code is needed later.
-  //if (Importer.getImportDeclErrorIfAny(FromD)) {
-  //  ToD = nullptr;
-  //  return true; // Already imported but with error.
-  //}
+  if (Importer.getImportDeclErrorIfAny(FromD)) {
+ToD = nullptr;
+return true; // Already imported but with error.
+  }
   ToD = cast_or_null(Importer.GetAlreadyImportedOrNull(FromD));
   if (ToD)
 return true; // Already imported.
@@ -5108,7 +5107,7 @@
   }
 } else { // ODR violation.
   // FIXME HandleNameConflict
-  return nullptr;
+  return make_error(ImportError::NameConflict);
 }
   }
 
@@ -7730,7 +7729,6 @@
 
 void ASTImporter::RegisterImportedDecl(Decl *FromD, Decl *ToD) {
   MapImported(FromD, ToD);
-  AddToLookupTable(ToD);
 }
 
 Expected ASTImporter::Import(QualType FromT) {
@@ -7803,6 +7801,11 @@
 return nullptr;
 
 
+  // Check whether there was a previous failed import.
+  // If yes return the existing error.
+  if (auto Error = getImportDeclErrorIfAny(FromD))
+return make_error(*Error);
+
   // Check whether we've already imported this declaration.
   Decl *ToD = GetAlreadyImportedOrNull(FromD);
   if (ToD) {
@@ -7813,24 +7816,65 @@
 
   // Import the declaration.
   ExpectedDecl ToDOrErr = ImportImpl(FromD);
-  if (!ToDOrErr)
+  if (!ToDOrErr) {
+// Failed to import.
+
+auto Pos = ImportedDecls.find(FromD);
+if (Pos != ImportedDecls.end()) {
+  // Import failed after the object was created.
+  // Remove all references to it.
+  auto *ToD = Pos->second;
+  ImportedDecls.erase(Pos);
+
+  // ImportedDecls and ImportedFromDecls are not symmetric.  It may happen
+  // (e.g. with namespaces) that several decls from the 'from' context are
+  // mapped to the same decl in the 'to' context.  If we removed entries
+  // from the LookupTable here then we may end up removing them multiple
+  // times.
+
+  // The Lookuptable contains decls only which are in the 'to' context.
+  // Remove from the Lookuptable only if it is *imported* into the 'to'
+  // context (and do not remove it if it was added during the initial
+  // traverse of the 'to' context).
+  auto PosF = ImportedFromDecls.find(ToD);
+  if (PosF != ImportedFromDecls.end()) {
+if (LookupTable)
+  if (auto *ToND = dyn_cast(ToD))
+LookupTable->remove(ToND);
+ImportedFromDecls.erase(PosF);
+  }
+
+  // FIXME: AST may contain remaining references to the failed object.
+}
+
+if (!getImportDeclErrorIfAny(FromD)) {
+  // Error encountered for the first time.
+ 

[PATCH] D62298: [CodeComplete] Filter override completions by function name

2019-05-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 201164.
ilya-biryukov added a comment.

- Do not add an extra 'override' on optional chunks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62298

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/overrides.cpp

Index: clang/test/CodeCompletion/overrides.cpp
===
--- clang/test/CodeCompletion/overrides.cpp
+++ clang/test/CodeCompletion/overrides.cpp
@@ -11,23 +11,23 @@
 class C : public B {
  public:
   void vfunc(bool param) override;
-  void
+  vfo
 };
 
-// Runs completion at ^void.
+// Runs completion at ^vfo
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:3 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
 // CHECK-CC1: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC1-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
 //
-// Runs completion at vo^id.
+// Runs completion at vf^o
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:5 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
-// CHECK-CC2: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC2-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
+// CHECK-CC2: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC2-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
 //
-// Runs completion at void ^.
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:8 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// Runs completion at void ^ on line 13.
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:13:8 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
 // CHECK-CC3-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
 // CHECK-CC3-NOT: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC3-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -37,6 +37,7 @@
 #include "llvm/Support/Path.h"
 #include 
 #include 
+#include 
 #include 
 
 using namespace clang;
@@ -1828,19 +1829,6 @@
   Results.AddResult(CodeCompletionResult(Builder.TakeString()));
 }
 
-static void printOverrideString(llvm::raw_ostream &OS,
-CodeCompletionString *CCS) {
-  for (const auto &C : *CCS) {
-if (C.Kind == CodeCompletionString::CK_Optional)
-  printOverrideString(OS, C.Optional);
-else
-  OS << C.Text;
-// Add a space after return type.
-if (C.Kind == CodeCompletionString::CK_ResultType)
-  OS << ' ';
-  }
-}
-
 static void AddOverrideResults(ResultBuilder &Results,
const CodeCompletionContext &CCContext,
CodeCompletionBuilder &Builder) {
@@ -3162,19 +3150,44 @@
   PP, Ctx, Result, IncludeBriefComments, CCContext, Policy);
 }
 
+static void printOverrideString(const CodeCompletionString &CCS,
+   std::string &BeforeName,
+   std::string &NameAndSignature) {
+  bool SeenTypedChunk = false;
+  for (auto &Chunk : CCS) {
+if (Chunk.Kind == CodeCompletionString::CK_Optional) {
+  assert(SeenTypedChunk && "optional parameter before name");
+  // Note that we put all chunks inside into NameAndSignature.
+  printOverrideString(*Chunk.Optional, NameAndSignature,
+ NameAndSignature);
+  continue;
+}
+SeenTypedChunk |= Chunk.Kind == CodeCompletionString::CK_TypedText;
+if (SeenTypedChunk)
+  NameAndSignature += Chunk.Text;
+else
+  BeforeName += Chunk.Text;
+  }
+}
+
 CodeCompletionString *
 CodeCompletionResult::createCodeCompletionStringForOverride(
 Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result,
 bool IncludeBriefComments, const CodeCompletionContext &CCContext,
 PrintingPolicy &Policy) {
-  std::string OverrideSignature;
-  llvm::raw_string_ostream OS(OverrideSignature);
   auto *CCS = createCodeCompletionStringForDecl(PP, Ctx, Result,
 /*IncludeBriefComments=*/false,
 CCContext, Policy);
-  printOverrideString(OS, CCS);
-  OS << " override";
-  Result.AddTypedTextChunk(Result.getAllocator().CopyString(OS.str()));
+  std::string BeforeName;
+  std::string NameAndSignature;
+  // For overrides all chunks go into the result, none are informative.
+  printOverrideString(*CCS, BeforeName, NameAndSignature);
+  NameAndSignature += " override";
+
+  R

[PATCH] D62335: [OpenCL][PR41963] Add overloads of old atomics with generic pointer type in C++ mode

2019-05-24 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 201165.
Anastasia added a comment.

Fixed `atomic_max` and `atomic_min`. Thanks to David for pointing this out on 
the bug!


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

https://reviews.llvm.org/D62335

Files:
  lib/Headers/opencl-c.h
  test/Headers/opencl-c-header.cl

Index: test/Headers/opencl-c-header.cl
===
--- test/Headers/opencl-c-header.cl
+++ test/Headers/opencl-c-header.cl
@@ -73,6 +73,14 @@
 }
 #endif //__OPENCL_C_VERSION__
 
+#if defined(__OPENCL_CPP_VERSION__)
+void test_atomics(__generic volatile unsigned int* a)
+{
+atomic_add(a, 1);
+}
+#endif
+
+
 // Verify that non-builtin cl_intel_planar_yuv extension is defined from
 // OpenCL 1.2 onwards.
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -13340,6 +13340,10 @@
 unsigned int __ovld atomic_add(volatile __global unsigned int *p, unsigned int val);
 int __ovld atomic_add(volatile __local int *p, int val);
 unsigned int __ovld atomic_add(volatile __local unsigned int *p, unsigned int val);
+#ifdef __OPENCL_CPP_VERSION__
+int __ovld atomic_add(volatile int *p, int val);
+unsigned int __ovld atomic_add(volatile unsigned int *p, unsigned int val);
+#endif
 
 #if defined(cl_khr_global_int32_base_atomics)
 int __ovld atom_add(volatile __global int *p, int val);
@@ -13366,6 +13370,10 @@
 unsigned int __ovld atomic_sub(volatile __global unsigned int *p, unsigned int val);
 int __ovld atomic_sub(volatile __local int *p, int val);
 unsigned int __ovld atomic_sub(volatile __local unsigned int *p, unsigned int val);
+#ifdef __OPENCL_CPP_VERSION__
+int __ovld atomic_sub(volatile int *p, int val);
+unsigned int __ovld atomic_sub(volatile unsigned int *p, unsigned int val);
+#endif
 
 #if defined(cl_khr_global_int32_base_atomics)
 int __ovld atom_sub(volatile __global int *p, int val);
@@ -13394,6 +13402,11 @@
 unsigned int __ovld atomic_xchg(volatile __local unsigned int *p, unsigned int val);
 float __ovld atomic_xchg(volatile __global float *p, float val);
 float __ovld atomic_xchg(volatile __local float *p, float val);
+#ifdef __OPENCL_CPP_VERSION__
+int __ovld atomic_xchg(volatile int *p, int val);
+unsigned int __ovld atomic_xchg(volatile unsigned int *p, unsigned int val);
+float __ovld atomic_xchg(volatile float *p, float val);
+#endif
 
 #if defined(cl_khr_global_int32_base_atomics)
 int __ovld atom_xchg(volatile __global int *p, int val);
@@ -13421,6 +13434,10 @@
 unsigned int __ovld atomic_inc(volatile __global unsigned int *p);
 int __ovld atomic_inc(volatile __local int *p);
 unsigned int __ovld atomic_inc(volatile __local unsigned int *p);
+#ifdef __OPENCL_CPP_VERSION__
+int __ovld atomic_inc(volatile int *p);
+unsigned int __ovld atomic_inc(volatile unsigned int *p);
+#endif
 
 #if defined(cl_khr_global_int32_base_atomics)
 int __ovld atom_inc(volatile __global int *p);
@@ -13448,6 +13465,10 @@
 unsigned int __ovld atomic_dec(volatile __global unsigned int *p);
 int __ovld atomic_dec(volatile __local int *p);
 unsigned int __ovld atomic_dec(volatile __local unsigned int *p);
+#ifdef __OPENCL_CPP_VERSION__
+int __ovld atomic_dec(volatile int *p);
+unsigned int __ovld atomic_dec(volatile unsigned int *p);
+#endif
 
 #if defined(cl_khr_global_int32_base_atomics)
 int __ovld atom_dec(volatile __global int *p);
@@ -13476,6 +13497,10 @@
 unsigned int __ovld atomic_cmpxchg(volatile __global unsigned int *p, unsigned int cmp, unsigned int val);
 int __ovld atomic_cmpxchg(volatile __local int *p, int cmp, int val);
 unsigned int __ovld atomic_cmpxchg(volatile __local unsigned int *p, unsigned int cmp, unsigned int val);
+#ifdef __OPENCL_CPP_VERSION__
+int __ovld atomic_cmpxchg(volatile int *p, int cmp, int val);
+unsigned int __ovld atomic_cmpxchg(volatile unsigned int *p, unsigned int cmp, unsigned int val);
+#endif
 
 #if defined(cl_khr_global_int32_base_atomics)
 int __ovld atom_cmpxchg(volatile __global int *p, int cmp, int val);
@@ -13504,6 +13529,10 @@
 unsigned int __ovld atomic_min(volatile __global unsigned int *p, unsigned int val);
 int __ovld atomic_min(volatile __local int *p, int val);
 unsigned int __ovld atomic_min(volatile __local unsigned int *p, unsigned int val);
+#ifdef __OPENCL_CPP_VERSION__
+int __ovld atomic_min(volatile int *p, int val);
+unsigned int __ovld atomic_min(volatile unsigned int *p, unsigned int val);
+#endif
 
 #if defined(cl_khr_global_int32_extended_atomics)
 int __ovld atom_min(volatile __global int *p, int val);
@@ -13532,6 +13561,10 @@
 unsigned int __ovld atomic_max(volatile __global unsigned int *p, unsigned int val);
 int __ovld atomic_max(volatile __local int *p, int val);
 unsigned int __ovld atomic_max(volatile __local unsigned int *p, unsigned int val);
+#ifdef __OPENCL_CPP_VERSION__
+int __

[PATCH] D62298: [CodeComplete] Filter override completions by function name

2019-05-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 201168.
ilya-biryukov added a comment.

- Update a comment in the test
- Reformat the code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62298

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/overrides.cpp

Index: clang/test/CodeCompletion/overrides.cpp
===
--- clang/test/CodeCompletion/overrides.cpp
+++ clang/test/CodeCompletion/overrides.cpp
@@ -11,23 +11,23 @@
 class C : public B {
  public:
   void vfunc(bool param) override;
-  void
+  vf
 };
 
-// Runs completion at ^void.
+// Runs completion at ^vf
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:3 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
 // CHECK-CC1: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC1-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
 //
-// Runs completion at vo^id.
+// Runs completion at vf^
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:5 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
-// CHECK-CC2: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC2-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
+// CHECK-CC2: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC2-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
 //
-// Runs completion at void ^.
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:8 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// Runs completion at void ^ on line 13.
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:13:8 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
 // CHECK-CC3-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
 // CHECK-CC3-NOT: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC3-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -37,6 +37,7 @@
 #include "llvm/Support/Path.h"
 #include 
 #include 
+#include 
 #include 
 
 using namespace clang;
@@ -1828,19 +1829,6 @@
   Results.AddResult(CodeCompletionResult(Builder.TakeString()));
 }
 
-static void printOverrideString(llvm::raw_ostream &OS,
-CodeCompletionString *CCS) {
-  for (const auto &C : *CCS) {
-if (C.Kind == CodeCompletionString::CK_Optional)
-  printOverrideString(OS, C.Optional);
-else
-  OS << C.Text;
-// Add a space after return type.
-if (C.Kind == CodeCompletionString::CK_ResultType)
-  OS << ' ';
-  }
-}
-
 static void AddOverrideResults(ResultBuilder &Results,
const CodeCompletionContext &CCContext,
CodeCompletionBuilder &Builder) {
@@ -3162,19 +3150,43 @@
   PP, Ctx, Result, IncludeBriefComments, CCContext, Policy);
 }
 
+static void printOverrideString(const CodeCompletionString &CCS,
+std::string &BeforeName,
+std::string &NameAndSignature) {
+  bool SeenTypedChunk = false;
+  for (auto &Chunk : CCS) {
+if (Chunk.Kind == CodeCompletionString::CK_Optional) {
+  assert(SeenTypedChunk && "optional parameter before name");
+  // Note that we put all chunks inside into NameAndSignature.
+  printOverrideString(*Chunk.Optional, NameAndSignature, NameAndSignature);
+  continue;
+}
+SeenTypedChunk |= Chunk.Kind == CodeCompletionString::CK_TypedText;
+if (SeenTypedChunk)
+  NameAndSignature += Chunk.Text;
+else
+  BeforeName += Chunk.Text;
+  }
+}
+
 CodeCompletionString *
 CodeCompletionResult::createCodeCompletionStringForOverride(
 Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result,
 bool IncludeBriefComments, const CodeCompletionContext &CCContext,
 PrintingPolicy &Policy) {
-  std::string OverrideSignature;
-  llvm::raw_string_ostream OS(OverrideSignature);
   auto *CCS = createCodeCompletionStringForDecl(PP, Ctx, Result,
 /*IncludeBriefComments=*/false,
 CCContext, Policy);
-  printOverrideString(OS, CCS);
-  OS << " override";
-  Result.AddTypedTextChunk(Result.getAllocator().CopyString(OS.str()));
+  std::string BeforeName;
+  std::string NameAndSignature;
+  // For overrides all chunks go into the result, none are informative.
+  printOverrideString(*CCS, BeforeName, NameAndSignature);
+  NameAndSignature += " override";
+
+  Result.AddTextChunk(Result.getAllocator()

[PATCH] D62298: [CodeComplete] Filter override completions by function name

2019-05-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 201167.
ilya-biryukov added a comment.

- Remove redundant test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62298

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/overrides.cpp

Index: clang/test/CodeCompletion/overrides.cpp
===
--- clang/test/CodeCompletion/overrides.cpp
+++ clang/test/CodeCompletion/overrides.cpp
@@ -11,23 +11,23 @@
 class C : public B {
  public:
   void vfunc(bool param) override;
-  void
+  vf
 };
 
-// Runs completion at ^void.
+// Runs completion at ^vfo
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:3 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
 // CHECK-CC1: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC1-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
 //
-// Runs completion at vo^id.
+// Runs completion at vf^o
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:5 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
-// CHECK-CC2: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC2-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
+// CHECK-CC2: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC2-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
 //
-// Runs completion at void ^.
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:8 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// Runs completion at void ^ on line 13.
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:13:8 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
 // CHECK-CC3-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
 // CHECK-CC3-NOT: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHECK-CC3-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -37,6 +37,7 @@
 #include "llvm/Support/Path.h"
 #include 
 #include 
+#include 
 #include 
 
 using namespace clang;
@@ -1828,19 +1829,6 @@
   Results.AddResult(CodeCompletionResult(Builder.TakeString()));
 }
 
-static void printOverrideString(llvm::raw_ostream &OS,
-CodeCompletionString *CCS) {
-  for (const auto &C : *CCS) {
-if (C.Kind == CodeCompletionString::CK_Optional)
-  printOverrideString(OS, C.Optional);
-else
-  OS << C.Text;
-// Add a space after return type.
-if (C.Kind == CodeCompletionString::CK_ResultType)
-  OS << ' ';
-  }
-}
-
 static void AddOverrideResults(ResultBuilder &Results,
const CodeCompletionContext &CCContext,
CodeCompletionBuilder &Builder) {
@@ -3162,19 +3150,44 @@
   PP, Ctx, Result, IncludeBriefComments, CCContext, Policy);
 }
 
+static void printOverrideString(const CodeCompletionString &CCS,
+   std::string &BeforeName,
+   std::string &NameAndSignature) {
+  bool SeenTypedChunk = false;
+  for (auto &Chunk : CCS) {
+if (Chunk.Kind == CodeCompletionString::CK_Optional) {
+  assert(SeenTypedChunk && "optional parameter before name");
+  // Note that we put all chunks inside into NameAndSignature.
+  printOverrideString(*Chunk.Optional, NameAndSignature,
+ NameAndSignature);
+  continue;
+}
+SeenTypedChunk |= Chunk.Kind == CodeCompletionString::CK_TypedText;
+if (SeenTypedChunk)
+  NameAndSignature += Chunk.Text;
+else
+  BeforeName += Chunk.Text;
+  }
+}
+
 CodeCompletionString *
 CodeCompletionResult::createCodeCompletionStringForOverride(
 Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result,
 bool IncludeBriefComments, const CodeCompletionContext &CCContext,
 PrintingPolicy &Policy) {
-  std::string OverrideSignature;
-  llvm::raw_string_ostream OS(OverrideSignature);
   auto *CCS = createCodeCompletionStringForDecl(PP, Ctx, Result,
 /*IncludeBriefComments=*/false,
 CCContext, Policy);
-  printOverrideString(OS, CCS);
-  OS << " override";
-  Result.AddTypedTextChunk(Result.getAllocator().CopyString(OS.str()));
+  std::string BeforeName;
+  std::string NameAndSignature;
+  // For overrides all chunks go into the result, none are informative.
+  printOverrideString(*CCS, BeforeName, NameAndSignature);
+  NameAndSignature += " override";
+
+  Result.AddTextChunk(Result.get

[PATCH] D62375: [ASTImporter] Mark erroneous nodes in from ctx

2019-05-24 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added a reviewer: a_sidorin.
Herald added subscribers: cfe-commits, gamesh411, Szelethus, dkrupp, rnkovacs.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: clang.

During import of a specific Decl D, it may happen that some AST nodes
had already been created before we recognize an error. In this case we
signal back the error to the caller, but the "to" context remains
polluted with those nodes which had been created. Ideally, those nodes
should not had been created, but that time we did not know about the
error, the error happened later.  Since the AST is immutable (most of
the cases we can't remove existing nodes) we choose to mark these nodes
as erroneous.
Here are the steps of the algorithm:

1. We keep track of the nodes which we visit during the import of D: See

ImportPathTy.

2. If a Decl is already imported and it is already on the import path

(we have a cycle) then we copy/store the relevant part of the import
path. We store these cycles for each Decl.

3. When we recognize an error during the import of D then we set up this

error to all Decls in the stored cycles for D and we clear the stored
cycles.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62375

Files:
  clang/include/clang/AST/ASTImporter.h
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -358,6 +358,106 @@
   EXPECT_EQ(0U, count);
 }
 
+struct ImportPath : ASTImporterOptionSpecificTestBase {
+  Decl *FromTU;
+  FunctionDecl *D0, *D1, *D2;
+  ImportPath() {
+FromTU = getTuDecl("void f(); void f(); void f();", Lang_CXX);
+auto Pattern = functionDecl(hasName("f"));
+D0 = FirstDeclMatcher().match(FromTU, Pattern);
+D2 = LastDeclMatcher().match(FromTU, Pattern);
+D1 = D2->getPreviousDecl();
+  }
+};
+
+TEST_P(ImportPath, Push) {
+  ASTImporter::ImportPathTy path;
+  path.push(D0);
+  EXPECT_FALSE(path.hasCycleAtBack());
+}
+
+TEST_P(ImportPath, SmallCycle) {
+  ASTImporter::ImportPathTy path;
+  path.push(D0);
+  path.push(D0);
+  EXPECT_TRUE(path.hasCycleAtBack());
+  path.pop();
+  EXPECT_FALSE(path.hasCycleAtBack());
+  path.push(D0);
+  EXPECT_TRUE(path.hasCycleAtBack());
+}
+
+TEST_P(ImportPath, GetSmallCycle) {
+  ASTImporter::ImportPathTy path;
+  path.push(D0);
+  path.push(D0);
+  EXPECT_TRUE(path.hasCycleAtBack());
+  std::array Res;
+  int i = 0;
+  for (Decl *Di : path.getCycleAtBack()) {
+Res[i++] = Di;
+  }
+  ASSERT_EQ(i, 2);
+  EXPECT_EQ(Res[0], D0);
+  EXPECT_EQ(Res[1], D0);
+}
+
+TEST_P(ImportPath, GetCycle) {
+  ASTImporter::ImportPathTy path;
+  path.push(D0);
+  path.push(D1);
+  path.push(D2);
+  path.push(D0);
+  EXPECT_TRUE(path.hasCycleAtBack());
+  std::array Res;
+  int i = 0;
+  for (Decl *Di : path.getCycleAtBack()) {
+Res[i++] = Di;
+  }
+  ASSERT_EQ(i, 4);
+  EXPECT_EQ(Res[0], D0);
+  EXPECT_EQ(Res[1], D2);
+  EXPECT_EQ(Res[2], D1);
+  EXPECT_EQ(Res[3], D0);
+}
+
+TEST_P(ImportPath, CycleAfterCycle) {
+  ASTImporter::ImportPathTy path;
+  path.push(D0);
+  path.push(D1);
+  path.push(D0);
+  path.push(D1);
+  path.push(D2);
+  path.push(D0);
+  EXPECT_TRUE(path.hasCycleAtBack());
+  std::array Res;
+  int i = 0;
+  for (Decl *Di : path.getCycleAtBack()) {
+Res[i++] = Di;
+  }
+  ASSERT_EQ(i, 4);
+  EXPECT_EQ(Res[0], D0);
+  EXPECT_EQ(Res[1], D2);
+  EXPECT_EQ(Res[2], D1);
+  EXPECT_EQ(Res[3], D0);
+
+  path.pop();
+  path.pop();
+  path.pop();
+  EXPECT_TRUE(path.hasCycleAtBack());
+  i = 0;
+  for (Decl *Di : path.getCycleAtBack()) {
+Res[i++] = Di;
+  }
+  ASSERT_EQ(i, 3);
+  EXPECT_EQ(Res[0], D0);
+  EXPECT_EQ(Res[1], D1);
+  EXPECT_EQ(Res[2], D0);
+
+  path.pop();
+  EXPECT_FALSE(path.hasCycleAtBack());
+}
+
 TEST_P(ImportExpr, ImportStringLiteral) {
   MatchVerifier Verifier;
   testImport(
@@ -4501,12 +4601,6 @@
   EXPECT_EQ(*Res.begin(), A);
 }
 
-INSTANTIATE_TEST_CASE_P(ParameterizedTests, DeclContextTest,
-::testing::Values(ArgVector()), );
-
-INSTANTIATE_TEST_CASE_P(
-ParameterizedTests, CanonicalRedeclChain,
-::testing::Values(ArgVector()),);
 
 // FIXME This test is disabled currently, upcoming patches will make it
 // possible to enable.
@@ -4574,9 +4668,18 @@
   EXPECT_EQ(Imported->getPreviousDecl(), Friend);
 }
 
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, DeclContextTest,
+::testing::Values(ArgVector()), );
+
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, CanonicalRedeclChain,
+::testing::Values(ArgVector()), );
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportPath,
+::testing::Values(ArgVec

[PATCH] D62372: [clangd] Limit the size of synthesized fix message

2019-05-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!




Comment at: clang-tools-extra/clangd/Diagnostics.cpp:449
+
+  size_t FirstNewline = R.find('\n');
+  if (FirstNewline != llvm::StringRef::npos)

or maybe just `R = Code.split('\n').first` ?



Comment at: clang-tools-extra/clangd/Diagnostics.cpp:452
+R = R.take_front(FirstNewline);
+  if (R.size() > MaxLen)
+R = R.take_front(MaxLen);

no need for the check, already performed in take_front.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62372



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


[clang-tools-extra] r361623 - [CodeComplete] Filter override completions by function name

2019-05-24 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Fri May 24 03:18:39 2019
New Revision: 361623

URL: http://llvm.org/viewvc/llvm-project?rev=361623&view=rev
Log:
[CodeComplete] Filter override completions by function name

Summary:
We put only part of the signature starting with a function name into "typed 
text"
chunks now, previously the whole signature was "typed text".

This leads to meaningful fuzzy match scores, giving better signals to
compare with other completion items.

Ideally, we would not display the result type to the user, but that requires 
adding
a new kind of completion chunk.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: jkorous, arphaman, cfe-commits

Tags: #clang

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

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

Modified: clang-tools-extra/trunk/clangd/unittests/CodeCompleteTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/CodeCompleteTests.cpp?rev=361623&r1=361622&r2=361623&view=diff
==
--- clang-tools-extra/trunk/clangd/unittests/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/CodeCompleteTests.cpp Fri May 24 
03:18:39 2019
@@ -49,6 +49,9 @@ class IgnoreDiagnostics : public Diagnos
 
 // GMock helpers for matching completion items.
 MATCHER_P(Named, Name, "") { return arg.Name == Name; }
+MATCHER_P(NameStartsWith, Prefix, "") {
+  return llvm::StringRef(arg.Name).startswith(Prefix);
+}
 MATCHER_P(Scope, S, "") { return arg.Scope == S; }
 MATCHER_P(Qualifier, Q, "") { return arg.RequiredQualifier == Q; }
 MATCHER_P(Labeled, Label, "") {
@@ -1946,10 +1949,13 @@ TEST(CompletionTest, SuggestOverrides) {
   };
   )cpp");
   const auto Results = completions(Text);
-  EXPECT_THAT(Results.Completions,
-  AllOf(Contains(Labeled("void vfunc(bool param, int p) 
override")),
-Contains(Labeled("void ttt(bool param) const override")),
-Not(Contains(Labeled("void vfunc(bool param) 
override");
+  EXPECT_THAT(
+  Results.Completions,
+  AllOf(Contains(AllOf(Labeled("void vfunc(bool param, int p) override"),
+   NameStartsWith("vfunc"))),
+Contains(AllOf(Labeled("void ttt(bool param) const override"),
+   NameStartsWith("ttt"))),
+Not(Contains(Labeled("void vfunc(bool param) override");
 }
 
 TEST(CompletionTest, OverridesNonIdentName) {


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


r361623 - [CodeComplete] Filter override completions by function name

2019-05-24 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Fri May 24 03:18:39 2019
New Revision: 361623

URL: http://llvm.org/viewvc/llvm-project?rev=361623&view=rev
Log:
[CodeComplete] Filter override completions by function name

Summary:
We put only part of the signature starting with a function name into "typed 
text"
chunks now, previously the whole signature was "typed text".

This leads to meaningful fuzzy match scores, giving better signals to
compare with other completion items.

Ideally, we would not display the result type to the user, but that requires 
adding
a new kind of completion chunk.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: jkorous, arphaman, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/CodeCompletion/overrides.cpp

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=361623&r1=361622&r2=361623&view=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Fri May 24 03:18:39 2019
@@ -37,6 +37,7 @@
 #include "llvm/Support/Path.h"
 #include 
 #include 
+#include 
 #include 
 
 using namespace clang;
@@ -1828,19 +1829,6 @@ static void AddStaticAssertResult(CodeCo
   Results.AddResult(CodeCompletionResult(Builder.TakeString()));
 }
 
-static void printOverrideString(llvm::raw_ostream &OS,
-CodeCompletionString *CCS) {
-  for (const auto &C : *CCS) {
-if (C.Kind == CodeCompletionString::CK_Optional)
-  printOverrideString(OS, C.Optional);
-else
-  OS << C.Text;
-// Add a space after return type.
-if (C.Kind == CodeCompletionString::CK_ResultType)
-  OS << ' ';
-  }
-}
-
 static void AddOverrideResults(ResultBuilder &Results,
const CodeCompletionContext &CCContext,
CodeCompletionBuilder &Builder) {
@@ -3162,19 +3150,42 @@ CodeCompletionString *CodeCompletionResu
   PP, Ctx, Result, IncludeBriefComments, CCContext, Policy);
 }
 
+static void printOverrideString(const CodeCompletionString &CCS,
+std::string &BeforeName,
+std::string &NameAndSignature) {
+  bool SeenTypedChunk = false;
+  for (auto &Chunk : CCS) {
+if (Chunk.Kind == CodeCompletionString::CK_Optional) {
+  assert(SeenTypedChunk && "optional parameter before name");
+  // Note that we put all chunks inside into NameAndSignature.
+  printOverrideString(*Chunk.Optional, NameAndSignature, NameAndSignature);
+  continue;
+}
+SeenTypedChunk |= Chunk.Kind == CodeCompletionString::CK_TypedText;
+if (SeenTypedChunk)
+  NameAndSignature += Chunk.Text;
+else
+  BeforeName += Chunk.Text;
+  }
+}
+
 CodeCompletionString *
 CodeCompletionResult::createCodeCompletionStringForOverride(
 Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result,
 bool IncludeBriefComments, const CodeCompletionContext &CCContext,
 PrintingPolicy &Policy) {
-  std::string OverrideSignature;
-  llvm::raw_string_ostream OS(OverrideSignature);
   auto *CCS = createCodeCompletionStringForDecl(PP, Ctx, Result,
 /*IncludeBriefComments=*/false,
 CCContext, Policy);
-  printOverrideString(OS, CCS);
-  OS << " override";
-  Result.AddTypedTextChunk(Result.getAllocator().CopyString(OS.str()));
+  std::string BeforeName;
+  std::string NameAndSignature;
+  // For overrides all chunks go into the result, none are informative.
+  printOverrideString(*CCS, BeforeName, NameAndSignature);
+  NameAndSignature += " override";
+
+  Result.AddTextChunk(Result.getAllocator().CopyString(BeforeName));
+  Result.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  Result.AddTypedTextChunk(Result.getAllocator().CopyString(NameAndSignature));
   return Result.TakeString();
 }
 

Modified: cfe/trunk/test/CodeCompletion/overrides.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/overrides.cpp?rev=361623&r1=361622&r2=361623&view=diff
==
--- cfe/trunk/test/CodeCompletion/overrides.cpp (original)
+++ cfe/trunk/test/CodeCompletion/overrides.cpp Fri May 24 03:18:39 2019
@@ -11,23 +11,23 @@ void vfunc(bool param, int p) override;
 class C : public B {
  public:
   void vfunc(bool param) override;
-  void
+  vf
 };
 
-// Runs completion at ^void.
+// Runs completion at ^vf
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:3 %s -o - | 
FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: COMPLETION: Pattern : int ttt(bool param, int x = 3) const 
override{{$}}
 // CHECK-CC1: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
 // CHEC

[PATCH] D62298: [CodeComplete] Filter override completions by function name

2019-05-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE361623: [CodeComplete] Filter override completions by 
function name (authored by ibiryukov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62298?vs=201168&id=201178#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D62298

Files:
  clangd/unittests/CodeCompleteTests.cpp


Index: clangd/unittests/CodeCompleteTests.cpp
===
--- clangd/unittests/CodeCompleteTests.cpp
+++ clangd/unittests/CodeCompleteTests.cpp
@@ -49,6 +49,9 @@
 
 // GMock helpers for matching completion items.
 MATCHER_P(Named, Name, "") { return arg.Name == Name; }
+MATCHER_P(NameStartsWith, Prefix, "") {
+  return llvm::StringRef(arg.Name).startswith(Prefix);
+}
 MATCHER_P(Scope, S, "") { return arg.Scope == S; }
 MATCHER_P(Qualifier, Q, "") { return arg.RequiredQualifier == Q; }
 MATCHER_P(Labeled, Label, "") {
@@ -1946,10 +1949,13 @@
   };
   )cpp");
   const auto Results = completions(Text);
-  EXPECT_THAT(Results.Completions,
-  AllOf(Contains(Labeled("void vfunc(bool param, int p) 
override")),
-Contains(Labeled("void ttt(bool param) const override")),
-Not(Contains(Labeled("void vfunc(bool param) 
override");
+  EXPECT_THAT(
+  Results.Completions,
+  AllOf(Contains(AllOf(Labeled("void vfunc(bool param, int p) override"),
+   NameStartsWith("vfunc"))),
+Contains(AllOf(Labeled("void ttt(bool param) const override"),
+   NameStartsWith("ttt"))),
+Not(Contains(Labeled("void vfunc(bool param) override");
 }
 
 TEST(CompletionTest, OverridesNonIdentName) {


Index: clangd/unittests/CodeCompleteTests.cpp
===
--- clangd/unittests/CodeCompleteTests.cpp
+++ clangd/unittests/CodeCompleteTests.cpp
@@ -49,6 +49,9 @@
 
 // GMock helpers for matching completion items.
 MATCHER_P(Named, Name, "") { return arg.Name == Name; }
+MATCHER_P(NameStartsWith, Prefix, "") {
+  return llvm::StringRef(arg.Name).startswith(Prefix);
+}
 MATCHER_P(Scope, S, "") { return arg.Scope == S; }
 MATCHER_P(Qualifier, Q, "") { return arg.RequiredQualifier == Q; }
 MATCHER_P(Labeled, Label, "") {
@@ -1946,10 +1949,13 @@
   };
   )cpp");
   const auto Results = completions(Text);
-  EXPECT_THAT(Results.Completions,
-  AllOf(Contains(Labeled("void vfunc(bool param, int p) override")),
-Contains(Labeled("void ttt(bool param) const override")),
-Not(Contains(Labeled("void vfunc(bool param) override");
+  EXPECT_THAT(
+  Results.Completions,
+  AllOf(Contains(AllOf(Labeled("void vfunc(bool param, int p) override"),
+   NameStartsWith("vfunc"))),
+Contains(AllOf(Labeled("void ttt(bool param) const override"),
+   NameStartsWith("ttt"))),
+Not(Contains(Labeled("void vfunc(bool param) override");
 }
 
 TEST(CompletionTest, OverridesNonIdentName) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62372: [clangd] Limit the size of synthesized fix message

2019-05-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 201179.
ilya-biryukov marked 2 inline comments as done.
ilya-biryukov added a comment.

- Address comments, simplify


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62372

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

Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -120,7 +120,7 @@
  "use of undeclared identifier 'goo'; did you mean 'foo'?"),
 DiagSource(Diag::Clang), DiagName("undeclared_var_use_suggest"),
 WithFix(
-Fix(Test.range("typo"), "foo", "change 'go\\ o' to 'foo'")),
+Fix(Test.range("typo"), "foo", "change 'go\\…' to 'foo'")),
 // This is a pretty normal range.
 WithNote(Diag(Test.range("decl"), "'foo' declared here"))),
   // This range is zero-width and insertion. Therefore make sure we are
@@ -247,6 +247,36 @@
   DiagSeverity(DiagnosticsEngine::Error;
 }
 
+TEST(DiagnosticTest, LongFixMessages) {
+  // We limit the size of printed code.
+  Annotations Source(R"cpp(
+int main() {
+  int somereallyreallyreallyreallyreallyreallyreallyreallylongidentifier;
+  [[omereallyreallyreallyreallyreallyreallyreallyreallylongidentifier]]= 10;
+}
+  )cpp");
+  TestTU TU = TestTU::withCode(Source.code());
+  EXPECT_THAT(
+  TU.build().getDiagnostics(),
+  ElementsAre(WithFix(Fix(
+  Source.range(),
+  "somereallyreallyreallyreallyreallyreallyreallyreallylongidentifier",
+  "change 'omereallyreallyreallyreallyreallyreallyreallyreall…' to "
+  "'somereallyreallyreallyreallyreallyreallyreallyreal…'";
+  // Only show changes up to a first newline.
+  Source = Annotations(R"cpp(
+int main() {
+  int ident;
+  [[ide\
+n]] = 10;
+}
+  )cpp");
+  TU = TestTU::withCode(Source.code());
+  EXPECT_THAT(TU.build().getDiagnostics(),
+  ElementsAre(WithFix(
+  Fix(Source.range(), "ident", "change 'ide\\…' to 'ident'";
+}
+
 TEST(DiagnosticTest, ClangTidyWarningAsErrorTrumpsSuppressionComment) {
   Annotations Main(R"cpp(
 int main() {
Index: clang-tools-extra/clangd/Diagnostics.cpp
===
--- clang-tools-extra/clangd/Diagnostics.cpp
+++ clang-tools-extra/clangd/Diagnostics.cpp
@@ -25,7 +25,9 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -437,6 +439,21 @@
   LangOpts = None;
 }
 
+/// Sanitizes a piece for presenting it in a synthesized fix message. Ensures
+/// the result is not too large and does not contain newlines.
+static void writeCodeToFixMessage(llvm::raw_ostream &OS, llvm::StringRef Code) {
+  constexpr unsigned MaxLen = 50;
+
+  // Only show the first line if there are many.
+  llvm::StringRef R = Code.split('\n').first;
+  // Shorten the message if it's too long.
+  R = R.take_front(MaxLen);
+
+  OS << R;
+  if (R.size() != Code.size())
+OS << "…";
+}
+
 void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
   const clang::Diagnostic &Info) {
   DiagnosticConsumer::HandleDiagnostic(DiagLevel, Info);
@@ -494,12 +511,23 @@
   llvm::StringRef Insert = FixIt.CodeToInsert;
   if (!Invalid) {
 llvm::raw_svector_ostream M(Message);
-if (!Remove.empty() && !Insert.empty())
-  M << "change '" << Remove << "' to '" << Insert << "'";
-else if (!Remove.empty())
-  M << "remove '" << Remove << "'";
-else if (!Insert.empty())
-  M << "insert '" << Insert << "'";
+if (!Remove.empty() && !Insert.empty()) {
+  M << "change '";
+  writeCodeToFixMessage(M, Remove);
+  M << "' to '";
+  writeCodeToFixMessage(M, Insert);
+  M << "'";
+}
+else if (!Remove.empty()) {
+  M << "remove '";
+  writeCodeToFixMessage(M, Remove);
+  M << "'";
+}
+else if (!Insert.empty()) {
+  M << "insert '";
+  writeCodeToFixMessage(M, Insert);
+  M << "'";
+}
 // Don't allow source code to inject newlines into diagnostics.
 std::replace(Message.begin(), Message.end(), '\n', ' ');
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r361625 - [clangd] Limit the size of synthesized fix message

2019-05-24 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Fri May 24 03:26:23 2019
New Revision: 361625

URL: http://llvm.org/viewvc/llvm-project?rev=361625&view=rev
Log:
[clangd] Limit the size of synthesized fix message

Summary: A temporary workaround until we figure out a better way to present 
fixes.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

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

Modified: clang-tools-extra/trunk/clangd/Diagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Diagnostics.cpp?rev=361625&r1=361624&r2=361625&view=diff
==
--- clang-tools-extra/trunk/clangd/Diagnostics.cpp (original)
+++ clang-tools-extra/trunk/clangd/Diagnostics.cpp Fri May 24 03:26:23 2019
@@ -25,7 +25,9 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -437,6 +439,21 @@ void StoreDiags::EndSourceFile() {
   LangOpts = None;
 }
 
+/// Sanitizes a piece for presenting it in a synthesized fix message. Ensures
+/// the result is not too large and does not contain newlines.
+static void writeCodeToFixMessage(llvm::raw_ostream &OS, llvm::StringRef Code) 
{
+  constexpr unsigned MaxLen = 50;
+
+  // Only show the first line if there are many.
+  llvm::StringRef R = Code.split('\n').first;
+  // Shorten the message if it's too long.
+  R = R.take_front(MaxLen);
+
+  OS << R;
+  if (R.size() != Code.size())
+OS << "…";
+}
+
 void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
   const clang::Diagnostic &Info) {
   DiagnosticConsumer::HandleDiagnostic(DiagLevel, Info);
@@ -494,12 +511,21 @@ void StoreDiags::HandleDiagnostic(Diagno
   llvm::StringRef Insert = FixIt.CodeToInsert;
   if (!Invalid) {
 llvm::raw_svector_ostream M(Message);
-if (!Remove.empty() && !Insert.empty())
-  M << "change '" << Remove << "' to '" << Insert << "'";
-else if (!Remove.empty())
-  M << "remove '" << Remove << "'";
-else if (!Insert.empty())
-  M << "insert '" << Insert << "'";
+if (!Remove.empty() && !Insert.empty()) {
+  M << "change '";
+  writeCodeToFixMessage(M, Remove);
+  M << "' to '";
+  writeCodeToFixMessage(M, Insert);
+  M << "'";
+} else if (!Remove.empty()) {
+  M << "remove '";
+  writeCodeToFixMessage(M, Remove);
+  M << "'";
+} else if (!Insert.empty()) {
+  M << "insert '";
+  writeCodeToFixMessage(M, Insert);
+  M << "'";
+}
 // Don't allow source code to inject newlines into diagnostics.
 std::replace(Message.begin(), Message.end(), '\n', ' ');
   }

Modified: clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp?rev=361625&r1=361624&r2=361625&view=diff
==
--- clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp Fri May 24 
03:26:23 2019
@@ -120,7 +120,7 @@ o]]();
  "use of undeclared identifier 'goo'; did you mean 
'foo'?"),
 DiagSource(Diag::Clang), 
DiagName("undeclared_var_use_suggest"),
 WithFix(
-Fix(Test.range("typo"), "foo", "change 'go\\ o' to 
'foo'")),
+Fix(Test.range("typo"), "foo", "change 'go\\…' to 
'foo'")),
 // This is a pretty normal range.
 WithNote(Diag(Test.range("decl"), "'foo' declared here"))),
   // This range is zero-width and insertion. Therefore make sure we are
@@ -247,6 +247,36 @@ TEST(DiagnosticTest, ClangTidyWarningAsE
   DiagSeverity(DiagnosticsEngine::Error;
 }
 
+TEST(DiagnosticTest, LongFixMessages) {
+  // We limit the size of printed code.
+  Annotations Source(R"cpp(
+int main() {
+  int somereallyreallyreallyreallyreallyreallyreallyreallylongidentifier;
+  [[omereallyreallyreallyreallyreallyreallyreallyreallylongidentifier]]= 
10;
+}
+  )cpp");
+  TestTU TU = TestTU::withCode(Source.code());
+  EXPECT_THAT(
+  TU.build().getDiagnostics(),
+  ElementsAre(WithFix(Fix(
+  Source.range(),
+  "somereallyreallyreallyreallyreallyreallyreallyreallylongidentifier",
+  "change 'omereallyreallyreallyreallyreallyreallyreallyreall…' to "
+  "'somereallyreallyreallyreallyreallyreallyreallyreal…'";
+  // Only show changes up to 

[PATCH] D62372: [clangd] Limit the size of synthesized fix message

2019-05-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE361625: [clangd] Limit the size of synthesized fix message 
(authored by ibiryukov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62372?vs=201179&id=201181#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D62372

Files:
  clangd/Diagnostics.cpp
  clangd/unittests/DiagnosticsTests.cpp

Index: clangd/unittests/DiagnosticsTests.cpp
===
--- clangd/unittests/DiagnosticsTests.cpp
+++ clangd/unittests/DiagnosticsTests.cpp
@@ -120,7 +120,7 @@
  "use of undeclared identifier 'goo'; did you mean 'foo'?"),
 DiagSource(Diag::Clang), DiagName("undeclared_var_use_suggest"),
 WithFix(
-Fix(Test.range("typo"), "foo", "change 'go\\ o' to 'foo'")),
+Fix(Test.range("typo"), "foo", "change 'go\\…' to 'foo'")),
 // This is a pretty normal range.
 WithNote(Diag(Test.range("decl"), "'foo' declared here"))),
   // This range is zero-width and insertion. Therefore make sure we are
@@ -247,6 +247,36 @@
   DiagSeverity(DiagnosticsEngine::Error;
 }
 
+TEST(DiagnosticTest, LongFixMessages) {
+  // We limit the size of printed code.
+  Annotations Source(R"cpp(
+int main() {
+  int somereallyreallyreallyreallyreallyreallyreallyreallylongidentifier;
+  [[omereallyreallyreallyreallyreallyreallyreallyreallylongidentifier]]= 10;
+}
+  )cpp");
+  TestTU TU = TestTU::withCode(Source.code());
+  EXPECT_THAT(
+  TU.build().getDiagnostics(),
+  ElementsAre(WithFix(Fix(
+  Source.range(),
+  "somereallyreallyreallyreallyreallyreallyreallyreallylongidentifier",
+  "change 'omereallyreallyreallyreallyreallyreallyreallyreall…' to "
+  "'somereallyreallyreallyreallyreallyreallyreallyreal…'";
+  // Only show changes up to a first newline.
+  Source = Annotations(R"cpp(
+int main() {
+  int ident;
+  [[ide\
+n]] = 10;
+}
+  )cpp");
+  TU = TestTU::withCode(Source.code());
+  EXPECT_THAT(TU.build().getDiagnostics(),
+  ElementsAre(WithFix(
+  Fix(Source.range(), "ident", "change 'ide\\…' to 'ident'";
+}
+
 TEST(DiagnosticTest, ClangTidyWarningAsErrorTrumpsSuppressionComment) {
   Annotations Main(R"cpp(
 int main() {
Index: clangd/Diagnostics.cpp
===
--- clangd/Diagnostics.cpp
+++ clangd/Diagnostics.cpp
@@ -25,7 +25,9 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -437,6 +439,21 @@
   LangOpts = None;
 }
 
+/// Sanitizes a piece for presenting it in a synthesized fix message. Ensures
+/// the result is not too large and does not contain newlines.
+static void writeCodeToFixMessage(llvm::raw_ostream &OS, llvm::StringRef Code) {
+  constexpr unsigned MaxLen = 50;
+
+  // Only show the first line if there are many.
+  llvm::StringRef R = Code.split('\n').first;
+  // Shorten the message if it's too long.
+  R = R.take_front(MaxLen);
+
+  OS << R;
+  if (R.size() != Code.size())
+OS << "…";
+}
+
 void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
   const clang::Diagnostic &Info) {
   DiagnosticConsumer::HandleDiagnostic(DiagLevel, Info);
@@ -494,12 +511,21 @@
   llvm::StringRef Insert = FixIt.CodeToInsert;
   if (!Invalid) {
 llvm::raw_svector_ostream M(Message);
-if (!Remove.empty() && !Insert.empty())
-  M << "change '" << Remove << "' to '" << Insert << "'";
-else if (!Remove.empty())
-  M << "remove '" << Remove << "'";
-else if (!Insert.empty())
-  M << "insert '" << Insert << "'";
+if (!Remove.empty() && !Insert.empty()) {
+  M << "change '";
+  writeCodeToFixMessage(M, Remove);
+  M << "' to '";
+  writeCodeToFixMessage(M, Insert);
+  M << "'";
+} else if (!Remove.empty()) {
+  M << "remove '";
+  writeCodeToFixMessage(M, Remove);
+  M << "'";
+} else if (!Insert.empty()) {
+  M << "insert '";
+  writeCodeToFixMessage(M, Insert);
+  M << "'";
+}
 // Don't allow source code to inject newlines into diagnostics.
 std::replace(Message.begin(), Message.end(), '\n', ' ');
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62376: [ASTImporter] Mark erroneous nodes in shared st

2019-05-24 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added a reviewer: a_sidorin.
Herald added subscribers: cfe-commits, gamesh411, Szelethus, dkrupp, rnkovacs.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: clang.

This is the third step of the full error handling. We store the errors
for the Decls in the "to" context too. For that, however, we have to put
these errors in a shared state (among all the ASTImporter objects which
handle the same "to" context but different "from" contexts).

After a series of imports from different "from" TUs we have a "to" context
which may have erroneous nodes in it. (Remember, the AST is immutable so
there is no way to delete a node once we had created it and we realized
the error later.) All these erroneous nodes are marked in
ASTImporterSharedState::ImportErrors.  Clients of the ASTImporter may
use this as an input. E.g. the static analyzer engine may not try to
analyze a function if that is marked as erroneous (it can be queried via
ASTImporterSharedState::getImportDeclErrorIfAny()).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62376

Files:
  clang/include/clang/AST/ASTImporter.h
  clang/include/clang/AST/ASTImporterSharedState.h
  clang/include/clang/CrossTU/CrossTranslationUnit.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/CrossTU/CrossTranslationUnit.cpp
  clang/lib/Frontend/ASTMerge.cpp
  clang/unittests/AST/ASTImporterFixtures.cpp
  clang/unittests/AST/ASTImporterFixtures.h
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -316,10 +316,11 @@
   RedirectingImporterTest() {
 Creator = [](ASTContext &ToContext, FileManager &ToFileManager,
  ASTContext &FromContext, FileManager &FromFileManager,
- bool MinimalImport, ASTImporterLookupTable *LookupTable) {
+ bool MinimalImport,
+ const std::shared_ptr &SharedState) {
   return new RedirectingImporter(ToContext, ToFileManager, FromContext,
  FromFileManager, MinimalImport,
- LookupTable);
+ SharedState);
 };
   }
 };
@@ -2888,7 +2889,7 @@
   CXXMethodDecl *Method =
   FirstDeclMatcher().match(ToClass, MethodMatcher);
   ToClass->removeDecl(Method);
-  LookupTablePtr->remove(Method);
+  SharedStatePtr->getLookupTable()->remove(Method);
 }
 
 ASSERT_EQ(DeclCounter().match(ToClass, MethodMatcher), 0u);
Index: clang/unittests/AST/ASTImporterFixtures.h
===
--- clang/unittests/AST/ASTImporterFixtures.h
+++ clang/unittests/AST/ASTImporterFixtures.h
@@ -17,8 +17,8 @@
 #include "gmock/gmock.h"
 
 #include "clang/AST/ASTImporter.h"
-#include "clang/AST/ASTImporterLookupTable.h"
 #include "clang/Frontend/ASTUnit.h"
+#include "clang/AST/ASTImporterSharedState.h"
 
 #include "DeclMatcher.h"
 #include "Language.h"
@@ -26,7 +26,7 @@
 namespace clang {
 
 class ASTImporter;
-class ASTImporterLookupTable;
+class ASTImporterSharedState;
 class ASTUnit;
 
 namespace ast_matchers {
@@ -77,9 +77,9 @@
 
 public:
   /// Allocates an ASTImporter (or one of its subclasses).
-  typedef std::function
+  typedef std::function &SharedState)>
   ImporterConstructor;
 
   // The lambda that constructs the ASTImporter we use in this test.
@@ -104,11 +104,13 @@
ImporterConstructor C = ImporterConstructor());
 ~TU();
 
-void lazyInitImporter(ASTImporterLookupTable &LookupTable, ASTUnit *ToAST);
-Decl *import(ASTImporterLookupTable &LookupTable, ASTUnit *ToAST,
- Decl *FromDecl);
-QualType import(ASTImporterLookupTable &LookupTable, ASTUnit *ToAST,
-QualType FromType);
+void
+lazyInitImporter(const std::shared_ptr &SharedState,
+ ASTUnit *ToAST);
+Decl *import(const std::shared_ptr &SharedState,
+ ASTUnit *ToAST, Decl *FromDecl);
+QualType import(const std::shared_ptr &SharedState,
+ASTUnit *ToAST, QualType FromType);
   };
 
   // We may have several From contexts and related translation units. In each
@@ -120,14 +122,14 @@
   // vector is expanding, with the list we won't have these issues.
   std::list FromTUs;
 
-  // Initialize the lookup table if not initialized already.
-  void lazyInitLookupTable(TranslationUnitDecl *ToTU);
+  // Initialize the shared state if not initialized already.
+  void lazyInitSharedState(TranslationUnitDecl *ToTU);
 
   void lazyInitToAST(Language ToLang, StringRef ToSrcCode, StringRef FileName);
   TU *findFromTU(Decl *From);
 
 protected:
-  std::unique_ptr LookupTablePtr;
+  std::shared_ptr SharedStatePtr;
 
 public:
   // We may have several From context but onl

[PATCH] D62377: [OpenCL] Add support for the cl_arm_integer_dot_product extensions

2019-05-24 Thread Kévin Petit via Phabricator via cfe-commits
kpet created this revision.
kpet added a reviewer: Anastasia.
Herald added subscribers: cfe-commits, kristof.beyls, javed.absar, yaxunl.
Herald added a project: clang.

Repository:
  rC Clang

https://reviews.llvm.org/D62377

Files:
  clang/include/clang/Basic/OpenCLExtensions.def
  clang/lib/Headers/opencl-c.h
  clang/test/CodeGenOpenCL/arm-integer-dot-product.cl
  clang/test/SemaOpenCL/arm-integer-dot-product.cl

Index: clang/test/SemaOpenCL/arm-integer-dot-product.cl
===
--- /dev/null
+++ clang/test/SemaOpenCL/arm-integer-dot-product.cl
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -finclude-default-header -verify -cl-std=CL1.2 -emit-llvm -o - -O0
+
+void test_negative() {
+uchar4 ua8, ub8;
+char4 sa8, sb8;
+ushort2 ua16, ub16;
+short2 sa16, sb16;
+uint ur;
+int sr;
+ur = arm_dot(ua8, ub8); // expected-error{{no matching function for call to 'arm_dot'}}
+// expected-note@opencl-c.h:* {{candidate function not viable}}
+// expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_int8' to be enabled}}
+sr = arm_dot(sa8, sb8); // expected-error{{no matching function for call to 'arm_dot'}}
+// expected-note@opencl-c.h:* {{candidate function not viable}}
+// expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_int8' to be enabled}}
+ur = arm_dot_acc(ua8, ub8, ur); // expected-error{{no matching function for call to 'arm_dot_acc'}}
+// expected-note@opencl-c.h:* {{candidate function not viable}}
+// expected-note@opencl-c.h:* {{candidate function not viable}}
+// expected-note@opencl-c.h:* {{candidate function not viable}}
+// expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_accumulate_int8' to be enabled}}
+sr = arm_dot_acc(sa8, sb8, sr); // expected-error{{no matching function for call to 'arm_dot_acc'}}
+// expected-note@opencl-c.h:* {{candidate function not viable}}
+// expected-note@opencl-c.h:* {{candidate function not viable}}
+// expected-note@opencl-c.h:* {{candidate function not viable}}
+// expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_accumulate_int8' to be enabled}}
+ur = arm_dot_acc(ua16, ub16, ur); // expected-error{{no matching function for call to 'arm_dot_acc'}}
+// expected-note@opencl-c.h:* {{candidate function not viable}}
+// expected-note@opencl-c.h:* {{candidate function not viable}}
+// expected-note@opencl-c.h:* {{candidate function not viable}}
+// expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_accumulate_int16' to be enabled}}
+sr = arm_dot_acc(sa16, sb16, sr); // expected-error{{no matching function for call to 'arm_dot_acc'}}
+// expected-note@opencl-c.h:* {{candidate function not viable}}
+// expected-note@opencl-c.h:* {{candidate function not viable}}
+// expected-note@opencl-c.h:* {{candidate function not viable}}
+// expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_accumulate_int16' to be enabled}}
+ur = arm_dot_acc_sat(ua8, ub8, ur); // expected-error{{no matching function for call to 'arm_dot_acc_sat'}}
+// expected-note@opencl-c.h:* {{candidate function not viable}}
+// expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_accumulate_saturate_int8' to be enabled}}
+sr = arm_dot_acc_sat(sa8, sb8, sr); // expected-error{{no matching function for call to 'arm_dot_acc_sat'}}
+// expected-note@opencl-c.h:* {{candidate function not viable}}
+// expected-note@opencl-c.h:* {{candidate unavailable as it requires OpenCL extension 'cl_arm_integer_dot_product_accumulate_saturate_int8' to be enabled}}
+}
+
Index: clang/test/CodeGenOpenCL/arm-integer-dot-product.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/arm-integer-dot-product.cl
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -finclude-default-header -cl-std=CL1.2 -emit-llvm -o - -O0 | FileCheck %s
+
+#pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : enable
+void test_int8(uchar4 ua, uchar4 ub, char4 sa, char4 sb) {
+uint ur = arm_dot(ua, ub);
+// CHECK: call spir_func i32 @_Z7arm_dotDv4_hS_
+int sr = arm_dot(sa, sb);
+// CHECK: call spir_func i32 @_Z7arm_dotDv4_cS_
+}
+#pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : disable
+
+#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int8 : enable
+void test_accumulate_int8(uchar4 ua, uchar4 ub, uint uc, char4 sa, char4 sb, int c) {
+uint ur = arm_dot_acc(ua, ub, uc);
+// CHECK: call spir_func i32

[clang-tools-extra] r361628 - Made cppcoreguidelines-pro-type-member-init-use-assignment run in all language modes

2019-05-24 Thread Dmitri Gribenko via cfe-commits
Author: gribozavr
Date: Fri May 24 03:39:00 2019
New Revision: 361628

URL: http://llvm.org/viewvc/llvm-project?rev=361628&view=rev
Log:
Made cppcoreguidelines-pro-type-member-init-use-assignment run in all language 
modes

Modified:

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-use-assignment.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-use-assignment.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-use-assignment.cpp?rev=361628&r1=361627&r2=361628&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-use-assignment.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-use-assignment.cpp
 Fri May 24 03:39:00 2019
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t -- 
-config="{CheckOptions: [{key: 
"cppcoreguidelines-pro-type-member-init.UseAssignment", value: 1}]}" -- 
-std=c++11
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t -- 
-config="{CheckOptions: [{key: 
"cppcoreguidelines-pro-type-member-init.UseAssignment", value: 1}]}"
 
 struct T {
   int i;


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


[clang-tools-extra] r361629 - Make cppcoreguidelines-pro-type-member-init-use-assignment.cpp pass on platforms where char is unsigned

2019-05-24 Thread Dmitri Gribenko via cfe-commits
Author: gribozavr
Date: Fri May 24 03:50:15 2019
New Revision: 361629

URL: http://llvm.org/viewvc/llvm-project?rev=361629&view=rev
Log:
Make cppcoreguidelines-pro-type-member-init-use-assignment.cpp pass on 
platforms where char is unsigned

The other options are to completely specify the triple (reduces test
coverage), or to specify a regex that allows either '0' or '0U' for char
initializers, however, that relaxes the test.

Modified:

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-use-assignment.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-use-assignment.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-use-assignment.cpp?rev=361629&r1=361628&r2=361629&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-use-assignment.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-use-assignment.cpp
 Fri May 24 03:50:15 2019
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t -- 
-config="{CheckOptions: [{key: 
"cppcoreguidelines-pro-type-member-init.UseAssignment", value: 1}]}"
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t -- 
-config="{CheckOptions: [{key: 
"cppcoreguidelines-pro-type-member-init.UseAssignment", value: 1}]}" -- 
-fsigned-char
 
 struct T {
   int i;


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


[PATCH] D62377: [OpenCL] Add support for the cl_arm_integer_dot_product extensions

2019-05-24 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

This deserves at least a link to the published spec in the description!


Repository:
  rC Clang

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

https://reviews.llvm.org/D62377



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


[PATCH] D62377: [OpenCL] Add support for the cl_arm_integer_dot_product extensions

2019-05-24 Thread Kévin Petit via Phabricator via cfe-commits
kpet added a comment.

Yes, indeed :).


Repository:
  rC Clang

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

https://reviews.llvm.org/D62377



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


[PATCH] D59402: Fix-it hints for -Wmissing-{prototypes,variable-declarations}

2019-05-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

My only real concern about this is that sometimes the fix-it will be wrong 
because the issue is a typo in the definition. However, it seems like that 
could be handled by preferring typo correction when the edit distance is below 
a certain threshold or something along those lines, and could be done later.




Comment at: lib/Sema/SemaDecl.cpp:13216
+  << FD
+  << (!PossiblePrototype && (FD->getStorageClass() != SC_Extern)
+  ? FixItHint::CreateInsertion(FD->getBeginLoc(), "static ")

You can drop the parens around the `!=` operator subexpressions.



Comment at: lib/Sema/SemaDecl.cpp:13220
+
+  if (PossiblePrototype && (FD->getNumParams() == 0)) {
 // We found a declaration that is not a prototype,

You can drop the parens here.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59402



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


[PATCH] D59402: Fix-it hints for -Wmissing-{prototypes,variable-declarations}

2019-05-24 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D59402#1515703 , @aaron.ballman 
wrote:

> My only real concern about this is that sometimes the fix-it will be wrong 
> because the issue is a typo in the definition.


You're right about that, there are multiple reasons why one would see the 
warning. But if your program compiles and links fine, then this seems to be the 
only reason left.

- If the function is in a header and should be declared `inline`, you're most 
likely getting linker errors with duplicate symbols.
- If there is a typo, and the definition doesn't match the declaration, there 
should also be a linker error about a missing symbol.

We had a discussion in our team about activating the warning, and a colleague 
of mine remarked "to fix this, you would have to declare every function before 
defining it, even when its only declared & defined in a source file". That's 
when I realized the warning might be a bit misleading, and suggesting to add 
`static` could fix that. It's also how the warning should be fixed in our code 
in almost all cases. (There are a few cases where it fires in a header that is 
only included once.)


Repository:
  rC Clang

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

https://reviews.llvm.org/D59402



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


[PATCH] D60776: [clang-tidy] Add test support for the fix description.

2019-05-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 201221.
hokein added a comment.

Use CHECK-NOTES.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60776

Files:
  clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp


Index: clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
===
--- clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
+++ clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
@@ -78,13 +78,15 @@
 // - Using declarations -
 // eol-comments aren't removed (yet)
 using n::A; // A
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'A' is unused
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: using decl 'A' is unused
+// CHECK-NOTES: [[@LINE-2]]:10: note: remove the using
 // CHECK-FIXES: {{^}}// A
 using n::B;
 using n::C;
 using n::D;
 using n::E; // E
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'E' is unused
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: using decl 'E' is unused
+// CHECK-NOTES: [[@LINE-2]]:10: note: remove the using
 // CHECK-FIXES: {{^}}// E
 using n::F;
 using n::G;
@@ -99,10 +101,12 @@
 using n::UsedFunc;
 using n::UsedTemplateFunc;
 using n::UnusedInstance; // UnusedInstance
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'UnusedInstance' is 
unused
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: using decl 'UnusedInstance' is unused
+// CHECK-NOTES: [[@LINE-2]]:10: note: remove the using
 // CHECK-FIXES: {{^}}// UnusedInstance
 using n::UnusedFunc; // UnusedFunc
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'UnusedFunc' is unused
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: using decl 'UnusedFunc' is unused
+// CHECK-NOTES: [[@LINE-2]]:10: note: remove the using
 // CHECK-FIXES: {{^}}// UnusedFunc
 using n::cout;
 using n::endl;
@@ -115,7 +119,8 @@
 }
 
 using n::OverloadFunc; // OverloadFunc
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'OverloadFunc' is 
unused
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: using decl 'OverloadFunc' is unused
+// CHECK-NOTES: [[@LINE-2]]:10: note: remove the using
 // CHECK-FIXES: {{^}}// OverloadFunc
 
 #define DEFINE_INT(name)\
@@ -150,9 +155,11 @@
 }
 
 using n::Color1;
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Color1' is unused
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: using decl 'Color1' is unused
+// CHECK-NOTES: [[@LINE-2]]:10: note: remove the using
 using n::Green;
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Green' is unused
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: using decl 'Green' is unused
+// CHECK-NOTES: [[@LINE-2]]:10: note: remove the using
 using n::Color2;
 using n::Color3;
 using n::Blue;
@@ -166,8 +173,8 @@
 
 // FIXME: Currently non-type template arguments are not supported.
 using n::Constant;
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Constant' is unused
-
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: using decl 'Constant' is unused
+// CHECK-NOTES: [[@LINE-2]]:10: note: remove the using
 // - Usages -
 void f(B b);
 void g() {


Index: clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
===
--- clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
+++ clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
@@ -78,13 +78,15 @@
 // - Using declarations -
 // eol-comments aren't removed (yet)
 using n::A; // A
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'A' is unused
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: using decl 'A' is unused
+// CHECK-NOTES: [[@LINE-2]]:10: note: remove the using
 // CHECK-FIXES: {{^}}// A
 using n::B;
 using n::C;
 using n::D;
 using n::E; // E
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'E' is unused
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: using decl 'E' is unused
+// CHECK-NOTES: [[@LINE-2]]:10: note: remove the using
 // CHECK-FIXES: {{^}}// E
 using n::F;
 using n::G;
@@ -99,10 +101,12 @@
 using n::UsedFunc;
 using n::UsedTemplateFunc;
 using n::UnusedInstance; // UnusedInstance
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'UnusedInstance' is unused
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: using decl 'UnusedInstance' is unused
+// CHECK-NOTES: [[@LINE-2]]:10: note: remove the using
 // CHECK-FIXES: {{^}}// UnusedInstance
 using n::UnusedFunc; // UnusedFunc
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'UnusedFunc' is unused
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: using decl 'UnusedFunc' is unused
+// CHECK-NOTES: [[@LINE-2]]:10: note: remove the using
 // CHECK-FIXES: {{^}}// UnusedFunc
 using n::cout;
 using n::endl;
@@ -115,7 +119,8 @@
 }
 
 using n::OverloadFunc; // OverloadFunc
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'OverloadFunc' is unused
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: using decl 'OverloadFunc' is unused
+// CHECK-NOTES: [[@LINE-

[PATCH] D60776: [clang-tidy] Add test support for the fix description.

2019-05-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Based on our last offline discussion, it is possible to use `CHECK-NOTES` to 
verify fix descriptions. However, `CHECK-NOTES` enforce sto verify all `note` 
diagnostic messages, some existing tests will be failed because they don't 
cover all notes (the number is not large, only ~60), I'll update the tests when 
updating the relative checks.

Finally (after every check provides fix descriptions), we may deprecate 
`CHECK-MESSAGES`, and in favor of `CHECK-NOTES`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60776



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


[PATCH] D62389: [clangd] Place cursor better after completing patterns

2019-05-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: hokein.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay.
Herald added a project: clang.

By producing the $0 marker in the snippets at the last placeholder.
This produces nicer results in most cases, e.g. for

  namespace <#name#> {
<#decls#>
  }

we now produce ${0:decls} instead of ${2:decls} and the final cursor
placement is more convenient.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62389

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CodeCompletionStrings.cpp
  clang-tools-extra/clangd/CodeCompletionStrings.h
  clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp

Index: clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp
@@ -22,10 +22,12 @@
 CCTUInfo(Allocator), Builder(*Allocator, CCTUInfo) {}
 
 protected:
-  void computeSignature(const CodeCompletionString &CCS) {
+  void computeSignature(const CodeCompletionString &CCS,
+bool CompletingPattern = false) {
 Signature.clear();
 Snippet.clear();
-getSignature(CCS, &Signature, &Snippet);
+getSignature(CCS, &Signature, &Snippet, /*RequiredQualifier=*/nullptr,
+ CompletingPattern);
   }
 
   std::shared_ptr Allocator;
@@ -99,6 +101,25 @@
   EXPECT_EQ(Snippet, "(${1:\\$p\\}1})");
 }
 
+TEST_F(CompletionStringTest, SnippetsInPatterns) {
+  auto MakeCCS = [this]() -> const CodeCompletionString & {
+CodeCompletionBuilder Builder(*Allocator, CCTUInfo);
+Builder.AddTypedTextChunk("namespace");
+Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+Builder.AddPlaceholderChunk("name");
+Builder.AddChunk(CodeCompletionString::CK_Equal);
+Builder.AddPlaceholderChunk("target");
+Builder.AddChunk(CodeCompletionString::CK_SemiColon);
+return *Builder.TakeString();
+  };
+  computeSignature(MakeCCS(), /*CompletingPattern=*/false);
+  EXPECT_EQ(Snippet, " ${1:name} = ${2:target};");
+
+  // When completing a pattern, the last placeholder holds the cursor position.
+  computeSignature(MakeCCS(), /*CompletingPattern=*/true);
+  EXPECT_EQ(Snippet, " ${1:name} = ${0:target};");
+}
+
 TEST_F(CompletionStringTest, IgnoreInformativeQualifier) {
   Builder.AddTypedTextChunk("X");
   Builder.AddInformativeChunk("info ok");
Index: clang-tools-extra/clangd/CodeCompletionStrings.h
===
--- clang-tools-extra/clangd/CodeCompletionStrings.h
+++ clang-tools-extra/clangd/CodeCompletionStrings.h
@@ -38,12 +38,15 @@
 /// Formats the signature for an item, as a display string and snippet.
 /// e.g. for const_reference std::vector::at(size_type) const, this returns:
 ///   *Signature = "(size_type) const"
-///   *Snippet = "(${0:size_type})"
+///   *Snippet = "(${1:size_type})"
 /// If set, RequiredQualifiers is the text that must be typed before the name.
 /// e.g "Base::" when calling a base class member function that's hidden.
+/// When \p CompletingPattern is true, the last placeholder will be of the form
+/// ${0:…}, indicating the cursor should stay there.
 void getSignature(const CodeCompletionString &CCS, std::string *Signature,
   std::string *Snippet,
-  std::string *RequiredQualifiers = nullptr);
+  std::string *RequiredQualifiers = nullptr,
+  bool CompletingPattern = false);
 
 /// Assembles formatted documentation for a completion result. This includes
 /// documentation comments and other relevant information like annotations.
Index: clang-tools-extra/clangd/CodeCompletionStrings.cpp
===
--- clang-tools-extra/clangd/CodeCompletionStrings.cpp
+++ clang-tools-extra/clangd/CodeCompletionStrings.cpp
@@ -11,6 +11,8 @@
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/RawCommentList.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Sema/CodeCompleteConsumer.h"
+#include 
 #include 
 
 namespace clang {
@@ -73,8 +75,23 @@
 }
 
 void getSignature(const CodeCompletionString &CCS, std::string *Signature,
-  std::string *Snippet, std::string *RequiredQualifiers) {
-  unsigned ArgCount = 0;
+  std::string *Snippet, std::string *RequiredQualifiers,
+  bool CompletingPattern) {
+  // Placeholder with this index will be ${0:…} to mark final cursor position.
+  // Usually we do not add $0, so the cursor is placed at end of completed text.
+  unsigned CursorSnippetArg = std::numeric_limits::max();
+  if (CompletingPattern) {
+// In patterns, it's best to place the cursor at the last placeholder, to
+// handle cases like
+//namespace ${1:name} {
+

[PATCH] D62156: [Sema][PR41730] Diagnose addr space mismatch while constructing objects

2019-05-24 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 201228.
Anastasia marked an inline comment as done.
Anastasia added a comment.

- Added candidates as not viable
- Added dedicated diagnostic note
- Added assert


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

https://reviews.llvm.org/D62156

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Overload.h
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaOverload.cpp
  test/CodeGenCXX/address-space-of-this.cpp
  test/CodeGenOpenCLCXX/addrspace-ctor.cl
  test/SemaCXX/address-space-ctor.cpp

Index: test/SemaCXX/address-space-ctor.cpp
===
--- /dev/null
+++ test/SemaCXX/address-space-ctor.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -std=c++14 -triple=spir -verify -fsyntax-only
+// RUN: %clang_cc1 %s -std=c++17 -triple=spir -verify -fsyntax-only
+
+struct MyType {
+  MyType(int i) : i(i) {}
+  int i;
+};
+
+//expected-note@-5{{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const MyType &' for 1st argument}}
+//expected-note@-6{{candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'MyType &&' for 1st argument}}
+//expected-note@-6{{candidate constructor ignored: address space mismatch between object and constructor}}
+//expected-note@-8{{candidate constructor ignored: address space mismatch between object and constructor}}
+//expected-note@-9{{candidate constructor ignored: address space mismatch between object and constructor}}
+//expected-note@-9{{candidate constructor ignored: address space mismatch between object and constructor}}
+
+// FIXME: We can't implicitly convert between address spaces yet.
+MyType __attribute__((address_space(10))) m1 = 123; //expected-error{{no viable conversion from 'int' to '__attribute__((address_space(10))) MyType'}}
+MyType __attribute__((address_space(10))) m2(123);  //expected-error{{no matching constructor for initialization of '__attribute__((address_space(10))) MyType'}}
Index: test/CodeGenOpenCLCXX/addrspace-ctor.cl
===
--- /dev/null
+++ test/CodeGenOpenCLCXX/addrspace-ctor.cl
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -emit-llvm -O0 -o - | FileCheck %s
+
+struct MyType {
+  MyType(int i) : i(i) {}
+  MyType(int i) __constant : i(i) {}
+  int i;
+  void bar();
+};
+
+//CHECK: call void @_ZNU3AS26MyTypeC1Ei(%struct.MyType addrspace(2)* @const1, i32 1)
+__constant MyType const1 = 1;
+//CHECK: call void @_ZNU3AS26MyTypeC1Ei(%struct.MyType addrspace(2)* @const2, i32 2)
+__constant MyType const2(2);
+//CHECK: call void @_ZNU3AS46MyTypeC1Ei(%struct.MyType addrspace(4)* addrspacecast (%struct.MyType addrspace(1)* @glob to %struct.MyType addrspace(4)*), i32 1)
+MyType glob(1);
Index: test/CodeGenCXX/address-space-of-this.cpp
===
--- test/CodeGenCXX/address-space-of-this.cpp
+++ test/CodeGenCXX/address-space-of-this.cpp
@@ -1,8 +1,11 @@
 // RUN: %clang_cc1 %s -std=c++14 -triple=spir -emit-llvm -o - | FileCheck %s
 // RUN: %clang_cc1 %s -std=c++17 -triple=spir -emit-llvm -o - | FileCheck %s
+// XFAIL: *
 
+// FIXME: We can't compile address space method qualifiers yet.
+// Therefore there is no way to check correctness of this code.
 struct MyType {
-  MyType(int i) : i(i) {}
+  MyType(int i) __attribute__((address_space(10))) : i(i) {}
   int i;
 };
 //CHECK: call void @_ZN6MyTypeC1Ei(%struct.MyType* addrspacecast (%struct.MyType addrspace(10)* @m to %struct.MyType*), i32 123)
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -6090,6 +6090,15 @@
 return;
   }
 }
+
+// Check that addr space of an object being constructed is convertible to
+// the one ctor qualified with.
+if (!Qualifiers::isAddressSpaceSupersetOf(
+Constructor->getMethodQualifiers().getAddressSpace(),
+CandidateSet.getDestAS())) {
+  Candidate.Viable = false;
+  Candidate.FailureKind = ovl_fail_object_addrspace_mismatch;
+}
   }
 
   unsigned NumParams = Proto->getNumParams();
@@ -10380,6 +10389,13 @@
 return;
   }
 
+  case ovl_fail_object_addrspace_mismatch: {
+S.Diag(Fn->getLocation(),
+   diag::note_ovl_candidate_illegal_constructor_adrspace_mismatch);
+MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl);
+return;
+  }
+
   case ovl_fail_trivial_conversion:
   case ovl_fail_bad_final_conversion:
   case ovl_fail_final_conversion_not_exact:
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -3735,6 +3735,7 @@
bool OnlyListConstructors, bool IsListInit,
 

[PATCH] D62156: [Sema][PR41730] Diagnose addr space mismatch while constructing objects

2019-05-24 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/Sema/SemaDeclCXX.cpp:8229
+  if (FTI.hasMethodTypeCVRUQualifiers()) {
+FTI.MethodQualifiers->forEachCVRUQualifier(
 [&](DeclSpec::TQ TypeQual, StringRef QualName, SourceLocation SL) {

rjmccall wrote:
> rjmccall wrote:
> > We want to catch `_Atomic`, too, so please just change this loop to ignore 
> > address-space qualifiers, using a flag to decide whether to call 
> > `setInvalidType`.
> If there aren't any qualifiers we're skipping, the flag isn't necessary.
We are skipping addr space currently. I use this flag to avoid setting 
declaration as invalid below if it's only qualified by an addr space.


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

https://reviews.llvm.org/D62156



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


[PATCH] D62377: [OpenCL] Add support for the cl_arm_integer_dot_product extensions

2019-05-24 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D62377



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


[PATCH] D62390: [LibTooling] Add Explanation parameter to `makeRule`.

2019-05-24 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: ilya-biryukov.
Herald added a project: clang.

Conceptually, a single-case RewriteRule has a matcher, edit(s) and an (optional)
explanation. `makeRule` previously only took the matcher and edit(s). This
change adds (optional) support for the explanation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62390

Files:
  clang/include/clang/Tooling/Refactoring/Transformer.h
  clang/lib/Tooling/Refactoring/Transformer.cpp
  clang/unittests/Tooling/TransformerTest.cpp


Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -147,8 +147,7 @@
   on(expr(hasType(isOrPointsTo(StringType)))
  .bind(StringExpr)),
   callee(cxxMethodDecl(hasName("c_str")),
-  change(text("REPLACED")));
-  R.Cases[0].Explanation = text("Use size() method directly on string.");
+  change(text("REPLACED")), text("Use size() method directly on string."));
   return R;
 }
 
Index: clang/lib/Tooling/Refactoring/Transformer.cpp
===
--- clang/lib/Tooling/Refactoring/Transformer.cpp
+++ clang/lib/Tooling/Refactoring/Transformer.cpp
@@ -96,10 +96,10 @@
   return E;
 }
 
-RewriteRule tooling::makeRule(DynTypedMatcher M,
-  SmallVector Edits) {
-  return RewriteRule{
-  {RewriteRule::Case{std::move(M), std::move(Edits), nullptr}}};
+RewriteRule tooling::makeRule(DynTypedMatcher M, SmallVector Edits,
+  TextGenerator Explanation) {
+  return RewriteRule{{RewriteRule::Case{std::move(M), std::move(Edits),
+std::move(Explanation)}}};
 }
 
 // Determines whether A is a base type of B in the class hierarchy, including
Index: clang/include/clang/Tooling/Refactoring/Transformer.h
===
--- clang/include/clang/Tooling/Refactoring/Transformer.h
+++ clang/include/clang/Tooling/Refactoring/Transformer.h
@@ -125,14 +125,16 @@
 
 /// Convenience function for constructing a simple \c RewriteRule.
 RewriteRule makeRule(ast_matchers::internal::DynTypedMatcher M,
- SmallVector Edits);
+ SmallVector Edits,
+ TextGenerator Explanation = nullptr);
 
 /// Convenience overload of \c makeRule for common case of only one edit.
 inline RewriteRule makeRule(ast_matchers::internal::DynTypedMatcher M,
-ASTEdit Edit) {
+ASTEdit Edit,
+TextGenerator Explanation = nullptr) {
   SmallVector Edits;
   Edits.emplace_back(std::move(Edit));
-  return makeRule(std::move(M), std::move(Edits));
+  return makeRule(std::move(M), std::move(Edits), std::move(Explanation));
 }
 
 /// Applies the first rule whose pattern matches; other rules are ignored.


Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -147,8 +147,7 @@
   on(expr(hasType(isOrPointsTo(StringType)))
  .bind(StringExpr)),
   callee(cxxMethodDecl(hasName("c_str")),
-  change(text("REPLACED")));
-  R.Cases[0].Explanation = text("Use size() method directly on string.");
+  change(text("REPLACED")), text("Use size() method directly on string."));
   return R;
 }
 
Index: clang/lib/Tooling/Refactoring/Transformer.cpp
===
--- clang/lib/Tooling/Refactoring/Transformer.cpp
+++ clang/lib/Tooling/Refactoring/Transformer.cpp
@@ -96,10 +96,10 @@
   return E;
 }
 
-RewriteRule tooling::makeRule(DynTypedMatcher M,
-  SmallVector Edits) {
-  return RewriteRule{
-  {RewriteRule::Case{std::move(M), std::move(Edits), nullptr}}};
+RewriteRule tooling::makeRule(DynTypedMatcher M, SmallVector Edits,
+  TextGenerator Explanation) {
+  return RewriteRule{{RewriteRule::Case{std::move(M), std::move(Edits),
+std::move(Explanation)}}};
 }
 
 // Determines whether A is a base type of B in the class hierarchy, including
Index: clang/include/clang/Tooling/Refactoring/Transformer.h
===
--- clang/include/clang/Tooling/Refactoring/Transformer.h
+++ clang/include/clang/Tooling/Refactoring/Transformer.h
@@ -125,14 +125,16 @@
 
 /// Convenience function for constructing a simple \c RewriteRule.
 RewriteRule makeRule(ast_matchers::internal::DynTyped

[PATCH] D62340: [clang-tidy] In TransformerClangTidyCheck, require Explanation field.

2019-05-24 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added inline comments.



Comment at: 
clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp:38
   " else ", statement(T;
+  Rule.Cases[0].Explanation = tooling::text("no explanation");
+  return Rule;

ilya-biryukov wrote:
> NIT: this might be the first place people look at when writing the check, so 
> we might want to provide a real explanation here.
> Something like `negate condition and revert then and else branches`
will do. But, realized this is a bit ugly so sent  
https://reviews.llvm.org/D62390 to add support for the explanation to 
`makeRule`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62340



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


[PATCH] D62390: [LibTooling] Add Explanation parameter to `makeRule`.

2019-05-24 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. Much nicer now!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62390



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


[PATCH] D62391: [CodeComplete] Complete 'return true/false' in boolean functions

2019-05-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: kadircet.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62391

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/patterns.cpp


Index: clang/test/CodeCompletion/patterns.cpp
===
--- clang/test/CodeCompletion/patterns.cpp
+++ clang/test/CodeCompletion/patterns.cpp
@@ -30,10 +30,23 @@
 void void_return() {
   // line 31
 }
+bool bool_return() {
+  // line 34
+}
 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:28:1 %s -o - | FileCheck -check-prefix=RETURN-VAL %s
-// RETURN-VAL-NOT: COMPLETION: Pattern : return;{{$}}
+// RETURN-VAL-NOT: COMPLETION: Pattern : return;
+// RETURN-VAL-NOT: COMPLETION: Pattern : return false;
+// RETURN-VAL-NOT: COMPLETION: Pattern : return true;
 // RETURN-VAL: COMPLETION: Pattern : return <#expression#>;{{$}}
 
 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:31:1 %s -o - | FileCheck -check-prefix=RETURN-VOID %s
-// RETURN-VOID-NOT: COMPLETION: Pattern : return <#expression#>;{{$}}
+// RETURN-VOID-NOT: COMPLETION: Pattern : return false;
+// RETURN-VOID-NOT: COMPLETION: Pattern : return true;
+// RETURN-VOID-NOT: COMPLETION: Pattern : return <#expression#>;
 // RETURN-VOID: COMPLETION: Pattern : return;{{$}}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:34:1 %s -o - | FileCheck -check-prefix=RETURN-BOOL %s
+// RETURN-BOOL-NOT: COMPLETION: Pattern : return;
+// RETURN-BOOL: COMPLETION: Pattern : return <#expression#>;{{$}}
+// RETURN-BOOL: COMPLETION: Pattern : return false;{{$}}
+// RETURN-BOOL: COMPLETION: Pattern : return true;{{$}}
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -2168,23 +2168,38 @@
   Results.AddResult(Result(Builder.TakeString()));
 }
 
-// "return expression ;" or "return ;", depending on whether we
-// know the function is void or not.
-bool isVoid = false;
+// "return expression ;" or "return ;", depending on the return type.
+QualType ReturnType;
 if (const auto *Function = dyn_cast(SemaRef.CurContext))
-  isVoid = Function->getReturnType()->isVoidType();
+  ReturnType = Function->getReturnType();
 else if (const auto *Method = dyn_cast(SemaRef.CurContext))
-  isVoid = Method->getReturnType()->isVoidType();
+  ReturnType = Method->getReturnType();
 else if (SemaRef.getCurBlock() &&
  !SemaRef.getCurBlock()->ReturnType.isNull())
-  isVoid = SemaRef.getCurBlock()->ReturnType->isVoidType();
-Builder.AddTypedTextChunk("return");
-if (!isVoid) {
-  Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  ReturnType = SemaRef.getCurBlock()->ReturnType;;
+if (ReturnType.isNull() || ReturnType->isVoidType()) {
+  Builder.AddTypedTextChunk("return");
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
+  Results.AddResult(Result(Builder.TakeString()));
+} else {
+  assert(!ReturnType.isNull());
+  // "return expression ;"
+  Builder.AddTypedTextChunk("return");
+  Builder.AddChunk(clang::CodeCompletionString::CK_HorizontalSpace);
   Builder.AddPlaceholderChunk("expression");
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
+  Results.AddResult(Result(Builder.TakeString()));
+  // When boolean, also add 'return true;' and 'return false;'.
+  if (ReturnType->isBooleanType()) {
+Builder.AddTypedTextChunk("return true");
+Builder.AddChunk(CodeCompletionString::CK_SemiColon);
+Results.AddResult(Result(Builder.TakeString()));
+
+Builder.AddTypedTextChunk("return false");
+Builder.AddChunk(CodeCompletionString::CK_SemiColon);
+Results.AddResult(Result(Builder.TakeString()));
+  }
 }
-Builder.AddChunk(CodeCompletionString::CK_SemiColon);
-Results.AddResult(Result(Builder.TakeString()));
 
 // goto identifier ;
 Builder.AddTypedTextChunk("goto");


Index: clang/test/CodeCompletion/patterns.cpp
===
--- clang/test/CodeCompletion/patterns.cpp
+++ clang/test/CodeCompletion/patterns.cpp
@@ -30,10 +30,23 @@
 void void_return() {
   // line 31
 }
+bool bool_return() {
+  // line 34
+}
 // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:28:1 %s -o - | FileCheck -check-prefix=RETURN-VAL %s
-// RETURN-VAL-NOT: COMPLETION: Pattern : return;{{$}}
+// RETURN-VAL-NOT: COMPLETION: Pattern : return;
+// RETURN-VAL-NOT: COMPLETION: Pattern : return false;
+// RETURN-VAL-NOT: COMPLETION: Pattern : return true;
 // RETURN-VAL: COMPLETION: Pattern : return <#expression#>;{{$}}
 
 // RUN: %clang_cc1 -fsyntax-only -

[PATCH] D61472: [X86FixupLEAs] Turn optIncDec into a generic two address LEA optimizer. Support LEA64_32r properly.

2019-05-24 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment.

I haven't looked closely at the series of transforms that gets us here, so let 
me ask: would it be more efficient to produce the add/inc/dec machine 
instructions directly rather than LEA? Or do we do this because the 3-address 
opportunity helps register allocation, so this late reversal is a special-case 
of the more generally useful transforms that produce LEA in the 1st place?




Comment at: llvm/lib/Target/X86/X86FixupLEAs.cpp:11
 // re-written as LEA instructions in order to reduce pipeline delays.
 // When optimizing for size it replaces suitable LEAs with INC or DEC.
 //

Should update this comment to better match the logic:
"It replaces LEAs with ADD/INC/DEC when that is better for size/speed." ?


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

https://reviews.llvm.org/D61472



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


[PATCH] D62394: [ARM][CMSE] Add CMSE header & builtins

2019-05-24 Thread Javed Absar via Phabricator via cfe-commits
javed.absar created this revision.
javed.absar added reviewers: snidertm, dmgreen.
Herald added subscribers: kristof.beyls, mgorny.

This is patch C2 as mentioned in RFC 
http://lists.llvm.org/pipermail/cfe-dev/2019-March/061834.html

This adds cmse builtin functions, and introduces arm_cmse.h header which has  
useful macros, functions and data types for end-users of cmse.


https://reviews.llvm.org/D62394

Files:
  include/clang/Basic/BuiltinsARM.def
  lib/Headers/CMakeLists.txt
  lib/Headers/arm_cmse.h
  test/CodeGen/arm-cmse-nonsecure.c
  test/CodeGen/arm-cmse-secure.c
  test/CodeGen/arm-cmse.c
  test/Headers/arm-cmse-header-ns.c
  test/Headers/arm-cmse-header.c

Index: test/Headers/arm-cmse-header.c
===
--- /dev/null
+++ test/Headers/arm-cmse-header.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple thumbv8m.base-linux-gnueabihf  -fsyntax-only -ffreestanding %s -verify -mcmse
+// RUN: %clang_cc1 -triple thumbv8m.base-linux-gnueabihf  -fsyntax-only -ffreestanding -x c++ %s -verify -mcmse
+// expected-no-diagnostics
+
+#include 
+
+typedef void (*callback_t)(void);
+
+void func(callback_t fptr, void *p)
+{
+  cmse_TT(p);
+  cmse_TTT(p);
+  cmse_TTA(p);
+  cmse_TTAT(p);
+
+  cmse_TT_fptr(fptr);
+  cmse_TTT_fptr(fptr);
+  cmse_TTA_fptr(fptr);
+  cmse_TTAT_fptr(fptr);
+}
Index: test/Headers/arm-cmse-header-ns.c
===
--- /dev/null
+++ test/Headers/arm-cmse-header-ns.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple thumbv8m.base-linux-gnueabihf  -fsyntax-only -ffreestanding %s 2>&1 | FileCheck --check-prefix=CHECK-c %s
+// RUN: not %clang_cc1 -triple thumbv8m.base-linux-gnueabihf  -fsyntax-only -ffreestanding -x c++ %s 2>&1 | FileCheck --check-prefix=CHECK-cpp %s
+
+#include 
+
+typedef void (*callback_t)(void);
+
+void func(callback_t fptr, void *p)
+{
+  cmse_TT(p);
+  cmse_TTT(p);
+  cmse_TT_fptr(fptr);
+  cmse_TTT_fptr(fptr);
+
+  cmse_TTA(p);
+  cmse_TTAT(p);
+  cmse_TTA_fptr(fptr);
+  cmse_TTAT_fptr(fptr);
+// CHECK-c: warning: implicit declaration of function 'cmse_TTA'
+// CHECK-c: warning: implicit declaration of function 'cmse_TTAT'
+// CHECK-c: warning: implicit declaration of function 'cmse_TTA_fptr'
+// CHECK-c: warning: implicit declaration of function 'cmse_TTAT_fptr'
+// CHECK-cpp: error: use of undeclared identifier 'cmse_TTA'
+// CHECK-cpp: error: use of undeclared identifier 'cmse_TTAT'
+// CHECK-cpp: error: use of undeclared identifier 'cmse_TTA_fptr'
+// CHECK-cpp: error: use of undeclared identifier 'cmse_TTAT_fptr'
+}
Index: test/CodeGen/arm-cmse.c
===
--- /dev/null
+++ test/CodeGen/arm-cmse.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple thumbv8m.base-none-eabi -O1 -emit-llvm %s -o - | FileCheck %s
+int test_cmse_TT(void *p){
+  return __builtin_arm_cmse_TT(p);
+  // CHECK: call i32 @llvm.arm.cmse.tt(i8* %{{.*}})
+}
+
+int test_cmse_TTT(void *p){
+  return __builtin_arm_cmse_TTT(p);
+  // CHECK: call i32 @llvm.arm.cmse.ttt(i8* %{{.*}})
+}
+
+int test_cmse_TTA(void *p){
+  return __builtin_arm_cmse_TTA(p);
+  // CHECK: call i32 @llvm.arm.cmse.tta(i8* %{{.*}})
+}
+
+int test_cmse_TTAT(void *p){
+  return __builtin_arm_cmse_TTAT(p);
+  // CHECK: call i32 @llvm.arm.cmse.ttat(i8* %{{.*}})
+}
Index: test/CodeGen/arm-cmse-secure.c
===
--- /dev/null
+++ test/CodeGen/arm-cmse-secure.c
@@ -0,0 +1,66 @@
+// RUN: %clang -fvisibility=default -mlittle-endian -mcmse -Xclang -ffreestanding -target thumbv8m.base-linux-gnueabihf -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang -fvisibility=default -mbig-endian-mcmse -Xclang -ffreestanding -target thumbv8m.base-linux-gnueabihf -emit-llvm -S -o - %s | FileCheck %s
+
+#include 
+
+unsigned test_cmse_primitives(void *p) {
+// CHECK: define {{.*}} i32 @test_cmse_primitives
+  cmse_address_info_t tt_val, ttt_val;
+  cmse_address_info_t tta_val, ttat_val;
+  unsigned sum;
+
+  tt_val = cmse_TT(p);
+  ttt_val = cmse_TTT(p);
+  tta_val = cmse_TTA(p);
+  ttat_val = cmse_TTAT(p);
+// CHECK: call i32 @llvm.arm.cmse.tt
+// CHECK: call i32 @llvm.arm.cmse.ttt
+// CHECK: call i32 @llvm.arm.cmse.tta
+// CHECK: call i32 @llvm.arm.cmse.ttat
+
+  sum = tt_val.value;
+  sum += ttt_val.value;
+  sum += tta_val.value;
+  sum += ttat_val.value;
+
+  sum += tt_val.flags.mpu_region;
+  sum += tt_val.flags.sau_region;
+  sum += tt_val.flags.mpu_region_valid;
+  sum += tt_val.flags.sau_region_valid;
+  sum += tt_val.flags.read_ok;
+  sum += tt_val.flags.readwrite_ok;
+  sum += tt_val.flags.nonsecure_read_ok;
+  sum += tt_val.flags.nonsecure_readwrite_ok;
+  sum += tt_val.flags.secure;
+  sum += tt_val.flags.idau_region_valid;
+  sum += tt_val.flags.idau_region;
+
+  return sum;
+}
+
+void *test_address_range(void *p) {
+// CHECK: define {{.*}} i8* @test_address_range
+  return cmse_check_address_range(p, 128, CMSE_MPU_UNPRIV
+  

r361641 - [OpenCL] Add support for the cl_arm_integer_dot_product extensions

2019-05-24 Thread Kevin Petit via cfe-commits
Author: kpet
Date: Fri May 24 07:53:52 2019
New Revision: 361641

URL: http://llvm.org/viewvc/llvm-project?rev=361641&view=rev
Log:
[OpenCL] Add support for the cl_arm_integer_dot_product extensions

The specification is available in the Khronos OpenCL registry:

https://www.khronos.org/registry/OpenCL/extensions/arm/cl_arm_integer_dot_product.txt

Signed-off-by: Kevin Petit 

Added:
cfe/trunk/test/CodeGenOpenCL/arm-integer-dot-product.cl
cfe/trunk/test/SemaOpenCL/arm-integer-dot-product.cl
Modified:
cfe/trunk/include/clang/Basic/OpenCLExtensions.def
cfe/trunk/lib/Headers/opencl-c.h

Modified: cfe/trunk/include/clang/Basic/OpenCLExtensions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLExtensions.def?rev=361641&r1=361640&r2=361641&view=diff
==
--- cfe/trunk/include/clang/Basic/OpenCLExtensions.def (original)
+++ cfe/trunk/include/clang/Basic/OpenCLExtensions.def Fri May 24 07:53:52 2019
@@ -81,6 +81,12 @@ OPENCLEXT_INTERNAL(cl_clang_storage_clas
 OPENCLEXT_INTERNAL(cl_amd_media_ops, 100, ~0U)
 OPENCLEXT_INTERNAL(cl_amd_media_ops2, 100, ~0U)
 
+// ARM OpenCL extensions
+OPENCLEXT_INTERNAL(cl_arm_integer_dot_product_int8, 120, ~0U)
+OPENCLEXT_INTERNAL(cl_arm_integer_dot_product_accumulate_int8, 120, ~0U)
+OPENCLEXT_INTERNAL(cl_arm_integer_dot_product_accumulate_int16, 120, ~0U)
+OPENCLEXT_INTERNAL(cl_arm_integer_dot_product_accumulate_saturate_int8, 120, 
~0U)
+
 // Intel OpenCL extensions
 OPENCLEXT_INTERNAL(cl_intel_subgroups, 120, ~0U)
 OPENCLEXT_INTERNAL(cl_intel_subgroups_short, 120, ~0U)

Modified: cfe/trunk/lib/Headers/opencl-c.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c.h?rev=361641&r1=361640&r2=361641&view=diff
==
--- cfe/trunk/lib/Headers/opencl-c.h (original)
+++ cfe/trunk/lib/Headers/opencl-c.h Fri May 24 07:53:52 2019
@@ -17033,6 +17033,34 @@ uint8 __ovld amd_sadw(uint8 src0, uint8
 uint16 __ovld amd_sadw(uint16 src0, uint16 src1, uint16 src2);
 #endif // cl_amd_media_ops2
 
+#if defined(cl_arm_integer_dot_product_int8)
+#pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : begin
+uint __ovld arm_dot(uchar4 a, uchar4 b);
+int __ovld arm_dot(char4 a, char4 b);
+#pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : end
+#endif // defined(cl_arm_integer_dot_product_int8)
+
+#if defined(cl_arm_integer_dot_product_accumulate_int8)
+#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int8 : begin
+uint __ovld arm_dot_acc(uchar4 a, uchar4 b, uint c);
+int __ovld arm_dot_acc(char4 a, char4 b, int c);
+#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int8 : end
+#endif // defined(cl_arm_integer_dot_product_accumulate_int8)
+
+#if defined(cl_arm_integer_dot_product_accumulate_int16)
+#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int16 : begin
+uint __ovld arm_dot_acc(ushort2 a, ushort2 b, uint c);
+int __ovld arm_dot_acc(short2 a, short2 b, int c);
+#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int16 : end
+#endif // defined(cl_arm_integer_dot_product_accumulate_int16)
+
+#if defined(cl_arm_integer_dot_product_accumulate_saturate_int8)
+#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_saturate_int8 : 
begin
+uint __ovld arm_dot_acc_sat(uchar4 a, uchar4 b, uint c);
+int __ovld arm_dot_acc_sat(char4 a, char4 b, int c);
+#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_saturate_int8 : 
end
+#endif // defined(cl_arm_integer_dot_product_accumulate_saturate_int8)
+
 // Disable any extensions we may have enabled previously.
 #pragma OPENCL EXTENSION all : disable
 

Added: cfe/trunk/test/CodeGenOpenCL/arm-integer-dot-product.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/arm-integer-dot-product.cl?rev=361641&view=auto
==
--- cfe/trunk/test/CodeGenOpenCL/arm-integer-dot-product.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/arm-integer-dot-product.cl Fri May 24 07:53:52 
2019
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -finclude-default-header 
-cl-std=CL1.2 -emit-llvm -o - -O0 | FileCheck %s
+
+#pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : enable
+void test_int8(uchar4 ua, uchar4 ub, char4 sa, char4 sb) {
+uint ur = arm_dot(ua, ub);
+// CHECK: call spir_func i32 @_Z7arm_dotDv4_hS_
+int sr = arm_dot(sa, sb);
+// CHECK: call spir_func i32 @_Z7arm_dotDv4_cS_
+}
+#pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : disable
+
+#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int8 : enable
+void test_accumulate_int8(uchar4 ua, uchar4 ub, uint uc, char4 sa, char4 sb, 
int c) {
+uint ur = arm_dot_acc(ua, ub, uc);
+// CHECK: call spir_func i32 @_Z11arm_dot_accDv4_hS_j
+int sr = arm_dot_acc(sa, sb, c);
+// CHEC

r361643 - [LibTooling] Add Explanation parameter to `makeRule`.

2019-05-24 Thread Yitzhak Mandelbaum via cfe-commits
Author: ymandel
Date: Fri May 24 08:11:45 2019
New Revision: 361643

URL: http://llvm.org/viewvc/llvm-project?rev=361643&view=rev
Log:
[LibTooling] Add Explanation parameter to `makeRule`.

Summary:
Conceptually, a single-case RewriteRule has a matcher, edit(s) and an (optional)
explanation. `makeRule` previously only took the matcher and edit(s). This
change adds (optional) support for the explanation.

Reviewers: ilya-biryukov

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h
cfe/trunk/lib/Tooling/Refactoring/Transformer.cpp
cfe/trunk/unittests/Tooling/TransformerTest.cpp

Modified: cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h?rev=361643&r1=361642&r2=361643&view=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h (original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h Fri May 24 
08:11:45 2019
@@ -125,14 +125,16 @@ struct RewriteRule {
 
 /// Convenience function for constructing a simple \c RewriteRule.
 RewriteRule makeRule(ast_matchers::internal::DynTypedMatcher M,
- SmallVector Edits);
+ SmallVector Edits,
+ TextGenerator Explanation = nullptr);
 
 /// Convenience overload of \c makeRule for common case of only one edit.
 inline RewriteRule makeRule(ast_matchers::internal::DynTypedMatcher M,
-ASTEdit Edit) {
+ASTEdit Edit,
+TextGenerator Explanation = nullptr) {
   SmallVector Edits;
   Edits.emplace_back(std::move(Edit));
-  return makeRule(std::move(M), std::move(Edits));
+  return makeRule(std::move(M), std::move(Edits), std::move(Explanation));
 }
 
 /// Applies the first rule whose pattern matches; other rules are ignored.

Modified: cfe/trunk/lib/Tooling/Refactoring/Transformer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/Transformer.cpp?rev=361643&r1=361642&r2=361643&view=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/Transformer.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/Transformer.cpp Fri May 24 08:11:45 2019
@@ -96,10 +96,10 @@ ASTEdit tooling::change(RangeSelector S,
   return E;
 }
 
-RewriteRule tooling::makeRule(DynTypedMatcher M,
-  SmallVector Edits) {
-  return RewriteRule{
-  {RewriteRule::Case{std::move(M), std::move(Edits), nullptr}}};
+RewriteRule tooling::makeRule(DynTypedMatcher M, SmallVector Edits,
+  TextGenerator Explanation) {
+  return RewriteRule{{RewriteRule::Case{std::move(M), std::move(Edits),
+std::move(Explanation)}}};
 }
 
 // Determines whether A is a base type of B in the class hierarchy, including

Modified: cfe/trunk/unittests/Tooling/TransformerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/TransformerTest.cpp?rev=361643&r1=361642&r2=361643&view=diff
==
--- cfe/trunk/unittests/Tooling/TransformerTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/TransformerTest.cpp Fri May 24 08:11:45 2019
@@ -147,8 +147,7 @@ static RewriteRule ruleStrlenSize() {
   on(expr(hasType(isOrPointsTo(StringType)))
  .bind(StringExpr)),
   callee(cxxMethodDecl(hasName("c_str")),
-  change(text("REPLACED")));
-  R.Cases[0].Explanation = text("Use size() method directly on string.");
+  change(text("REPLACED")), text("Use size() method directly on string."));
   return R;
 }
 


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


[PATCH] D62390: [LibTooling] Add Explanation parameter to `makeRule`.

2019-05-24 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361643: [LibTooling] Add Explanation parameter to 
`makeRule`. (authored by ymandel, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62390?vs=201229&id=201251#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62390

Files:
  cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h
  cfe/trunk/lib/Tooling/Refactoring/Transformer.cpp
  cfe/trunk/unittests/Tooling/TransformerTest.cpp


Index: cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h
===
--- cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h
+++ cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h
@@ -125,14 +125,16 @@
 
 /// Convenience function for constructing a simple \c RewriteRule.
 RewriteRule makeRule(ast_matchers::internal::DynTypedMatcher M,
- SmallVector Edits);
+ SmallVector Edits,
+ TextGenerator Explanation = nullptr);
 
 /// Convenience overload of \c makeRule for common case of only one edit.
 inline RewriteRule makeRule(ast_matchers::internal::DynTypedMatcher M,
-ASTEdit Edit) {
+ASTEdit Edit,
+TextGenerator Explanation = nullptr) {
   SmallVector Edits;
   Edits.emplace_back(std::move(Edit));
-  return makeRule(std::move(M), std::move(Edits));
+  return makeRule(std::move(M), std::move(Edits), std::move(Explanation));
 }
 
 /// Applies the first rule whose pattern matches; other rules are ignored.
Index: cfe/trunk/lib/Tooling/Refactoring/Transformer.cpp
===
--- cfe/trunk/lib/Tooling/Refactoring/Transformer.cpp
+++ cfe/trunk/lib/Tooling/Refactoring/Transformer.cpp
@@ -96,10 +96,10 @@
   return E;
 }
 
-RewriteRule tooling::makeRule(DynTypedMatcher M,
-  SmallVector Edits) {
-  return RewriteRule{
-  {RewriteRule::Case{std::move(M), std::move(Edits), nullptr}}};
+RewriteRule tooling::makeRule(DynTypedMatcher M, SmallVector Edits,
+  TextGenerator Explanation) {
+  return RewriteRule{{RewriteRule::Case{std::move(M), std::move(Edits),
+std::move(Explanation)}}};
 }
 
 // Determines whether A is a base type of B in the class hierarchy, including
Index: cfe/trunk/unittests/Tooling/TransformerTest.cpp
===
--- cfe/trunk/unittests/Tooling/TransformerTest.cpp
+++ cfe/trunk/unittests/Tooling/TransformerTest.cpp
@@ -147,8 +147,7 @@
   on(expr(hasType(isOrPointsTo(StringType)))
  .bind(StringExpr)),
   callee(cxxMethodDecl(hasName("c_str")),
-  change(text("REPLACED")));
-  R.Cases[0].Explanation = text("Use size() method directly on string.");
+  change(text("REPLACED")), text("Use size() method directly on string."));
   return R;
 }
 


Index: cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h
===
--- cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h
+++ cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h
@@ -125,14 +125,16 @@
 
 /// Convenience function for constructing a simple \c RewriteRule.
 RewriteRule makeRule(ast_matchers::internal::DynTypedMatcher M,
- SmallVector Edits);
+ SmallVector Edits,
+ TextGenerator Explanation = nullptr);
 
 /// Convenience overload of \c makeRule for common case of only one edit.
 inline RewriteRule makeRule(ast_matchers::internal::DynTypedMatcher M,
-ASTEdit Edit) {
+ASTEdit Edit,
+TextGenerator Explanation = nullptr) {
   SmallVector Edits;
   Edits.emplace_back(std::move(Edit));
-  return makeRule(std::move(M), std::move(Edits));
+  return makeRule(std::move(M), std::move(Edits), std::move(Explanation));
 }
 
 /// Applies the first rule whose pattern matches; other rules are ignored.
Index: cfe/trunk/lib/Tooling/Refactoring/Transformer.cpp
===
--- cfe/trunk/lib/Tooling/Refactoring/Transformer.cpp
+++ cfe/trunk/lib/Tooling/Refactoring/Transformer.cpp
@@ -96,10 +96,10 @@
   return E;
 }
 
-RewriteRule tooling::makeRule(DynTypedMatcher M,
-  SmallVector Edits) {
-  return RewriteRule{
-  {RewriteRule::Case{std::move(M), std::move(Edits), nullptr}}};
+RewriteRule tooling::makeRule(DynTypedMatcher M, SmallVector Edits,
+  TextGenerator Explanation) {

[PATCH] D62340: [clang-tidy] In TransformerClangTidyCheck, require Explanation field.

2019-05-24 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 201256.
ymandel added a comment.

updated to use new version of `makeRule`; changed explanation text in test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62340

Files:
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
  clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp


Index: clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
@@ -26,15 +26,18 @@
   using tooling::change;
   using tooling::node;
   using tooling::statement;
+  using tooling::text;
   using tooling::stencil::cat;
 
   StringRef C = "C", T = "T", E = "E";
-  return tooling::makeRule(ifStmt(hasCondition(expr().bind(C)),
-  hasThen(stmt().bind(T)),
-  hasElse(stmt().bind(E))),
-   change(statement(RewriteRule::RootID),
-  cat("if(!(", node(C), ")) ", statement(E),
-  " else ", statement(T;
+  RewriteRule Rule = tooling::makeRule(
+  ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
+ hasElse(stmt().bind(E))),
+  change(
+  statement(RewriteRule::RootID),
+  cat("if(!(", node(C), ")) ", statement(E), " else ", statement(T))),
+  text("negate condition and reverse `then` and `else` branches"));
+  return Rule;
 }
 
 class IfInverterCheck : public TransformerClangTidyCheck {
Index: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
===
--- clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
+++ clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
@@ -31,10 +31,14 @@
 // };
 class TransformerClangTidyCheck : public ClangTidyCheck {
 public:
+  // All cases in \p R must have a non-null \c Explanation, even though \c
+  // Explanation is optional for RewriteRule in general. Because the primary
+  // purpose of clang-tidy checks is to provide users with diagnostics, we
+  // assume that a missing explanation is a bug.  If no explanation is desired,
+  // indicate that explicitly (for example, by passing `text("no explanation")`
+  //  to `makeRule` as the `Explanation` argument).
   TransformerClangTidyCheck(tooling::RewriteRule R, StringRef Name,
-ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context), Rule(std::move(R)) {}
-
+ClangTidyContext *Context);
   void registerMatchers(ast_matchers::MatchFinder *Finder) final;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) final;
 
Index: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
@@ -13,6 +13,17 @@
 namespace utils {
 using tooling::RewriteRule;
 
+TransformerClangTidyCheck::TransformerClangTidyCheck(tooling::RewriteRule R,
+ StringRef Name,
+ ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context), Rule(std::move(R)) {
+  for (const auto &Case : Rule.Cases) {
+assert(Case.Explanation != nullptr &&
+   "clang-tidy checks must have an explanation by default;"
+   " explicitly provide an empty explanation if none is desired");
+  }
+}
+
 void TransformerClangTidyCheck::registerMatchers(
 ast_matchers::MatchFinder *Finder) {
   Finder->addDynamicMatcher(tooling::detail::buildMatcher(Rule), this);
@@ -44,15 +55,13 @@
   if (Transformations->empty())
 return;
 
-  StringRef Message = "no explanation";
-  if (Case.Explanation) {
-if (Expected E = Case.Explanation(Result))
-  Message = *E;
-else
-  llvm::errs() << "Error in explanation: " << llvm::toString(E.takeError())
-   << "\n";
+  Expected Explanation = Case.Explanation(Result);
+  if (!Explanation) {
+llvm::errs() << "Error in explanation: "
+ << llvm::toString(Explanation.takeError()) << "\n";
+return;
   }
-  DiagnosticBuilder Diag = diag(RootLoc, Message);
+  DiagnosticBuilder Diag = diag(RootLoc, *Explanation);
   for (const auto &T : *Transformations) {
 Diag << FixItHint::CreateReplacement(T.Range, T.Replacement);
   }


Index: clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
===
--- cla

[PATCH] D62399: [clang] Add storage for APValue in ConstantExpr

2019-05-24 Thread Tyker via Phabricator via cfe-commits
Tyker created this revision.
Tyker added a reviewer: rsmith.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith, hiraditya.
Herald added a reviewer: martong.
Herald added a reviewer: shafik.
Herald added projects: clang, LLVM.

When using ConstantExpr we often need the result of the expression to be kept 
in the AST. Currently this is done on a by the node that needs the result and 
has been done multiple times for enumerator, for constexpr variables... . This 
patch adds to ConstantExpr the ability to store the result of evaluating the 
expression. no functional changes expected.

Changes:

- Add trailling object to ConstantExpr that can hold an APValue or an APSInt. 
the APSInt is here because most ConstantExpr yield integral values so they will 
only take enough memory to store an integral values in this case.
- Add basic* serialization support for the trailing result.
- Move conversion functions from an enum to a fltSemantics from 
clang::FloatingLiteral to llvm::APFloatBase. this change is to make it usable 
for serializing APValues.
- Add basic* Import support for the trailing result.
- ConstantExpr created in CheckConvertedConstantExpression now stores the 
result in the ConstantExpr Node.
- Adapt AST dump to print the result when present.

basic* : Uninitialized, Int, Float, FixedPoint, ComplexInt, ComplexFloat,
the result is not yet used anywhere but for -ast-dump.


Repository:
  rC Clang

https://reviews.llvm.org/D62399

Files:
  clang/include/clang/AST/APValue.h
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/AST/TextNodeDumper.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/AST/APValue.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/AST/ast-dump-color.cpp
  llvm/include/llvm/ADT/APFloat.h
  llvm/lib/Support/APFloat.cpp

Index: llvm/lib/Support/APFloat.cpp
===
--- llvm/lib/Support/APFloat.cpp
+++ llvm/lib/Support/APFloat.cpp
@@ -113,6 +113,42 @@
   static const fltSemantics semPPCDoubleDoubleLegacy = {1023, -1022 + 53,
 53 + 53, 128};
 
+  const llvm::fltSemantics &APFloatBase::EnumToSemantics(Semantics S) {
+switch (S) {
+case S_IEEEhalf:
+  return IEEEhalf();
+case S_IEEEsingle:
+  return IEEEsingle();
+case S_IEEEdouble:
+  return IEEEdouble();
+case S_x87DoubleExtended:
+  return x87DoubleExtended();
+case S_IEEEquad:
+  return IEEEquad();
+case S_PPCDoubleDouble:
+  return PPCDoubleDouble();
+}
+llvm_unreachable("Unrecognised floating semantics");
+  }
+
+  APFloatBase::Semantics
+  APFloatBase::SemanticsToEnum(const llvm::fltSemantics &Sem) {
+if (&Sem == &llvm::APFloat::IEEEhalf())
+  return S_IEEEhalf;
+else if (&Sem == &llvm::APFloat::IEEEsingle())
+  return S_IEEEsingle;
+else if (&Sem == &llvm::APFloat::IEEEdouble())
+  return S_IEEEdouble;
+else if (&Sem == &llvm::APFloat::x87DoubleExtended())
+  return S_x87DoubleExtended;
+else if (&Sem == &llvm::APFloat::IEEEquad())
+  return S_IEEEquad;
+else if (&Sem == &llvm::APFloat::PPCDoubleDouble())
+  return S_PPCDoubleDouble;
+else
+  llvm_unreachable("Unknown floating semantics");
+  }
+
   const fltSemantics &APFloatBase::IEEEhalf() {
 return semIEEEhalf;
   }
Index: llvm/include/llvm/ADT/APFloat.h
===
--- llvm/include/llvm/ADT/APFloat.h
+++ llvm/include/llvm/ADT/APFloat.h
@@ -147,6 +147,17 @@
 
   /// \name Floating Point Semantics.
   /// @{
+  enum Semantics {
+S_IEEEhalf,
+S_IEEEsingle,
+S_IEEEdouble,
+S_x87DoubleExtended,
+S_IEEEquad,
+S_PPCDoubleDouble
+  };
+
+  static const llvm::fltSemantics &EnumToSemantics(Semantics S);
+  static Semantics SemanticsToEnum(const llvm::fltSemantics &Sem);
 
   static const fltSemantics &IEEEhalf() LLVM_READNONE;
   static const fltSemantics &IEEEsingle() LLVM_READNONE;
Index: clang/test/AST/ast-dump-color.cpp
===
--- clang/test/AST/ast-dump-color.cpp
+++ clang/test/AST/ast-dump-color.cpp
@@ -49,13 +49,13 @@
 //CHECK: {{^}}[[Blue]]| |   |-[[RESET]][[MAGENTA]]IntegerLiteral[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:10:11[[RESET]]> [[Green]]'int'[[RESET]][[Cyan:.\[0;36m]][[RESET]][[Cyan]][[RESET]][[CYAN]] 1[[RESET]]{{$}}
 //CHECK: {{^}}[[Blue]]| |   `-[[RESET]][[MAGENTA]]CompoundStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:14[[RES

[PATCH] D62377: [OpenCL] Add support for the cl_arm_integer_dot_product extensions

2019-05-24 Thread Kévin Petit via Phabricator via cfe-commits
kpet closed this revision.
kpet added a comment.

Committed as r361641.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62377



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


r361645 - [CodeComplete] Add whitespace around braces in lambda completions

2019-05-24 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Fri May 24 09:16:15 2019
New Revision: 361645

URL: http://llvm.org/viewvc/llvm-project?rev=361645&view=rev
Log:
[CodeComplete] Add whitespace around braces in lambda completions

This produces nicer output.
Trivial follow-up to r361461, so sending without review.

Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/CodeCompletion/lambdas.cpp

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=361645&r1=361644&r2=361645&view=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Fri May 24 09:16:15 2019
@@ -4177,8 +4177,11 @@ static void AddLambdaCompletion(ResultBu
 };
 Completion.AddChunk(CodeCompletionString::CK_RightParen);
   }
+  Completion.AddChunk(clang::CodeCompletionString::CK_HorizontalSpace);
   Completion.AddChunk(CodeCompletionString::CK_LeftBrace);
+  Completion.AddChunk(CodeCompletionString::CK_HorizontalSpace);
   Completion.AddPlaceholderChunk("body");
+  Completion.AddChunk(CodeCompletionString::CK_HorizontalSpace);
   Completion.AddChunk(CodeCompletionString::CK_RightBrace);
 
   Results.AddResult(Completion.TakeString());

Modified: cfe/trunk/test/CodeCompletion/lambdas.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/lambdas.cpp?rev=361645&r1=361644&r2=361645&view=diff
==
--- cfe/trunk/test/CodeCompletion/lambdas.cpp (original)
+++ cfe/trunk/test/CodeCompletion/lambdas.cpp Fri May 24 09:16:15 2019
@@ -9,17 +9,17 @@ void test() {
   function y = {};
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:7:28 %s -o - | FileCheck -check-prefix=CHECK-1 %s
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:9:35 %s -o - | FileCheck -check-prefix=CHECK-1 %s
-  // CHECK-1: COMPLETION: Pattern : [<#=#>](int <#parameter#>, double 
<#parameter#>){<#body#>}
+  // CHECK-1: COMPLETION: Pattern : [<#=#>](int <#parameter#>, double 
<#parameter#>) { <#body#> }
 
   // == Placeholders for suffix types must be placed properly.
   function z = {};
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:15:36 %s -o - | FileCheck -check-prefix=CHECK-2 %s
-  // CHECK-2: COMPLETION: Pattern : [<#=#>](void (* 
<#parameter#>)(int)){<#body#>}
+  // CHECK-2: COMPLETION: Pattern : [<#=#>](void (* <#parameter#>)(int)) { 
<#body#> }
 
   // == No need for a parameter list if function has no parameters.
   function a = {};
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:20:24 %s -o - | FileCheck -check-prefix=CHECK-3 %s
-  // CHECK-3: COMPLETION: Pattern : [<#=#>]{<#body#>}
+  // CHECK-3: COMPLETION: Pattern : [<#=#>] { <#body#> }
 }
 
 template 
@@ -33,7 +33,7 @@ void test2() {
   function_typedef b = {};
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:30:35 %s -o - | FileCheck -check-prefix=CHECK-4 %s
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:33:24 %s -o - | FileCheck -check-prefix=CHECK-4 %s
-  // CHECK-4: COMPLETION: Pattern : [<#=#>](vector 
<#parameter#>){<#body#>}
+  // CHECK-4: COMPLETION: Pattern : [<#=#>](vector <#parameter#>) { 
<#body#> }
 }
 
 // Check another common function wrapper name.
@@ -42,7 +42,7 @@ template  struct unique_functio
 void test3() {
   unique_function a = {};
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns 
-code-completion-at=%s:43:31 %s -o - | FileCheck -check-prefix=CHECK-5 %s
-  // CHECK-5: COMPLETION: Pattern : [<#=#>]{<#body#>}
+  // CHECK-5: COMPLETION: Pattern : [<#=#>] { <#body#> }
 }
 
 template  struct weird_function {};


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


[PATCH] D37813: clang-format: better handle namespace macros

2019-05-24 Thread Francois Ferrand via Phabricator via cfe-commits
Typz marked 2 inline comments as done.
Typz added inline comments.



Comment at: unittests/Format/NamespaceEndCommentsFixerTest.cpp:526
   EXPECT_EQ("namespace A {\n"
 "  int i;\n"
 "} // namespace A",

Should I also fix these tests?

They already existed before this patch, but do not follow LLVM namespace indent 
style either.



Comment at: unittests/Format/NamespaceEndCommentsFixerTest.cpp:582
+  EXPECT_EQ("TESTSUITE() {\n"
+"  int i;\n"
+"} // TESTSUITE()",

klimek wrote:
> All of the fixNamespaceEndComments tests are indented, but standard llvm 
> style doesn't indent in namespaces at all iiuc.
Ok, understood. I can fix that.


Repository:
  rC Clang

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

https://reviews.llvm.org/D37813



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


[PATCH] D59402: Fix-it hints for -Wmissing-{prototypes,variable-declarations}

2019-05-24 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Please see https://clang.llvm.org/docs/InternalsManual.html#fix-it-hints , 
especially the "need to obey these rules" bit. I'm not sure that's fulfilled 
here. Maybe the fixit should be on a note instead?


Repository:
  rC Clang

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

https://reviews.llvm.org/D59402



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


[clang-tools-extra] r361647 - [clang-tidy] In TransformerClangTidyCheck, require Explanation field.

2019-05-24 Thread Yitzhak Mandelbaum via cfe-commits
Author: ymandel
Date: Fri May 24 09:32:03 2019
New Revision: 361647

URL: http://llvm.org/viewvc/llvm-project?rev=361647&view=rev
Log:
[clang-tidy] In TransformerClangTidyCheck, require Explanation field.

Summary:
In general, the `Explanation` field is optional in `RewriteRule` cases. But,
because the primary purpose of clang-tidy checks is to provide users with
diagnostics, we assume that a missing explanation is a bug.  This change adds an
assertion that checks all cases for an explanation, and updates the code to rely
on that assertion correspondingly.

Reviewers: ilya-biryukov

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h

clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp

Modified: clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp?rev=361647&r1=361646&r2=361647&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp Fri 
May 24 09:32:03 2019
@@ -13,6 +13,17 @@ namespace tidy {
 namespace utils {
 using tooling::RewriteRule;
 
+TransformerClangTidyCheck::TransformerClangTidyCheck(tooling::RewriteRule R,
+ StringRef Name,
+ ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context), Rule(std::move(R)) {
+  for (const auto &Case : Rule.Cases) {
+assert(Case.Explanation != nullptr &&
+   "clang-tidy checks must have an explanation by default;"
+   " explicitly provide an empty explanation if none is desired");
+  }
+}
+
 void TransformerClangTidyCheck::registerMatchers(
 ast_matchers::MatchFinder *Finder) {
   Finder->addDynamicMatcher(tooling::detail::buildMatcher(Rule), this);
@@ -44,15 +55,13 @@ void TransformerClangTidyCheck::check(
   if (Transformations->empty())
 return;
 
-  StringRef Message = "no explanation";
-  if (Case.Explanation) {
-if (Expected E = Case.Explanation(Result))
-  Message = *E;
-else
-  llvm::errs() << "Error in explanation: " << llvm::toString(E.takeError())
-   << "\n";
+  Expected Explanation = Case.Explanation(Result);
+  if (!Explanation) {
+llvm::errs() << "Error in explanation: "
+ << llvm::toString(Explanation.takeError()) << "\n";
+return;
   }
-  DiagnosticBuilder Diag = diag(RootLoc, Message);
+  DiagnosticBuilder Diag = diag(RootLoc, *Explanation);
   for (const auto &T : *Transformations) {
 Diag << FixItHint::CreateReplacement(T.Range, T.Replacement);
   }

Modified: clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h?rev=361647&r1=361646&r2=361647&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h 
(original)
+++ clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h Fri 
May 24 09:32:03 2019
@@ -31,10 +31,14 @@ namespace utils {
 // };
 class TransformerClangTidyCheck : public ClangTidyCheck {
 public:
+  // All cases in \p R must have a non-null \c Explanation, even though \c
+  // Explanation is optional for RewriteRule in general. Because the primary
+  // purpose of clang-tidy checks is to provide users with diagnostics, we
+  // assume that a missing explanation is a bug.  If no explanation is desired,
+  // indicate that explicitly (for example, by passing `text("no explanation")`
+  //  to `makeRule` as the `Explanation` argument).
   TransformerClangTidyCheck(tooling::RewriteRule R, StringRef Name,
-ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context), Rule(std::move(R)) {}
-
+ClangTidyContext *Context);
   void registerMatchers(ast_matchers::MatchFinder *Finder) final;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) final;
 

Modified: 
clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp?rev=361647&r1=361646&r2=361647&view=diff
==
--- 
clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp 
(original)
+++ 
clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp 
Fri May 24 09:32:03 2019

[PATCH] D62340: [clang-tidy] In TransformerClangTidyCheck, require Explanation field.

2019-05-24 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361647: [clang-tidy] In TransformerClangTidyCheck, require 
Explanation field. (authored by ymandel, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62340?vs=201256&id=201272#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62340

Files:
  clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
  clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
  clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp


Index: clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
+++ clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
@@ -31,10 +31,14 @@
 // };
 class TransformerClangTidyCheck : public ClangTidyCheck {
 public:
+  // All cases in \p R must have a non-null \c Explanation, even though \c
+  // Explanation is optional for RewriteRule in general. Because the primary
+  // purpose of clang-tidy checks is to provide users with diagnostics, we
+  // assume that a missing explanation is a bug.  If no explanation is desired,
+  // indicate that explicitly (for example, by passing `text("no explanation")`
+  //  to `makeRule` as the `Explanation` argument).
   TransformerClangTidyCheck(tooling::RewriteRule R, StringRef Name,
-ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context), Rule(std::move(R)) {}
-
+ClangTidyContext *Context);
   void registerMatchers(ast_matchers::MatchFinder *Finder) final;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) final;
 
Index: clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
@@ -13,6 +13,17 @@
 namespace utils {
 using tooling::RewriteRule;
 
+TransformerClangTidyCheck::TransformerClangTidyCheck(tooling::RewriteRule R,
+ StringRef Name,
+ ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context), Rule(std::move(R)) {
+  for (const auto &Case : Rule.Cases) {
+assert(Case.Explanation != nullptr &&
+   "clang-tidy checks must have an explanation by default;"
+   " explicitly provide an empty explanation if none is desired");
+  }
+}
+
 void TransformerClangTidyCheck::registerMatchers(
 ast_matchers::MatchFinder *Finder) {
   Finder->addDynamicMatcher(tooling::detail::buildMatcher(Rule), this);
@@ -44,15 +55,13 @@
   if (Transformations->empty())
 return;
 
-  StringRef Message = "no explanation";
-  if (Case.Explanation) {
-if (Expected E = Case.Explanation(Result))
-  Message = *E;
-else
-  llvm::errs() << "Error in explanation: " << llvm::toString(E.takeError())
-   << "\n";
+  Expected Explanation = Case.Explanation(Result);
+  if (!Explanation) {
+llvm::errs() << "Error in explanation: "
+ << llvm::toString(Explanation.takeError()) << "\n";
+return;
   }
-  DiagnosticBuilder Diag = diag(RootLoc, Message);
+  DiagnosticBuilder Diag = diag(RootLoc, *Explanation);
   for (const auto &T : *Transformations) {
 Diag << FixItHint::CreateReplacement(T.Range, T.Replacement);
   }
Index: 
clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
===
--- 
clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
+++ 
clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
@@ -26,15 +26,18 @@
   using tooling::change;
   using tooling::node;
   using tooling::statement;
+  using tooling::text;
   using tooling::stencil::cat;
 
   StringRef C = "C", T = "T", E = "E";
-  return tooling::makeRule(ifStmt(hasCondition(expr().bind(C)),
-  hasThen(stmt().bind(T)),
-  hasElse(stmt().bind(E))),
-   change(statement(RewriteRule::RootID),
-  cat("if(!(", node(C), ")) ", statement(E),
-  " else ", statement(T;
+  RewriteRule Rule = tooling::makeRule(
+  ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
+ hasElse(stmt().bind(E))),
+  change(
+  statement(RewriteRule::RootID),
+  cat("if(!(", node(C), ")) ", statement(E), " else ", statement(T))),
+  text("negate condition and r

[PATCH] D62405: [CodeComplete] Consistently break after '{' in multi-line patterns

2019-05-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: gribozavr.
Herald added a project: clang.

Completion can return multi-line patterns in some cases, e.g.

  for (<#init#>; <#cond#>; <#inc#>) {
  <#body#>
  }

However, most patterns break the line only before closing brace,
resulting in code like:

  namespace <#name#> { <#decls#>
  }

While some (e.g. the 'for' example above) are breaking lines after the
opening brace too.

This change ensures all patterns consistently break after the opening
brace, this leads to nicer UX when using those in an actual editor.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62405

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/ordinary-name-cxx11.cpp
  clang/test/CodeCompletion/ordinary-name.cpp

Index: clang/test/CodeCompletion/ordinary-name.cpp
===
--- clang/test/CodeCompletion/ordinary-name.cpp
+++ clang/test/CodeCompletion/ordinary-name.cpp
@@ -12,7 +12,9 @@
   // CHECK-CC1-NEXT: COMPLETION: Pattern : const_cast<<#type#>>(<#expression#>)
   // CHECK-CC1: COMPLETION: Pattern : [#void#]delete <#expression#>
   // CHECK-CC1-NEXT: COMPLETION: Pattern : [#void#]delete [] <#expression#>
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : do{<#statements#>
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : do{
+  // CHECK-CC1-NEXT: <#statements#>
+  // CHECK-CC1-NEXT: }
   // CHECK-CC1: COMPLETION: double
   // CHECK-CC1-NEXT: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>)
   // CHECK-CC1-NEXT: COMPLETION: enum
@@ -21,8 +23,12 @@
   // CHECK-CC1-NEXT: COMPLETION: float
   // CHECK-CC1-NEXT: COMPLETION: foo : [#void#]foo()
   // CHECK-CC1-NEXT: COMPLETION: Pattern : for(<#init-statement#>;<#condition#>;<#inc-expression#>){
+  // CHECK-CC1-NEXT: <#statements#>{{$}}
+  // CHECK-CC1-NEXT: }
   // CHECK-CC1: COMPLETION: Pattern : goto <#label#>;
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : if(<#condition#>){<#statements#>
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : if(<#condition#>){
+  // CHECK-CC1-NEXT: <#statements#>{{$}}
+  // CHECK-CC1-NEXT: }
   // CHECK-CC1: COMPLETION: int
   // CHECK-CC1-NEXT: COMPLETION: long
   // CHECK-CC1-NEXT: COMPLETION: Pattern : new <#type#>(<#expressions#>)
@@ -40,7 +46,11 @@
   // CHECK-CC1: COMPLETION: t : t
   // CHECK-CC1-NEXT: COMPLETION: Pattern : [#void#]throw <#expression#>
   // CHECK-CC1-NEXT: COMPLETION: Pattern : [#bool#]true
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : try{<#statements#>
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : try{
+  // CHECK-CC1-NEXT: <#statements#>
+  // CHECK-CC1-NEXT: }catch(<#declaration#>){
+  // CHECK-CC1-NEXT: <#statements#>
+  // CHECK-CC1-NEXT: }
   // CHECK-CC1: COMPLETION: TYPEDEF : TYPEDEF
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>
   // CHECK-CC1-NEXT: COMPLETION: Pattern : [#std::type_info#]typeid(<#expression-or-type#>)
@@ -53,7 +63,9 @@
   // CHECK-CC1-NEXT: COMPLETION: void
   // CHECK-CC1-NEXT: COMPLETION: volatile
   // CHECK-CC1-NEXT: COMPLETION: wchar_t
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : while(<#condition#>){<#statements#>
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : while(<#condition#>){
+  // CHECK-CC1-NEXT: <#statements#>
+  // CHECK-CC1-NEXT: }
   // CHECK-CC1: COMPLETION: X : X
   // CHECK-CC1-NEXT: COMPLETION: y : [#int#]y
   // CHECK-CC1-NEXT: COMPLETION: z : [#void#]z(<#int#>)
@@ -71,7 +83,9 @@
   // CHECK-CC2-NEXT: COMPLETION: inline
   // CHECK-CC2-NEXT: COMPLETION: int
   // CHECK-CC2-NEXT: COMPLETION: long
-  // CHECK-CC2-NEXT: COMPLETION: Pattern : namespace <#identifier#>{<#declarations#>
+  // CHECK-CC2-NEXT: COMPLETION: Pattern : namespace <#identifier#>{
+  // CHECK-CC2-NEXT: <#declarations#>
+  // CHECK-CC2-NEXT: }
   // CHECK-CC2: COMPLETION: Pattern : namespace <#name#> = <#namespace#>;
   // CHECK-CC2-NEXT: COMPLETION: operator
   // CHECK-CC2-NEXT: COMPLETION: short
@@ -181,7 +195,7 @@
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : const_cast<<#type#>>(<#expression#>)
   // CHECK-NO-RTTI: COMPLETION: Pattern : [#void#]delete <#expression#>
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : [#void#]delete [] <#expression#>
-  // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : do{<#statements#>
+  // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : do{
   // CHECK-NO-RTTI: COMPLETION: double
   // CHECK-NO-RTTI-NOT: dynamic_cast
   // CHECK-NO-RTTI: COMPLETION: enum
@@ -191,7 +205,7 @@
   // CHECK-NO-RTTI-NEXT: COMPLETION: foo : [#void#]foo()
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : for(<#init-statement#>;<#condition#>;<#inc-expression#>){
   // CHECK-NO-RTTI: COMPLETION: Pattern : goto <#label#>;
-  // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : if(<#condition#>){<#statements#>
+  // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : if(<#condition#>){
   // CHECK-NO-RTTI: COMPLETION: int
   // CHECK-NO-RTTI-NEXT: COMPLETION: long
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : new <#type#>(<#expressions#>)
@@ -222,7 +236,7 @@
   /

[PATCH] D62406: [WebAssembly] Use "linker" as linker shortname.

2019-05-24 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 created this revision.
Herald added subscribers: cfe-commits, sunfish, aheejin, jgravelle-google, 
dschuff.
Herald added a project: clang.
sbc100 added a reviewer: dschuff.

This is in line with other platforms.

Also, move the single statement methods into the header (also
in line with other platform).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62406

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Driver/ToolChains/WebAssembly.h


Index: clang/lib/Driver/ToolChains/WebAssembly.h
===
--- clang/lib/Driver/ToolChains/WebAssembly.h
+++ clang/lib/Driver/ToolChains/WebAssembly.h
@@ -20,9 +20,10 @@
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  explicit Linker(const ToolChain &TC);
-  bool isLinkJob() const override;
-  bool hasIntegratedCPP() const override;
+  explicit Linker(const ToolChain &TC)
+  : GnuTool("wasm::Linker", "linker", TC) {}
+  bool isLinkJob() const override { return true; }
+  bool hasIntegratedCPP() const override { return false; }
   std::string getLinkerPath(const llvm::opt::ArgList &Args) const;
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -22,9 +22,6 @@
 using namespace clang;
 using namespace llvm::opt;
 
-wasm::Linker::Linker(const ToolChain &TC)
-: GnuTool("wasm::Linker", "lld", TC) {}
-
 /// Following the conventions in https://wiki.debian.org/Multiarch/Tuples,
 /// we remove the vendor field to form the multiarch triple.
 static std::string getMultiarchTriple(const Driver &D,
@@ -34,10 +31,6 @@
 TargetTriple.getOSAndEnvironmentName()).str();
 }
 
-bool wasm::Linker::isLinkJob() const { return true; }
-
-bool wasm::Linker::hasIntegratedCPP() const { return false; }
-
 std::string wasm::Linker::getLinkerPath(const ArgList &Args) const {
   const ToolChain &ToolChain = getToolChain();
   if (const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {


Index: clang/lib/Driver/ToolChains/WebAssembly.h
===
--- clang/lib/Driver/ToolChains/WebAssembly.h
+++ clang/lib/Driver/ToolChains/WebAssembly.h
@@ -20,9 +20,10 @@
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  explicit Linker(const ToolChain &TC);
-  bool isLinkJob() const override;
-  bool hasIntegratedCPP() const override;
+  explicit Linker(const ToolChain &TC)
+  : GnuTool("wasm::Linker", "linker", TC) {}
+  bool isLinkJob() const override { return true; }
+  bool hasIntegratedCPP() const override { return false; }
   std::string getLinkerPath(const llvm::opt::ArgList &Args) const;
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -22,9 +22,6 @@
 using namespace clang;
 using namespace llvm::opt;
 
-wasm::Linker::Linker(const ToolChain &TC)
-: GnuTool("wasm::Linker", "lld", TC) {}
-
 /// Following the conventions in https://wiki.debian.org/Multiarch/Tuples,
 /// we remove the vendor field to form the multiarch triple.
 static std::string getMultiarchTriple(const Driver &D,
@@ -34,10 +31,6 @@
 TargetTriple.getOSAndEnvironmentName()).str();
 }
 
-bool wasm::Linker::isLinkJob() const { return true; }
-
-bool wasm::Linker::hasIntegratedCPP() const { return false; }
-
 std::string wasm::Linker::getLinkerPath(const ArgList &Args) const {
   const ToolChain &ToolChain = getToolChain();
   if (const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D62340: [clang-tidy] In TransformerClangTidyCheck, require Explanation field.

2019-05-24 Thread Ilya Biryukov via cfe-commits
This seems to produce warnings about unused variables:
…/llvm/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp:20:20:
warning: unused variable 'Case' [-Wunused-variable]

  for (const auto &Case : Rule.Cases) {

Could you take a look?

On Fri, May 24, 2019 at 6:29 PM Yitzhak Mandelbaum via Phabricator <
revi...@reviews.llvm.org> wrote:

> This revision was automatically updated to reflect the committed changes.
> Closed by commit rL361647: [clang-tidy] In TransformerClangTidyCheck,
> require Explanation field. (authored by ymandel, committed by ).
> Herald added a project: LLVM.
> Herald added a subscriber: llvm-commits.
>
> Changed prior to commit:
>   https://reviews.llvm.org/D62340?vs=201256&id=201272#toc
>
> Repository:
>   rL LLVM
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D62340/new/
>
> https://reviews.llvm.org/D62340
>
> Files:
>   clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
>   clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
>
> clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
>
>
> Index: clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
> ===
> --- clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
> +++ clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
> @@ -31,10 +31,14 @@
>  // };
>  class TransformerClangTidyCheck : public ClangTidyCheck {
>  public:
> +  // All cases in \p R must have a non-null \c Explanation, even though \c
> +  // Explanation is optional for RewriteRule in general. Because the
> primary
> +  // purpose of clang-tidy checks is to provide users with diagnostics, we
> +  // assume that a missing explanation is a bug.  If no explanation is
> desired,
> +  // indicate that explicitly (for example, by passing `text("no
> explanation")`
> +  //  to `makeRule` as the `Explanation` argument).
>TransformerClangTidyCheck(tooling::RewriteRule R, StringRef Name,
> -ClangTidyContext *Context)
> -  : ClangTidyCheck(Name, Context), Rule(std::move(R)) {}
> -
> +ClangTidyContext *Context);
>void registerMatchers(ast_matchers::MatchFinder *Finder) final;
>void check(const ast_matchers::MatchFinder::MatchResult &Result) final;
>
> Index:
> clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
> ===
> --- clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
> +++ clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
> @@ -13,6 +13,17 @@
>  namespace utils {
>  using tooling::RewriteRule;
>
> +TransformerClangTidyCheck::TransformerClangTidyCheck(tooling::RewriteRule
> R,
> + StringRef Name,
> + ClangTidyContext
> *Context)
> +: ClangTidyCheck(Name, Context), Rule(std::move(R)) {
> +  for (const auto &Case : Rule.Cases) {
> +assert(Case.Explanation != nullptr &&
> +   "clang-tidy checks must have an explanation by default;"
> +   " explicitly provide an empty explanation if none is desired");
> +  }
> +}
> +
>  void TransformerClangTidyCheck::registerMatchers(
>  ast_matchers::MatchFinder *Finder) {
>Finder->addDynamicMatcher(tooling::detail::buildMatcher(Rule), this);
> @@ -44,15 +55,13 @@
>if (Transformations->empty())
>  return;
>
> -  StringRef Message = "no explanation";
> -  if (Case.Explanation) {
> -if (Expected E = Case.Explanation(Result))
> -  Message = *E;
> -else
> -  llvm::errs() << "Error in explanation: " <<
> llvm::toString(E.takeError())
> -   << "\n";
> +  Expected Explanation = Case.Explanation(Result);
> +  if (!Explanation) {
> +llvm::errs() << "Error in explanation: "
> + << llvm::toString(Explanation.takeError()) << "\n";
> +return;
>}
> -  DiagnosticBuilder Diag = diag(RootLoc, Message);
> +  DiagnosticBuilder Diag = diag(RootLoc, *Explanation);
>for (const auto &T : *Transformations) {
>  Diag << FixItHint::CreateReplacement(T.Range, T.Replacement);
>}
> Index:
> clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
> ===
> ---
> clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
> +++
> clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
> @@ -26,15 +26,18 @@
>using tooling::change;
>using tooling::node;
>using tooling::statement;
> +  using tooling::text;
>using tooling::stencil::cat;
>
>StringRef C = "C", T = "T", E = "E";
> -  return tooling::makeRule(ifStmt(hasCondition(expr().bind(C)),
> -  hasThen(stmt().bind(T)),
> -  

r361650 - [ASTImporter] Call to HandleNameConflict in VisitRecordDecl mistakeningly using Name instead of SearchName

2019-05-24 Thread Shafik Yaghmour via cfe-commits
Author: shafik
Date: Fri May 24 09:53:44 2019
New Revision: 361650

URL: http://llvm.org/viewvc/llvm-project?rev=361650&view=rev
Log:
[ASTImporter] Call to HandleNameConflict in VisitRecordDecl mistakeningly using 
Name instead of SearchName

Summary:
https://reviews.llvm.org/D51633 added error handling to the 
ASTNodeImporter::VisitRecordDecl for the conflicting names case. This could 
lead to erroneous return of an error in that case since we should have been 
using SearchName. Name may be empty in the case where we find the name via 
D->getTypedefNameForAnonDecl()->getDeclName().

This fix is very similar to https://reviews.llvm.org/D59665

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

Modified:
cfe/trunk/lib/AST/ASTImporter.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=361650&r1=361649&r2=361650&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Fri May 24 09:53:44 2019
@@ -2585,7 +2585,7 @@ ExpectedDecl ASTNodeImporter::VisitRecor
 } // for
 
 if (!ConflictingDecls.empty() && SearchName) {
-  Name = Importer.HandleNameConflict(Name, DC, IDNS,
+  Name = Importer.HandleNameConflict(SearchName, DC, IDNS,
  ConflictingDecls.data(),
  ConflictingDecls.size());
   if (!Name)


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


[PATCH] D62407: [OpenMP] Add test for requires and unified shared memory clause with declare target link

2019-05-24 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
gtbercea added reviewers: ABataev, caomhin.
Herald added subscribers: cfe-commits, jdoerfert, guansong.
Herald added a project: clang.

This patch adds a test for requires with unified share memory clause when a 
declare target link is present.

This test needs to go in prior to changes to declare target link for comparison 
purposes.


Repository:
  rC Clang

https://reviews.llvm.org/D62407

Files:
  test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp


Index: test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
===
--- /dev/null
+++ test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
@@ -0,0 +1,67 @@
+// Test declare target link under unified memory requirement.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-cuda-mode -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s 
-o - | FileCheck %s --check-prefix CHECK
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+#define N 1000
+
+double var = 10.0;
+
+#pragma omp requires unified_shared_memory
+#pragma omp declare target link(var)
+
+int bar(int n){
+  double sum = 0;
+
+#pragma omp target
+  for(int i = 0; i < n; i++) {
+sum += var;
+  }
+
+  return sum;
+}
+
+// CHECK: [[VAR:@.+]] = global double 1.00e+01
+// CHECK: [[VAR_DECL_TGT_LINK_PTR:@.+]] = global double* [[VAR]]
+
+// CHECK: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [3 x i64] [i64 
4, i64 8, i64 8]
+// CHECK: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [3 x i64] 
[i64 800, i64 800, i64 531]
+
+// CHECK: [[N_CASTED:%.+]] = alloca i64
+// CHECK: [[SUM_CASTED:%.+]] = alloca i64
+
+// CHECK: [[OFFLOAD_BASEPTRS:%.+]] = alloca [3 x i8*]
+// CHECK: [[OFFLOAD_PTRS:%.+]] = alloca [3 x i8*]
+
+// CHECK: [[LOAD1:%.+]] = load i64, i64* [[N_CASTED]]
+// CHECK: [[LOAD2:%.+]] = load i64, i64* [[SUM_CASTED]]
+
+// CHECK: [[BPTR1:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK: [[BCAST1:%.+]] = bitcast i8** [[BPTR1]] to i64*
+// CHECK: store i64 [[LOAD1]], i64* [[BCAST1]]
+// CHECK: [[BPTR2:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 0
+// CHECK: [[BCAST2:%.+]] = bitcast i8** [[BPTR2]] to i64*
+// CHECK: store i64 [[LOAD1]], i64* [[BCAST2]]
+
+// CHECK: [[BPTR3:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 1
+// CHECK: [[BCAST3:%.+]] = bitcast i8** [[BPTR3]] to i64*
+// CHECK: store i64 [[LOAD2]], i64* [[BCAST3]]
+// CHECK: [[BPTR4:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 1
+// CHECK: [[BCAST4:%.+]] = bitcast i8** [[BPTR4]] to i64*
+// CHECK: store i64 [[LOAD2]], i64* [[BCAST4]]
+
+// CHECK: [[BPTR5:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 2
+// CHECK: [[BCAST5:%.+]] = bitcast i8** [[BPTR5]] to double***
+// CHECK: store double** [[VAR_DECL_TGT_LINK_PTR]], double*** [[BCAST5]]
+// CHECK: [[BPTR6:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 2
+// CHECK: [[BCAST6:%.+]] = bitcast i8** [[BPTR6]] to double**
+// CHECK: store double* [[VAR]], double** [[BCAST6]]
+
+// CHECK: [[BPTR7:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK: [[BPTR8:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 0
+
+// CHECK: call i32 @__tgt_target(i64 -1, i8* @{{.*}}.region_id, i32 3, i8** 
%16, i8** %17, i64* getelementptr inbounds ([3 x i64], [3 x i64]* 
[[OFFLOAD_SIZES]], i32 0, i32 0), i64* getelementptr inbounds ([3 x i64], [3 x 
i64]* [[OFFLOAD_MAPTYPES]], i32 0, i32 0))
+
+#endif


Index: test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
===
--- /dev/null
+++ test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
@@ -0,0 +1,67 @@
+// Test declare target link under unified memory requirement.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-cuda-mode -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+#define N 1000
+
+double var = 10.0;
+
+#pragma omp requires unified_shared_memory
+#pragma omp declare target link(var)
+
+int bar(int n){
+  double sum = 0;
+
+#pragma omp target
+  for(int i = 0; i < n; i++) {
+sum += var;
+  }
+
+  return sum;
+}
+
+// CHECK: [[VAR:@.+]] = global double 1.00e+01
+// CHECK: [[VAR_DECL_TGT_LINK_PTR:@.+]] = global double* [[VAR]]
+
+// CHECK: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [3 x i64] [i64 4, i64 8, i64 8]
+// CHECK: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [3 x i64] [i64 800, i64 800, i64 531]
+
+// CHECK: [[N_CASTED:%.+]] = alloca i64
+// CHECK: [[SUM_CASTED:%.+]] = alloca i64
+
+// CHECK: [[OFFLOAD_

[PATCH] D62407: [OpenMP] Add test for requires and unified shared memory clause with declare target link

2019-05-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Just one question - why it is not the part of the whole patch for the unified 
memory support in clang?


Repository:
  rC Clang

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

https://reviews.llvm.org/D62407



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


[PATCH] D62368: Add support for Hygon Dhyana processor

2019-05-24 Thread Kostya Kortchinsky via Phabricator via cfe-commits
cryptoad added a comment.

Regarding the Scudo side of the patch: the code has to be able to compile with 
gcc as well, and not necessarily the latest version.
This won't compile on systems without a `signature_HYGON_*`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62368



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


[PATCH] D62156: [Sema][PR41730] Diagnose addr space mismatch while constructing objects

2019-05-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:3653
+def note_ovl_candidate_illegal_constructor_adrspace_mismatch : Note<
+"candidate constructor ignored: address space mismatch between object and 
constructor">;
 def note_ovl_candidate_bad_deduction : Note<

"candidate constructor ignored: cannot be used to construct an object in 
address space %0"?



Comment at: lib/Sema/SemaDeclCXX.cpp:8229
+  if (FTI.hasMethodTypeCVRUQualifiers()) {
+FTI.MethodQualifiers->forEachCVRUQualifier(
 [&](DeclSpec::TQ TypeQual, StringRef QualName, SourceLocation SL) {

Anastasia wrote:
> rjmccall wrote:
> > rjmccall wrote:
> > > We want to catch `_Atomic`, too, so please just change this loop to 
> > > ignore address-space qualifiers, using a flag to decide whether to call 
> > > `setInvalidType`.
> > If there aren't any qualifiers we're skipping, the flag isn't necessary.
> We are skipping addr space currently. I use this flag to avoid setting 
> declaration as invalid below if it's only qualified by an addr space.
Okay.  Does `forEachQualifier` not visit address-space qualifiers?

Please leave a comment explaining that that's the intended behavior: we should 
visit everything except an address space.



Comment at: lib/Sema/SemaOverload.cpp:6095
+// Check that addr space of an object being constructed is convertible to
+// the one ctor qualified with.
+if (!Qualifiers::isAddressSpaceSupersetOf(

"Check that the constructor is capable of constructing an object in the 
destination address space."

Should there be an exception here for trivial default/copy/move constructors?



Comment at: test/CodeGenCXX/address-space-of-this.cpp:3
 // RUN: %clang_cc1 %s -std=c++17 -triple=spir -emit-llvm -o - | FileCheck %s
+// XFAIL: *
 

Is there nothing in this test that's worth continuing to check while we work on 
fixing this problem?


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

https://reviews.llvm.org/D62156



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


[PATCH] D62343: [cmake] Remove old unused version of FindZ3.cmake from clang [NFC]

2019-05-24 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62343



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


Re: [PATCH] D62340: [clang-tidy] In TransformerClangTidyCheck, require Explanation field.

2019-05-24 Thread Yitzhak Mandelbaum via cfe-commits
looking now...

On Fri, May 24, 2019 at 12:49 PM Ilya Biryukov  wrote:

> This seems to produce warnings about unused variables:
> …/llvm/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp:20:20:
> warning: unused variable 'Case' [-Wunused-variable]
>
>   for (const auto &Case : Rule.Cases) {
>
> Could you take a look?
>
> On Fri, May 24, 2019 at 6:29 PM Yitzhak Mandelbaum via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> This revision was automatically updated to reflect the committed changes.
>> Closed by commit rL361647: [clang-tidy] In TransformerClangTidyCheck,
>> require Explanation field. (authored by ymandel, committed by ).
>> Herald added a project: LLVM.
>> Herald added a subscriber: llvm-commits.
>>
>> Changed prior to commit:
>>   https://reviews.llvm.org/D62340?vs=201256&id=201272#toc
>>
>> Repository:
>>   rL LLVM
>>
>> CHANGES SINCE LAST ACTION
>>   https://reviews.llvm.org/D62340/new/
>>
>> https://reviews.llvm.org/D62340
>>
>> Files:
>>   clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
>>   clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
>>
>> clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
>>
>>
>> Index:
>> clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
>> ===
>> --- clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
>> +++ clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
>> @@ -31,10 +31,14 @@
>>  // };
>>  class TransformerClangTidyCheck : public ClangTidyCheck {
>>  public:
>> +  // All cases in \p R must have a non-null \c Explanation, even though
>> \c
>> +  // Explanation is optional for RewriteRule in general. Because the
>> primary
>> +  // purpose of clang-tidy checks is to provide users with diagnostics,
>> we
>> +  // assume that a missing explanation is a bug.  If no explanation is
>> desired,
>> +  // indicate that explicitly (for example, by passing `text("no
>> explanation")`
>> +  //  to `makeRule` as the `Explanation` argument).
>>TransformerClangTidyCheck(tooling::RewriteRule R, StringRef Name,
>> -ClangTidyContext *Context)
>> -  : ClangTidyCheck(Name, Context), Rule(std::move(R)) {}
>> -
>> +ClangTidyContext *Context);
>>void registerMatchers(ast_matchers::MatchFinder *Finder) final;
>>void check(const ast_matchers::MatchFinder::MatchResult &Result) final;
>>
>> Index:
>> clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
>> ===
>> --- clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
>> +++ clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
>> @@ -13,6 +13,17 @@
>>  namespace utils {
>>  using tooling::RewriteRule;
>>
>> +TransformerClangTidyCheck::TransformerClangTidyCheck(tooling::RewriteRule
>> R,
>> + StringRef Name,
>> + ClangTidyContext
>> *Context)
>> +: ClangTidyCheck(Name, Context), Rule(std::move(R)) {
>> +  for (const auto &Case : Rule.Cases) {
>> +assert(Case.Explanation != nullptr &&
>> +   "clang-tidy checks must have an explanation by default;"
>> +   " explicitly provide an empty explanation if none is
>> desired");
>> +  }
>> +}
>> +
>>  void TransformerClangTidyCheck::registerMatchers(
>>  ast_matchers::MatchFinder *Finder) {
>>Finder->addDynamicMatcher(tooling::detail::buildMatcher(Rule), this);
>> @@ -44,15 +55,13 @@
>>if (Transformations->empty())
>>  return;
>>
>> -  StringRef Message = "no explanation";
>> -  if (Case.Explanation) {
>> -if (Expected E = Case.Explanation(Result))
>> -  Message = *E;
>> -else
>> -  llvm::errs() << "Error in explanation: " <<
>> llvm::toString(E.takeError())
>> -   << "\n";
>> +  Expected Explanation = Case.Explanation(Result);
>> +  if (!Explanation) {
>> +llvm::errs() << "Error in explanation: "
>> + << llvm::toString(Explanation.takeError()) << "\n";
>> +return;
>>}
>> -  DiagnosticBuilder Diag = diag(RootLoc, Message);
>> +  DiagnosticBuilder Diag = diag(RootLoc, *Explanation);
>>for (const auto &T : *Transformations) {
>>  Diag << FixItHint::CreateReplacement(T.Range, T.Replacement);
>>}
>> Index:
>> clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
>> ===
>> ---
>> clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
>> +++
>> clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
>> @@ -26,15 +26,18 @@
>>using tooling::change;
>>using tooling::node;
>>using tooling::statement;
>> +  using tooling::text;
>>using tooling::stencil:

[PATCH] D62406: [WebAssembly] Use "linker" as linker shortname.

2019-05-24 Thread Dan Gohman via Phabricator via cfe-commits
sunfish accepted this revision.
sunfish added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62406



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


r361651 - [WebAssembly] Use "linker" as linker shortname.

2019-05-24 Thread Sam Clegg via cfe-commits
Author: sbc
Date: Fri May 24 10:36:07 2019
New Revision: 361651

URL: http://llvm.org/viewvc/llvm-project?rev=361651&view=rev
Log:
[WebAssembly] Use "linker" as linker shortname.

This is in line with other platforms.

Also, move the single statement methods into the header (also
in line with other platform).

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

Modified:
cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
cfe/trunk/lib/Driver/ToolChains/WebAssembly.h

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=361651&r1=361650&r2=361651&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Fri May 24 10:36:07 2019
@@ -22,9 +22,6 @@ using namespace clang::driver::toolchain
 using namespace clang;
 using namespace llvm::opt;
 
-wasm::Linker::Linker(const ToolChain &TC)
-: GnuTool("wasm::Linker", "lld", TC) {}
-
 /// Following the conventions in https://wiki.debian.org/Multiarch/Tuples,
 /// we remove the vendor field to form the multiarch triple.
 static std::string getMultiarchTriple(const Driver &D,
@@ -34,10 +31,6 @@ static std::string getMultiarchTriple(co
 TargetTriple.getOSAndEnvironmentName()).str();
 }
 
-bool wasm::Linker::isLinkJob() const { return true; }
-
-bool wasm::Linker::hasIntegratedCPP() const { return false; }
-
 std::string wasm::Linker::getLinkerPath(const ArgList &Args) const {
   const ToolChain &ToolChain = getToolChain();
   if (const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.h?rev=361651&r1=361650&r2=361651&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.h Fri May 24 10:36:07 2019
@@ -20,9 +20,10 @@ namespace wasm {
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  explicit Linker(const ToolChain &TC);
-  bool isLinkJob() const override;
-  bool hasIntegratedCPP() const override;
+  explicit Linker(const ToolChain &TC)
+  : GnuTool("wasm::Linker", "linker", TC) {}
+  bool isLinkJob() const override { return true; }
+  bool hasIntegratedCPP() const override { return false; }
   std::string getLinkerPath(const llvm::opt::ArgList &Args) const;
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,


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


[PATCH] D62406: [WebAssembly] Use "linker" as linker shortname.

2019-05-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361651: [WebAssembly] Use "linker" as linker 
shortname. (authored by sbc, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62406?vs=201276&id=201284#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62406

Files:
  cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
  cfe/trunk/lib/Driver/ToolChains/WebAssembly.h


Index: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
@@ -22,9 +22,6 @@
 using namespace clang;
 using namespace llvm::opt;
 
-wasm::Linker::Linker(const ToolChain &TC)
-: GnuTool("wasm::Linker", "lld", TC) {}
-
 /// Following the conventions in https://wiki.debian.org/Multiarch/Tuples,
 /// we remove the vendor field to form the multiarch triple.
 static std::string getMultiarchTriple(const Driver &D,
@@ -34,10 +31,6 @@
 TargetTriple.getOSAndEnvironmentName()).str();
 }
 
-bool wasm::Linker::isLinkJob() const { return true; }
-
-bool wasm::Linker::hasIntegratedCPP() const { return false; }
-
 std::string wasm::Linker::getLinkerPath(const ArgList &Args) const {
   const ToolChain &ToolChain = getToolChain();
   if (const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
Index: cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
===
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
@@ -20,9 +20,10 @@
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  explicit Linker(const ToolChain &TC);
-  bool isLinkJob() const override;
-  bool hasIntegratedCPP() const override;
+  explicit Linker(const ToolChain &TC)
+  : GnuTool("wasm::Linker", "linker", TC) {}
+  bool isLinkJob() const override { return true; }
+  bool hasIntegratedCPP() const override { return false; }
   std::string getLinkerPath(const llvm::opt::ArgList &Args) const;
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,


Index: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
@@ -22,9 +22,6 @@
 using namespace clang;
 using namespace llvm::opt;
 
-wasm::Linker::Linker(const ToolChain &TC)
-: GnuTool("wasm::Linker", "lld", TC) {}
-
 /// Following the conventions in https://wiki.debian.org/Multiarch/Tuples,
 /// we remove the vendor field to form the multiarch triple.
 static std::string getMultiarchTriple(const Driver &D,
@@ -34,10 +31,6 @@
 TargetTriple.getOSAndEnvironmentName()).str();
 }
 
-bool wasm::Linker::isLinkJob() const { return true; }
-
-bool wasm::Linker::hasIntegratedCPP() const { return false; }
-
 std::string wasm::Linker::getLinkerPath(const ArgList &Args) const {
   const ToolChain &ToolChain = getToolChain();
   if (const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
Index: cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
===
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.h
@@ -20,9 +20,10 @@
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  explicit Linker(const ToolChain &TC);
-  bool isLinkJob() const override;
-  bool hasIntegratedCPP() const override;
+  explicit Linker(const ToolChain &TC)
+  : GnuTool("wasm::Linker", "linker", TC) {}
+  bool isLinkJob() const override { return true; }
+  bool hasIntegratedCPP() const override { return false; }
   std::string getLinkerPath(const llvm::opt::ArgList &Args) const;
   void ConstructJob(Compilation &C, const JobAction &JA,
 const InputInfo &Output, const InputInfoList &Inputs,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D62340: [clang-tidy] In TransformerClangTidyCheck, require Explanation field.

2019-05-24 Thread Yitzhak Mandelbaum via cfe-commits
So, it only shows up in Release build, I assume because the assert is left
out:
  for (const auto &Case : Rule.Cases) {
assert(Case.Explanation != nullptr &&
   "clang-tidy checks must have an explanation by default;"
   " explicitly provide an empty explanation if none is desired");
  }
I can think of a few solutions, please let me know if there's a
standard/preferred approach:

1. Use std::all_of.
assert(std::all_of(Rule.Cases.cbegin(), Rule.Cases.cend(), [](const
RewriteRule::Case &C) { return C.Explanation != nullptr; }
   && ...);

2. Trivially use the variable.
I could add a trivial use to the loop
  for (const auto &Case : Rule.Cases) {
+   (void)Case;
assert(Case.Explanation != nullptr &&
   "clang-tidy checks must have an explanation by default;"
   " explicitly provide an empty explanation if none is desired");
  }

3. Use llvm_unreachable instead.
Rewrite the assert to
if (Case.Explanation == nullptr)
  llvm_unreachable(...)

On Fri, May 24, 2019 at 1:16 PM Yitzhak Mandelbaum 
wrote:

> looking now...
>
> On Fri, May 24, 2019 at 12:49 PM Ilya Biryukov 
> wrote:
>
>> This seems to produce warnings about unused variables:
>> …/llvm/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp:20:20:
>> warning: unused variable 'Case' [-Wunused-variable]
>>
>>   for (const auto &Case : Rule.Cases) {
>>
>> Could you take a look?
>>
>> On Fri, May 24, 2019 at 6:29 PM Yitzhak Mandelbaum via Phabricator <
>> revi...@reviews.llvm.org> wrote:
>>
>>> This revision was automatically updated to reflect the committed changes.
>>> Closed by commit rL361647: [clang-tidy] In TransformerClangTidyCheck,
>>> require Explanation field. (authored by ymandel, committed by ).
>>> Herald added a project: LLVM.
>>> Herald added a subscriber: llvm-commits.
>>>
>>> Changed prior to commit:
>>>   https://reviews.llvm.org/D62340?vs=201256&id=201272#toc
>>>
>>> Repository:
>>>   rL LLVM
>>>
>>> CHANGES SINCE LAST ACTION
>>>   https://reviews.llvm.org/D62340/new/
>>>
>>> https://reviews.llvm.org/D62340
>>>
>>> Files:
>>>   clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
>>>   clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
>>>
>>> clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
>>>
>>>
>>> Index:
>>> clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
>>> ===
>>> --- clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
>>> +++ clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
>>> @@ -31,10 +31,14 @@
>>>  // };
>>>  class TransformerClangTidyCheck : public ClangTidyCheck {
>>>  public:
>>> +  // All cases in \p R must have a non-null \c Explanation, even though
>>> \c
>>> +  // Explanation is optional for RewriteRule in general. Because the
>>> primary
>>> +  // purpose of clang-tidy checks is to provide users with diagnostics,
>>> we
>>> +  // assume that a missing explanation is a bug.  If no explanation is
>>> desired,
>>> +  // indicate that explicitly (for example, by passing `text("no
>>> explanation")`
>>> +  //  to `makeRule` as the `Explanation` argument).
>>>TransformerClangTidyCheck(tooling::RewriteRule R, StringRef Name,
>>> -ClangTidyContext *Context)
>>> -  : ClangTidyCheck(Name, Context), Rule(std::move(R)) {}
>>> -
>>> +ClangTidyContext *Context);
>>>void registerMatchers(ast_matchers::MatchFinder *Finder) final;
>>>void check(const ast_matchers::MatchFinder::MatchResult &Result)
>>> final;
>>>
>>> Index:
>>> clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
>>> ===
>>> ---
>>> clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
>>> +++
>>> clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
>>> @@ -13,6 +13,17 @@
>>>  namespace utils {
>>>  using tooling::RewriteRule;
>>>
>>> +TransformerClangTidyCheck::TransformerClangTidyCheck(tooling::RewriteRule
>>> R,
>>> + StringRef Name,
>>> + ClangTidyContext
>>> *Context)
>>> +: ClangTidyCheck(Name, Context), Rule(std::move(R)) {
>>> +  for (const auto &Case : Rule.Cases) {
>>> +assert(Case.Explanation != nullptr &&
>>> +   "clang-tidy checks must have an explanation by default;"
>>> +   " explicitly provide an empty explanation if none is
>>> desired");
>>> +  }
>>> +}
>>> +
>>>  void TransformerClangTidyCheck::registerMatchers(
>>>  ast_matchers::MatchFinder *Finder) {
>>>Finder->addDynamicMatcher(tooling::detail::buildMatcher(Rule), this);
>>> @@ -44,15 +55,13 @@
>>>if (Transformations->empty())
>>>  return;
>>>
>>> -  StringRef Message = "no explanation";
>>> -  if (Case.Explanation) {
>>> -   

r361652 - Add support for dumping Objective C AST declaration nodes to JSON.

2019-05-24 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri May 24 10:39:55 2019
New Revision: 361652

URL: http://llvm.org/viewvc/llvm-project?rev=361652&view=rev
Log:
Add support for dumping Objective C AST declaration nodes to JSON.

Added:
cfe/trunk/test/AST/ast-dump-decl-json.m
Modified:
cfe/trunk/include/clang/AST/JSONNodeDumper.h
cfe/trunk/lib/AST/JSONNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/JSONNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/JSONNodeDumper.h?rev=361652&r1=361651&r2=361652&view=diff
==
--- cfe/trunk/include/clang/AST/JSONNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/JSONNodeDumper.h Fri May 24 10:39:55 2019
@@ -218,6 +218,19 @@ public:
   void VisitAccessSpecDecl(const AccessSpecDecl *ASD);
   void VisitFriendDecl(const FriendDecl *FD);
 
+  void VisitObjCIvarDecl(const ObjCIvarDecl *D);
+  void VisitObjCMethodDecl(const ObjCMethodDecl *D);
+  void VisitObjCTypeParamDecl(const ObjCTypeParamDecl *D);
+  void VisitObjCCategoryDecl(const ObjCCategoryDecl *D);
+  void VisitObjCCategoryImplDecl(const ObjCCategoryImplDecl *D);
+  void VisitObjCProtocolDecl(const ObjCProtocolDecl *D);
+  void VisitObjCInterfaceDecl(const ObjCInterfaceDecl *D);
+  void VisitObjCImplementationDecl(const ObjCImplementationDecl *D);
+  void VisitObjCCompatibleAliasDecl(const ObjCCompatibleAliasDecl *D);
+  void VisitObjCPropertyDecl(const ObjCPropertyDecl *D);
+  void VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D);
+  void VisitBlockDecl(const BlockDecl *D);
+
   void VisitDeclRefExpr(const DeclRefExpr *DRE);
   void VisitPredefinedExpr(const PredefinedExpr *PE);
   void VisitUnaryOperator(const UnaryOperator *UO);

Modified: cfe/trunk/lib/AST/JSONNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/JSONNodeDumper.cpp?rev=361652&r1=361651&r2=361652&view=diff
==
--- cfe/trunk/lib/AST/JSONNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/JSONNodeDumper.cpp Fri May 24 10:39:55 2019
@@ -150,7 +150,15 @@ void JSONNodeDumper::Visit(const CXXCtor
 }
 
 void JSONNodeDumper::Visit(const OMPClause *C) {}
-void JSONNodeDumper::Visit(const BlockDecl::Capture &C) {}
+
+void JSONNodeDumper::Visit(const BlockDecl::Capture &C) {
+  JOS.attribute("kind", "Capture");
+  attributeOnlyIfTrue("byref", C.isByRef());
+  attributeOnlyIfTrue("nested", C.isNested());
+  if (C.getVariable())
+JOS.attribute("var", createBareDeclRef(C.getVariable()));
+}
+
 void JSONNodeDumper::Visit(const GenericSelectionExpr::ConstAssociation &A) {
   JOS.attribute("associationKind", A.getTypeSourceInfo() ? "case" : "default");
   attributeOnlyIfTrue("selected", A.isSelected());
@@ -215,9 +223,11 @@ llvm::json::Object JSONNodeDumper::creat
 }
 
 llvm::json::Object JSONNodeDumper::createBareDeclRef(const Decl *D) {
-  llvm::json::Object Ret{
-  {"id", createPointerRepresentation(D)},
-  {"kind", (llvm::Twine(D->getDeclKindName()) + "Decl").str()}};
+  llvm::json::Object Ret{{"id", createPointerRepresentation(D)}};
+  if (!D)
+return Ret;
+
+  Ret["kind"] = (llvm::Twine(D->getDeclKindName()) + "Decl").str();
   if (const auto *ND = dyn_cast(D))
 Ret["name"] = ND->getDeclName().getAsString();
   if (const auto *VD = dyn_cast(D))
@@ -645,6 +655,147 @@ void JSONNodeDumper::VisitFriendDecl(con
 JOS.attribute("type", createQualType(T->getType()));
 }
 
+void JSONNodeDumper::VisitObjCIvarDecl(const ObjCIvarDecl *D) {
+  VisitNamedDecl(D);
+  JOS.attribute("type", createQualType(D->getType()));
+  attributeOnlyIfTrue("synthesized", D->getSynthesize());
+  switch (D->getAccessControl()) {
+  case ObjCIvarDecl::None: JOS.attribute("access", "none"); break;
+  case ObjCIvarDecl::Private: JOS.attribute("access", "private"); break;
+  case ObjCIvarDecl::Protected: JOS.attribute("access", "protected"); break;
+  case ObjCIvarDecl::Public: JOS.attribute("access", "public"); break;
+  case ObjCIvarDecl::Package: JOS.attribute("access", "package"); break;
+  }
+}
+
+void JSONNodeDumper::VisitObjCMethodDecl(const ObjCMethodDecl *D) {
+  VisitNamedDecl(D);
+  JOS.attribute("returnType", createQualType(D->getReturnType()));
+  JOS.attribute("instance", D->isInstanceMethod());
+  attributeOnlyIfTrue("variadic", D->isVariadic());
+}
+
+void JSONNodeDumper::VisitObjCTypeParamDecl(const ObjCTypeParamDecl *D) {
+  VisitNamedDecl(D);
+  JOS.attribute("type", createQualType(D->getUnderlyingType()));
+  attributeOnlyIfTrue("bounded", D->hasExplicitBound());
+  switch (D->getVariance()) {
+  case ObjCTypeParamVariance::Invariant:
+break;
+  case ObjCTypeParamVariance::Covariant:
+JOS.attribute("variance", "covariant");
+break;
+  case ObjCTypeParamVariance::Contravariant:
+JOS.attribute("variance", "contravariant");
+break;
+  }
+}
+
+void JSONNodeDumper::VisitObjCCategoryDecl(const ObjCCategoryDecl *D) {
+  VisitNamedDe

r361653 - [NewPassManager] Add tuning option: LoopUnrolling [clang-change]

2019-05-24 Thread Alina Sbirlea via cfe-commits
Author: asbirlea
Date: Fri May 24 10:40:52 2019
New Revision: 361653

URL: http://llvm.org/viewvc/llvm-project?rev=361653&view=rev
Log:
[NewPassManager] Add tuning option: LoopUnrolling [clang-change]

Summary:
Use CodeGenOpts's setting for loop unrolling.
[to be coupled with D61618]

Reviewers: chandlerc

Subscribers: jlebar, dmgreen, cfe-commits, llvm-commits

Tags: #clang

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

Added:
cfe/trunk/test/CodeGen/loop-unroll.c
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=361653&r1=361652&r2=361653&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri May 24 10:40:52 2019
@@ -1051,6 +1051,7 @@ void EmitAssemblyHelper::EmitAssemblyWit
   }
 
   PipelineTuningOptions PTO;
+  PTO.LoopUnrolling = CodeGenOpts.UnrollLoops;
   // For historical reasons, loop interleaving is set to mirror setting for 
loop
   // unrolling.
   PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;

Added: cfe/trunk/test/CodeGen/loop-unroll.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/loop-unroll.c?rev=361653&view=auto
==
--- cfe/trunk/test/CodeGen/loop-unroll.c (added)
+++ cfe/trunk/test/CodeGen/loop-unroll.c Fri May 24 10:40:52 2019
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 -funroll-loops 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 -fno-unroll-loops 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 
-fexperimental-new-pass-manager -S -O1 -funroll-loops -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 
-fexperimental-new-pass-manager -S -O1 -fno-unroll-loops -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+
+// CHECK-ENABLE-UNROLL-LABEL: @for_test()
+// CHECK-ENABLE-UNROLL: br label %[[FORBODY:[a-z0-9_\.]+]]
+// CHECK-ENABLE-UNROLL: [[FORBODY]]:
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: br i1 %[[EXITCOND:[a-z0-9_\.]+]], label 
%[[FORBODY5:[a-z0-9_\.]+]], label %[[FORBODY]]
+// CHECK-ENABLE-UNROLL: [[FORBODY5]]:
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+
+// CHECK-DISABLE-UNROLL-LABEL: @for_test()
+// CHECK-DISABLE-UNROLL: br label %[[FORBODY:[a-z0-9_\.]+]]
+// CHECK-DISABLE-UNROLL: [[FORBODY]]:
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL-NOT: store
+// CHECK-DISABLE-UNROLL: br i1 %[[EXITCOND:[a-z0-9_\.]+]], label 
%[[FORBODY5:[a-z0-9_\.]+]], label %[[FORBODY]]
+// CHECK-DISABLE-UNROLL: [[FORBODY5]]:
+// CHECK-DISABLE-UNROLL: fmul
+// CHECK-DISABLE-UNROLL: fadd
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL: fmul
+// CHECK-DISABLE-UNROLL: fadd
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL-NOT: fmul
+// CHECK-DISABLE-UNROLL-NOT: fadd
+// CHECK-DISABLE-UNROLL-NOT: store
+
+int printf(const char * restrict format, ...);
+
+void for_test() {
+  double A[1000], B[1000];
+  int L = 500;
+  for (int i = 0; i < L; i++) {
+A[i] = i;
+  }
+  for (int i = 0; i < L; i++) {
+B[i] = A[i]*5;
+B[i]++;
+A[i] *= 7;
+A[i]++;
+  }
+  printf("%lf %lf\n", A[0], B[0]);
+}


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


[PATCH] D61620: [NewPassManager] Add tuning option: LoopUnrolling [clang-change]

2019-05-24 Thread Alina Sbirlea via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361653: [NewPassManager] Add tuning option: LoopUnrolling 
[clang-change] (authored by asbirlea, committed by ).
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D61620?vs=198704&id=201285#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61620

Files:
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/test/CodeGen/loop-unroll.c


Index: cfe/trunk/test/CodeGen/loop-unroll.c
===
--- cfe/trunk/test/CodeGen/loop-unroll.c
+++ cfe/trunk/test/CodeGen/loop-unroll.c
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 -funroll-loops 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 -fno-unroll-loops 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 
-fexperimental-new-pass-manager -S -O1 -funroll-loops -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 
-fexperimental-new-pass-manager -S -O1 -fno-unroll-loops -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+
+// CHECK-ENABLE-UNROLL-LABEL: @for_test()
+// CHECK-ENABLE-UNROLL: br label %[[FORBODY:[a-z0-9_\.]+]]
+// CHECK-ENABLE-UNROLL: [[FORBODY]]:
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: br i1 %[[EXITCOND:[a-z0-9_\.]+]], label 
%[[FORBODY5:[a-z0-9_\.]+]], label %[[FORBODY]]
+// CHECK-ENABLE-UNROLL: [[FORBODY5]]:
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+
+// CHECK-DISABLE-UNROLL-LABEL: @for_test()
+// CHECK-DISABLE-UNROLL: br label %[[FORBODY:[a-z0-9_\.]+]]
+// CHECK-DISABLE-UNROLL: [[FORBODY]]:
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL-NOT: store
+// CHECK-DISABLE-UNROLL: br i1 %[[EXITCOND:[a-z0-9_\.]+]], label 
%[[FORBODY5:[a-z0-9_\.]+]], label %[[FORBODY]]
+// CHECK-DISABLE-UNROLL: [[FORBODY5]]:
+// CHECK-DISABLE-UNROLL: fmul
+// CHECK-DISABLE-UNROLL: fadd
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL: fmul
+// CHECK-DISABLE-UNROLL: fadd
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL-NOT: fmul
+// CHECK-DISABLE-UNROLL-NOT: fadd
+// CHECK-DISABLE-UNROLL-NOT: store
+
+int printf(const char * restrict format, ...);
+
+void for_test() {
+  double A[1000], B[1000];
+  int L = 500;
+  for (int i = 0; i < L; i++) {
+A[i] = i;
+  }
+  for (int i = 0; i < L; i++) {
+B[i] = A[i]*5;
+B[i]++;
+A[i] *= 7;
+A[i]++;
+  }
+  printf("%lf %lf\n", A[0], B[0]);
+}
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -1051,6 +1051,7 @@
   }
 
   PipelineTuningOptions PTO;
+  PTO.LoopUnrolling = CodeGenOpts.UnrollLoops;
   // For historical reasons, loop interleaving is set to mirror setting for 
loop
   // unrolling.
   PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;


Index: cfe/trunk/test/CodeGen/loop-unroll.c
===
--- cfe/trunk/test/CodeGen/loop-unroll.c
+++ cfe/trunk/test/CodeGen/loop-unroll.c
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 -funroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 -fno-unroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -fexperimental-new-pass-manager -S -O1 -funroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -fexperimental-new-pass-manager -S -O1 -fno-unroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+
+// CHECK-ENABLE-UNROLL-LABEL: @for_test()
+// CHECK-ENABLE-UNROLL: br label %[[FORBODY:[a-z0-9_\.]+]]
+// CHECK-ENABLE-UNROLL: [[FORBODY]]:
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: br i1 %[[EXITCOND:[a-z0-9_\.]+]], label %[[FORBODY5:[a-z0-9_\.]+]], label %[[FORBODY]]
+// CHECK-ENABLE-UNROLL: [[FORBODY5]]:
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHE

[PATCH] D62279: Use LTO capable linker

2019-05-24 Thread Wink Saville via Phabricator via cfe-commits
winksaville updated this revision to Diff 201288.
winksaville added a comment.

Added libcxxabi and rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62279

Files:
  clang/cmake/caches/DistributionExample-stage2.cmake
  clang/cmake/caches/DistributionExample.cmake


Index: clang/cmake/caches/DistributionExample.cmake
===
--- clang/cmake/caches/DistributionExample.cmake
+++ clang/cmake/caches/DistributionExample.cmake
@@ -2,7 +2,7 @@
 
 #Enable LLVM projects and runtimes
 set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld" CACHE STRING "")
-set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi" CACHE STRING "")
 
 # Only build the native target in stage1 since it is a throwaway build.
 set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
@@ -17,6 +17,11 @@
 # the proper LTO library dependencies can be connected.
 set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
 
+if (NOT APPLE)
+  # Since LLVM_ENABLE_LTO is ON we need a LTO capable linker
+  set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
+endif()
+
 # Expose stage2 targets through the stage1 build configuration.
 set(CLANG_BOOTSTRAP_TARGETS
   check-all
Index: clang/cmake/caches/DistributionExample-stage2.cmake
===
--- clang/cmake/caches/DistributionExample-stage2.cmake
+++ clang/cmake/caches/DistributionExample-stage2.cmake
@@ -2,7 +2,7 @@
 # bootstrap build.
 
 set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld" CACHE STRING "")
-set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi" CACHE STRING "")
 
 set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "")
 


Index: clang/cmake/caches/DistributionExample.cmake
===
--- clang/cmake/caches/DistributionExample.cmake
+++ clang/cmake/caches/DistributionExample.cmake
@@ -2,7 +2,7 @@
 
 #Enable LLVM projects and runtimes
 set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld" CACHE STRING "")
-set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi" CACHE STRING "")
 
 # Only build the native target in stage1 since it is a throwaway build.
 set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
@@ -17,6 +17,11 @@
 # the proper LTO library dependencies can be connected.
 set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
 
+if (NOT APPLE)
+  # Since LLVM_ENABLE_LTO is ON we need a LTO capable linker
+  set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
+endif()
+
 # Expose stage2 targets through the stage1 build configuration.
 set(CLANG_BOOTSTRAP_TARGETS
   check-all
Index: clang/cmake/caches/DistributionExample-stage2.cmake
===
--- clang/cmake/caches/DistributionExample-stage2.cmake
+++ clang/cmake/caches/DistributionExample-stage2.cmake
@@ -2,7 +2,7 @@
 # bootstrap build.
 
 set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld" CACHE STRING "")
-set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi" CACHE STRING "")
 
 set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "")
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62407: [OpenMP] Add test for requires and unified shared memory clause with declare target link

2019-05-24 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

In D62407#1516298 , @ABataev wrote:

> Just one question - why it is not the part of the whole patch for the unified 
> memory support in clang?


This test will need to change in the unified memory case. That's why its being 
introduced.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62407



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


[PATCH] D62407: [OpenMP] Add test for requires and unified shared memory clause with declare target link

2019-05-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Just add it to the original patch


Repository:
  rC Clang

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

https://reviews.llvm.org/D62407



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


[PATCH] D62412: [LibTooling] Fix unused-variable warning after r361647.

2019-05-24 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: ilya-biryukov.
Herald added a project: clang.

A range-for was added in r361647 where the range variable was only used in an
assertion.  As a result, it warned for Release builds. This revision
restructures the assertion to avoid the problem.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62412

Files:
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp


Index: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
@@ -7,21 +7,23 @@
 
//===--===//
 
 #include "TransformerClangTidyCheck.h"
+#include 
 
 namespace clang {
 namespace tidy {
 namespace utils {
 using tooling::RewriteRule;
 
-TransformerClangTidyCheck::TransformerClangTidyCheck(tooling::RewriteRule R,
+TransformerClangTidyCheck::TransformerClangTidyCheck(RewriteRule R,
  StringRef Name,
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context), Rule(std::move(R)) {
-  for (const auto &Case : Rule.Cases) {
-assert(Case.Explanation != nullptr &&
-   "clang-tidy checks must have an explanation by default;"
-   " explicitly provide an empty explanation if none is desired");
-  }
+  assert(std::all_of(Rule.Cases.begin(), Rule.Cases.end(),
+ [](const RewriteRule::Case &C) {
+   return C.Explanation != nullptr;
+ }) &&
+ "clang-tidy checks must have an explanation by default;"
+ " explicitly provide an empty explanation if none is desired");
 }
 
 void TransformerClangTidyCheck::registerMatchers(


Index: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
@@ -7,21 +7,23 @@
 //===--===//
 
 #include "TransformerClangTidyCheck.h"
+#include 
 
 namespace clang {
 namespace tidy {
 namespace utils {
 using tooling::RewriteRule;
 
-TransformerClangTidyCheck::TransformerClangTidyCheck(tooling::RewriteRule R,
+TransformerClangTidyCheck::TransformerClangTidyCheck(RewriteRule R,
  StringRef Name,
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context), Rule(std::move(R)) {
-  for (const auto &Case : Rule.Cases) {
-assert(Case.Explanation != nullptr &&
-   "clang-tidy checks must have an explanation by default;"
-   " explicitly provide an empty explanation if none is desired");
-  }
+  assert(std::all_of(Rule.Cases.begin(), Rule.Cases.end(),
+ [](const RewriteRule::Case &C) {
+   return C.Explanation != nullptr;
+ }) &&
+ "clang-tidy checks must have an explanation by default;"
+ " explicitly provide an empty explanation if none is desired");
 }
 
 void TransformerClangTidyCheck::registerMatchers(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D62340: [clang-tidy] In TransformerClangTidyCheck, require Explanation field.

2019-05-24 Thread Yitzhak Mandelbaum via cfe-commits
version 1 here: https://reviews.llvm.org/D62412






On Fri, May 24, 2019 at 1:36 PM Yitzhak Mandelbaum 
wrote:

> So, it only shows up in Release build, I assume because the assert is left
> out:
>   for (const auto &Case : Rule.Cases) {
> assert(Case.Explanation != nullptr &&
>"clang-tidy checks must have an explanation by default;"
>" explicitly provide an empty explanation if none is desired");
>   }
> I can think of a few solutions, please let me know if there's a
> standard/preferred approach:
>
> 1. Use std::all_of.
> assert(std::all_of(Rule.Cases.cbegin(), Rule.Cases.cend(), [](const
> RewriteRule::Case &C) { return C.Explanation != nullptr; }
>&& ...);
>
> 2. Trivially use the variable.
> I could add a trivial use to the loop
>   for (const auto &Case : Rule.Cases) {
> +   (void)Case;
> assert(Case.Explanation != nullptr &&
>"clang-tidy checks must have an explanation by default;"
>" explicitly provide an empty explanation if none is desired");
>   }
>
> 3. Use llvm_unreachable instead.
> Rewrite the assert to
> if (Case.Explanation == nullptr)
>   llvm_unreachable(...)
>
> On Fri, May 24, 2019 at 1:16 PM Yitzhak Mandelbaum 
> wrote:
>
>> looking now...
>>
>> On Fri, May 24, 2019 at 12:49 PM Ilya Biryukov 
>> wrote:
>>
>>> This seems to produce warnings about unused variables:
>>> …/llvm/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp:20:20:
>>> warning: unused variable 'Case' [-Wunused-variable]
>>>
>>>   for (const auto &Case : Rule.Cases) {
>>>
>>> Could you take a look?
>>>
>>> On Fri, May 24, 2019 at 6:29 PM Yitzhak Mandelbaum via Phabricator <
>>> revi...@reviews.llvm.org> wrote:
>>>
 This revision was automatically updated to reflect the committed
 changes.
 Closed by commit rL361647: [clang-tidy] In TransformerClangTidyCheck,
 require Explanation field. (authored by ymandel, committed by ).
 Herald added a project: LLVM.
 Herald added a subscriber: llvm-commits.

 Changed prior to commit:
   https://reviews.llvm.org/D62340?vs=201256&id=201272#toc

 Repository:
   rL LLVM

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

 https://reviews.llvm.org/D62340

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

 clang-tools-extra/trunk/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp


 Index:
 clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
 ===
 --- clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
 +++ clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.h
 @@ -31,10 +31,14 @@
  // };
  class TransformerClangTidyCheck : public ClangTidyCheck {
  public:
 +  // All cases in \p R must have a non-null \c Explanation, even
 though \c
 +  // Explanation is optional for RewriteRule in general. Because the
 primary
 +  // purpose of clang-tidy checks is to provide users with
 diagnostics, we
 +  // assume that a missing explanation is a bug.  If no explanation is
 desired,
 +  // indicate that explicitly (for example, by passing `text("no
 explanation")`
 +  //  to `makeRule` as the `Explanation` argument).
TransformerClangTidyCheck(tooling::RewriteRule R, StringRef Name,
 -ClangTidyContext *Context)
 -  : ClangTidyCheck(Name, Context), Rule(std::move(R)) {}
 -
 +ClangTidyContext *Context);
void registerMatchers(ast_matchers::MatchFinder *Finder) final;
void check(const ast_matchers::MatchFinder::MatchResult &Result)
 final;

 Index:
 clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
 ===
 ---
 clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
 +++
 clang-tools-extra/trunk/clang-tidy/utils/TransformerClangTidyCheck.cpp
 @@ -13,6 +13,17 @@
  namespace utils {
  using tooling::RewriteRule;

 +TransformerClangTidyCheck::TransformerClangTidyCheck(tooling::RewriteRule
 R,
 + StringRef Name,
 + ClangTidyContext
 *Context)
 +: ClangTidyCheck(Name, Context), Rule(std::move(R)) {
 +  for (const auto &Case : Rule.Cases) {
 +assert(Case.Explanation != nullptr &&
 +   "clang-tidy checks must have an explanation by default;"
 +   " explicitly provide an empty explanation if none is
 desired");
 +  }
 +}
 +
  void TransformerClangTidyCheck::registerMatchers(
  ast_ma

[PATCH] D59402: Fix-it hints for -Wmissing-{prototypes,variable-declarations}

2019-05-24 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert planned changes to this revision.
aaronpuchert added a comment.

I guess you're referring to "[fix-it hints] should only be used when it’s very 
likely they match the user’s intent".

When turning on the warning on an existing code base, I think that `static` is 
almost always right. But when writing new code with the warning active, it 
might indeed not be the right thing. It could be that the declaration has been 
forgotten, or it has a typo. We wouldn't want users to apply `static` blindly, 
so a note explaining when it is appropriate does actually make a lot of sense. 
Perhaps I can also detect if this is in a header and not emit the note then. 
(Or emit a note suggesting `inline`.)

@aaron.ballman Would moving the fix-it to a note alleviate your concerns?


Repository:
  rC Clang

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

https://reviews.llvm.org/D59402



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


[PATCH] D62413: [OpenCL][PR41727] Prevent ICE on global dtors

2019-05-24 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added a reviewer: rjmccall.
Herald added subscribers: ebevhan, yaxunl.

Preserve address spaces of global objects while generating 'atexit' stub.


https://reviews.llvm.org/D62413

Files:
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenOpenCLCXX/atexit.cl

Index: test/CodeGenOpenCLCXX/atexit.cl
===
--- /dev/null
+++ test/CodeGenOpenCLCXX/atexit.cl
@@ -0,0 +1,11 @@
+//RUN: %clang_cc1 %s -triple spir -cl-std=c++ -emit-llvm -O0 -o - | FileCheck %s
+
+struct S {
+  ~S(){};
+};
+S s;
+
+//CHECK-LABEL: define internal void @__cxx_global_var_init()
+// call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.S addrspace(4)*)* @_ZNU3AS41SD1Ev to void (i8*)*), i8 addrspace(1)* getelementptr inbounds (%struct.S, %struct.S addrspace(1)* @s, i32 0, i32 0), i8 addrspace(1)* @__dso_handle)
+
+//declare i32 @__cxa_atexit(void (i8*)*, i8 addrspace(1)*, i8 addrspace(1)*)
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -2299,8 +2299,19 @@
   llvm::Type *dtorTy =
 llvm::FunctionType::get(CGF.VoidTy, CGF.Int8PtrTy, false)->getPointerTo();
 
+  // Preserve address space of addr.
+  auto AddrAS = addr ? addr->getType()->getPointerAddressSpace() : 0;
+  auto AddrInt8PtrTy =
+  AddrAS ? CGF.Int8Ty->getPointerTo(AddrAS) : CGF.Int8PtrTy;
+
+  // Create a variable that binds the atexit to this shared object.
+  llvm::Constant *handle =
+  CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle");
+  auto *GV = cast(handle->stripPointerCasts());
+  GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
+
   // extern "C" int __cxa_atexit(void (*f)(void *), void *p, void *d);
-  llvm::Type *paramTys[] = { dtorTy, CGF.Int8PtrTy, CGF.Int8PtrTy };
+  llvm::Type *paramTys[] = {dtorTy, AddrInt8PtrTy, handle->getType()};
   llvm::FunctionType *atexitTy =
 llvm::FunctionType::get(CGF.IntTy, paramTys, false);
 
@@ -2309,12 +2320,6 @@
   if (llvm::Function *fn = dyn_cast(atexit.getCallee()))
 fn->setDoesNotThrow();
 
-  // Create a variable that binds the atexit to this shared object.
-  llvm::Constant *handle =
-  CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle");
-  auto *GV = cast(handle->stripPointerCasts());
-  GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
-
   if (!addr)
 // addr is null when we are trying to register a dtor annotated with
 // __attribute__((destructor)) in a constructor function. Using null here is
@@ -2324,7 +2329,7 @@
 
   llvm::Value *args[] = {llvm::ConstantExpr::getBitCast(
  cast(dtor.getCallee()), dtorTy),
- llvm::ConstantExpr::getBitCast(addr, CGF.Int8PtrTy),
+ llvm::ConstantExpr::getBitCast(addr, AddrInt8PtrTy),
  handle};
   CGF.EmitNounwindRuntimeCall(atexit, args);
 }
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -3533,8 +3533,12 @@
 llvm::Constant *
 CodeGenModule::CreateRuntimeVariable(llvm::Type *Ty,
  StringRef Name) {
-  auto *Ret =
-  GetOrCreateLLVMGlobal(Name, llvm::PointerType::getUnqual(Ty), nullptr);
+  auto PtrTy =
+  getContext().getLangOpts().OpenCL
+  ? llvm::PointerType::get(
+Ty, getContext().getTargetAddressSpace(LangAS::opencl_global))
+  : llvm::PointerType::getUnqual(Ty);
+  auto *Ret = GetOrCreateLLVMGlobal(Name, PtrTy, nullptr);
   setDSOLocal(cast(Ret->stripPointerCasts()));
   return Ret;
 }
Index: lib/CodeGen/CGDeclCXX.cpp
===
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -14,6 +14,7 @@
 #include "CGCXXABI.h"
 #include "CGObjCRuntime.h"
 #include "CGOpenMPRuntime.h"
+#include "TargetInfo.h"
 #include "clang/Basic/CodeGenOptions.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/Intrinsics.h"
@@ -118,8 +119,17 @@
 CXXDestructorDecl *Dtor = Record->getDestructor();
 
 Func = CGM.getAddrAndTypeOfCXXStructor(GlobalDecl(Dtor, Dtor_Complete));
-Argument = llvm::ConstantExpr::getBitCast(
-Addr.getPointer(), CGF.getTypes().ConvertType(Type)->getPointerTo());
+// FIXME: A solution is needed for opencl_constant. We could create
+// atexit_constant, but more generic solution would probably be to mangle
+// address space?
+auto DestTy = CGF.getTypes().ConvertType(Type)->getPointerTo(
+CGM.getContext().getTargetAddressSpace(LangAS::opencl_global));
+auto SrcAS = D.getType().getQualifiers().getAddressSpace();
+if (LangAS::opencl_global == SrcAS)
+  Argument = llvm::ConstantExpr::getBitCast(Addr.getPointer(), DestTy);

[PATCH] D62407: [OpenMP] Add test for requires and unified shared memory clause with declare target link

2019-05-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

After some offline discussion, the patch is accepted. It is required to 
demonstrate the changes in 
https://reviews.llvm.org/D60883


Repository:
  rC Clang

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

https://reviews.llvm.org/D62407



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


[PATCH] D59402: Fix-it hints for -Wmissing-{prototypes,variable-declarations}

2019-05-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D59402#1516421 , @aaronpuchert 
wrote:

> I guess you're referring to "[fix-it hints] should only be used when it’s 
> very likely they match the user’s intent".


Also, we're not attempting to recover from the error, which is a good point 
that @thakis raised. aka, if you apply the fix-it, you should also treat the 
declaration as though it were declared `static`.

> When turning on the warning on an existing code base, I think that `static` 
> is almost always right. But when writing new code with the warning active, it 
> might indeed not be the right thing. It could be that the declaration has 
> been forgotten, or it has a typo. We wouldn't want users to apply `static` 
> blindly, so a note explaining when it is appropriate does actually make a lot 
> of sense. Perhaps I can also detect if this is in a header and not emit the 
> note then. (Or emit a note suggesting `inline`.)
> 
> @aaron.ballman Would moving the fix-it to a note alleviate your concerns?

Yes, it would -- you also wouldn't have to attempt the recovery in this case.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59402



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


[PATCH] D62404: [clang-tidy] Fix null pointer dereference in readability-identifier-naming

2019-05-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D62404#1516243 , @markstegeman 
wrote:

> I haven't yet been able to figure out how to properly add a test for this 
> bug, since the expected result is a failure to compile while the current 
> test/clang-tidy/readability-identifier-naming.cpp must compile to pass.
>
> Any suggestions?


The way we usually handle this is to create a separate test file that exhibits 
the previously crashing code with a comment saying the test case used to crash. 
IIRC, you can use a CHECK line to check that you get the expected error.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D62404



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


[PATCH] D59402: Fix-it hints for -Wmissing-{prototypes,variable-declarations}

2019-05-24 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D59402#1516432 , @aaron.ballman 
wrote:

> Also, we're not attempting to recover from the error, which is a good point 
> that @thakis raised. aka, if you apply the fix-it, you should also treat the 
> declaration as though it were declared `static`.


I think the recovery rule only applies to errors, there is no need to recover 
from a warning. If we attempted recovery from a warning, we might generate 
different object code depending on the warning level.

But I think your original comment nails it: we can't be really sure that this 
is the right fix, and my empirical data doesn't (necessarily) translate well to 
writing new code with the warning on.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59402



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


[PATCH] D59402: Fix-it hints for -Wmissing-{prototypes,variable-declarations}

2019-05-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:11810
+  << var
+  << ((var->getStorageClass() != SC_Extern)
+  ? FixItHint::CreateInsertion(var->getBeginLoc(), "static ")

It would be more appropriate to suppress the fixit if any storage class 
specifier is present, since a declaration can have only one such specifier.



Comment at: lib/Sema/SemaDecl.cpp:13225-13230
   if (FunctionNoProtoTypeLoc FTL = TL.getAs())
-Diag(PossibleZeroParamPrototype->getLocation(),
+Diag(PossiblePrototype->getLocation(),
  diag::note_declaration_not_a_prototype)
-<< PossibleZeroParamPrototype
+<< PossiblePrototype
 << FixItHint::CreateInsertion(FTL.getRParenLoc(), "void");
 }

If we produce this note, we should not also produce the "add static" suggestion.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59402



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


[PATCH] D59402: Fix-it hints for -Wmissing-{prototypes,variable-declarations}

2019-05-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D59402#1516479 , @aaronpuchert 
wrote:

> In D59402#1516432 , @aaron.ballman 
> wrote:
>
> > Also, we're not attempting to recover from the error, which is a good point 
> > that @thakis raised. aka, if you apply the fix-it, you should also treat 
> > the declaration as though it were declared `static`.
>
>
> I think the recovery rule only applies to errors, there is no need to recover 
> from a warning.


That is incorrect, because `-Werror` can be used to promote warnings to errors. 
Please see https://clang.llvm.org/docs/InternalsManual.html#fix-it-hints for 
the rule and rationale; if it's insufficiently clear on this, we should fix it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59402



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


r361658 - [OpenMP] Add test for requires and unified shared memory clause with declare target link

2019-05-24 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Fri May 24 11:48:42 2019
New Revision: 361658

URL: http://llvm.org/viewvc/llvm-project?rev=361658&view=rev
Log:
[OpenMP] Add test for requires and unified shared memory clause with declare 
target link

Summary:
This patch adds a test for requires with unified share memory clause when a 
declare target link is present.

This test needs to go in prior to changes to declare target link for comparison 
purposes.

Reviewers: ABataev, caomhin

Reviewed By: ABataev

Subscribers: guansong, jdoerfert, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp

Added: cfe/trunk/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp?rev=361658&view=auto
==
--- cfe/trunk/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp 
(added)
+++ cfe/trunk/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp Fri 
May 24 11:48:42 2019
@@ -0,0 +1,67 @@
+// Test declare target link under unified memory requirement.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-cuda-mode -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s 
-o - | FileCheck %s --check-prefix CHECK
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+#define N 1000
+
+double var = 10.0;
+
+#pragma omp requires unified_shared_memory
+#pragma omp declare target link(var)
+
+int bar(int n){
+  double sum = 0;
+
+#pragma omp target
+  for(int i = 0; i < n; i++) {
+sum += var;
+  }
+
+  return sum;
+}
+
+// CHECK: [[VAR:@.+]] = global double 1.00e+01
+// CHECK: [[VAR_DECL_TGT_LINK_PTR:@.+]] = global double* [[VAR]]
+
+// CHECK: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [3 x i64] [i64 
4, i64 8, i64 8]
+// CHECK: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [3 x i64] 
[i64 800, i64 800, i64 531]
+
+// CHECK: [[N_CASTED:%.+]] = alloca i64
+// CHECK: [[SUM_CASTED:%.+]] = alloca i64
+
+// CHECK: [[OFFLOAD_BASEPTRS:%.+]] = alloca [3 x i8*]
+// CHECK: [[OFFLOAD_PTRS:%.+]] = alloca [3 x i8*]
+
+// CHECK: [[LOAD1:%.+]] = load i64, i64* [[N_CASTED]]
+// CHECK: [[LOAD2:%.+]] = load i64, i64* [[SUM_CASTED]]
+
+// CHECK: [[BPTR1:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK: [[BCAST1:%.+]] = bitcast i8** [[BPTR1]] to i64*
+// CHECK: store i64 [[LOAD1]], i64* [[BCAST1]]
+// CHECK: [[BPTR2:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 0
+// CHECK: [[BCAST2:%.+]] = bitcast i8** [[BPTR2]] to i64*
+// CHECK: store i64 [[LOAD1]], i64* [[BCAST2]]
+
+// CHECK: [[BPTR3:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 1
+// CHECK: [[BCAST3:%.+]] = bitcast i8** [[BPTR3]] to i64*
+// CHECK: store i64 [[LOAD2]], i64* [[BCAST3]]
+// CHECK: [[BPTR4:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 1
+// CHECK: [[BCAST4:%.+]] = bitcast i8** [[BPTR4]] to i64*
+// CHECK: store i64 [[LOAD2]], i64* [[BCAST4]]
+
+// CHECK: [[BPTR5:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 2
+// CHECK: [[BCAST5:%.+]] = bitcast i8** [[BPTR5]] to double***
+// CHECK: store double** [[VAR_DECL_TGT_LINK_PTR]], double*** [[BCAST5]]
+// CHECK: [[BPTR6:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 2
+// CHECK: [[BCAST6:%.+]] = bitcast i8** [[BPTR6]] to double**
+// CHECK: store double* [[VAR]], double** [[BCAST6]]
+
+// CHECK: [[BPTR7:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK: [[BPTR8:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 0
+
+// CHECK: call i32 @__tgt_target(i64 -1, i8* @{{.*}}.region_id, i32 3, i8** 
[[BPTR7]], i8** [[BPTR8]], i64* getelementptr inbounds ([3 x i64], [3 x i64]* 
[[OFFLOAD_SIZES]], i32 0, i32 0), i64* getelementptr inbounds ([3 x i64], [3 x 
i64]* [[OFFLOAD_MAPTYPES]], i32 0, i32 0))
+
+#endif


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


[PATCH] D62407: [OpenMP] Add test for requires and unified shared memory clause with declare target link

2019-05-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361658: [OpenMP] Add test for requires and unified shared 
memory clause with declare… (authored by gbercea, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62407?vs=201275&id=201298#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D62407

Files:
  test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp


Index: test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
===
--- test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
+++ test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
@@ -0,0 +1,67 @@
+// Test declare target link under unified memory requirement.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-cuda-mode -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s 
-o - | FileCheck %s --check-prefix CHECK
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+#define N 1000
+
+double var = 10.0;
+
+#pragma omp requires unified_shared_memory
+#pragma omp declare target link(var)
+
+int bar(int n){
+  double sum = 0;
+
+#pragma omp target
+  for(int i = 0; i < n; i++) {
+sum += var;
+  }
+
+  return sum;
+}
+
+// CHECK: [[VAR:@.+]] = global double 1.00e+01
+// CHECK: [[VAR_DECL_TGT_LINK_PTR:@.+]] = global double* [[VAR]]
+
+// CHECK: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [3 x i64] [i64 
4, i64 8, i64 8]
+// CHECK: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [3 x i64] 
[i64 800, i64 800, i64 531]
+
+// CHECK: [[N_CASTED:%.+]] = alloca i64
+// CHECK: [[SUM_CASTED:%.+]] = alloca i64
+
+// CHECK: [[OFFLOAD_BASEPTRS:%.+]] = alloca [3 x i8*]
+// CHECK: [[OFFLOAD_PTRS:%.+]] = alloca [3 x i8*]
+
+// CHECK: [[LOAD1:%.+]] = load i64, i64* [[N_CASTED]]
+// CHECK: [[LOAD2:%.+]] = load i64, i64* [[SUM_CASTED]]
+
+// CHECK: [[BPTR1:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK: [[BCAST1:%.+]] = bitcast i8** [[BPTR1]] to i64*
+// CHECK: store i64 [[LOAD1]], i64* [[BCAST1]]
+// CHECK: [[BPTR2:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 0
+// CHECK: [[BCAST2:%.+]] = bitcast i8** [[BPTR2]] to i64*
+// CHECK: store i64 [[LOAD1]], i64* [[BCAST2]]
+
+// CHECK: [[BPTR3:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 1
+// CHECK: [[BCAST3:%.+]] = bitcast i8** [[BPTR3]] to i64*
+// CHECK: store i64 [[LOAD2]], i64* [[BCAST3]]
+// CHECK: [[BPTR4:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 1
+// CHECK: [[BCAST4:%.+]] = bitcast i8** [[BPTR4]] to i64*
+// CHECK: store i64 [[LOAD2]], i64* [[BCAST4]]
+
+// CHECK: [[BPTR5:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 2
+// CHECK: [[BCAST5:%.+]] = bitcast i8** [[BPTR5]] to double***
+// CHECK: store double** [[VAR_DECL_TGT_LINK_PTR]], double*** [[BCAST5]]
+// CHECK: [[BPTR6:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 2
+// CHECK: [[BCAST6:%.+]] = bitcast i8** [[BPTR6]] to double**
+// CHECK: store double* [[VAR]], double** [[BCAST6]]
+
+// CHECK: [[BPTR7:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK: [[BPTR8:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* 
[[OFFLOAD_PTRS]], i32 0, i32 0
+
+// CHECK: call i32 @__tgt_target(i64 -1, i8* @{{.*}}.region_id, i32 3, i8** 
[[BPTR7]], i8** [[BPTR8]], i64* getelementptr inbounds ([3 x i64], [3 x i64]* 
[[OFFLOAD_SIZES]], i32 0, i32 0), i64* getelementptr inbounds ([3 x i64], [3 x 
i64]* [[OFFLOAD_MAPTYPES]], i32 0, i32 0))
+
+#endif


Index: test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
===
--- test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
+++ test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
@@ -0,0 +1,67 @@
+// Test declare target link under unified memory requirement.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-cuda-mode -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+#define N 1000
+
+double var = 10.0;
+
+#pragma omp requires unified_shared_memory
+#pragma omp declare target link(var)
+
+int bar(int n){
+  double sum = 0;
+
+#pragma omp target
+  for(int i = 0; i < n; i++) {
+sum += var;
+  }
+
+  return sum;
+}
+
+// CHECK: [[VAR:@.+]] = global double 1.00e+01
+// CHECK: [[VAR_DECL_TGT_LINK_PTR:@.+]] = global double* [[VAR]]
+
+// CHECK: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [3 x i64] [i64 4, i64 8, i64 8]
+// CHECK: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [3 x i64] [i64 800, i64 800, i64 531]

r361660 - Add JSON dumping tests for ObjC statements; add support for dumping @catch catch-all statements.

2019-05-24 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri May 24 11:58:29 2019
New Revision: 361660

URL: http://llvm.org/viewvc/llvm-project?rev=361660&view=rev
Log:
Add JSON dumping tests for ObjC statements; add support for dumping @catch 
catch-all statements.

Added:
cfe/trunk/test/AST/ast-dump-stmt-json.m
Modified:
cfe/trunk/include/clang/AST/JSONNodeDumper.h
cfe/trunk/lib/AST/JSONNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/JSONNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/JSONNodeDumper.h?rev=361660&r1=361659&r2=361660&view=diff
==
--- cfe/trunk/include/clang/AST/JSONNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/JSONNodeDumper.h Fri May 24 11:58:29 2019
@@ -260,6 +260,7 @@ public:
   void VisitLabelStmt(const LabelStmt *LS);
   void VisitGotoStmt(const GotoStmt *GS);
   void VisitWhileStmt(const WhileStmt *WS);
+  void VisitObjCAtCatchStmt(const ObjCAtCatchStmt *OACS);
 
   void visitTextComment(const comments::TextComment *C,
 const comments::FullComment *);

Modified: cfe/trunk/lib/AST/JSONNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/JSONNodeDumper.cpp?rev=361660&r1=361659&r2=361660&view=diff
==
--- cfe/trunk/lib/AST/JSONNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/JSONNodeDumper.cpp Fri May 24 11:58:29 2019
@@ -966,6 +966,13 @@ void JSONNodeDumper::VisitWhileStmt(cons
   attributeOnlyIfTrue("hasVar", WS->hasVarStorage());
 }
 
+void JSONNodeDumper::VisitObjCAtCatchStmt(const ObjCAtCatchStmt* OACS) {
+  // FIXME: it would be nice for the ASTNodeTraverser would handle the catch
+  // parameter the same way for C++ and ObjC rather. In this case, C++ gets a
+  // null child node and ObjC gets no child node.
+  attributeOnlyIfTrue("isCatchAll", OACS->getCatchParamDecl() == nullptr);
+}
+
 StringRef JSONNodeDumper::getCommentCommandName(unsigned CommandID) const {
   if (Traits)
 return Traits->getCommandInfo(CommandID)->Name;

Added: cfe/trunk/test/AST/ast-dump-stmt-json.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-stmt-json.m?rev=361660&view=auto
==
--- cfe/trunk/test/AST/ast-dump-stmt-json.m (added)
+++ cfe/trunk/test/AST/ast-dump-stmt-json.m Fri May 24 11:58:29 2019
@@ -0,0 +1,719 @@
+// RUN: %clang_cc1 -Wno-unused -fblocks -fobjc-exceptions -ast-dump=json 
-ast-dump-filter Test %s | FileCheck %s
+
+void TestBlockExpr(int x) {
+  ^{ x; };
+}
+
+void TestExprWithCleanup(int x) {
+  ^{ x; };
+}
+
+@interface A
+@end
+
+void TestObjCAtCatchStmt() {
+  @try {
+  } @catch(A *a) {
+  } @catch(...) {
+  } @finally {
+  }
+}
+
+
+// CHECK:  "kind": "FunctionDecl", 
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "col": 6, 
+// CHECK-NEXT:   "file": "{{.*}}", 
+// CHECK-NEXT:   "line": 3
+// CHECK-NEXT:  }, 
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"col": 1, 
+// CHECK-NEXT:"file": "{{.*}}", 
+// CHECK-NEXT:"line": 3
+// CHECK-NEXT:   }, 
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"col": 1, 
+// CHECK-NEXT:"file": "{{.*}}", 
+// CHECK-NEXT:"line": 5
+// CHECK-NEXT:   }
+// CHECK-NEXT:  }, 
+// CHECK-NEXT:  "name": "TestBlockExpr", 
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "void (int)"
+// CHECK-NEXT:  }, 
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}", 
+// CHECK-NEXT:"kind": "ParmVarDecl", 
+// CHECK-NEXT:"loc": {
+// CHECK-NEXT: "col": 24, 
+// CHECK-NEXT: "file": "{{.*}}", 
+// CHECK-NEXT: "line": 3
+// CHECK-NEXT:}, 
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "col": 20, 
+// CHECK-NEXT:  "file": "{{.*}}", 
+// CHECK-NEXT:  "line": 3
+// CHECK-NEXT: }, 
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "col": 24, 
+// CHECK-NEXT:  "file": "{{.*}}", 
+// CHECK-NEXT:  "line": 3
+// CHECK-NEXT: }
+// CHECK-NEXT:}, 
+// CHECK-NEXT:"isUsed": true, 
+// CHECK-NEXT:"name": "x", 
+// CHECK-NEXT:"type": {
+// CHECK-NEXT: "qualType": "int"
+// CHECK-NEXT:}
+// CHECK-NEXT:   }, 
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}", 
+// CHECK-NEXT:"kind": "CompoundStmt", 
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "col": 27, 
+// CHECK-NEXT:  "file": "{{.*}}", 
+// CHECK-NEXT:  "line": 3
+// CHECK-NEXT: }, 
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "col": 1, 
+// CHECK-NEXT:  "file": "{{.*}}", 
+// CHECK-NEXT:  "line": 5
+// CHECK-NEXT: }
+// CHECK-NEXT:}, 
+// CHECK-NEXT:"inner": [
+// CHECK-NEXT: {
+// CHECK-NEXT:  "id": "0x{{.*}}", 
+// CHECK-NEXT:  "kind": "ExprWithCleanups", 
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEX

[PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-05-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.

Ok, from the Linux kernel's perspective, I believe we have worked out all 
underlying issues in LLVM wrt callbr that would prevent us from using asm goto 
successfully.  This patch now has my blessing; thanks for all the hard work 
that went into this large feature.  Please wait for a final LGTM from @rsmith .


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

https://reviews.llvm.org/D56571



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


[PATCH] D53157: Teach the IRBuilder about constrained fadd and friends

2019-05-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: include/llvm/IR/IRBuilder.h:110
   : Context(context), DefaultFPMathTag(FPMathTag),
-DefaultOperandBundles(OpBundles) {
+IsFPConstrained(false), DefaultConstrainedExcept(nullptr),
+DefaultConstrainedRounding(nullptr), DefaultOperandBundles(OpBundles) {

Instead of adding these here, make these inline initializers on lines 100-102.



Comment at: include/llvm/IR/IRBuilder.h:228
+  /// Enable/Disable use of constrained floating point math
+  void setIsConstrainedFP(bool IsCon) { IsFPConstrained = IsCon; }
+

kpn wrote:
> kbarton wrote:
> > This is a minor quibble, but the method is setIsConstrainedFP, while the 
> > member is IsFPConstrained. 
> > I'm not sure if that is intentionally different, or an oversight. 
> Yeah, that's an oversight. Fixed.
IS this fixed?



Comment at: include/llvm/IR/IRBuilder.h:1249
+if (IsFPConstrained)
+  return CreateConstrainedFAdd(L, R, FMFSource, Name, nullptr, nullptr);
+

Why set the last 2 to nullptr when you have defaults for these?



Comment at: include/llvm/IR/IRBuilder.h:1259
+  Instruction *FMFSource = nullptr,
   const Twine &Name = "",
+  MDNode *RoundingMD = nullptr,   
+  MDNode *ExceptMD = nullptr) {

The last 2 parameters are never actually used except in the test.  Are these 
really important to have if they are never used in source?



Comment at: include/llvm/IR/IRBuilder.h:1408
 
+  CallInst *CreateConstrainedFRem(Value *L, Value *R, 
+  Instruction *FMFSource = nullptr, 

All these CreateConstrainedXXX should be distilled down to a single function 
that takes the intrinsic as a parameter.


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

https://reviews.llvm.org/D53157



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


[PATCH] D60883: [OpenMP] Avoid emitting maps for target link variables when unified memory is used

2019-05-24 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 201307.
gtbercea added a comment.

- Add test.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60883

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp

Index: test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
===
--- test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
+++ test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
@@ -26,42 +26,35 @@
 // CHECK: [[VAR:@.+]] = global double 1.00e+01
 // CHECK: [[VAR_DECL_TGT_LINK_PTR:@.+]] = global double* [[VAR]]
 
-// CHECK: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [3 x i64] [i64 4, i64 8, i64 8]
-// CHECK: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [3 x i64] [i64 800, i64 800, i64 531]
+// CHECK: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [2 x i64] [i64 4, i64 8]
+// CHECK: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [2 x i64] [i64 800, i64 800]
 
 // CHECK: [[N_CASTED:%.+]] = alloca i64
 // CHECK: [[SUM_CASTED:%.+]] = alloca i64
 
-// CHECK: [[OFFLOAD_BASEPTRS:%.+]] = alloca [3 x i8*]
-// CHECK: [[OFFLOAD_PTRS:%.+]] = alloca [3 x i8*]
+// CHECK: [[OFFLOAD_BASEPTRS:%.+]] = alloca [2 x i8*]
+// CHECK: [[OFFLOAD_PTRS:%.+]] = alloca [2 x i8*]
 
 // CHECK: [[LOAD1:%.+]] = load i64, i64* [[N_CASTED]]
 // CHECK: [[LOAD2:%.+]] = load i64, i64* [[SUM_CASTED]]
 
-// CHECK: [[BPTR1:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK: [[BPTR1:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 0
 // CHECK: [[BCAST1:%.+]] = bitcast i8** [[BPTR1]] to i64*
 // CHECK: store i64 [[LOAD1]], i64* [[BCAST1]]
-// CHECK: [[BPTR2:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 0
+// CHECK: [[BPTR2:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 0
 // CHECK: [[BCAST2:%.+]] = bitcast i8** [[BPTR2]] to i64*
 // CHECK: store i64 [[LOAD1]], i64* [[BCAST2]]
 
-// CHECK: [[BPTR3:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 1
+// CHECK: [[BPTR3:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 1
 // CHECK: [[BCAST3:%.+]] = bitcast i8** [[BPTR3]] to i64*
 // CHECK: store i64 [[LOAD2]], i64* [[BCAST3]]
-// CHECK: [[BPTR4:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 1
+// CHECK: [[BPTR4:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 1
 // CHECK: [[BCAST4:%.+]] = bitcast i8** [[BPTR4]] to i64*
 // CHECK: store i64 [[LOAD2]], i64* [[BCAST4]]
 
-// CHECK: [[BPTR5:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 2
-// CHECK: [[BCAST5:%.+]] = bitcast i8** [[BPTR5]] to double***
-// CHECK: store double** [[VAR_DECL_TGT_LINK_PTR]], double*** [[BCAST5]]
-// CHECK: [[BPTR6:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 2
-// CHECK: [[BCAST6:%.+]] = bitcast i8** [[BPTR6]] to double**
-// CHECK: store double* [[VAR]], double** [[BCAST6]]
+// CHECK: [[BPTR7:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK: [[BPTR8:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 0
 
-// CHECK: [[BPTR7:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_BASEPTRS]], i32 0, i32 0
-// CHECK: [[BPTR8:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[OFFLOAD_PTRS]], i32 0, i32 0
-
-// CHECK: call i32 @__tgt_target(i64 -1, i8* @{{.*}}.region_id, i32 3, i8** [[BPTR7]], i8** [[BPTR8]], i64* getelementptr inbounds ([3 x i64], [3 x i64]* [[OFFLOAD_SIZES]], i32 0, i32 0), i64* getelementptr inbounds ([3 x i64], [3 x i64]* [[OFFLOAD_MAPTYPES]], i32 0, i32 0))
+// CHECK: call i32 @__tgt_target(i64 -1, i8* @{{.*}}.region_id, i32 2, i8** [[BPTR7]], i8** [[BPTR8]], i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[OFFLOAD_SIZES]], i32 0, i32 0), i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[OFFLOAD_MAPTYPES]], i32 0, i32 0))
 
 #endif
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -2598,7 +2598,8 @@
   llvm::Optional Res =
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
   if (VD->hasGlobalStorage() && CS && !CS->capturesVariable(VD) &&
-  (!Res || *Res != OMPDeclareTargetDeclAttr::MT_Link))
+  (Stack->hasRequiresDeclWithClause() ||
+   !Res || *Res != OMPDeclareTargetDeclAttr::MT_Link))
 return;
 
   SourceLocation ELoc = E->getExprLoc();
Index: lib/CodeGen/CGOpenMPRuntime.h
==

r361662 - Adding an explicit triple to this test to appease build bots.

2019-05-24 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri May 24 12:19:00 2019
New Revision: 361662

URL: http://llvm.org/viewvc/llvm-project?rev=361662&view=rev
Log:
Adding an explicit triple to this test to appease build bots.

Modified:
cfe/trunk/test/AST/ast-dump-stmt-json.m

Modified: cfe/trunk/test/AST/ast-dump-stmt-json.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-stmt-json.m?rev=361662&r1=361661&r2=361662&view=diff
==
--- cfe/trunk/test/AST/ast-dump-stmt-json.m (original)
+++ cfe/trunk/test/AST/ast-dump-stmt-json.m Fri May 24 12:19:00 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -Wno-unused -fblocks -fobjc-exceptions -ast-dump=json 
-ast-dump-filter Test %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-win32 -Wno-unused -fblocks 
-fobjc-exceptions -ast-dump=json -ast-dump-filter Test %s | FileCheck %s
 
 void TestBlockExpr(int x) {
   ^{ x; };


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


r361663 - [cmake] Remove old unused version of FindZ3.cmake from clang [NFC]

2019-05-24 Thread Don Hinton via cfe-commits
Author: dhinton
Date: Fri May 24 12:21:21 2019
New Revision: 361663

URL: http://llvm.org/viewvc/llvm-project?rev=361663&view=rev
Log:
[cmake] Remove old unused version of FindZ3.cmake from clang [NFC]

Summary: This file was moved to llvm in D54978, r356929, but the old
file was never removed.

Reviewed By: beanz

Tags: #clang

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

Removed:
cfe/trunk/cmake/modules/FindZ3.cmake

Removed: cfe/trunk/cmake/modules/FindZ3.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/FindZ3.cmake?rev=361662&view=auto
==
(empty)


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


[PATCH] D62343: [cmake] Remove old unused version of FindZ3.cmake from clang [NFC]

2019-05-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361663: [cmake] Remove old unused version of FindZ3.cmake 
from clang [NFC] (authored by dhinton, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62343?vs=201058&id=201308#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D62343

Files:
  cmake/modules/FindZ3.cmake




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


  1   2   >