[PATCH] D58429: [CodeGen] Enable the complex-math test for arm

2019-02-20 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: peter.smith.
Herald added subscribers: cfe-commits, jdoerfert, kristof.beyls.
Herald added a project: clang.

This test wasn't running due to a missing : after the RUN statement.
Enabling this test revealed that it's actually broken.


Repository:
  rC Clang

https://reviews.llvm.org/D58429

Files:
  clang/test/CodeGen/complex-math.c


Index: clang/test/CodeGen/complex-math.c
===
--- clang/test/CodeGen/complex-math.c
+++ clang/test/CodeGen/complex-math.c
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple x86_64-pc-win64 -o - | FileCheck 
%s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple i686-unknown-unknown -o - | 
FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple powerpc-unknown-unknown -o - | 
FileCheck %s --check-prefix=PPC
-// RUN %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | 
FileCheck %s --check-prefix=ARM
+// RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | 
FileCheck %s --check-prefix=ARM
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabihf -o - | 
FileCheck %s --check-prefix=ARMHF
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple thumbv7k-apple-watchos2.0 -o - 
-target-abi aapcs16 | FileCheck %s --check-prefix=ARM7K
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple aarch64-unknown-unknown 
-ffast-math -o - | FileCheck %s --check-prefix=AARCH64-FASTMATH
@@ -621,7 +621,7 @@
   // use the base AAPCS.
 
   // ARM-LABEL: @foo(
-  // ARM: call void { double, double } @__muldc3
+  // ARM: call void @__muldc3
 
   // ARMHF-LABEL: @foo(
   // ARMHF: call { double, double } @__muldc3


Index: clang/test/CodeGen/complex-math.c
===
--- clang/test/CodeGen/complex-math.c
+++ clang/test/CodeGen/complex-math.c
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple x86_64-pc-win64 -o - | FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple i686-unknown-unknown -o - | FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple powerpc-unknown-unknown -o - | FileCheck %s --check-prefix=PPC
-// RUN %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | FileCheck %s --check-prefix=ARM
+// RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | FileCheck %s --check-prefix=ARM
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabihf -o - | FileCheck %s --check-prefix=ARMHF
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple thumbv7k-apple-watchos2.0 -o - -target-abi aapcs16 | FileCheck %s --check-prefix=ARM7K
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple aarch64-unknown-unknown -ffast-math -o - | FileCheck %s --check-prefix=AARCH64-FASTMATH
@@ -621,7 +621,7 @@
   // use the base AAPCS.
 
   // ARM-LABEL: @foo(
-  // ARM: call void { double, double } @__muldc3
+  // ARM: call void @__muldc3
 
   // ARMHF-LABEL: @foo(
   // ARMHF: call { double, double } @__muldc3
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58293: [clang][Index] Enable indexing of Template Type Parameters behind a flag

2019-02-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 187528.
kadircet marked 2 inline comments as done.
kadircet added a comment.

- Move `handleDecl` call to top of the loop


Repository:
  rC Clang

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

https://reviews.llvm.org/D58293

Files:
  include/clang/Index/IndexingAction.h
  lib/Index/IndexDecl.cpp
  lib/Index/IndexSymbol.cpp
  lib/Index/IndexTypeSourceInfo.cpp
  lib/Index/IndexingContext.cpp
  lib/Index/IndexingContext.h
  unittests/Index/IndexTests.cpp

Index: unittests/Index/IndexTests.cpp
===
--- unittests/Index/IndexTests.cpp
+++ unittests/Index/IndexTests.cpp
@@ -93,6 +93,7 @@
   IndexingOptions Opts;
 };
 
+using testing::AllOf;
 using testing::Contains;
 using testing::Not;
 using testing::UnorderedElementsAre;
@@ -134,6 +135,29 @@
   EXPECT_THAT(Index->Symbols, Not(Contains(QName("bar";
 }
 
+TEST(IndexTest, IndexTypeParmDecls) {
+  std::string Code = R"cpp(
+template  class C, typename NoRef>
+struct Foo {
+  T t = I;
+  C x;
+};
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols, AllOf(Not(Contains(QName("Foo::T"))),
+Not(Contains(QName("Foo::I"))),
+Not(Contains(QName("Foo::C");
+
+  Opts.IndexTemplateParameters = true;
+  Index->Symbols.clear();
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  AllOf(Contains(QName("Foo::T")), Contains(QName("Foo::I")),
+Contains(QName("Foo::C")), Contains(QName("Foo::NoRef";
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: lib/Index/IndexingContext.h
===
--- lib/Index/IndexingContext.h
+++ lib/Index/IndexingContext.h
@@ -63,6 +63,8 @@
 
   bool shouldIndexParametersInDeclarations() const;
 
+  bool shouldIndexTemplateParameters() const;
+
   static bool isTemplateImplicitInstantiation(const Decl *D);
 
   bool handleDecl(const Decl *D, SymbolRoleSet Roles = SymbolRoleSet(),
Index: lib/Index/IndexingContext.cpp
===
--- lib/Index/IndexingContext.cpp
+++ lib/Index/IndexingContext.cpp
@@ -44,6 +44,10 @@
   return IndexOpts.IndexParametersInDeclarations;
 }
 
+bool IndexingContext::shouldIndexTemplateParameters() const {
+  return IndexOpts.IndexTemplateParameters;
+}
+
 bool IndexingContext::handleDecl(const Decl *D,
  SymbolRoleSet Roles,
  ArrayRef Relations) {
@@ -76,8 +80,11 @@
   if (!shouldIndexFunctionLocalSymbols() && isFunctionLocalSymbol(D))
 return true;
 
-  if (isa(D) || isa(D))
+  if (!shouldIndexTemplateParameters() &&
+  (isa(D) || isa(D) ||
+   isa(D))) {
 return true;
+  }
 
   return handleDeclOccurrence(D, Loc, /*IsRef=*/true, Parent, Roles, Relations,
   RefE, RefD, DC);
Index: lib/Index/IndexTypeSourceInfo.cpp
===
--- lib/Index/IndexTypeSourceInfo.cpp
+++ lib/Index/IndexTypeSourceInfo.cpp
@@ -45,6 +45,13 @@
   return false;\
   } while (0)
 
+  bool VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TTPL) {
+SourceLocation Loc = TTPL.getNameLoc();
+TemplateTypeParmDecl *TTPD = TTPL.getDecl();
+return IndexCtx.handleReference(TTPD, Loc, Parent, ParentDC,
+SymbolRoleSet());
+  }
+
   bool VisitTypedefTypeLoc(TypedefTypeLoc TL) {
 SourceLocation Loc = TL.getNameLoc();
 TypedefNameDecl *ND = TL.getTypedefNameDecl();
Index: lib/Index/IndexSymbol.cpp
===
--- lib/Index/IndexSymbol.cpp
+++ lib/Index/IndexSymbol.cpp
@@ -55,9 +55,6 @@
   if (isa(D))
 return true;
 
-  if (isa(D))
-return true;
-
   if (isa(D))
 return true;
 
Index: lib/Index/IndexDecl.cpp
===
--- lib/Index/IndexDecl.cpp
+++ lib/Index/IndexDecl.cpp
@@ -672,6 +672,8 @@
 shouldIndexTemplateParameterDefaultValue(Parent)) {
   const TemplateParameterList *Params = D->getTemplateParameters();
   for (const NamedDecl *TP : *Params) {
+if (IndexCtx.shouldIndexTemplateParameters())
+  IndexCtx.handleDecl(TP);
 if (const auto *TTP = dyn_cast(TP)) {
   if (TTP->hasDefaultArgument())
 IndexCtx.indexTypeSourceInfo(TTP->getDefaultArgumentInfo(), Parent);
Index: include/clang/Index/IndexingAction.h
===
--- include/clang/Index/IndexingAction.h
+++ include/clang/Index/IndexingAction.h
@@ -46,6 +

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

2019-02-20 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D50488#1403197 , @mgrang wrote:

> > It's because it invokes CodeChecker, which by default enables 
> > valist.Uninitialized, but not ValistBase. Do you have assert failures after 
> > my hotfix?
>
> @Szelethus Thanks. I run into this assert when run through CodeChecker:
>
>   Assertion `CheckerTags.count(tag) != 0 && "Requested checker is not 
> registered! Maybe you should add it as a " "dependency in Checkers.td?"'
>
>
> Is there a workaround?


Uhh, I'm afraid the only way out is to actually fix the problem :) couple 
questions:

1. Are you *sure* that you rebased to rC354235 
 (which is the hotfix I mentioned), 
CodeChecker runs *that* clang when the assert failure happens?
2. Can you provide a stacktrace? Luckily, that would for sure point me to the 
problematic checker.

In D50488#1403199 , @mgrang wrote:

> Also I don't see the helptext for PointerSorting when I run:
>
>   clang -cc1 -analyzer-checker-help | grep Pointer
>  
> alpha.core.PointerArithmCheck for pointer arithmetic on locations 
> other than array elements
> alpha.core.PointerSub   Check for pointer subtractions on two 
> pointers pointing to different memory chunks
> alpha.nondeterminism.PointerSorting
> cplusplus.InnerPointer  Check for inner pointers of C++ 
> containers used after re/deallocation
>


How about `clang -cc1 -analyzer-checker-help | grep Pointer -A3`? There could 
be a linebreak after the ckecker's name (raises the question though whether it 
should be there).

In D50488#1403212 , @mgrang wrote:

> > There is a revision to solve this problem here: D58065 
> > . I guess your input, as someone who 
> > didn't participate in the checker dependency related patch reviews would be 
> > invaluable, in terms of whether my description is understandable enough.
>
> Thanks. I took a look at the documentation and it looks fine to me (modulo 
> the comments from other reviewers and a couple of minor typos). I feel the 
> csa-testbench documentation (https://github.com/Xazax-hun/csa-testbench) is 
> very minimal and does not document a lot of intricacies which I had to figure 
> out by trial-and-error.


Due to an upcoming conference, I didn't bother with it much, i just used 
CodeChecker on its own, which is fairly well documented.
I'm trying to move my checker out of alpha, and my testing goes as follows:

1. Clone LLVM+Clang, cppcheck, rtags, bitcoin, xerces (you could throw in vim, 
tmux, as your checker isnt C++ exclusive, or whatever else)
2. Create compile_commands.json either with CMake 
(-DCANE_GENERATE_COMPILE_COMMANDS, or smt similar), or `CodeChecker log`
3. `CodeChecker analyze` projects, paying attention to not forgetting the 
CodeChecker flag `--verbose debug_analyzer` (and enabling your checker ofc), 
and piping the output to a file
4. Create a `CodeChecker server`, `CodeChecker store` the results, and stare at 
the web gui for hours. Its very pretty btw ;)

Csa-testbench is a work in progress, so I guess you can expect more in the 
future :)

Thanks for your work, even through a few annoyances, very much appreciated!


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

https://reviews.llvm.org/D50488



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


[PATCH] D58236: Make address space conversions a bit stricter.

2019-02-20 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan updated this revision to Diff 187531.

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

https://reviews.llvm.org/D58236

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaExpr.cpp
  test/CodeGenOpenCL/numbered-address-space.cl
  test/SemaOpenCL/address-spaces.cl
  test/SemaOpenCL/event_t_overload.cl
  test/SemaOpenCL/numbered-address-space.cl
  test/SemaOpenCL/queue_t_overload.cl

Index: test/SemaOpenCL/queue_t_overload.cl
===
--- test/SemaOpenCL/queue_t_overload.cl
+++ test/SemaOpenCL/queue_t_overload.cl
@@ -7,6 +7,6 @@
   queue_t q;
   foo(q, src1);
   foo(0, src2);
-  foo(q, src3); // expected-error {{call to 'foo' is ambiguous}}
+  foo(q, src3); // expected-error {{no matching function for call to 'foo'}}
   foo(1, src3); // expected-error {{no matching function for call to 'foo'}}
 }
Index: test/SemaOpenCL/numbered-address-space.cl
===
--- test/SemaOpenCL/numbered-address-space.cl
+++ test/SemaOpenCL/numbered-address-space.cl
@@ -26,6 +26,6 @@
 
 void test_generic_as_to_builtin_parameterimplicit_cast_numeric(__attribute__((address_space(3))) int *as3_ptr, float src) {
   generic int* generic_ptr = as3_ptr;
-  volatile float result = __builtin_amdgcn_ds_fmaxf(generic_ptr, src, 0, 0, false); // expected-warning {{incompatible pointer types passing '__generic int *' to parameter of type '__local float *'}}
+  volatile float result = __builtin_amdgcn_ds_fmaxf(generic_ptr, src, 0, 0, false); // expected-error {{passing '__generic int *' to parameter of type '__local float *' changes address space of pointer}}
 }
 
Index: test/SemaOpenCL/event_t_overload.cl
===
--- test/SemaOpenCL/event_t_overload.cl
+++ test/SemaOpenCL/event_t_overload.cl
@@ -7,5 +7,5 @@
   event_t evt;
   foo(evt, src1);
   foo(0, src2);
-  foo(evt, src3); // expected-error {{call to 'foo' is ambiguous}}
+  foo(evt, src3); // expected-error {{no matching function for call to 'foo'}}
 }
Index: test/SemaOpenCL/address-spaces.cl
===
--- test/SemaOpenCL/address-spaces.cl
+++ test/SemaOpenCL/address-spaces.cl
@@ -52,6 +52,98 @@
   p = (__private int *)p2;
 }
 
+#if !__OPENCL_CPP_VERSION__
+void nested(__global int *g, __global int * __private *gg, __local int *l, __local int * __private *ll, __global float * __private *gg_f) {
+  g = gg;// expected-error {{assigning '__global int **' to '__global int *' changes address space of pointer}}
+  g = l; // expected-error {{assigning '__local int *' to '__global int *' changes address space of pointer}}
+  g = ll;// expected-error {{assigning '__local int **' to '__global int *' changes address space of pointer}}
+  g = gg_f;  // expected-error {{assigning '__global float **' to '__global int *' changes address space of pointer}}
+  g = (__global int *)gg_f; // expected-error {{casting '__global float **' to type '__global int *' changes address space of pointer}}
+
+  gg = g;// expected-error {{assigning '__global int *' to '__global int **' changes address space of pointer}}
+  gg = l;// expected-error {{assigning '__local int *' to '__global int **' changes address space of pointer}}
+  gg = ll;   // expected-error {{assigning '__local int **' to '__global int **' changes address space of nested pointer}}
+  gg = gg_f; // expected-warning {{incompatible pointer types assigning to '__global int **' from '__global float **'}}
+  gg = (__global int * __private *)gg_f;
+
+  l = g; // expected-error {{assigning '__global int *' to '__local int *' changes address space of pointer}}
+  l = gg;// expected-error {{assigning '__global int **' to '__local int *' changes address space of pointer}}
+  l = ll;// expected-error {{assigning '__local int **' to '__local int *' changes address space of pointer}}
+  l = gg_f;  // expected-error {{assigning '__global float **' to '__local int *' changes address space of pointer}}
+  l = (__local int *)gg_f; // expected-error {{casting '__global float **' to type '__local int *' changes address space of pointer}}
+
+  ll = g;// expected-error {{assigning '__global int *' to '__local int **' changes address space of pointer}}
+  ll = gg;   // expected-error {{assigning '__global int **' to '__local int **' changes address space of nested pointer}}
+  ll = l;// expected-error {{assigning '__local int *' to '__local int **' changes address space of pointer}}
+  ll = gg_f; // expected-error {{assigning '__global float **' to '__local int **' changes address space of nested pointer}}
+  ll = (__local int * __private *)gg_f; // expected-error {{casting '__global float **' to type '__local int **' changes address space of nested pointer}}
+
+  gg_f = g;  // expected-error {{assigning '__globa

[clang-tools-extra] r354442 - [clangd] Testcase for bug 39811

2019-02-20 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Wed Feb 20 01:41:26 2019
New Revision: 354442

URL: http://llvm.org/viewvc/llvm-project?rev=354442&view=rev
Log:
[clangd] Testcase for bug 39811

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, 
cfe-commits

Tags: #clang

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

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

Modified: clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp?rev=354442&r1=354441&r2=354442&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp Wed Feb 20 01:41:26 
2019
@@ -1441,6 +1441,35 @@ TEST(FindReferences, NoQueryForLocalSymb
   }
 }
 
+TEST(GoTo, WithSysRoot) {
+  const char *CustoomRoot = "/sys/root/";
+  Annotations Main(R"cpp(
+  #include "header.h"
+  int main() {
+return f^oo();
+  })cpp");
+  Annotations Header("int [[foo]](){return 42;}");
+
+  MockCompilationDatabase CDB;
+  CDB.ExtraClangFlags = {"--sysroot", CustoomRoot};
+  IgnoreDiagnostics DiagConsumer;
+  MockFSProvider FS;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  // Fill the filesystem.
+  auto FooCpp = testPath("foo.cpp");
+  FS.Files[FooCpp] = Main.code();
+  auto HeaderPath = (llvm::StringRef(CustoomRoot) + "include/header.h").str();
+  FS.Files[HeaderPath] = Header.code();
+
+  runAddDocument(Server, FooCpp, Main.code());
+
+  // Go to a definition in main source file.
+  auto Locations = runLocateSymbolAt(Server, FooCpp, Main.point());
+  EXPECT_TRUE(bool(Locations)) << "findDefinitions returned an error";
+  EXPECT_THAT(*Locations, ElementsAre(Sym("foo", Header.range(;
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang


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


[PATCH] D58133: [clangd] Testcase for bug 39811

2019-02-20 Thread Kadir Cetinkaya 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 rL354442: [clangd] Testcase for bug 39811 (authored by 
kadircet, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58133

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


Index: clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
@@ -1441,6 +1441,35 @@
   }
 }
 
+TEST(GoTo, WithSysRoot) {
+  const char *CustoomRoot = "/sys/root/";
+  Annotations Main(R"cpp(
+  #include "header.h"
+  int main() {
+return f^oo();
+  })cpp");
+  Annotations Header("int [[foo]](){return 42;}");
+
+  MockCompilationDatabase CDB;
+  CDB.ExtraClangFlags = {"--sysroot", CustoomRoot};
+  IgnoreDiagnostics DiagConsumer;
+  MockFSProvider FS;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  // Fill the filesystem.
+  auto FooCpp = testPath("foo.cpp");
+  FS.Files[FooCpp] = Main.code();
+  auto HeaderPath = (llvm::StringRef(CustoomRoot) + "include/header.h").str();
+  FS.Files[HeaderPath] = Header.code();
+
+  runAddDocument(Server, FooCpp, Main.code());
+
+  // Go to a definition in main source file.
+  auto Locations = runLocateSymbolAt(Server, FooCpp, Main.point());
+  EXPECT_TRUE(bool(Locations)) << "findDefinitions returned an error";
+  EXPECT_THAT(*Locations, ElementsAre(Sym("foo", Header.range(;
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang


Index: clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
@@ -1441,6 +1441,35 @@
   }
 }
 
+TEST(GoTo, WithSysRoot) {
+  const char *CustoomRoot = "/sys/root/";
+  Annotations Main(R"cpp(
+  #include "header.h"
+  int main() {
+return f^oo();
+  })cpp");
+  Annotations Header("int [[foo]](){return 42;}");
+
+  MockCompilationDatabase CDB;
+  CDB.ExtraClangFlags = {"--sysroot", CustoomRoot};
+  IgnoreDiagnostics DiagConsumer;
+  MockFSProvider FS;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  // Fill the filesystem.
+  auto FooCpp = testPath("foo.cpp");
+  FS.Files[FooCpp] = Main.code();
+  auto HeaderPath = (llvm::StringRef(CustoomRoot) + "include/header.h").str();
+  FS.Files[HeaderPath] = Header.code();
+
+  runAddDocument(Server, FooCpp, Main.code());
+
+  // Go to a definition in main source file.
+  auto Locations = runLocateSymbolAt(Server, FooCpp, Main.point());
+  EXPECT_TRUE(bool(Locations)) << "findDefinitions returned an error";
+  EXPECT_THAT(*Locations, ElementsAre(Sym("foo", Header.range(;
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58236: Make address space conversions a bit stricter.

2019-02-20 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan marked 2 inline comments as done.
ebevhan added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6996
+  "|%diff{casting $ to type $|casting between types}0,1}2"
+  " changes address space of nested pointer">;
 def err_typecheck_incompatible_ownership : Error<

Anastasia wrote:
> ebevhan wrote:
> > Anastasia wrote:
> > > I am wondering if we could just unify with the diagnostic above?
> > > 
> > > We could add another select at the end:
> > >   " changes address space of %select{nested|}3 pointer"
> > That is doable, but all of the 'typecheck' errors/warnings are made to be 
> > regular. If I add another parameter, there needs to be a special case in 
> > DiagnoseAssignmentResult for that error in particular.
> Oh I see... might not worth it?
I think keeping the generality makes it a bit simpler. Technically many of the 
errors here could be folded into one or two instead, but that hasn't been done, 
so...



Comment at: test/SemaOpenCL/address-spaces.cl:89
+  __local int * __global * __private * lll;
+  lll = gg; // expected-warning {{incompatible pointer types assigning to 
'__local int *__global **' from '__global int **'}}
+}

Anastasia wrote:
> ebevhan wrote:
> > ebevhan wrote:
> > > Anastasia wrote:
> > > > ebevhan wrote:
> > > > > This doesn't seem entirely correct still, but I'm not sure what to do 
> > > > > about it.
> > > > Is it because `Sema::IncompatiblePointer` has priority? We might want 
> > > > to change that. I think it was ok before because qualifier's mismatch 
> > > > was only a warning but now with the address spaces we are giving an 
> > > > error. I wonder if adding a separate enum item for address spaces 
> > > > (something like `Sema::IncompatibleNestedPointerAddressSpace`) would 
> > > > simplify things.
> > > > Is it because `Sema::IncompatiblePointer` has priority?
> > > 
> > > Sort of. The problem is that the AS pointee qualifiers match up until the 
> > > 'end' of the RHS pointer chain (LHS: `private->global->local`, RHS: 
> > > `private->global`), so we never get an 'incompatible address space' to 
> > > begin with. We only get that if 1) the bottommost type is equal after 
> > > unwrapping pointers (as far as both sides go), or 2) any of the 'shared' 
> > > AS qualifiers (as far as both sides go) were different.
> > > 
> > > The idea is that stopping when either side is no longer a pointer will 
> > > produce 'incompatible pointers' when you have different pointer depths, 
> > > but it doesn't consider anything below the 'shallowest' side of the 
> > > pointer chain, so we miss out on any AS mismatches further down.
> > > 
> > > (Not that there's anything to mismatch, really. There is no matching 
> > > pointer on the other side, so what is really the error?)
> > > 
> > > What should the criteria be for when the pointer types 'run out'? I could 
> > > have it keep digging through the other pointer until it hits a different 
> > > AS? This would mean that this:
> > > ```
> > > int  a;
> > > int ** b = a;
> > > ```
> > > could give a different warning than it does today, though (incompatible 
> > > nested qualifiers instead of incompatible pointers, which doesn't make 
> > > sense...) . We would have to skip the `lhptee == rhptee` check if we 
> > > 'kept going' despite one side not being a pointer type. So I don't know 
> > > if that's the right approach in general.
> > > 
> > > Or should we be searching 'backwards' instead, starting from the 
> > > innermost pointee? I don't know.
> > > 
> > > It really feels like the whole `checkPointerTypesForAssignment` routine 
> > > and everything surrounding it is a bit messy. It relies on an implicit 
> > > result from another function (`typesAreCompatible`) and then tries to 
> > > deduce why that function thought the types weren't compatible. Then 
> > > another function later on (`DiagnoseAssignmentResult`) tries to deduce 
> > > why THIS function thought something was wrong.
> > > 
> > > > I wonder if adding a separate enum item for address spaces (something 
> > > > like `Sema::IncompatibleNestedPointerAddressSpace`) would simplify 
> > > > things.
> > > 
> > > This would simplify the logic on the error emission side, since we don't 
> > > need to duplicate the logic for determining what went wrong, but doesn't 
> > > help with diagnosing the actual problem. Probably a good idea to add it 
> > > anyway, I just wanted to avoid adding a new enum member since that means 
> > > updating a lot of code elsewhere.
> > > We only get that if 1) the bottommost type is equal after unwrapping 
> > > pointers (as far as both sides go), or 2) any of the 'shared' AS 
> > > qualifiers (as far as both sides go) were different.
> > 
> > Sorry, should only be 2) here. Was focused on the whole 'incompatible 
> > nested qualifiers' result.
> > What should the criteria be for when the pointer types 'run out'? I could 
> > have it keep digging throug

[PATCH] D58367: [analyzer] NFC: Improve upon the concept of BugReporterVisitor.

2019-02-20 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Thank you for working this. I totally agree with you: whenever the checker 
spawns a new node in the exploded graph there is no point to leave it unmarked 
and then revers engineer it. `BugReporterVisitor`s should only care for nodes 
which are not spawned by the checker reporting the bug. This way we could get 
rid of some unnecessary visitors, e.g. `CXXSelfAssignmentBRVisitor`. This also 
opens an easier way for checkers similar to `CXXSelfAssignmentChecker` which 
does not report any bug but creates a new execution path which may end in a bug 
reported by another checker. Using note tags there is no need to create a 
separate `BugReporterVisitor` for every such checker and add it globally to 
every bug report.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:348
+/// additional PathDiagnosticEventPieces along the path.
+class NoteTag : public ProgramPointTag {
+public:

I am not sure whether `BugReporterVisitors.h` is the best place for this 
structure. I would rather put this into `ProgramPoint.h` or maybe 
`BugReporter.h`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58367



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


[PATCH] D58429: [CodeGen] Enable the complex-math test for arm

2019-02-20 Thread Peter Smith via Phabricator via cfe-commits
peter.smith accepted this revision.
peter.smith added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for the fix. My apologies for missing that at the time, it looks 
like a cut and paste error on my part.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58429



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


[clang-tools-extra] r354444 - [clangd] Try to fix windows build bots

2019-02-20 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Wed Feb 20 02:32:04 2019
New Revision: 35

URL: http://llvm.org/viewvc/llvm-project?rev=35&view=rev
Log:
[clangd] Try to fix windows build bots

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

Modified: clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp?rev=35&r1=354443&r2=35&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp Wed Feb 20 02:32:04 
2019
@@ -1442,7 +1442,11 @@ TEST(FindReferences, NoQueryForLocalSymb
 }
 
 TEST(GoTo, WithSysRoot) {
-  const char *CustoomRoot = "/sys/root/";
+#ifdef _WIN32
+  const char *CustomRoot = "C:\\sys\\root\\";
+#else
+  const char *CustomRoot = "/sys/root/";
+#endif
   Annotations Main(R"cpp(
   #include "header.h"
   int main() {
@@ -1451,7 +1455,7 @@ TEST(GoTo, WithSysRoot) {
   Annotations Header("int [[foo]](){return 42;}");
 
   MockCompilationDatabase CDB;
-  CDB.ExtraClangFlags = {"--sysroot", CustoomRoot};
+  CDB.ExtraClangFlags = {"--sysroot", CustomRoot};
   IgnoreDiagnostics DiagConsumer;
   MockFSProvider FS;
   ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
@@ -1459,7 +1463,8 @@ TEST(GoTo, WithSysRoot) {
   // Fill the filesystem.
   auto FooCpp = testPath("foo.cpp");
   FS.Files[FooCpp] = Main.code();
-  auto HeaderPath = (llvm::StringRef(CustoomRoot) + "include/header.h").str();
+  llvm::SmallString<128> HeaderPath(CustomRoot);
+  llvm::sys::path::append(HeaderPath, "include", "header.h");
   FS.Files[HeaderPath] = Header.code();
 
   runAddDocument(Server, FooCpp, Main.code());


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


[PATCH] D58388: [OpenCL] Simplify LLVM IR generated for OpenCL blocks

2019-02-20 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/CodeGen/CGBlocks.cpp:1275
+// We *can* call the block directly unless it is a function argument.
+if (!isa(E->getCalleeDecl()))
+  Func = CGM.getOpenCLRuntime().getInvokeFunction(E->getCallee());

I think it's reasonable enough... if we restrict blocks as parameters in the 
spec later it should be easy enough to modify this code. 



Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:131
+static const BlockExpr *getBlockExpr(const Expr *E) {
+  if (auto Cast = dyn_cast(E)) {
+E = Cast->getSubExpr();

Btw, does this handle the case when we assign a variable multiple time? I was 
just wondering if we need a loop somewhere?

I.e. does something like this work now:

```
typedef void (^bl_t)(local void *);

bl_t a = ...;
bl_t b = a;
bl_t c = b;

c();
enqueue_kernel(... c, ...);
```




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

https://reviews.llvm.org/D58388



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


[PATCH] D58278: Prepare ground for re-lexing modular headers.

2019-02-20 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Friendly ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58278



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


[PATCH] D58236: Make address space conversions a bit stricter.

2019-02-20 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:7795
+if (lhq.getAddressSpace() != rhq.getAddressSpace())
+  return Sema::IncompatibleNestedPointerDiscardsQualifiers;
+

I am wondering since the behavior is so specialized for the address spaces 
whether we should name this something like 
`IncompatibleNestedPointerAddressSpaceMismatch`.



Comment at: test/SemaOpenCL/address-spaces.cl:87
+
+  // FIXME: This doesn't seem right. This should be an error, not a warning.
+  __local int * __global * __private * lll;

Are we sure it has to be an error? May be we can change this wording to 
something like - unknown behavior that needs clarifying? Some similar text to 
your comment in the code.


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

https://reviews.llvm.org/D58236



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


[PATCH] D57523: Fix uninitialized value in ABIArgInfo

2019-02-20 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: jdoerfert.
Herald added a project: clang.

I've been staring at this, trying to figure out if the code somehow ends up 
using the uninitialized values, but I can't find it. So either it's hard to 
find, or GCC is doing something wrong.

But anyway, I think committing your change makes sense, but I think don't think 
we can say "Fix uninitialized value in ABIArgInfo", because it's not clear what 
needs fixing. Instead, I'd say "Always initialize the members in ABIArgInfo". 
That kind of makes sense in itself as it makes the code safer and possibly 
simpler, and of course it's also good that it fixes this problem.

What do you think?


Repository:
  rC Clang

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

https://reviews.llvm.org/D57523



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


[PATCH] D58436: [clang-format] Do not emit replacements if Java imports are OK

2019-02-20 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added subscribers: cfe-commits, jdoerfert.
Herald added a project: clang.

Currently clang-format would always emit a replacement for a block of Java 
imports even if it is correctly formatted:

  % cat /tmp/Aggregator.java
  import X;
  % clang-format /tmp/Aggregator.java
  import X;
  % clang-format -output-replacements-xml /tmp/Aggregator.java
  
  
  import X;
  
  %

This change makes clang-format not emit replacements in this case. Note that
there is logic to not emit replacements in this case for C++.


Repository:
  rC Clang

https://reviews.llvm.org/D58436

Files:
  lib/Format/Format.cpp
  unittests/Format/SortImportsTestJava.cpp


Index: unittests/Format/SortImportsTestJava.cpp
===
--- unittests/Format/SortImportsTestJava.cpp
+++ unittests/Format/SortImportsTestJava.cpp
@@ -262,6 +262,14 @@
  "import org.a;"));
 }
 
+TEST_F(SortImportsTestJava, NoReplacementsForValidImports) {
+  // Identical #includes have led to a failure with an unstable sort.
+  std::string Code = "import org.a;\n"
+ "import org.b;\n";
+  EXPECT_TRUE(
+  sortIncludes(FmtStyle, Code, GetCodeRange(Code), "input.java").empty());
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1853,6 +1853,7 @@
 static void sortJavaImports(const FormatStyle &Style,
 const SmallVectorImpl 
&Imports,
 ArrayRef Ranges, StringRef 
FileName,
+StringRef Code,
 tooling::Replacements &Replaces) {
   unsigned ImportsBeginOffset = Imports.front().Offset;
   unsigned ImportsEndOffset =
@@ -1868,12 +1869,12 @@
 findJavaImportGroup(Style, Imports[i].Identifier));
   }
   llvm::sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
-// Negating IsStatic to push static imports above non-static imports.
-return std::make_tuple(!Imports[LHSI].IsStatic, JavaImportGroups[LHSI],
-   Imports[LHSI].Identifier) <
-   std::make_tuple(!Imports[RHSI].IsStatic, JavaImportGroups[RHSI],
-   Imports[RHSI].Identifier);
-  });
+// Negating IsStatic to push static imports above non-static imports.
+return std::make_tuple(!Imports[LHSI].IsStatic, JavaImportGroups[LHSI],
+   Imports[LHSI].Identifier) <
+   std::make_tuple(!Imports[RHSI].IsStatic, JavaImportGroups[RHSI],
+   Imports[RHSI].Identifier);
+  });
 
   // Deduplicate imports.
   Indices.erase(std::unique(Indices.begin(), Indices.end(),
@@ -1902,6 +1903,11 @@
 CurrentImportGroup = JavaImportGroups[Index];
   }
 
+  // If the imports are out of order, we generate a single replacement fixing
+  // the entire block. Otherwise, no replacement is generated.
+  if (result == Code.substr(Imports.front().Offset, ImportsBlockSize))
+return;
+
   auto Err = Replaces.add(tooling::Replacement(FileName, 
Imports.front().Offset,
ImportsBlockSize, result));
   // FIXME: better error handling. For now, just skip the replacement for the
@@ -1967,7 +1973,7 @@
 SearchFrom = Pos + 1;
   }
   if (!ImportsInBlock.empty())
-sortJavaImports(Style, ImportsInBlock, Ranges, FileName, Replaces);
+sortJavaImports(Style, ImportsInBlock, Ranges, FileName, Code, Replaces);
   return Replaces;
 }
 


Index: unittests/Format/SortImportsTestJava.cpp
===
--- unittests/Format/SortImportsTestJava.cpp
+++ unittests/Format/SortImportsTestJava.cpp
@@ -262,6 +262,14 @@
  "import org.a;"));
 }
 
+TEST_F(SortImportsTestJava, NoReplacementsForValidImports) {
+  // Identical #includes have led to a failure with an unstable sort.
+  std::string Code = "import org.a;\n"
+ "import org.b;\n";
+  EXPECT_TRUE(
+  sortIncludes(FmtStyle, Code, GetCodeRange(Code), "input.java").empty());
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1853,6 +1853,7 @@
 static void sortJavaImports(const FormatStyle &Style,
 const SmallVectorImpl &Imports,
 ArrayRef Ranges, StringRef FileName,
+StringRef Code,
 tooling::Replacements &Replaces) {
   unsigned ImportsBeginOffset = Imports.front().Offset;
   unsigned ImportsEndOffset =
@@ -1868,12 +1869,12 @@
 findJavaImportGroup(Style, Imports[i].Identifier));
   }
   llvm::sort(Indices, [&](unsigne

r354452 - [clang-format] Do not emit replacements if Java imports are OK

2019-02-20 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Wed Feb 20 03:44:21 2019
New Revision: 354452

URL: http://llvm.org/viewvc/llvm-project?rev=354452&view=rev
Log:
[clang-format] Do not emit replacements if Java imports are OK

Summary:
Currently clang-format would always emit a replacement for a block of Java 
imports even if it is correctly formatted:
```
% cat /tmp/Aggregator.java
import X;
% clang-format /tmp/Aggregator.java
import X;
% clang-format -output-replacements-xml /tmp/Aggregator.java


import X;

%
```
This change makes clang-format not emit replacements in this case. Note that
there is logic to not emit replacements in this case for C++.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: jdoerfert, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/SortImportsTestJava.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=354452&r1=354451&r2=354452&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed Feb 20 03:44:21 2019
@@ -1853,6 +1853,7 @@ static unsigned findJavaImportGroup(cons
 static void sortJavaImports(const FormatStyle &Style,
 const SmallVectorImpl 
&Imports,
 ArrayRef Ranges, StringRef 
FileName,
+StringRef Code,
 tooling::Replacements &Replaces) {
   unsigned ImportsBeginOffset = Imports.front().Offset;
   unsigned ImportsEndOffset =
@@ -1868,12 +1869,12 @@ static void sortJavaImports(const Format
 findJavaImportGroup(Style, Imports[i].Identifier));
   }
   llvm::sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
-// Negating IsStatic to push static imports above non-static imports.
-return std::make_tuple(!Imports[LHSI].IsStatic, JavaImportGroups[LHSI],
-   Imports[LHSI].Identifier) <
-   std::make_tuple(!Imports[RHSI].IsStatic, JavaImportGroups[RHSI],
-   Imports[RHSI].Identifier);
-  });
+// Negating IsStatic to push static imports above non-static imports.
+return std::make_tuple(!Imports[LHSI].IsStatic, JavaImportGroups[LHSI],
+   Imports[LHSI].Identifier) <
+   std::make_tuple(!Imports[RHSI].IsStatic, JavaImportGroups[RHSI],
+   Imports[RHSI].Identifier);
+  });
 
   // Deduplicate imports.
   Indices.erase(std::unique(Indices.begin(), Indices.end(),
@@ -1902,6 +1903,11 @@ static void sortJavaImports(const Format
 CurrentImportGroup = JavaImportGroups[Index];
   }
 
+  // If the imports are out of order, we generate a single replacement fixing
+  // the entire block. Otherwise, no replacement is generated.
+  if (result == Code.substr(Imports.front().Offset, ImportsBlockSize))
+return;
+
   auto Err = Replaces.add(tooling::Replacement(FileName, 
Imports.front().Offset,
ImportsBlockSize, result));
   // FIXME: better error handling. For now, just skip the replacement for the
@@ -1967,7 +1973,7 @@ tooling::Replacements sortJavaImports(co
 SearchFrom = Pos + 1;
   }
   if (!ImportsInBlock.empty())
-sortJavaImports(Style, ImportsInBlock, Ranges, FileName, Replaces);
+sortJavaImports(Style, ImportsInBlock, Ranges, FileName, Code, Replaces);
   return Replaces;
 }
 

Modified: cfe/trunk/unittests/Format/SortImportsTestJava.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/SortImportsTestJava.cpp?rev=354452&r1=354451&r2=354452&view=diff
==
--- cfe/trunk/unittests/Format/SortImportsTestJava.cpp (original)
+++ cfe/trunk/unittests/Format/SortImportsTestJava.cpp Wed Feb 20 03:44:21 2019
@@ -262,6 +262,14 @@ TEST_F(SortImportsTestJava, NoNewlineAtE
  "import org.a;"));
 }
 
+TEST_F(SortImportsTestJava, NoReplacementsForValidImports) {
+  // Identical #includes have led to a failure with an unstable sort.
+  std::string Code = "import org.a;\n"
+ "import org.b;\n";
+  EXPECT_TRUE(
+  sortIncludes(FmtStyle, Code, GetCodeRange(Code), "input.java").empty());
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang


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


[PATCH] D58436: [clang-format] Do not emit replacements if Java imports are OK

2019-02-20 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354452: [clang-format] Do not emit replacements if Java 
imports are OK (authored by krasimir, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58436

Files:
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/unittests/Format/SortImportsTestJava.cpp


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -1853,6 +1853,7 @@
 static void sortJavaImports(const FormatStyle &Style,
 const SmallVectorImpl 
&Imports,
 ArrayRef Ranges, StringRef 
FileName,
+StringRef Code,
 tooling::Replacements &Replaces) {
   unsigned ImportsBeginOffset = Imports.front().Offset;
   unsigned ImportsEndOffset =
@@ -1868,12 +1869,12 @@
 findJavaImportGroup(Style, Imports[i].Identifier));
   }
   llvm::sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
-// Negating IsStatic to push static imports above non-static imports.
-return std::make_tuple(!Imports[LHSI].IsStatic, JavaImportGroups[LHSI],
-   Imports[LHSI].Identifier) <
-   std::make_tuple(!Imports[RHSI].IsStatic, JavaImportGroups[RHSI],
-   Imports[RHSI].Identifier);
-  });
+// Negating IsStatic to push static imports above non-static imports.
+return std::make_tuple(!Imports[LHSI].IsStatic, JavaImportGroups[LHSI],
+   Imports[LHSI].Identifier) <
+   std::make_tuple(!Imports[RHSI].IsStatic, JavaImportGroups[RHSI],
+   Imports[RHSI].Identifier);
+  });
 
   // Deduplicate imports.
   Indices.erase(std::unique(Indices.begin(), Indices.end(),
@@ -1902,6 +1903,11 @@
 CurrentImportGroup = JavaImportGroups[Index];
   }
 
+  // If the imports are out of order, we generate a single replacement fixing
+  // the entire block. Otherwise, no replacement is generated.
+  if (result == Code.substr(Imports.front().Offset, ImportsBlockSize))
+return;
+
   auto Err = Replaces.add(tooling::Replacement(FileName, 
Imports.front().Offset,
ImportsBlockSize, result));
   // FIXME: better error handling. For now, just skip the replacement for the
@@ -1967,7 +1973,7 @@
 SearchFrom = Pos + 1;
   }
   if (!ImportsInBlock.empty())
-sortJavaImports(Style, ImportsInBlock, Ranges, FileName, Replaces);
+sortJavaImports(Style, ImportsInBlock, Ranges, FileName, Code, Replaces);
   return Replaces;
 }
 
Index: cfe/trunk/unittests/Format/SortImportsTestJava.cpp
===
--- cfe/trunk/unittests/Format/SortImportsTestJava.cpp
+++ cfe/trunk/unittests/Format/SortImportsTestJava.cpp
@@ -262,6 +262,14 @@
  "import org.a;"));
 }
 
+TEST_F(SortImportsTestJava, NoReplacementsForValidImports) {
+  // Identical #includes have led to a failure with an unstable sort.
+  std::string Code = "import org.a;\n"
+ "import org.b;\n";
+  EXPECT_TRUE(
+  sortIncludes(FmtStyle, Code, GetCodeRange(Code), "input.java").empty());
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang


Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -1853,6 +1853,7 @@
 static void sortJavaImports(const FormatStyle &Style,
 const SmallVectorImpl &Imports,
 ArrayRef Ranges, StringRef FileName,
+StringRef Code,
 tooling::Replacements &Replaces) {
   unsigned ImportsBeginOffset = Imports.front().Offset;
   unsigned ImportsEndOffset =
@@ -1868,12 +1869,12 @@
 findJavaImportGroup(Style, Imports[i].Identifier));
   }
   llvm::sort(Indices, [&](unsigned LHSI, unsigned RHSI) {
-// Negating IsStatic to push static imports above non-static imports.
-return std::make_tuple(!Imports[LHSI].IsStatic, JavaImportGroups[LHSI],
-   Imports[LHSI].Identifier) <
-   std::make_tuple(!Imports[RHSI].IsStatic, JavaImportGroups[RHSI],
-   Imports[RHSI].Identifier);
-  });
+// Negating IsStatic to push static imports above non-static imports.
+return std::make_tuple(!Imports[LHSI].IsStatic, JavaImportGroups[LHSI],
+   Imports[LHSI].Identifier) <
+   std::make_tuple(!Imports[RHSI].IsStatic, JavaImportGroups[RHSI],
+   Imports[RHSI].Identifier);
+  });
 
   // Deduplicat

[clang-tools-extra] r354453 - [clangd] Revert r354442 and r354444

2019-02-20 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Wed Feb 20 03:45:20 2019
New Revision: 354453

URL: http://llvm.org/viewvc/llvm-project?rev=354453&view=rev
Log:
[clangd] Revert r354442 and r35

Looks like sysroot is only working on linux.

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

Modified: clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp?rev=354453&r1=354452&r2=354453&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp Wed Feb 20 03:45:20 
2019
@@ -1441,40 +1441,6 @@ TEST(FindReferences, NoQueryForLocalSymb
   }
 }
 
-TEST(GoTo, WithSysRoot) {
-#ifdef _WIN32
-  const char *CustomRoot = "C:\\sys\\root\\";
-#else
-  const char *CustomRoot = "/sys/root/";
-#endif
-  Annotations Main(R"cpp(
-  #include "header.h"
-  int main() {
-return f^oo();
-  })cpp");
-  Annotations Header("int [[foo]](){return 42;}");
-
-  MockCompilationDatabase CDB;
-  CDB.ExtraClangFlags = {"--sysroot", CustomRoot};
-  IgnoreDiagnostics DiagConsumer;
-  MockFSProvider FS;
-  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
-
-  // Fill the filesystem.
-  auto FooCpp = testPath("foo.cpp");
-  FS.Files[FooCpp] = Main.code();
-  llvm::SmallString<128> HeaderPath(CustomRoot);
-  llvm::sys::path::append(HeaderPath, "include", "header.h");
-  FS.Files[HeaderPath] = Header.code();
-
-  runAddDocument(Server, FooCpp, Main.code());
-
-  // Go to a definition in main source file.
-  auto Locations = runLocateSymbolAt(Server, FooCpp, Main.point());
-  EXPECT_TRUE(bool(Locations)) << "findDefinitions returned an error";
-  EXPECT_THAT(*Locations, ElementsAre(Sym("foo", Header.range(;
-}
-
 } // namespace
 } // namespace clangd
 } // namespace clang


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


[PATCH] D57108: [clang-tidy] diagnose possibiltiy to add 'noexcept' in modernize-use-noexcept

2019-02-20 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Great! However, I would rename the test files: `modernize-use-noexcept-opt.cpp` 
is inaccurate since there are multiple options, it could be e.g. 
`modernize-use-noexcept-dont-use-noexcept-false.cpp`. 
`modernize-use-noexcept-new-noexcept.cpp` is a bit misleading because of the 
`new` which is a valid C++ keyword. 
`modernize-use-noexcept-add-missing-noexcept.cpp` sounds better for me.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57108



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


[PATCH] D49754: Add -m(no-)spe, and e500 CPU definitions and support to clang

2019-02-20 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai added a comment.
This revision is now accepted and ready to land.

Please, no more patches without context. This one was actually easy to review 
without context and the comments are minor, so I'm fine with these being 
addressed on the commit.




Comment at: lib/Basic/Targets/PPC.cpp:318
+  Features["spe"] = llvm::StringSwitch(CPU)
+.Case("e500", true)
+.Case("8548", true)

The `e500v2` that you added doesn't support SPE?



Comment at: test/Misc/target-invalid-cpu-note.c:82
 // PPC-SAME: 603e, 603ev, 604, 604e, 620, 630, g3, 7400, g4, 7450, g4+, 750,
-// PPC-SAME: 970, g5, a2, a2q, e500mc, e5500, power3, pwr3, power4, pwr4,
+// PPC-SAME: 970, g5, a2, a2q, e500, e500mc, e5500, power3, pwr3, power4, pwr4,
 // PPC-SAME: power5, pwr5, power5x, pwr5x, power6, pwr6, power6x, pwr6x, 
power7,

I think you may have missed adding `8548` to this line or above. Of course, the 
test should still pass, but we should add it.



Comment at: test/Preprocessor/init.c:7021
+//
+// PPC32-SPE:#define __SPE__ 1
+//

Please add a check for the other predefined macro you added.


Repository:
  rC Clang

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

https://reviews.llvm.org/D49754



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


[clang-tools-extra] r354456 - [clangd] Fix a typo. NFC

2019-02-20 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Feb 20 04:31:44 2019
New Revision: 354456

URL: http://llvm.org/viewvc/llvm-project?rev=354456&view=rev
Log:
[clangd] Fix a typo. NFC

The documentation for -index-file mentioned clang-index instead of
clangd-indexer.

Modified:
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp

Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp?rev=354456&r1=354455&r2=354456&view=diff
==
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Wed Feb 20 04:31:44 2019
@@ -163,7 +163,7 @@ static llvm::cl::opt IndexFile(
 "index-file",
 llvm::cl::desc(
 "Index file to build the static index. The file must have been created 
"
-"by a compatible clangd-index.\n"
+"by a compatible clangd-indexer.\n"
 "WARNING: This option is experimental only, and will be removed "
 "eventually. Don't rely on it."),
 llvm::cl::init(""), llvm::cl::Hidden);


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


[PATCH] D49754: Add -m(no-)spe, and e500 CPU definitions and support to clang

2019-02-20 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

In D49754#1402790 , @vit9696 wrote:

> This is a series of patches, which I believe should merged altogether. 
> Currently the following patches are relevant:


No, please don't merge them together. It is much more manageable for review 
when they're separate patches. I realize that this makes it a bit more 
difficult for the author to keep the dependency ordering straight, but I think 
preference needs to be given to the "reviewability" of the code.


Repository:
  rC Clang

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

https://reviews.llvm.org/D49754



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


[PATCH] D57577: Make predefined FLT16 macros conditional on support for the type

2019-02-20 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai marked an inline comment as done.
nemanjai added a comment.
Herald added a subscriber: jdoerfert.

Since I haven't seen any further objections to this, I'll commit this later 
today.




Comment at: test/Preprocessor/init.c:9169
 // WEBASSEMBLY-NEXT:#define __FLOAT128__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_DECIMAL_DIG__ 5
-// WEBASSEMBLY-NEXT:#define __FLT16_DENORM_MIN__ 5.9604644775390625e-8F16

SjoerdMeijer wrote:
> Perhaps change this in WEBASSEMBLY-NOT so that we also have one negative test 
> for this?
I will do this on the commit.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57577



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


[PATCH] D58440: [clangd] Store index in '.clangd/index' instead of '.clangd-index'

2019-02-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: kadircet, sammccall.
Herald added subscribers: arphaman, jkorous, MaskRay, ioeric.
Herald added a project: clang.

To take up the .clangd folder for other potential uses in the future.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58440

Files:
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
  clang-tools-extra/test/clangd/background-index.test


Index: clang-tools-extra/test/clangd/background-index.test
===
--- clang-tools-extra/test/clangd/background-index.test
+++ clang-tools-extra/test/clangd/background-index.test
@@ -13,7 +13,7 @@
 # RUN: clangd -background-index -background-index-rebuild-period=0 -lit-test < 
%t/definition.jsonrpc | FileCheck %t/definition.jsonrpc
 
 # Test that the index is writing files in the expected location.
-# RUN: ls %t/.clangd-index/foo.cpp.*.idx
+# RUN: ls %t/.clangd/index/foo.cpp.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
 # RUN: rm %t/foo.cpp
Index: clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
===
--- clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
+++ clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
@@ -63,19 +63,19 @@
 }
 
 // Uses disk as a storage for index shards. Creates a directory called
-// ".clangd-index/" under the path provided during construction.
+// ".clangd/index/" under the path provided during construction.
 class DiskBackedIndexStorage : public BackgroundIndexStorage {
   std::string DiskShardRoot;
 
 public:
-  // Sets DiskShardRoot to (Directory + ".clangd-index/") which is the base
+  // Sets DiskShardRoot to (Directory + ".clangd/index/") which is the base
   // directory for all shard files.
   DiskBackedIndexStorage(llvm::StringRef Directory) {
 llvm::SmallString<128> CDBDirectory(Directory);
-llvm::sys::path::append(CDBDirectory, ".clangd-index/");
+llvm::sys::path::append(CDBDirectory, ".clangd", "index/");
 DiskShardRoot = CDBDirectory.str();
 std::error_code OK;
-std::error_code EC = llvm::sys::fs::create_directory(DiskShardRoot);
+std::error_code EC = llvm::sys::fs::create_directories(DiskShardRoot);
 if (EC != OK) {
   elog("Failed to create directory {0} for index storage: {1}",
DiskShardRoot, EC.message());
Index: clang-tools-extra/clangd/index/Background.h
===
--- clang-tools-extra/clangd/index/Background.h
+++ clang-tools-extra/clangd/index/Background.h
@@ -54,7 +54,7 @@
   llvm::unique_function;
 
   // Creates an Index Storage that saves shards into disk. Index storage uses
-  // CDBDirectory + ".clangd-index/" as the folder to save shards.
+  // CDBDirectory + ".clangd/index/" as the folder to save shards.
   static Factory createDiskBackedStorageFactory();
 };
 


Index: clang-tools-extra/test/clangd/background-index.test
===
--- clang-tools-extra/test/clangd/background-index.test
+++ clang-tools-extra/test/clangd/background-index.test
@@ -13,7 +13,7 @@
 # RUN: clangd -background-index -background-index-rebuild-period=0 -lit-test < %t/definition.jsonrpc | FileCheck %t/definition.jsonrpc
 
 # Test that the index is writing files in the expected location.
-# RUN: ls %t/.clangd-index/foo.cpp.*.idx
+# RUN: ls %t/.clangd/index/foo.cpp.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
 # RUN: rm %t/foo.cpp
Index: clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
===
--- clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
+++ clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
@@ -63,19 +63,19 @@
 }
 
 // Uses disk as a storage for index shards. Creates a directory called
-// ".clangd-index/" under the path provided during construction.
+// ".clangd/index/" under the path provided during construction.
 class DiskBackedIndexStorage : public BackgroundIndexStorage {
   std::string DiskShardRoot;
 
 public:
-  // Sets DiskShardRoot to (Directory + ".clangd-index/") which is the base
+  // Sets DiskShardRoot to (Directory + ".clangd/index/") which is the base
   // directory for all shard files.
   DiskBackedIndexStorage(llvm::StringRef Directory) {
 llvm::SmallString<128> CDBDirectory(Directory);
-llvm::sys::path::append(CDBDirectory, ".clangd-index/");
+llvm::sys::path::append(CDBDirectory, ".clangd", "index/");
 DiskShardRoot = CDBDirectory.str();
 std::error_code OK;
-std::error_code EC = llvm::sys::fs::create_directory(DiskShardRoot);
+std::error_code EC = llvm::sys::fs::create_directories(DiskShardRoot);
 if (EC != OK) {
   elog("Failed to create directory {0} for index storage: {1}"

Re: r354351 - Remove extraneous space in MSVC-style diagnostic output

2019-02-20 Thread Hans Wennborg via cfe-commits
Merged to release_80 in r354459.

On Tue, Feb 19, 2019 at 5:57 PM Hans Wennborg via cfe-commits
 wrote:
>
> Author: hans
> Date: Tue Feb 19 08:58:25 2019
> New Revision: 354351
>
> URL: http://llvm.org/viewvc/llvm-project?rev=354351&view=rev
> Log:
> Remove extraneous space in MSVC-style diagnostic output
>
> There was an extra space between the file location and the diagnostic
> message:
>
>   /tmp/a.c(1,12):  warning: unused parameter 'unused'
>
> the tests didn't catch this due to FileCheck not running in 
> --strict-whitespace mode.
>
> Reported by Marco: 
> http://lists.llvm.org/pipermail/cfe-dev/2019-February/061326.html
>
> Differential revision: https://reviews.llvm.org/D58377
>
> Modified:
> cfe/trunk/lib/Frontend/TextDiagnostic.cpp
> cfe/trunk/test/Misc/diag-format.c
>
> Modified: cfe/trunk/lib/Frontend/TextDiagnostic.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnostic.cpp?rev=354351&r1=354350&r2=354351&view=diff
> ==
> --- cfe/trunk/lib/Frontend/TextDiagnostic.cpp (original)
> +++ cfe/trunk/lib/Frontend/TextDiagnostic.cpp Tue Feb 19 08:58:25 2019
> @@ -837,7 +837,7 @@ void TextDiagnostic::emitDiagnosticLoc(F
>  if (LangOpts.MSCompatibilityVersion &&
>  !LangOpts.isCompatibleWithMSVC(LangOptions::MSVC2015))
>OS << ' ';
> -OS << ": ";
> +OS << ':';
>  break;
>}
>
>
> Modified: cfe/trunk/test/Misc/diag-format.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-format.c?rev=354351&r1=354350&r2=354351&view=diff
> ==
> --- cfe/trunk/test/Misc/diag-format.c (original)
> +++ cfe/trunk/test/Misc/diag-format.c Tue Feb 19 08:58:25 2019
> @@ -1,30 +1,30 @@
> -// RUN: %clang -fsyntax-only  %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
> -// RUN: %clang -fsyntax-only -fdiagnostics-format=clang %s 2>&1 | FileCheck 
> %s -check-prefix=DEFAULT
> -// RUN: %clang -fsyntax-only -fdiagnostics-format=clang -target 
> x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
> +// RUN: %clang -fsyntax-only  %s 2>&1 | FileCheck %s --strict-whitespace 
> -check-prefix=DEFAULT
> +// RUN: %clang -fsyntax-only -fdiagnostics-format=clang %s 2>&1 | FileCheck 
> %s --strict-whitespace -check-prefix=DEFAULT
> +// RUN: %clang -fsyntax-only -fdiagnostics-format=clang -target 
> x86_64-pc-win32 %s 2>&1 | FileCheck %s --strict-whitespace 
> -check-prefix=DEFAULT
>  //
> -// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1300  
> %s 2>&1 | FileCheck %s -check-prefix=MSVC2010
> -// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc 
> -fms-compatibility-version=13.00  %s 2>&1 | FileCheck %s 
> -check-prefix=MSVC2010
> -// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1300 
> -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC2010
> -// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc 
> -fms-compatibility-version=13.00 -target x86_64-pc-win32 %s 2>&1 | FileCheck 
> %s -check-prefix=MSVC2010
> -// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1300 
> -target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s 
> -check-prefix=MSVC2010
> -// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1800 
> -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC2013
> -// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -target 
> x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC
> -// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1900 
> -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC2015
> -// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc 
> -fms-compatibility-version=13.00 -target x86_64-pc-win32 -fshow-column %s 
> 2>&1 | FileCheck %s -check-prefix=MSVC2010
> -// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1800 
> -target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s 
> -check-prefix=MSVC2013
> -// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -target 
> x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s -check-prefix=MSVC
> -// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1900 
> -target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s 
> -check-prefix=MSVC2015
> +// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1300  
> %s 2>&1 | FileCheck %s --strict-whitespace -check-prefix=MSVC2010
> +// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc 
> -fms-compatibility-version=13.00  %s 2>&1 | FileCheck %s --strict-whitespace 
> -check-prefix=MSVC2010
> +// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1300 
> -target x86_64-pc-win32 %s 2>&1 | FileCheck %s --strict-whitespace 
> -check-prefix=MSVC2010
> +// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc 
> -fms-compatibility-version=13.00 -target x86_64-pc-win32 %s 2>&1 | FileCheck 

[PATCH] D58346: [Sema] Change addr space diagnostics in casts to follow C++ style

2019-02-20 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added inline comments.



Comment at: lib/Sema/SemaCast.cpp:2224
+  } else if (IsLValueCast) {
 Kind = CK_LValueBitCast;
   } else if (DestType->isObjCObjectPointerType()) {

Anastasia wrote:
> ebevhan wrote:
> > Anastasia wrote:
> > > ebevhan wrote:
> > > > This might not be applicable to this patch, but just something I 
> > > > noticed.
> > > > 
> > > > So `reinterpret_cast` only operates on pointers when dealing with 
> > > > address spaces. What about something like
> > > > ```
> > > > T a;
> > > > T& a_ref = reinterpret_cast(a);
> > > > ```
> > > > `reinterpret_cast` on an lvalue like this is equivalent to 
> > > > `*reinterpret_cast(&a)`. So for AS code:
> > > > ```
> > > > __private T x;
> > > > __generic T& ref = reinterpret_cast<__generic T&>(x);
> > > > ```
> > > > This should work, since `*reinterpret_cast<__generic T*>(&x)` is valid, 
> > > > correct?
> > > > 
> > > > What if we have the reference cast case with a different address space 
> > > > like this? Doesn't the `IsLValueCast` check need to be first?
> > > > 
> > > > What if we have the reference cast case with a different address space 
> > > > like this? Doesn't the IsLValueCast check need to be first?
> > > 
> > > Ok, let me see if I understand you. I changed `__generic` -> `__global` 
> > > since it's invalid and the error is produced as follows:
> > >   test.cl:7:21: error: reinterpret_cast from 'int' to '__global int &' is 
> > > not allowed
> > >   __global int& ref = reinterpret_cast<__global int&>(x);
> > > 
> > > Is this not what we are expecting here?
> > My last sentence could have been a bit clearer. Yes, for the 
> > `__private`->`__global` case, it should error. But I was thinking more of 
> > the case where the AS conversion is valid, like `__private`->`__generic`. 
> > Then we will do the AS conversion, but we should have done both an AS 
> > conversion and an `LValueBitCast`, because we need to both convert the 
> > 'pointer' and also dereference it.
> Hmm... it seems like here we can only have one cast kind... I guess 
> `CK_LValueBitCast` leads to the generation of `bitcast` in the IR? But 
> `addrspacecast` can perform both bit reinterpretation and address 
> translation, so perhaps it makes sense to only have an address space 
> conversion in this case? Unless some other logic is needed elsewhere before 
> CodeGen... I will try to construct a test case in plain C++. 
> Hmm... it seems like here we can only have one cast kind... I guess 
> CK_LValueBitCast leads to the generation of bitcast in the IR?

That's likely, yes. The dereference in the example disappears if we assign to a 
`T&` and it becomes implied if we assign to a `T` through lvalue-to-rvalue 
conversion, so in both cases we're taking the address of something and then 
converting the address to a different type.

> But addrspacecast can perform both bit reinterpretation and address 
> translation, so perhaps it makes sense to only have an address space 
> conversion in this case? Unless some other logic is needed elsewhere before 
> CodeGen... I will try to construct a test case in plain C++.

Oh, you're right! For some reason I was thinking that `addrspacecast` could 
only change the addrspace of the argument, but apparently it could change the 
pointee type too. At least according to the langref. So long as nothing in 
Clang assumes that a CK_AddressSpaceConversion can't change the pointee type as 
well as the address space I guess it should be safe.

When I try a 'simultaneous' conversion in C, I don't get a single 
addrspacecast, though: https://godbolt.org/z/Q818yW So I wonder if existing 
code handles this.

A test case would be good.



Comment at: lib/Sema/SemaCast.cpp:2309
+auto DestPointeeTypeWithoutAS = Self.Context.removeAddrSpaceQualType(
+DestPointeeType.getCanonicalType());
+return Self.Context.hasSameType(SrcPointeeTypeWithoutAS,

Anastasia wrote:
> Anastasia wrote:
> > ebevhan wrote:
> > > Maybe I'm mistaken, but won't getting the canonical type here drop 
> > > qualifiers (like cv) in nested pointers? If so, an addrspace_cast might 
> > > strip qualifiers by mistake.
> > Yes, indeed I will need to extend this to nested pointers when we are 
> > ready. But for now I can try to change this bit... however I am not sure it 
> > will work w/o canonical types when we have typedef. I will try to create an 
> > example and see.
> I checked the canonical type does preserve the qualifiers correctly.
> 
> Here is the AST dump of the following C type `mytype const __generic*` where  
> `typedef  __generic int* mytype;`.
> 
> 
> ```
> PointerType 0x204d3b0 'const __generic mytype *'
> `-QualType 0x204d369 'const __generic mytype' const __generic
>   `-TypedefType 0x204d320 'mytype' sugar
> |-Typedef 0x204d1b0 'mytype'
> `-PointerType 0x204d170 '__generic int *'
>   `-QualType 0x204d158 '__generic int' __generic
> `-BuiltinType 0x2009750 '

[PATCH] D57914: [Driver] Allow enum SanitizerOrdinal to represent more than 64 different sanitizer checks, NFC.

2019-02-20 Thread pierre gousseau via Phabricator via cfe-commits
pgousseau updated this revision to Diff 187553.
pgousseau added a comment.

Applied suggested changes.


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

https://reviews.llvm.org/D57914

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/Sanitizers.def
  include/clang/Basic/Sanitizers.h
  include/clang/Driver/ToolChain.h
  lib/Basic/SanitizerSpecialCaseList.cpp
  lib/Basic/Sanitizers.cpp
  lib/CodeGen/CGExpr.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDeclAttr.cpp

Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -6199,7 +6199,8 @@
 if (!S.checkStringLiteralArgumentAttr(AL, I, SanitizerName, &LiteralLoc))
   return;
 
-if (parseSanitizerValue(SanitizerName, /*AllowGroups=*/true) == 0)
+if (parseSanitizerValue(SanitizerName, /*AllowGroups=*/true) ==
+SanitizerMask())
   S.Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName;
 else if (isGlobalVar(D) && SanitizerName != "address")
   S.Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -551,7 +551,7 @@
 DiagnosticsEngine &Diags, SanitizerSet &S) {
   for (const auto &Sanitizer : Sanitizers) {
 SanitizerMask K = parseSanitizerValue(Sanitizer, /*AllowGroups=*/false);
-if (K == 0)
+if (K == SanitizerMask())
   Diags.Report(diag::err_drv_invalid_value) << FlagName << Sanitizer;
 else
   S.set(K, true);
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -25,29 +25,32 @@
 using namespace clang::driver;
 using namespace llvm::opt;
 
-enum : SanitizerMask {
-  NeedsUbsanRt = Undefined | Integer | ImplicitConversion | Nullability | CFI,
-  NeedsUbsanCxxRt = Vptr | CFI,
-  NotAllowedWithTrap = Vptr,
-  NotAllowedWithMinimalRuntime = Vptr,
-  RequiresPIE = DataFlow | HWAddress | Scudo,
-  NeedsUnwindTables = Address | HWAddress | Thread | Memory | DataFlow,
-  SupportsCoverage = Address | HWAddress | KernelAddress | KernelHWAddress |
- Memory | KernelMemory | Leak | Undefined | Integer |
- ImplicitConversion | Nullability | DataFlow | Fuzzer |
- FuzzerNoLink,
-  RecoverableByDefault = Undefined | Integer | ImplicitConversion | Nullability,
-  Unrecoverable = Unreachable | Return,
-  AlwaysRecoverable = KernelAddress | KernelHWAddress,
-  LegacyFsanitizeRecoverMask = Undefined | Integer,
-  NeedsLTO = CFI,
-  TrappingSupported = (Undefined & ~Vptr) | UnsignedIntegerOverflow |
-  ImplicitConversion | Nullability | LocalBounds | CFI,
-  TrappingDefault = CFI,
-  CFIClasses =
-  CFIVCall | CFINVCall | CFIMFCall | CFIDerivedCast | CFIUnrelatedCast,
-  CompatibleWithMinimalRuntime = TrappingSupported | Scudo | ShadowCallStack,
-};
+const SanitizerMask NeedsUbsanRt =
+Undefined | Integer | ImplicitConversion | Nullability | CFI;
+const SanitizerMask NeedsUbsanCxxRt = Vptr | CFI;
+const SanitizerMask NotAllowedWithTrap = Vptr;
+const SanitizerMask NotAllowedWithMinimalRuntime = Vptr;
+const SanitizerMask RequiresPIE = DataFlow | HWAddress | Scudo;
+const SanitizerMask NeedsUnwindTables =
+Address | HWAddress | Thread | Memory | DataFlow;
+const SanitizerMask SupportsCoverage =
+Address | HWAddress | KernelAddress | KernelHWAddress | Memory |
+KernelMemory | Leak | Undefined | Integer | ImplicitConversion |
+Nullability | DataFlow | Fuzzer | FuzzerNoLink;
+const SanitizerMask RecoverableByDefault =
+Undefined | Integer | ImplicitConversion | Nullability;
+const SanitizerMask Unrecoverable = Unreachable | Return;
+const SanitizerMask AlwaysRecoverable = KernelAddress | KernelHWAddress;
+const SanitizerMask LegacyFsanitizeRecoverMask = Undefined | Integer;
+const SanitizerMask NeedsLTO = CFI;
+const SanitizerMask TrappingSupported =
+(Undefined & ~Vptr) | UnsignedIntegerOverflow | ImplicitConversion |
+Nullability | LocalBounds | CFI;
+const SanitizerMask TrappingDefault = CFI;
+const SanitizerMask CFIClasses =
+CFIVCall | CFINVCall | CFIMFCall | CFIDerivedCast | CFIUnrelatedCast;
+const SanitizerMask CompatibleWithMinimalRuntime =
+TrappingSupported | Scudo | ShadowCallStack;
 
 enum CoverageFeature {
   CoverageFunc = 1 << 0,
@@ -136,10 +139,10 @@
 
 static SanitizerMask parseSanitizeTrapArgs(const Driver &D,
const llvm::opt::ArgList &Args) {
-  SanitizerMask TrapRemove = 0; // During the loop below, the accumulated set of
+  SanitizerMask TrapRemove; // During the loop below, the accumulated set of
 

[PATCH] D57914: [Driver] Allow enum SanitizerOrdinal to represent more than 64 different sanitizer checks, NFC.

2019-02-20 Thread pierre gousseau via Phabricator via cfe-commits
pgousseau marked 7 inline comments as done.
pgousseau added inline comments.



Comment at: include/clang/Basic/Sanitizers.h:96
+return false;
+}
+return true;

riccibruno wrote:
> Is that vectorized by gcc/clang, or is that a sequence of branches ?
clang 6 or gcc 7.3 does not vectorize but clang 8 does!


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

https://reviews.llvm.org/D57914



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


[PATCH] D53701: [Analyzer] Record and process comparison of symbols instead of iterator positions in interator checkers

2019-02-20 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.
Herald added a subscriber: jdoerfert.

In D53701#1322255 , @NoQ wrote:

> Well, i mean, whenever you are inlining a method,  you //are// exposing 
> details of the "internals" of the inlined API to the user. The only 
> difference is whether this API itself deals with iterators. This sounds to me 
> as if we try not to inline iterator methods in general. Or try really hard to 
> prevent desynchronization between the two models.


When tracking multi-level iterator structures (iterator adapters or other 
constructs e.g. a leaf-iterator in a general tree) we mainly want to track the 
topmost level, but it is inaccurate without inlining their methods. We need the 
to track the real control flow. However, when reporting a bug we want to report 
it at the topmost level since the erroneous code is most probably the top-level 
code, not the API. That way we do not directly expose the layers below the API 
to the user. That is the reason that we have to handle all structures which 
behave as iterators as iterators, even if they contain iterators themselves. 
Since error-checking happens in the `checkPre...()` hooks, bugs are 
automatically catched at the topmost level.

> Ok, how about an eager state split for now?

Do you mean that upon iterator comparison I do not record the comparison and 
later retrieve it in the branches with concrete results but I do the 
state-split myself in `checkPostCall()`?


Repository:
  rC Clang

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

https://reviews.llvm.org/D53701



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


[PATCH] D58346: [Sema] Change addr space diagnostics in casts to follow C++ style

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



Comment at: lib/Sema/SemaCast.cpp:2224
+  } else if (IsLValueCast) {
 Kind = CK_LValueBitCast;
   } else if (DestType->isObjCObjectPointerType()) {

Anastasia wrote:
> ebevhan wrote:
> > Anastasia wrote:
> > > ebevhan wrote:
> > > > This might not be applicable to this patch, but just something I 
> > > > noticed.
> > > > 
> > > > So `reinterpret_cast` only operates on pointers when dealing with 
> > > > address spaces. What about something like
> > > > ```
> > > > T a;
> > > > T& a_ref = reinterpret_cast(a);
> > > > ```
> > > > `reinterpret_cast` on an lvalue like this is equivalent to 
> > > > `*reinterpret_cast(&a)`. So for AS code:
> > > > ```
> > > > __private T x;
> > > > __generic T& ref = reinterpret_cast<__generic T&>(x);
> > > > ```
> > > > This should work, since `*reinterpret_cast<__generic T*>(&x)` is valid, 
> > > > correct?
> > > > 
> > > > What if we have the reference cast case with a different address space 
> > > > like this? Doesn't the `IsLValueCast` check need to be first?
> > > > 
> > > > What if we have the reference cast case with a different address space 
> > > > like this? Doesn't the IsLValueCast check need to be first?
> > > 
> > > Ok, let me see if I understand you. I changed `__generic` -> `__global` 
> > > since it's invalid and the error is produced as follows:
> > >   test.cl:7:21: error: reinterpret_cast from 'int' to '__global int &' is 
> > > not allowed
> > >   __global int& ref = reinterpret_cast<__global int&>(x);
> > > 
> > > Is this not what we are expecting here?
> > My last sentence could have been a bit clearer. Yes, for the 
> > `__private`->`__global` case, it should error. But I was thinking more of 
> > the case where the AS conversion is valid, like `__private`->`__generic`. 
> > Then we will do the AS conversion, but we should have done both an AS 
> > conversion and an `LValueBitCast`, because we need to both convert the 
> > 'pointer' and also dereference it.
> Hmm... it seems like here we can only have one cast kind... I guess 
> `CK_LValueBitCast` leads to the generation of `bitcast` in the IR? But 
> `addrspacecast` can perform both bit reinterpretation and address 
> translation, so perhaps it makes sense to only have an address space 
> conversion in this case? Unless some other logic is needed elsewhere before 
> CodeGen... I will try to construct a test case in plain C++. 
I am not sure I understood the problem you are describing, may be I need an 
example...

But the valid address space conversion example in OpenCL

```
__private T x = ...;
__generic T& ref = reinterpret_cast<__generic T&>(x);
```
produces correctly `addrspacecast`

```
  %0 = load i32*, i32** %x.addr, align 4
  %1 = addrspacecast i32* %0 to i32 addrspace(4)*
  store i32 addrspace(4)* %1, i32 addrspace(4)** %ref
```

However, if we keep checking `CK_LValueBitCast` first clang attempts to 
generate `bitcast` but fails because pointers are in different address spaces.


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

https://reviews.llvm.org/D58346



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


[PATCH] D58346: [Sema] Change addr space diagnostics in casts to follow C++ style

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



Comment at: lib/Sema/SemaCast.cpp:2224
+  } else if (IsLValueCast) {
 Kind = CK_LValueBitCast;
   } else if (DestType->isObjCObjectPointerType()) {

ebevhan wrote:
> Anastasia wrote:
> > Anastasia wrote:
> > > ebevhan wrote:
> > > > Anastasia wrote:
> > > > > ebevhan wrote:
> > > > > > This might not be applicable to this patch, but just something I 
> > > > > > noticed.
> > > > > > 
> > > > > > So `reinterpret_cast` only operates on pointers when dealing with 
> > > > > > address spaces. What about something like
> > > > > > ```
> > > > > > T a;
> > > > > > T& a_ref = reinterpret_cast(a);
> > > > > > ```
> > > > > > `reinterpret_cast` on an lvalue like this is equivalent to 
> > > > > > `*reinterpret_cast(&a)`. So for AS code:
> > > > > > ```
> > > > > > __private T x;
> > > > > > __generic T& ref = reinterpret_cast<__generic T&>(x);
> > > > > > ```
> > > > > > This should work, since `*reinterpret_cast<__generic T*>(&x)` is 
> > > > > > valid, correct?
> > > > > > 
> > > > > > What if we have the reference cast case with a different address 
> > > > > > space like this? Doesn't the `IsLValueCast` check need to be first?
> > > > > > 
> > > > > > What if we have the reference cast case with a different address 
> > > > > > space like this? Doesn't the IsLValueCast check need to be first?
> > > > > 
> > > > > Ok, let me see if I understand you. I changed `__generic` -> 
> > > > > `__global` since it's invalid and the error is produced as follows:
> > > > >   test.cl:7:21: error: reinterpret_cast from 'int' to '__global int 
> > > > > &' is not allowed
> > > > >   __global int& ref = reinterpret_cast<__global int&>(x);
> > > > > 
> > > > > Is this not what we are expecting here?
> > > > My last sentence could have been a bit clearer. Yes, for the 
> > > > `__private`->`__global` case, it should error. But I was thinking more 
> > > > of the case where the AS conversion is valid, like 
> > > > `__private`->`__generic`. Then we will do the AS conversion, but we 
> > > > should have done both an AS conversion and an `LValueBitCast`, because 
> > > > we need to both convert the 'pointer' and also dereference it.
> > > Hmm... it seems like here we can only have one cast kind... I guess 
> > > `CK_LValueBitCast` leads to the generation of `bitcast` in the IR? But 
> > > `addrspacecast` can perform both bit reinterpretation and address 
> > > translation, so perhaps it makes sense to only have an address space 
> > > conversion in this case? Unless some other logic is needed elsewhere 
> > > before CodeGen... I will try to construct a test case in plain C++. 
> > I am not sure I understood the problem you are describing, may be I need an 
> > example...
> > 
> > But the valid address space conversion example in OpenCL
> > 
> > ```
> > __private T x = ...;
> > __generic T& ref = reinterpret_cast<__generic T&>(x);
> > ```
> > produces correctly `addrspacecast`
> > 
> > ```
> >   %0 = load i32*, i32** %x.addr, align 4
> >   %1 = addrspacecast i32* %0 to i32 addrspace(4)*
> >   store i32 addrspace(4)* %1, i32 addrspace(4)** %ref
> > ```
> > 
> > However, if we keep checking `CK_LValueBitCast` first clang attempts to 
> > generate `bitcast` but fails because pointers are in different address 
> > spaces.
> > Hmm... it seems like here we can only have one cast kind... I guess 
> > CK_LValueBitCast leads to the generation of bitcast in the IR?
> 
> That's likely, yes. The dereference in the example disappears if we assign to 
> a `T&` and it becomes implied if we assign to a `T` through lvalue-to-rvalue 
> conversion, so in both cases we're taking the address of something and then 
> converting the address to a different type.
> 
> > But addrspacecast can perform both bit reinterpretation and address 
> > translation, so perhaps it makes sense to only have an address space 
> > conversion in this case? Unless some other logic is needed elsewhere before 
> > CodeGen... I will try to construct a test case in plain C++.
> 
> Oh, you're right! For some reason I was thinking that `addrspacecast` could 
> only change the addrspace of the argument, but apparently it could change the 
> pointee type too. At least according to the langref. So long as nothing in 
> Clang assumes that a CK_AddressSpaceConversion can't change the pointee type 
> as well as the address space I guess it should be safe.
> 
> When I try a 'simultaneous' conversion in C, I don't get a single 
> addrspacecast, though: https://godbolt.org/z/Q818yW So I wonder if existing 
> code handles this.
> 
> A test case would be good.
Sorry, I haven't seen your previous comment before sending mine. :)


> 
> When I try a 'simultaneous' conversion in C, I don't get a single 
> addrspacecast

I think 2 conversions in IR are not necessary, not sure how we ended up doing 
this though... but we had related discussion on that while implementing some 
OpenCL fe

[PATCH] D49754: Add -m(no-)spe, and e500 CPU definitions and support to clang

2019-02-20 Thread vit9696 via Phabricator via cfe-commits
vit9696 added a comment.

@nemanjai, sorry, under merging I meant committing into llvm upstream.




Comment at: lib/Basic/Targets/PPC.cpp:318
+  Features["spe"] = llvm::StringSwitch(CPU)
+.Case("e500", true)
+.Case("8548", true)

nemanjai wrote:
> The `e500v2` that you added doesn't support SPE?
I rechecked the docs, and there is no e500v2 option for -mcpu in GCC:
https://gcc.gnu.org/onlinedocs/gcc-8.1.0/gcc/RS_002f6000-and-PowerPC-Options.html#RS_002f6000-and-PowerPC-Options.

GCC defines 8540 (currently missing) and 8548, which I suppose we should 
support with default switches for SPE. As for other options, there also is 
-me500, which enables SPE, and -me500mc, which does not. I believe the need of 
these options is discussible.

The author of the patch may have his own thoughts behind, but I am not sure if 
e500, e500v1, or e500v2 should be used as mcpu switches at all. I am not 
against it if it makes things more convenient though.


Repository:
  rC Clang

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

https://reviews.llvm.org/D49754



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


[PATCH] D50256: [Analyzer] [WIP] Basic support for multiplication and division in the constraint manager (for == and != only)

2019-02-20 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 2 inline comments as done.
baloghadamsoftware added inline comments.
Herald added a subscriber: jdoerfert.



Comment at: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:576-597
+  RangeSet New = getRange(St, Sym);
+  for (llvm::APSInt I = AdjustmentType.getZeroValue();
+  I < (Scale.Reciprocal ? AdjustmentType.getValue(1) : Scale.Val); ++I) {
+
+llvm::APSInt ScInt = AdjInt;
+if (!rescale(ScInt, Scale, I))
+  continue;

baloghadamsoftware wrote:
> NoQ wrote:
> > I believe that this code should be moved directly into `getRange()`. If 
> > it's about looking at a single symbol and figuring out what range 
> > information about it do we already have, it should go into `getRange()`. 
> > This way we don't need to duplicate it in all the `assume...()` functions, 
> > and also it's exactly what `getRange()` is supposed to accomplish.
> `getRange()` retrieves the existing range for the symbol. However, similarly 
> to the `Adjustment` we use the `Scale` to change the right side of the 
> relation, not the left one.
> 
> I also dislike code multiplication. Maybe we should use the Strategy pattern 
> here and create a function that does the loop. However, if you take a look at 
> D49074 you will see that the body of the loop may look quite different.
I took a look again at all the loops including D49074, but only the loop 
conditions match. There are no other similarities between the loop bodies. I 
can move the loop into another function taking a lambda as the loop body but it 
does not simplify the code so I see no point in it.



Comment at: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:616-617
+  RangeSet New = F.getEmptySet();
+  for (llvm::APSInt I = AdjustmentType.getZeroValue();
+  I < (Scale.Reciprocal ? AdjustmentType.getValue(1) : Scale.Val); ++I) {
+  

baloghadamsoftware wrote:
> NoQ wrote:
> > Mmm, what if `Scale.Val` is vry large?
> That is a real problem. We either have to limit this functionality for small 
> numbers (for the short term, maybe) or find a better algorithm (for the long 
> term).
Any suggestion for the limit? Maybe `256`?


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

https://reviews.llvm.org/D50256



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


[PATCH] D58346: [Sema] Change addr space diagnostics in casts to follow C++ style

2019-02-20 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added inline comments.



Comment at: lib/Sema/SemaCast.cpp:2224
+  } else if (IsLValueCast) {
 Kind = CK_LValueBitCast;
   } else if (DestType->isObjCObjectPointerType()) {

Anastasia wrote:
> ebevhan wrote:
> > Anastasia wrote:
> > > Anastasia wrote:
> > > > ebevhan wrote:
> > > > > Anastasia wrote:
> > > > > > ebevhan wrote:
> > > > > > > This might not be applicable to this patch, but just something I 
> > > > > > > noticed.
> > > > > > > 
> > > > > > > So `reinterpret_cast` only operates on pointers when dealing with 
> > > > > > > address spaces. What about something like
> > > > > > > ```
> > > > > > > T a;
> > > > > > > T& a_ref = reinterpret_cast(a);
> > > > > > > ```
> > > > > > > `reinterpret_cast` on an lvalue like this is equivalent to 
> > > > > > > `*reinterpret_cast(&a)`. So for AS code:
> > > > > > > ```
> > > > > > > __private T x;
> > > > > > > __generic T& ref = reinterpret_cast<__generic T&>(x);
> > > > > > > ```
> > > > > > > This should work, since `*reinterpret_cast<__generic T*>(&x)` is 
> > > > > > > valid, correct?
> > > > > > > 
> > > > > > > What if we have the reference cast case with a different address 
> > > > > > > space like this? Doesn't the `IsLValueCast` check need to be 
> > > > > > > first?
> > > > > > > 
> > > > > > > What if we have the reference cast case with a different address 
> > > > > > > space like this? Doesn't the IsLValueCast check need to be first?
> > > > > > 
> > > > > > Ok, let me see if I understand you. I changed `__generic` -> 
> > > > > > `__global` since it's invalid and the error is produced as follows:
> > > > > >   test.cl:7:21: error: reinterpret_cast from 'int' to '__global int 
> > > > > > &' is not allowed
> > > > > >   __global int& ref = reinterpret_cast<__global int&>(x);
> > > > > > 
> > > > > > Is this not what we are expecting here?
> > > > > My last sentence could have been a bit clearer. Yes, for the 
> > > > > `__private`->`__global` case, it should error. But I was thinking 
> > > > > more of the case where the AS conversion is valid, like 
> > > > > `__private`->`__generic`. Then we will do the AS conversion, but we 
> > > > > should have done both an AS conversion and an `LValueBitCast`, 
> > > > > because we need to both convert the 'pointer' and also dereference it.
> > > > Hmm... it seems like here we can only have one cast kind... I guess 
> > > > `CK_LValueBitCast` leads to the generation of `bitcast` in the IR? But 
> > > > `addrspacecast` can perform both bit reinterpretation and address 
> > > > translation, so perhaps it makes sense to only have an address space 
> > > > conversion in this case? Unless some other logic is needed elsewhere 
> > > > before CodeGen... I will try to construct a test case in plain C++. 
> > > I am not sure I understood the problem you are describing, may be I need 
> > > an example...
> > > 
> > > But the valid address space conversion example in OpenCL
> > > 
> > > ```
> > > __private T x = ...;
> > > __generic T& ref = reinterpret_cast<__generic T&>(x);
> > > ```
> > > produces correctly `addrspacecast`
> > > 
> > > ```
> > >   %0 = load i32*, i32** %x.addr, align 4
> > >   %1 = addrspacecast i32* %0 to i32 addrspace(4)*
> > >   store i32 addrspace(4)* %1, i32 addrspace(4)** %ref
> > > ```
> > > 
> > > However, if we keep checking `CK_LValueBitCast` first clang attempts to 
> > > generate `bitcast` but fails because pointers are in different address 
> > > spaces.
> > > Hmm... it seems like here we can only have one cast kind... I guess 
> > > CK_LValueBitCast leads to the generation of bitcast in the IR?
> > 
> > That's likely, yes. The dereference in the example disappears if we assign 
> > to a `T&` and it becomes implied if we assign to a `T` through 
> > lvalue-to-rvalue conversion, so in both cases we're taking the address of 
> > something and then converting the address to a different type.
> > 
> > > But addrspacecast can perform both bit reinterpretation and address 
> > > translation, so perhaps it makes sense to only have an address space 
> > > conversion in this case? Unless some other logic is needed elsewhere 
> > > before CodeGen... I will try to construct a test case in plain C++.
> > 
> > Oh, you're right! For some reason I was thinking that `addrspacecast` could 
> > only change the addrspace of the argument, but apparently it could change 
> > the pointee type too. At least according to the langref. So long as nothing 
> > in Clang assumes that a CK_AddressSpaceConversion can't change the pointee 
> > type as well as the address space I guess it should be safe.
> > 
> > When I try a 'simultaneous' conversion in C, I don't get a single 
> > addrspacecast, though: https://godbolt.org/z/Q818yW So I wonder if existing 
> > code handles this.
> > 
> > A test case would be good.
> Sorry, I haven't seen your previous comment before sending mine. :)
> 
> 
> > 
> > When I try a 'simultaneous' conversion in C, I don't get a single 
>

[PATCH] D58446: [CodeComplete] Collect visited contexts when scope specifier is invalid.

2019-02-20 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, jdoerfert.
Herald added a project: clang.

This will allow completion consumers to guess the specified scope by
putting together scopes in the context with the specified scope (e.g. when the
specified namespace is not imported yet).


Repository:
  rC Clang

https://reviews.llvm.org/D58446

Files:
  lib/Sema/SemaCodeComplete.cpp
  unittests/Sema/CodeCompleteTest.cpp


Index: unittests/Sema/CodeCompleteTest.cpp
===
--- unittests/Sema/CodeCompleteTest.cpp
+++ unittests/Sema/CodeCompleteTest.cpp
@@ -181,6 +181,18 @@
   EXPECT_TRUE(VisitedNS.empty());
 }
 
+TEST(SemaCodeCompleteTest, VisitedNSForInvalidQualifiedId) {
+  auto VisitedNS = runCodeCompleteOnCode(R"cpp(
+ namespace na {}
+ namespace ns1 {
+ using namespace na;
+ foo::^
+ }
+  )cpp")
+   .VisitedNamespaces;
+  EXPECT_THAT(VisitedNS, UnorderedElementsAre("ns1::", "na::"));
+}
+
 TEST(SemaCodeCompleteTest, VisitedNSWithoutQualifier) {
   auto VisitedNS = runCodeCompleteOnCode(R"cpp(
 namespace n1 {
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -5061,7 +5061,20 @@
   if (SS.isInvalid()) {
 CodeCompletionContext CC(CodeCompletionContext::CCC_Symbol);
 CC.setCXXScopeSpecifier(SS);
-HandleCodeCompleteResults(this, CodeCompleter, CC, nullptr, 0);
+// As SS is invalid, we try to collect accessible contexts from the current
+// scope with a dummy lookup so that the completion consumer can try to
+// guess what the specified scope is.
+ResultBuilder DummyResults(*this, CodeCompleter->getAllocator(),
+   CodeCompleter->getCodeCompletionTUInfo(), CC);
+if (S->getEntity()) {
+  CodeCompletionDeclConsumer Consumer(DummyResults, S->getEntity(),
+  BaseType);
+  LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
+ /*IncludeGlobalScope=*/false,
+ /*LoadExternal=*/false);
+}
+HandleCodeCompleteResults(this, CodeCompleter,
+  DummyResults.getCompletionContext(), nullptr, 0);
 return;
   }
   // Always pretend to enter a context to ensure that a dependent type


Index: unittests/Sema/CodeCompleteTest.cpp
===
--- unittests/Sema/CodeCompleteTest.cpp
+++ unittests/Sema/CodeCompleteTest.cpp
@@ -181,6 +181,18 @@
   EXPECT_TRUE(VisitedNS.empty());
 }
 
+TEST(SemaCodeCompleteTest, VisitedNSForInvalidQualifiedId) {
+  auto VisitedNS = runCodeCompleteOnCode(R"cpp(
+ namespace na {}
+ namespace ns1 {
+ using namespace na;
+ foo::^
+ }
+  )cpp")
+   .VisitedNamespaces;
+  EXPECT_THAT(VisitedNS, UnorderedElementsAre("ns1::", "na::"));
+}
+
 TEST(SemaCodeCompleteTest, VisitedNSWithoutQualifier) {
   auto VisitedNS = runCodeCompleteOnCode(R"cpp(
 namespace n1 {
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -5061,7 +5061,20 @@
   if (SS.isInvalid()) {
 CodeCompletionContext CC(CodeCompletionContext::CCC_Symbol);
 CC.setCXXScopeSpecifier(SS);
-HandleCodeCompleteResults(this, CodeCompleter, CC, nullptr, 0);
+// As SS is invalid, we try to collect accessible contexts from the current
+// scope with a dummy lookup so that the completion consumer can try to
+// guess what the specified scope is.
+ResultBuilder DummyResults(*this, CodeCompleter->getAllocator(),
+   CodeCompleter->getCodeCompletionTUInfo(), CC);
+if (S->getEntity()) {
+  CodeCompletionDeclConsumer Consumer(DummyResults, S->getEntity(),
+  BaseType);
+  LookupVisibleDecls(S, LookupOrdinaryName, Consumer,
+ /*IncludeGlobalScope=*/false,
+ /*LoadExternal=*/false);
+}
+HandleCodeCompleteResults(this, CodeCompleter,
+  DummyResults.getCompletionContext(), nullptr, 0);
 return;
   }
   // Always pretend to enter a context to ensure that a dependent type
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57914: [Driver] Allow enum SanitizerOrdinal to represent more than 64 different sanitizer checks, NFC.

2019-02-20 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno accepted this revision.
riccibruno marked an inline comment as done.
riccibruno added a comment.
This revision is now accepted and ready to land.

LGTM with an additional comment.




Comment at: include/clang/Basic/Sanitizers.h:81
+
+  explicit operator bool() {
+for (const auto &Val : maskLoToHigh)

This operator should be const-qualified.



Comment at: include/clang/Basic/Sanitizers.h:96
+
+  SanitizerMask &operator&=(const SanitizerMask &RHS) {
+for (unsigned k = 0; k < kNumElem; k++)

Nice, a round of applause for clang 8 I guess then. Thanks for looking!


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

https://reviews.llvm.org/D57914



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


[PATCH] D58448: [clangd] Improve global code completion when scope specifier is unresolved.

2019-02-20 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added reviewers: ilya-biryukov, sammccall.
Herald added subscribers: cfe-commits, jdoerfert, kadircet, arphaman, jkorous, 
MaskRay.
Herald added a project: clang.

Suppose `clangd::` is unresolved in the following example. Currently,
we simply use "clangd::" as the query scope. We can do better by combining with
accessible scopes in the context. The query scopes can be `{clangd::, 
clang::clangd::}`.

  namespace clang { clangd::^ }


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D58448

Files:
  clangd/CodeComplete.cpp
  unittests/clangd/CodeCompleteTests.cpp


Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -1094,8 +1094,10 @@
   } // namespace ns
   )cpp");
 
-  EXPECT_THAT(Requests, ElementsAre(Field(&FuzzyFindRequest::Scopes,
-  UnorderedElementsAre("bar::";
+  EXPECT_THAT(Requests,
+  ElementsAre(Field(
+  &FuzzyFindRequest::Scopes,
+  UnorderedElementsAre("a::bar::", "ns::bar::", "bar::";
 }
 
 TEST(CompletionTest, UnresolvedNestedQualifierIdQuery) {
@@ -2314,6 +2316,35 @@
   EXPECT_THAT(R.Completions, ElementsAre(Named("loopVar")));
 }
 
+TEST(CompletionTest, ScopeIsUnresolved) {
+  clangd::CodeCompleteOptions Opts = {};
+  Opts.AllScopes = true;
+
+  auto Results = completions(R"cpp(
+namespace a {
+void f() { b::X^ }
+}
+  )cpp",
+ {cls("a::b::XYZ")}, Opts);
+  EXPECT_THAT(Results.Completions,
+  UnorderedElementsAre(AllOf(Qualifier(""), Named("XYZ";
+}
+
+TEST(CompletionTest, NestedScopeIsUnresolved) {
+  clangd::CodeCompleteOptions Opts = {};
+  Opts.AllScopes = true;
+
+  auto Results = completions(R"cpp(
+namespace a {
+namespace b {}
+void f() { b::c::X^ }
+}
+  )cpp",
+ {cls("a::b::c::XYZ")}, Opts);
+  EXPECT_THAT(Results.Completions,
+  UnorderedElementsAre(AllOf(Qualifier(""), Named("XYZ";
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -48,6 +48,7 @@
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/FormatVariadic.h"
@@ -526,7 +527,7 @@
 std::set Results;
 for (llvm::StringRef AS : AccessibleScopes)
   Results.insert(
-  ((UnresolvedQualifier ? *UnresolvedQualifier : "") + AS).str());
+  (AS + (UnresolvedQualifier ? *UnresolvedQualifier : "")).str());
 return {Results.begin(), Results.end()};
   }
 };
@@ -570,16 +571,16 @@
   }
 
   // Unresolved qualifier.
-  // FIXME: When Sema can resolve part of a scope chain (e.g.
-  // "known::unknown::id"), we should expand the known part ("known::") rather
-  // than treating the whole thing as unknown.
-  SpecifiedScope Info;
-  Info.AccessibleScopes.push_back(""); // global namespace
+  SpecifiedScope Info = GetAllAccessibleScopes(CCContext);
+  if (Info.AccessibleScopes.empty())
+Info.AccessibleScopes.push_back(""); // Fallback to global namespace.
 
-  Info.UnresolvedQualifier =
+  llvm::StringRef SpelledSpecifier =
   Lexer::getSourceText(CharSourceRange::getCharRange((*SS)->getRange()),
-   CCSema.SourceMgr, clang::LangOptions())
-  .ltrim("::");
+   CCSema.SourceMgr, clang::LangOptions());
+  if (SpelledSpecifier.consume_front("::"))
+Info.AccessibleScopes = {""};
+  Info.UnresolvedQualifier = SpelledSpecifier;
   // Sema excludes the trailing "::".
   if (!Info.UnresolvedQualifier->empty())
 *Info.UnresolvedQualifier += "::";


Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -1094,8 +1094,10 @@
   } // namespace ns
   )cpp");
 
-  EXPECT_THAT(Requests, ElementsAre(Field(&FuzzyFindRequest::Scopes,
-  UnorderedElementsAre("bar::";
+  EXPECT_THAT(Requests,
+  ElementsAre(Field(
+  &FuzzyFindRequest::Scopes,
+  UnorderedElementsAre("a::bar::", "ns::bar::", "bar::";
 }
 
 TEST(CompletionTest, UnresolvedNestedQualifierIdQuery) {
@@ -2314,6 +2316,35 @@
   EXPECT_THAT(R.Completions, ElementsAre(Named("loopVar")));
 }
 
+TEST(CompletionTest, ScopeIsUnresolved) {
+  clangd::CodeCompleteOptions Opts = {};
+  Opts.AllScopes = true;
+
+  auto Results = completions(R"cpp(
+namespace a {
+void f() { b::X^ }
+}
+  )cpp",
+ 

[PATCH] D58447: [clangd] Fix a crash in Selection

2019-02-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: kadircet, sammccall.
Herald added subscribers: arphaman, jkorous, MaskRay, ioeric.
Herald added a project: clang.

The assertion checking that the range of the node is a token range does
not hold in case of "split" tokens, e.g. between two closing template
argument lists (vector>).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58447

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/unittests/clangd/SelectionTests.cpp


Index: clang-tools-extra/unittests/clangd/SelectionTests.cpp
===
--- clang-tools-extra/unittests/clangd/SelectionTests.cpp
+++ clang-tools-extra/unittests/clangd/SelectionTests.cpp
@@ -232,6 +232,11 @@
   }
 }
   )cpp",
+  R"cpp(
+  template 
+  struct unique_ptr {}
+  void foo(^$C[[unique_ptr>]]^ a) {}
+  )cpp",
   };
   for (const char *C : Cases) {
 Annotations Test(C);
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -198,11 +198,10 @@
   auto E = SM.getDecomposedLoc(R.getEnd());
   if (B.first != SelFile || E.first != SelFile)
 continue;
-  assert(R.isTokenRange());
   // Try to cover up to the next token, spaces between children don't 
count.
   if (auto Tok = Lexer::findNextToken(R.getEnd(), SM, LangOpts))
 E.second = SM.getFileOffset(Tok->getLocation());
-  else
+  else if (R.isTokenRange())
 E.second += Lexer::MeasureTokenLength(R.getEnd(), SM, LangOpts);
   ChildRanges.push_back({B.second, E.second});
 }


Index: clang-tools-extra/unittests/clangd/SelectionTests.cpp
===
--- clang-tools-extra/unittests/clangd/SelectionTests.cpp
+++ clang-tools-extra/unittests/clangd/SelectionTests.cpp
@@ -232,6 +232,11 @@
   }
 }
   )cpp",
+  R"cpp(
+  template 
+  struct unique_ptr {}
+  void foo(^$C[[unique_ptr>]]^ a) {}
+  )cpp",
   };
   for (const char *C : Cases) {
 Annotations Test(C);
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -198,11 +198,10 @@
   auto E = SM.getDecomposedLoc(R.getEnd());
   if (B.first != SelFile || E.first != SelFile)
 continue;
-  assert(R.isTokenRange());
   // Try to cover up to the next token, spaces between children don't count.
   if (auto Tok = Lexer::findNextToken(R.getEnd(), SM, LangOpts))
 E.second = SM.getFileOffset(Tok->getLocation());
-  else
+  else if (R.isTokenRange())
 E.second += Lexer::MeasureTokenLength(R.getEnd(), SM, LangOpts);
   ChildRanges.push_back({B.second, E.second});
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58447: [clangd] Fix a crash in Selection

2019-02-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 187569.
ilya-biryukov added a comment.

- Fix a syntax error in the test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58447

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/unittests/clangd/SelectionTests.cpp


Index: clang-tools-extra/unittests/clangd/SelectionTests.cpp
===
--- clang-tools-extra/unittests/clangd/SelectionTests.cpp
+++ clang-tools-extra/unittests/clangd/SelectionTests.cpp
@@ -232,6 +232,11 @@
   }
 }
   )cpp",
+  R"cpp(
+  template 
+  struct unique_ptr {};
+  void foo(^$C[[unique_ptr>]]^ a) {}
+  )cpp",
   };
   for (const char *C : Cases) {
 Annotations Test(C);
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -198,11 +198,10 @@
   auto E = SM.getDecomposedLoc(R.getEnd());
   if (B.first != SelFile || E.first != SelFile)
 continue;
-  assert(R.isTokenRange());
   // Try to cover up to the next token, spaces between children don't 
count.
   if (auto Tok = Lexer::findNextToken(R.getEnd(), SM, LangOpts))
 E.second = SM.getFileOffset(Tok->getLocation());
-  else
+  else if (R.isTokenRange())
 E.second += Lexer::MeasureTokenLength(R.getEnd(), SM, LangOpts);
   ChildRanges.push_back({B.second, E.second});
 }


Index: clang-tools-extra/unittests/clangd/SelectionTests.cpp
===
--- clang-tools-extra/unittests/clangd/SelectionTests.cpp
+++ clang-tools-extra/unittests/clangd/SelectionTests.cpp
@@ -232,6 +232,11 @@
   }
 }
   )cpp",
+  R"cpp(
+  template 
+  struct unique_ptr {};
+  void foo(^$C[[unique_ptr>]]^ a) {}
+  )cpp",
   };
   for (const char *C : Cases) {
 Annotations Test(C);
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -198,11 +198,10 @@
   auto E = SM.getDecomposedLoc(R.getEnd());
   if (B.first != SelFile || E.first != SelFile)
 continue;
-  assert(R.isTokenRange());
   // Try to cover up to the next token, spaces between children don't count.
   if (auto Tok = Lexer::findNextToken(R.getEnd(), SM, LangOpts))
 E.second = SM.getFileOffset(Tok->getLocation());
-  else
+  else if (R.isTokenRange())
 E.second += Lexer::MeasureTokenLength(R.getEnd(), SM, LangOpts);
   ChildRanges.push_back({B.second, E.second});
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57914: [Driver] Allow enum SanitizerOrdinal to represent more than 64 different sanitizer checks, NFC.

2019-02-20 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno requested changes to this revision.
riccibruno added a comment.
This revision now requires changes to proceed.

Wait no, can you really define the `SanitizerMask`s in the header ? Isn't that 
an odr violation ?


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

https://reviews.llvm.org/D57914



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


[PATCH] D58447: [clangd] Fix a crash in Selection

2019-02-20 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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58447



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


[PATCH] D58346: [Sema] Change addr space diagnostics in casts to follow C++ style

2019-02-20 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 187573.
Anastasia added a comment.

Added a CodeGen test to cover address space of reference in `reinterpret_cast`.


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

https://reviews.llvm.org/D58346

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaCast.cpp
  test/CodeGenOpenCLCXX/address-space-castoperators.cpp
  test/SemaCXX/address-space-conversion.cpp
  test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  test/SemaOpenCL/address-spaces.cl

Index: test/SemaOpenCL/address-spaces.cl
===
--- test/SemaOpenCL/address-spaces.cl
+++ test/SemaOpenCL/address-spaces.cl
@@ -26,24 +26,96 @@
 }
 
 void explicit_cast(__global int *g, __local int *l, __constant int *c, __private int *p, const __constant int *cc) {
-  g = (__global int *)l;  // expected-error {{casting '__local int *' to type '__global int *' changes address space of pointer}}
-  g = (__global int *)c;  // expected-error {{casting '__constant int *' to type '__global int *' changes address space of pointer}}
-  g = (__global int *)cc; // expected-error {{casting 'const __constant int *' to type '__global int *' changes address space of pointer}}
-  g = (__global int *)p;  // expected-error {{casting 'int *' to type '__global int *' changes address space of pointer}}
-
-  l = (__local int *)g;  // expected-error {{casting '__global int *' to type '__local int *' changes address space of pointer}}
-  l = (__local int *)c;  // expected-error {{casting '__constant int *' to type '__local int *' changes address space of pointer}}
-  l = (__local int *)cc; // expected-error {{casting 'const __constant int *' to type '__local int *' changes address space of pointer}}
-  l = (__local int *)p;  // expected-error {{casting 'int *' to type '__local int *' changes address space of pointer}}
-
-  c = (__constant int *)g; // expected-error {{casting '__global int *' to type '__constant int *' changes address space of pointer}}
-  c = (__constant int *)l; // expected-error {{casting '__local int *' to type '__constant int *' changes address space of pointer}}
-  c = (__constant int *)p; // expected-error {{casting 'int *' to type '__constant int *' changes address space of pointer}}
-
-  p = (__private int *)g;  // expected-error {{casting '__global int *' to type 'int *' changes address space of pointer}}
-  p = (__private int *)l;  // expected-error {{casting '__local int *' to type 'int *' changes address space of pointer}}
-  p = (__private int *)c;  // expected-error {{casting '__constant int *' to type 'int *' changes address space of pointer}}
-  p = (__private int *)cc; // expected-error {{casting 'const __constant int *' to type 'int *' changes address space of pointer}}
+  g = (__global int *)l;
+#if !__OPENCL_CPP_VERSION__
+// expected-error@-2 {{casting '__local int *' to type '__global int *' changes address space of pointer}}
+#else
+// expected-error@-4 {{C-style cast from '__local int *' to '__global int *' converts between mismatching address spaces}}
+#endif
+  g = (__global int *)c;
+#if !__OPENCL_CPP_VERSION__
+// expected-error@-2 {{casting '__constant int *' to type '__global int *' changes address space of pointer}}
+#else
+// expected-error@-4 {{C-style cast from '__constant int *' to '__global int *' converts between mismatching address spaces}}
+#endif
+  g = (__global int *)cc;
+#if !__OPENCL_CPP_VERSION__
+// expected-error@-2 {{casting 'const __constant int *' to type '__global int *' changes address space of pointer}}
+#else
+// expected-error@-4 {{C-style cast from 'const __constant int *' to '__global int *' converts between mismatching address spaces}}
+#endif
+  g = (__global int *)p;
+#if !__OPENCL_CPP_VERSION__
+// expected-error@-2 {{casting 'int *' to type '__global int *' changes address space of pointer}}
+#else
+// expected-error@-4 {{C-style cast from 'int *' to '__global int *' converts between mismatching address spaces}}
+#endif
+  l = (__local int *)g;
+#if !__OPENCL_CPP_VERSION__
+// expected-error@-2 {{casting '__global int *' to type '__local int *' changes address space of pointer}}
+#else
+// expected-error@-4 {{C-style cast from '__global int *' to '__local int *' converts between mismatching address spaces}}
+#endif
+  l = (__local int *)c;
+#if !__OPENCL_CPP_VERSION__
+// expected-error@-2 {{casting '__constant int *' to type '__local int *' changes address space of pointer}}
+#else
+// expected-error@-4 {{C-style cast from '__constant int *' to '__local int *' converts between mismatching address spaces}}
+#endif
+  l = (__local int *)cc;
+#if !__OPENCL_CPP_VERSION__
+// expected-error@-2 {{casting 'const __constant int *' to type '__local int *' changes address space of pointer}}
+#else
+// expected-error@-4 {{C-style cast from 'const __constant int *' to '__local int *' converts between mismatching address spaces}}
+#endif
+  l = (__local int *)p;
+#if !__OPENCL_CPP_VERSION

[PATCH] D58388: [OpenCL] Simplify LLVM IR generated for OpenCL blocks

2019-02-20 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin updated this revision to Diff 187575.
AlexeySotkin added a comment.

Fix resolving of block invoke function in case of sequence of assignments.


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

https://reviews.llvm.org/D58388

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  test/CodeGenOpenCL/blocks.cl
  test/CodeGenOpenCL/cl20-device-side-enqueue.cl

Index: test/CodeGenOpenCL/cl20-device-side-enqueue.cl
===
--- test/CodeGenOpenCL/cl20-device-side-enqueue.cl
+++ test/CodeGenOpenCL/cl20-device-side-enqueue.cl
@@ -312,9 +312,7 @@
   };
 
   // Uses global block literal [[BLG8]] and invoke function [[INVG8]].
-  // COMMON: [[r1:%.*]] = load i8 addrspace(4)*, i8 addrspace(4)* addrspace(4)* getelementptr inbounds (%struct.__opencl_block_literal_generic, %struct.__opencl_block_literal_generic addrspace(4)* addrspacecast (%struct.__opencl_block_literal_generic addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BLG8]] to %struct.__opencl_block_literal_generic addrspace(1)*) to %struct.__opencl_block_literal_generic addrspace(4)*), i32 0, i32 2)
-  // COMMON: [[r2:%.*]] = addrspacecast i8 addrspace(4)* [[r1]] to void (i8 addrspace(4)*)*
-  // COMMON: call spir_func void [[r2]](i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BLG8]] to i8 addrspace(1)*) to i8 addrspace(4)*))
+  // COMMON: call spir_func void @__device_side_enqueue_block_invoke_11(i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BLG8]] to i8 addrspace(1)*) to i8 addrspace(4)*))
   block_A();
 
   // Emits global block literal [[BLG8]] and block kernel [[INVGK8]]. [[INVGK8]] calls [[INVG8]].
@@ -333,15 +331,35 @@
   unsigned size = get_kernel_work_group_size(block_A);
 
   // Uses global block literal [[BLG8]] and invoke function [[INVG8]]. Make sure no redundant block literal and invoke functions are emitted.
-  // COMMON: [[r1:%.*]] = load i8 addrspace(4)*, i8 addrspace(4)* addrspace(4)* getelementptr inbounds (%struct.__opencl_block_literal_generic, %struct.__opencl_block_literal_generic addrspace(4)* addrspacecast (%struct.__opencl_block_literal_generic addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BLG8]] to %struct.__opencl_block_literal_generic addrspace(1)*) to %struct.__opencl_block_literal_generic addrspace(4)*), i32 0, i32 2)
-  // COMMON: [[r2:%.*]] = addrspacecast i8 addrspace(4)* [[r1]] to void (i8 addrspace(4)*)*
-  // COMMON: call spir_func void [[r2]](i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BLG8]] to i8 addrspace(1)*) to i8 addrspace(4)*))
+  // COMMON: call spir_func void @__device_side_enqueue_block_invoke_11(i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BLG8]] to i8 addrspace(1)*) to i8 addrspace(4)*))
   block_A();
 
+  // Make sure that block invoke function is resolved correctly after sequence of assignements.
+  // COMMON: store %struct.__opencl_block_literal_generic addrspace(4)*
+  // COMMON-SAME: addrspacecast (%struct.__opencl_block_literal_generic addrspace(1)*
+  // COMMON-SAME: bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL]] to %struct.__opencl_block_literal_generic addrspace(1)*)
+  // COMMON-SAME: to %struct.__opencl_block_literal_generic addrspace(4)*),
+  // COMMON-SAME: %struct.__opencl_block_literal_generic addrspace(4)** %b1,
+  bl_t b1 = block_G;
+  // COMMON: store %struct.__opencl_block_literal_generic addrspace(4)*
+  // COMMON-SAME: addrspacecast (%struct.__opencl_block_literal_generic addrspace(1)*
+  // COMMON-SAME: bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL]] to %struct.__opencl_block_literal_generic addrspace(1)*)
+  // COMMON-SAME: to %struct.__opencl_block_literal_generic addrspace(4)*),
+  // COMMON-SAME: %struct.__opencl_block_literal_generic addrspace(4)** %b2,
+  bl_t b2 = b1;
+  // COMMON: call spir_func void @block_G_block_invoke(i8 addrspace(4)* addrspacecast (i8 addrspace(1)*
+  // COMMON-SAME: bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL]] to i8 addrspace(1)*)
+  // COOMON-SAME: to i8 addrspace(4)*), i8 addrspace(3)* null)
+  b2(0);
+  // Uses global block literal [[BL_GLOBAL]] and block kernel [[INV_G_K]]. [[INV_G_K]] calls [[INV_G]].
+  // COMMON: call i32 @__get_kernel_preferred_work_group_size_multiple_impl(
+  // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8* bitcast ({{.*}} [[INV_G_K:[^ ]+_kernel]] to i8*) to i8 addrspace(4)*),
+  // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL]] to i8 addrspace(1)*) to i8 addrspace(4)*))
+  size = get_kernel_preferred_work_group_size_multiple(b2);
+
   void (^block_C)(void) = ^{
 calle

[PATCH] D58388: [OpenCL] Simplify LLVM IR generated for OpenCL blocks

2019-02-20 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin marked an inline comment as done.
AlexeySotkin added inline comments.



Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:131
+static const BlockExpr *getBlockExpr(const Expr *E) {
+  if (auto Cast = dyn_cast(E)) {
+E = Cast->getSubExpr();

Anastasia wrote:
> Btw, does this handle the case when we assign a variable multiple time? I was 
> just wondering if we need a loop somewhere?
> 
> I.e. does something like this work now:
> 
> ```
> typedef void (^bl_t)(local void *);
> 
> bl_t a = ...;
> bl_t b = a;
> bl_t c = b;
> 
> c();
> enqueue_kernel(... c, ...);
> ```
> 
> 
You are right, we need a loop. Now it works.


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

https://reviews.llvm.org/D58388



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


[PATCH] D58091: Customize warnings for missing built-in type

2019-02-20 Thread Brian Cain via Phabricator via cfe-commits
bcain accepted this revision.
bcain added a comment.
This revision is now accepted and ready to land.

I can confirm that this fix is effective at addressing the problem we 
experienced.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58091



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


[PATCH] D58186: Sync some doc changes ClangFormatStyleOptions.rst with doc comments in `Format.h`

2019-02-20 Thread Ronald Wampler via Phabricator via cfe-commits
rdwampler added a comment.

Ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58186



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


[PATCH] D57914: [Driver] Allow enum SanitizerOrdinal to represent more than 64 different sanitizer checks, NFC.

2019-02-20 Thread pierre gousseau via Phabricator via cfe-commits
pgousseau added a comment.

In D57914#1404053 , @riccibruno wrote:

> Wait no, can you really define the `SanitizerMask`s in the header ? Isn't 
> that an odr violation ?


A yes I better move the definitions, thanks!


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

https://reviews.llvm.org/D57914



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


[PATCH] D58449: Junk: Add assert to find GCCBuiltins with constant arguments missing

2019-02-20 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added a reviewer: atanasyan.
Herald added subscribers: jdoerfert, fedor.sergeev, aheejin, wdng, dschuff.

Don't bother reviewing this, I have no intention of committing this hack to 
find builtins missing immarg


https://reviews.llvm.org/D58449

Files:
  lib/Sema/SemaChecking.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -85,6 +85,10 @@
 #include "llvm/Support/Locale.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
+
+#include "llvm/IR/Intrinsics.h"
+#include "llvm/IR/Module.h"
+
 #include 
 #include 
 #include 
@@ -965,15 +969,178 @@
   if (Error != ASTContext::GE_None)
 ICEArguments = 0;  // Don't diagnose previously diagnosed errors.
 
-  // If any arguments are required to be ICE's, check and diagnose.
-  for (unsigned ArgNo = 0; ICEArguments != 0; ++ArgNo) {
-// Skip arguments not required to be ICE's.
-if ((ICEArguments & (1 << ArgNo)) == 0) continue;
+  static bool Once = false;
 
-llvm::APSInt Result;
-if (SemaBuiltinConstantArg(TheCall, ArgNo, Result))
-  return true;
-ICEArguments &= ~(1 << ArgNo);
+  if (!Once) {
+Once = true;
+unsigned Start = -1;
+unsigned End = -1;
+switch (Context.getTargetInfo().getTriple().getArch()) {
+case llvm::Triple::x86: {
+  Start = X86::LastTIBuiltin + 1;
+  End = X86::LastX86CommonBuiltin;
+  break;
+}
+case llvm::Triple::x86_64: {
+  Start = X86::LastTIBuiltin + 1;
+  //Start = X86::FirstX86_64Builtin;
+  End = X86::LastTSBuiltin;
+  break;
+}
+case llvm::Triple::mips:
+case llvm::Triple::mipsel:
+case llvm::Triple::mips64:
+case llvm::Triple::mips64el: {
+  Start = Mips::LastTIBuiltin + 1;
+  End = Mips::LastTSBuiltin;
+  break;
+}
+case llvm::Triple::hexagon: {
+  Start = Hexagon::LastTIBuiltin + 1;
+  End = Hexagon::LastTSBuiltin;
+  break;
+}
+case llvm::Triple::systemz: {
+  Start = SystemZ::LastTIBuiltin + 1;
+  End = SystemZ::LastTSBuiltin;
+  break;
+}
+case llvm::Triple::ppc:
+case llvm::Triple::ppc64:
+case llvm::Triple::ppc64le: {
+  Start = PPC::LastTIBuiltin + 1;
+  End = PPC::LastTSBuiltin;
+  break;
+}
+case llvm::Triple::aarch64:
+case llvm::Triple::aarch64_be: {
+  Start = AArch64::LastTIBuiltin + 1;
+  End = AArch64::LastTSBuiltin;
+  break;
+}
+case llvm::Triple::arm:
+case llvm::Triple::armeb:
+case llvm::Triple::thumb:
+case llvm::Triple::thumbeb: {
+  Start = ARM::LastTIBuiltin + 1;
+  End = ARM::LastTSBuiltin;
+  break;
+}
+case llvm::Triple::amdgcn:
+case llvm::Triple::r600: {
+  Start = AMDGPU::LastTIBuiltin + 1;
+  End = AMDGPU::LastTSBuiltin;
+  break;
+}
+case llvm::Triple::nvptx:
+case llvm::Triple::nvptx64: {
+  Start = NVPTX::LastTIBuiltin + 1;
+  End = NVPTX::LastTSBuiltin;
+  break;
+}
+case llvm::Triple::wasm32:
+case llvm::Triple::wasm64: {
+  Start = WebAssembly::LastTIBuiltin + 1;
+  End = WebAssembly::LastTSBuiltin;
+  break;
+}
+case llvm::Triple::riscv32:
+case llvm::Triple::riscv64: {
+#if 0
+  Start = RISCV::LastTIBuiltin + 1;
+  End = RISCV::LastTSBuiltin;
+#endif
+  Start = 0;
+  End = 0;
+  break;
+}
+case llvm::Triple::xcore: {
+  Start = XCore::LastTIBuiltin + 1;
+  End = XCore::LastTSBuiltin;
+  break;
+}
+case llvm::Triple::msp430:
+case llvm::Triple::sparc:
+case llvm::Triple::sparcv9:
+case llvm::Triple::sparcel:
+case llvm::Triple::spir:
+case llvm::Triple::spir64:
+  Start = 0;
+  End = 0;
+  break;
+default:
+  llvm_unreachable("todo");
+}
+
+unsigned MissingCount = 0;
+unsigned ExtraImmArg = 0;
+
+for (unsigned BuiltinID = Start; BuiltinID != End; ++BuiltinID) {
+  unsigned ICEArguments = 0;
+  ASTContext::GetBuiltinTypeError Error;
+  Context.GetBuiltinType(BuiltinID, Error, &ICEArguments);
+
+
+  const char *Name = getASTContext().BuiltinInfo.getName(BuiltinID);
+  llvm::Intrinsic::ID IntrinsicID = llvm::Intrinsic::not_intrinsic;
+  StringRef Prefix =
+llvm::Triple::getArchTypePrefix(Context.getTargetInfo().getTriple().getArch());
+  if (!Prefix.empty()) {
+IntrinsicID = llvm::Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(), Name);
+// NOTE we don't need to perform a compatibility flag check here since the
+// intrinsics are declared in Builtins*.def via LANGBUILTIN which filter the
+// MS builtins via ALL_MS_LANGUAGES and are filtered earlier.
+if (IntrinsicID == llvm::Intrinsic::not_intrinsic)
+  IntrinsicID = llvm::Intrinsic::getIntrinsicForMSBuiltin(Prefix.data(), Name);
+  }
+
+
+  llvm::LLVMContext C

[PATCH] D58388: [OpenCL] Simplify LLVM IR generated for OpenCL blocks

2019-02-20 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! Great! Thanks!


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

https://reviews.llvm.org/D58388



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


[PATCH] D58440: [clangd] Store index in '.clangd/index' instead of '.clangd-index'

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

Thanks!




Comment at: clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp:75
 llvm::SmallString<128> CDBDirectory(Directory);
-llvm::sys::path::append(CDBDirectory, ".clangd-index/");
+llvm::sys::path::append(CDBDirectory, ".clangd", "index/");
 DiskShardRoot = CDBDirectory.str();

NIT: it looks like we don't need the "/" at the end of "index/"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58440



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


r354481 - [CodeGen] Enable the complex-math test for arm

2019-02-20 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed Feb 20 08:53:08 2019
New Revision: 354481

URL: http://llvm.org/viewvc/llvm-project?rev=354481&view=rev
Log:
[CodeGen] Enable the complex-math test for arm

This test wasn't running due to a missing : after the RUN statement.
Enabling this test revealed that it's actually broken.

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

Modified:
cfe/trunk/test/CodeGen/complex-math.c

Modified: cfe/trunk/test/CodeGen/complex-math.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/complex-math.c?rev=354481&r1=354480&r2=354481&view=diff
==
--- cfe/trunk/test/CodeGen/complex-math.c (original)
+++ cfe/trunk/test/CodeGen/complex-math.c Wed Feb 20 08:53:08 2019
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple x86_64-pc-win64 -o - | FileCheck 
%s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple i686-unknown-unknown -o - | 
FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple powerpc-unknown-unknown -o - | 
FileCheck %s --check-prefix=PPC
-// RUN %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | 
FileCheck %s --check-prefix=ARM
+// RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | 
FileCheck %s --check-prefix=ARM
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabihf -o - | 
FileCheck %s --check-prefix=ARMHF
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple thumbv7k-apple-watchos2.0 -o - 
-target-abi aapcs16 | FileCheck %s --check-prefix=ARM7K
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple aarch64-unknown-unknown 
-ffast-math -o - | FileCheck %s --check-prefix=AARCH64-FASTMATH
@@ -621,7 +621,7 @@ _Complex double foo(_Complex double a, _
   // use the base AAPCS.
 
   // ARM-LABEL: @foo(
-  // ARM: call void { double, double } @__muldc3
+  // ARM: call void @__muldc3
 
   // ARMHF-LABEL: @foo(
   // ARMHF: call { double, double } @__muldc3


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


[PATCH] D58429: [CodeGen] Enable the complex-math test for arm

2019-02-20 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354481: [CodeGen] Enable the complex-math test for arm 
(authored by phosek, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58429?vs=187524&id=187593#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58429

Files:
  cfe/trunk/test/CodeGen/complex-math.c


Index: cfe/trunk/test/CodeGen/complex-math.c
===
--- cfe/trunk/test/CodeGen/complex-math.c
+++ cfe/trunk/test/CodeGen/complex-math.c
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple x86_64-pc-win64 -o - | FileCheck 
%s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple i686-unknown-unknown -o - | 
FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple powerpc-unknown-unknown -o - | 
FileCheck %s --check-prefix=PPC
-// RUN %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | 
FileCheck %s --check-prefix=ARM
+// RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | 
FileCheck %s --check-prefix=ARM
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabihf -o - | 
FileCheck %s --check-prefix=ARMHF
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple thumbv7k-apple-watchos2.0 -o - 
-target-abi aapcs16 | FileCheck %s --check-prefix=ARM7K
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple aarch64-unknown-unknown 
-ffast-math -o - | FileCheck %s --check-prefix=AARCH64-FASTMATH
@@ -621,7 +621,7 @@
   // use the base AAPCS.
 
   // ARM-LABEL: @foo(
-  // ARM: call void { double, double } @__muldc3
+  // ARM: call void @__muldc3
 
   // ARMHF-LABEL: @foo(
   // ARMHF: call { double, double } @__muldc3


Index: cfe/trunk/test/CodeGen/complex-math.c
===
--- cfe/trunk/test/CodeGen/complex-math.c
+++ cfe/trunk/test/CodeGen/complex-math.c
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple x86_64-pc-win64 -o - | FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple i686-unknown-unknown -o - | FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple powerpc-unknown-unknown -o - | FileCheck %s --check-prefix=PPC
-// RUN %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | FileCheck %s --check-prefix=ARM
+// RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | FileCheck %s --check-prefix=ARM
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabihf -o - | FileCheck %s --check-prefix=ARMHF
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple thumbv7k-apple-watchos2.0 -o - -target-abi aapcs16 | FileCheck %s --check-prefix=ARM7K
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple aarch64-unknown-unknown -ffast-math -o - | FileCheck %s --check-prefix=AARCH64-FASTMATH
@@ -621,7 +621,7 @@
   // use the base AAPCS.
 
   // ARM-LABEL: @foo(
-  // ARM: call void { double, double } @__muldc3
+  // ARM: call void @__muldc3
 
   // ARMHF-LABEL: @foo(
   // ARMHF: call { double, double } @__muldc3
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r354482 - Fix compile error with Intel's compiler (-Werror=pedantic)

2019-02-20 Thread Gabor Marton via cfe-commits
Author: martong
Date: Wed Feb 20 08:57:41 2019
New Revision: 354482

URL: http://llvm.org/viewvc/llvm-project?rev=354482&view=rev
Log:
Fix compile error with Intel's compiler (-Werror=pedantic)

An extra semicolon at the end of macro invocations caused a build bot
failure for Intel's compiler when pedantic is turned on.

Modified:
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=354482&r1=354481&r2=354482&view=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Wed Feb 20 08:57:41 2019
@@ -4156,175 +4156,175 @@ struct RedeclChain : ASTImporterOptionSp
 
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, Function, ,
-PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition);
+PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, Class, ,
-PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition);
+PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, Variable, ,
-PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition);
+PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
 // FIXME Enable this test, once we import function templates chains correctly.
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, FunctionTemplate, DISABLED_,
-PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition);
+PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, ClassTemplate, ,
-PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition);
+PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, FunctionTemplateSpec, ,
-PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition);
+PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
 
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
-RedeclChain, Function, , DefinitionShouldBeImportedAsADefinition);
+RedeclChain, Function, , DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
-RedeclChain, Class, , DefinitionShouldBeImportedAsADefinition);
+RedeclChain, Class, , DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
-RedeclChain, Variable, , DefinitionShouldBeImportedAsADefinition);
+RedeclChain, Variable, , DefinitionShouldBeImportedAsADefinition)
 // FIXME Enable this test, once we import function templates chains correctly.
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, FunctionTemplate, DISABLED_,
-DefinitionShouldBeImportedAsADefinition);
+DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
-RedeclChain, ClassTemplate, , DefinitionShouldBeImportedAsADefinition);
+RedeclChain, ClassTemplate, , DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, FunctionTemplateSpec, ,
-DefinitionShouldBeImportedAsADefinition);
+DefinitionShouldBeImportedAsADefinition)
 
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Function, ,
-ImportPrototypeAfterImportedPrototype);
+ImportPrototypeAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Class, ,
-ImportPrototypeAfterImportedPrototype);
+ImportPrototypeAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Variable, ,
-ImportPrototypeAfterImportedPrototype);
+ImportPrototypeAfterImportedPrototype)
 // FIXME Enable this test, once we import function templates chains correctly.
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate,
 DISABLED_,
-ImportPrototypeAfterImportedPrototype);
+ImportPrototypeAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, ,
-ImportPrototypeAfterImportedPrototype);
+ImportPrototypeAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplateSpec, ,
-ImportPrototypeAfterImportedPrototype);
+ImportPrototypeAfterImportedPrototype)
 
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Function, ,
- 

[clang-tools-extra] r354485 - Update property prefix regex to allow numbers.

2019-02-20 Thread Yan Zhang via cfe-commits
Author: wizard
Date: Wed Feb 20 09:32:41 2019
New Revision: 354485

URL: http://llvm.org/viewvc/llvm-project?rev=354485&view=rev
Log:
Update property prefix regex to allow numbers.

Subscribers: jfb, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m

Modified: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp?rev=354485&r1=354484&r2=354485&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp Wed 
Feb 20 09:32:41 2019
@@ -80,7 +80,8 @@ std::string validPropertyNameRegex(bool
 }
 
 bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) {
-  auto RegexExp = llvm::Regex("^[a-zA-Z]+_[a-zA-Z0-9][a-zA-Z0-9_]+$");
+  auto RegexExp =
+  llvm::Regex("^[a-zA-Z][a-zA-Z0-9]*_[a-zA-Z0-9][a-zA-Z0-9_]+$");
   return RegexExp.match(PropertyName);
 }
 
@@ -91,8 +92,7 @@ bool prefixedPropertyNameValid(llvm::Str
   if (Prefix.lower() != Prefix) {
 return false;
   }
-  auto RegexExp =
-  llvm::Regex(llvm::StringRef(validPropertyNameRegex(false)));
+  auto RegexExp = llvm::Regex(llvm::StringRef(validPropertyNameRegex(false)));
   return RegexExp.match(PropertyName.substr(Start + 1));
 }
 }  // namespace
@@ -101,13 +101,12 @@ void PropertyDeclarationCheck::registerM
   // this check should only be applied to ObjC sources.
   if (!getLangOpts().ObjC) return;
 
-  Finder->addMatcher(
-  objcPropertyDecl(
-  // the property name should be in Lower Camel Case like
-  // 'lowerCamelCase'
-  unless(matchesName(validPropertyNameRegex(true
-  .bind("property"),
-  this);
+  Finder->addMatcher(objcPropertyDecl(
+ // the property name should be in Lower Camel Case 
like
+ // 'lowerCamelCase'
+ unless(matchesName(validPropertyNameRegex(true
+ .bind("property"),
+ this);
 }
 
 void PropertyDeclarationCheck::check(const MatchFinder::MatchResult &Result) {

Modified: clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m?rev=354485&r1=354484&r2=354485&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m Wed Feb 
20 09:32:41 2019
@@ -46,6 +46,7 @@ typedef void *CGColorRef;
 @property(strong, nonatomic) NSString *URLStr;
 @property(assign, nonatomic) int abc_camelCase;
 @property(strong, nonatomic) NSString *abc_URL;
+@property(strong, nonatomic) NSString *opac2_sourceComponent;
 @end
 
 @interface Foo ()


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


[PATCH] D56896: Update property prefix regex to allow numbers.

2019-02-20 Thread Yan Zhang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE354485: Update property prefix regex to allow numbers. 
(authored by Wizard, committed by ).
Herald added a subscriber: jdoerfert.
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D56896?vs=182439&id=187599#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56896

Files:
  clang-tidy/objc/PropertyDeclarationCheck.cpp
  test/clang-tidy/objc-property-declaration.m


Index: clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -80,7 +80,8 @@
 }
 
 bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) {
-  auto RegexExp = llvm::Regex("^[a-zA-Z]+_[a-zA-Z0-9][a-zA-Z0-9_]+$");
+  auto RegexExp =
+  llvm::Regex("^[a-zA-Z][a-zA-Z0-9]*_[a-zA-Z0-9][a-zA-Z0-9_]+$");
   return RegexExp.match(PropertyName);
 }
 
@@ -91,8 +92,7 @@
   if (Prefix.lower() != Prefix) {
 return false;
   }
-  auto RegexExp =
-  llvm::Regex(llvm::StringRef(validPropertyNameRegex(false)));
+  auto RegexExp = llvm::Regex(llvm::StringRef(validPropertyNameRegex(false)));
   return RegexExp.match(PropertyName.substr(Start + 1));
 }
 }  // namespace
@@ -101,13 +101,12 @@
   // this check should only be applied to ObjC sources.
   if (!getLangOpts().ObjC) return;
 
-  Finder->addMatcher(
-  objcPropertyDecl(
-  // the property name should be in Lower Camel Case like
-  // 'lowerCamelCase'
-  unless(matchesName(validPropertyNameRegex(true
-  .bind("property"),
-  this);
+  Finder->addMatcher(objcPropertyDecl(
+ // the property name should be in Lower Camel Case 
like
+ // 'lowerCamelCase'
+ unless(matchesName(validPropertyNameRegex(true
+ .bind("property"),
+ this);
 }
 
 void PropertyDeclarationCheck::check(const MatchFinder::MatchResult &Result) {
Index: test/clang-tidy/objc-property-declaration.m
===
--- test/clang-tidy/objc-property-declaration.m
+++ test/clang-tidy/objc-property-declaration.m
@@ -46,9 +46,10 @@
 @property(strong, nonatomic) NSString *URLStr;
 @property(assign, nonatomic) int abc_camelCase;
 @property(strong, nonatomic) NSString *abc_URL;
+@property(strong, nonatomic) NSString *opac2_sourceComponent;
 @end
 
 @interface Foo ()
 @property(assign, nonatomic) int abc_inClassExtension;
 // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 
'abc_inClassExtension' not using lowerCamelCase style or not prefixed in a 
category, according to the Apple Coding Guidelines [objc-property-declaration]
 @end
\ No newline at end of file


Index: clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -80,7 +80,8 @@
 }
 
 bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) {
-  auto RegexExp = llvm::Regex("^[a-zA-Z]+_[a-zA-Z0-9][a-zA-Z0-9_]+$");
+  auto RegexExp =
+  llvm::Regex("^[a-zA-Z][a-zA-Z0-9]*_[a-zA-Z0-9][a-zA-Z0-9_]+$");
   return RegexExp.match(PropertyName);
 }
 
@@ -91,8 +92,7 @@
   if (Prefix.lower() != Prefix) {
 return false;
   }
-  auto RegexExp =
-  llvm::Regex(llvm::StringRef(validPropertyNameRegex(false)));
+  auto RegexExp = llvm::Regex(llvm::StringRef(validPropertyNameRegex(false)));
   return RegexExp.match(PropertyName.substr(Start + 1));
 }
 }  // namespace
@@ -101,13 +101,12 @@
   // this check should only be applied to ObjC sources.
   if (!getLangOpts().ObjC) return;
 
-  Finder->addMatcher(
-  objcPropertyDecl(
-  // the property name should be in Lower Camel Case like
-  // 'lowerCamelCase'
-  unless(matchesName(validPropertyNameRegex(true
-  .bind("property"),
-  this);
+  Finder->addMatcher(objcPropertyDecl(
+ // the property name should be in Lower Camel Case like
+ // 'lowerCamelCase'
+ unless(matchesName(validPropertyNameRegex(true
+ .bind("property"),
+ this);
 }
 
 void PropertyDeclarationCheck::check(const MatchFinder::MatchResult &Result) {
Index: test/clang-tidy/objc-property-declaration.m
===
--- test/clang-tidy/objc-property-declaration.m
+++ test/clang-tidy/objc-property-declaration.m
@@ -46,9 +46,10 @@
 @property(strong, nonatomic) NSString *URLStr;
 @property(assign, nonatomic) int abc_camelCase;
 @property(strong, nonatomic) NSString *abc_URL;
+@property(strong, nonatomic) NSString *opac2

r354486 - [OPENMP] Delay emission of the asm target-specific error messages.

2019-02-20 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Feb 20 09:42:57 2019
New Revision: 354486

URL: http://llvm.org/viewvc/llvm-project?rev=354486&view=rev
Log:
[OPENMP] Delay emission of the asm target-specific error messages.

Summary:
Added the ability to emit target-specific builtin assembler error
messages only in case if the function is really is going to be emitted
for the device.

Reviewers: rjmccall

Subscribers: guansong, jdoerfert, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaStmtAsm.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=354486&r1=354485&r2=354486&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Feb 20 09:42:57 2019
@@ -10275,6 +10275,8 @@ public:
   ///  // Otherwise, continue parsing as normal.
   DeviceDiagBuilder diagIfOpenMPDeviceCode(SourceLocation Loc, unsigned 
DiagID);
 
+  DeviceDiagBuilder targetDiag(SourceLocation Loc, unsigned DiagID);
+
   enum CUDAFunctionTarget {
 CFT_Device,
 CFT_Global,

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=354486&r1=354485&r2=354486&view=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Wed Feb 20 09:42:57 2019
@@ -1487,6 +1487,14 @@ void Sema::markKnownEmitted(
   }
 }
 
+Sema::DeviceDiagBuilder Sema::targetDiag(SourceLocation Loc,
+ unsigned DiagID) {
+  if (LangOpts.OpenMP && LangOpts.OpenMPIsDevice)
+return diagIfOpenMPDeviceCode(Loc, DiagID);
+  return DeviceDiagBuilder(DeviceDiagBuilder::K_Immediate, Loc, DiagID,
+   getCurFunctionDecl(), *this);
+}
+
 /// Looks through the macro-expansion chain for the given
 /// location, looking for a macro expansion with the given name.
 /// If one is found, returns true and sets the location to that

Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=354486&r1=354485&r2=354486&view=diff
==
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Wed Feb 20 09:42:57 2019
@@ -272,9 +272,9 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceL
 
 TargetInfo::ConstraintInfo Info(Literal->getString(), OutputName);
 if (!Context.getTargetInfo().validateOutputConstraint(Info))
-  return StmtError(
-  Diag(Literal->getBeginLoc(), diag::err_asm_invalid_output_constraint)
-  << Info.getConstraintStr());
+  return StmtResult(targetDiag(Literal->getBeginLoc(),
+   diag::err_asm_invalid_output_constraint)
+<< Info.getConstraintStr());
 
 ExprResult ER = CheckPlaceholderExpr(Exprs[i]);
 if (ER.isInvalid())
@@ -327,11 +327,10 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceL
 }
 
 unsigned Size = Context.getTypeSize(OutputExpr->getType());
-if (!Context.getTargetInfo().validateOutputSize(Literal->getString(),
-Size))
-  return StmtError(
-  Diag(OutputExpr->getBeginLoc(), diag::err_asm_invalid_output_size)
-  << Info.getConstraintStr());
+if (!Context.getTargetInfo().validateOutputSize(Literal->getString(), 
Size))
+  return StmtResult(targetDiag(OutputExpr->getBeginLoc(),
+   diag::err_asm_invalid_output_size)
+<< Info.getConstraintStr());
   }
 
   SmallVector InputConstraintInfos;
@@ -347,9 +346,9 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceL
 TargetInfo::ConstraintInfo Info(Literal->getString(), InputName);
 if (!Context.getTargetInfo().validateInputConstraint(OutputConstraintInfos,
  Info)) {
-  return StmtError(
-  Diag(Literal->getBeginLoc(), diag::err_asm_invalid_input_constraint)
-  << Info.getConstraintStr());
+  return StmtResult(targetDiag(Literal->getBeginLoc(),
+   diag::err_asm_invalid_input_constraint)
+<< Info.getConstraintStr());
 }
 
 ExprResult ER = CheckPlaceholderExpr(Exprs[i]);
@@ -421,8 +420,8 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceL
 unsigned Size = Context.getTypeSize(Ty);
 if (!Context.getTargetInfo().validateInputSize(Literal->getString(),
Size))
-  return StmtError(
-  Diag(InputExpr->getBeginLoc(), diag::err_asm_invalid_i

[PATCH] D58243: [OPENMP] Delay emission of the asm target-specific error messages.

2019-02-20 Thread Alexey Bataev 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 rL354486: [OPENMP] Delay emission of the asm target-specific 
error messages. (authored by ABataev, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58243

Files:
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/Sema.cpp
  cfe/trunk/lib/Sema/SemaStmtAsm.cpp
  cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -10275,6 +10275,8 @@
   ///  // Otherwise, continue parsing as normal.
   DeviceDiagBuilder diagIfOpenMPDeviceCode(SourceLocation Loc, unsigned DiagID);
 
+  DeviceDiagBuilder targetDiag(SourceLocation Loc, unsigned DiagID);
+
   enum CUDAFunctionTarget {
 CFT_Device,
 CFT_Global,
Index: cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c
===
--- cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c
+++ cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c
@@ -0,0 +1,118 @@
+// RUN: %clang_cc1 -fopenmp -x c -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -fsyntax-only
+// RUN: %clang_cc1 -verify -DDIAGS -DIMMEDIATE -fopenmp -x c -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -fsyntax-only
+// RUN: %clang_cc1 -verify -DDIAGS -DDELAYED -fopenmp -x c -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -fsyntax-only
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+#ifndef DIAGS
+// expected-no-diagnostics
+#endif // DIAGS
+
+#ifdef IMMEDIATE
+#pragma omp declare target
+#endif //IMMEDIATE
+void t1(int r) {
+#ifdef DIAGS
+// expected-error@+4 {{invalid input constraint 'mx' in asm}}
+#endif // DIAGS
+  __asm__("PR3908 %[lf] %[xx] %[li] %[r]"
+  : [ r ] "+r"(r)
+  : [ lf ] "mx"(0), [ li ] "mr"(0), [ xx ] "x"((double)(0)));
+}
+
+unsigned t2(signed char input) {
+  unsigned output;
+#ifdef DIAGS
+// expected-error@+3 {{invalid output constraint '=a' in asm}}
+#endif // DIAGS
+  __asm__("xyz"
+  : "=a"(output)
+  : "0"(input));
+  return output;
+}
+
+double t3(double x) {
+  register long double result;
+#ifdef DIAGS
+// expected-error@+3 {{invalid output constraint '=t' in asm}}
+#endif // DIAGS
+  __asm __volatile("frndint"
+   : "=t"(result)
+   : "0"(x));
+  return result;
+}
+
+unsigned char t4(unsigned char a, unsigned char b) {
+  unsigned int la = a;
+  unsigned int lb = b;
+  unsigned int bigres;
+  unsigned char res;
+#ifdef DIAGS
+// expected-error@+3 {{invalid output constraint '=la' in asm}}
+#endif // DIAGS
+  __asm__("0:\n1:\n"
+  : [ bigres ] "=la"(bigres)
+  : [ la ] "0"(la), [ lb ] "c"(lb)
+  : "edx", "cc");
+  res = bigres;
+  return res;
+}
+
+void t5(void) {
+#ifdef DIAGS
+// expected-error@+6 {{unknown register name 'st' in asm}}
+#endif // DIAGS
+  __asm__ __volatile__(
+  "finit"
+  :
+  :
+  : "st", "st(1)", "st(2)", "st(3)",
+"st(4)", "st(5)", "st(6)", "st(7)",
+"fpsr", "fpcr");
+}
+
+typedef long long __m256i __attribute__((__vector_size__(32)));
+void t6(__m256i *p) {
+#ifdef DIAGS
+// expected-error@+3 {{unknown register name 'ymm0' in asm}}
+#endif // DIAGS
+  __asm__ volatile("vmovaps  %0, %%ymm0" ::"m"(*(__m256i *)p)
+   : "ymm0");
+}
+#ifdef IMMEDIATE
+#pragma omp end declare target
+#endif //IMMEDIATE
+
+int main() {
+#ifdef DELAYED
+#pragma omp target
+#endif // DELAYED
+  {
+#ifdef DELAYED
+// expected-note@+2 {{called by 'main'}}
+#endif // DELAYED
+t1(0);
+#ifdef DELAYED
+// expected-note@+2 {{called by 'main'}}
+#endif // DELAYED
+t2(0);
+#ifdef DELAYED
+// expected-note@+2 {{called by 'main'}}
+#endif // DELAYED
+t3(0);
+#ifdef DELAYED
+// expected-note@+2 {{called by 'main'}}
+#endif // DELAYED
+t4(0, 0);
+#ifdef DELAYED
+// expected-note@+2 {{called by 'main'}}
+#endif // DELAYED
+t5();
+#ifdef DELAYED
+// expected-note@+2 {{called by 'main'}}
+#endif // DELAYED
+t6(0);
+  }
+  return 0;
+}
Index: cfe/trunk/lib/Sema/Sema.cpp
===
--- cfe/trunk/lib/Sema/Sema.cpp
+++ cfe/trunk/lib/Sema/Sema.cpp
@@ -1487,6 +1487,14 @@
   }
 }
 
+Sema::DeviceDiagBuilder Sema::targetDiag(Source

[PATCH] D58095: [clang-tidy] Make google-objc-function-naming ignore implicit functions 🙈

2019-02-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Still LGTM, thanks for adding the license snippet!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58095



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


[PATCH] D53701: [Analyzer] Record and process comparison of symbols instead of iterator positions in interator checkers

2019-02-20 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 187611.
baloghadamsoftware added a comment.

Instead of recording comparisons do an eager state split if the result is a 
symbolic value.


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

https://reviews.llvm.org/D53701

Files:
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp

Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -133,8 +133,6 @@
   }
 };
 
-typedef llvm::PointerUnion RegionOrSymbol;
-
 // Structure to record the symbolic begin and end position of a container
 struct ContainerData {
 private:
@@ -172,41 +170,21 @@
   }
 };
 
-// Structure fo recording iterator comparisons. We needed to retrieve the
-// original comparison expression in assumptions.
-struct IteratorComparison {
-private:
-  RegionOrSymbol Left, Right;
-  bool Equality;
-
-public:
-  IteratorComparison(RegionOrSymbol L, RegionOrSymbol R, bool Eq)
-  : Left(L), Right(R), Equality(Eq) {}
-
-  RegionOrSymbol getLeft() const { return Left; }
-  RegionOrSymbol getRight() const { return Right; }
-  bool isEquality() const { return Equality; }
-  bool operator==(const IteratorComparison &X) const {
-return Left == X.Left && Right == X.Right && Equality == X.Equality;
-  }
-  bool operator!=(const IteratorComparison &X) const {
-return Left != X.Left || Right != X.Right || Equality != X.Equality;
-  }
-  void Profile(llvm::FoldingSetNodeID &ID) const { ID.AddInteger(Equality); }
-};
-
 class IteratorChecker
 : public Checker, check::Bind,
- check::LiveSymbols, check::DeadSymbols,
- eval::Assume> {
+ check::LiveSymbols, check::DeadSymbols> {
 
   std::unique_ptr OutOfRangeBugType;
   std::unique_ptr MismatchedBugType;
   std::unique_ptr InvalidatedBugType;
 
-  void handleComparison(CheckerContext &C, const SVal &RetVal, const SVal &LVal,
-const SVal &RVal, OverloadedOperatorKind Op) const;
+  void handleComparison(CheckerContext &C, const Expr *CE, const SVal &RetVal,
+const SVal &LVal, const SVal &RVal,
+OverloadedOperatorKind Op) const;
+  void processComparison(CheckerContext &C, ProgramStateRef State,
+ SymbolRef Sym1, SymbolRef Sym2, const SVal &RetVal,
+ OverloadedOperatorKind Op) const;
   void verifyAccess(CheckerContext &C, const SVal &Val) const;
   void verifyDereference(CheckerContext &C, const SVal &Val) const;
   void handleIncrement(CheckerContext &C, const SVal &RetVal, const SVal &Iter,
@@ -281,8 +259,6 @@
  CheckerContext &C) const;
   void checkLiveSymbols(ProgramStateRef State, SymbolReaper &SR) const;
   void checkDeadSymbols(SymbolReaper &SR, CheckerContext &C) const;
-  ProgramStateRef evalAssume(ProgramStateRef State, SVal Cond,
- bool Assumption) const;
 };
 } // namespace
 
@@ -292,9 +268,6 @@
 
 REGISTER_MAP_WITH_PROGRAMSTATE(ContainerMap, const MemRegion *, ContainerData)
 
-REGISTER_MAP_WITH_PROGRAMSTATE(IteratorComparisonMap, const SymExpr *,
-   IteratorComparison)
-
 namespace {
 
 bool isIteratorType(const QualType &Type);
@@ -324,16 +297,6 @@
 bool hasSubscriptOperator(ProgramStateRef State, const MemRegion *Reg);
 bool frontModifiable(ProgramStateRef State, const MemRegion *Reg);
 bool backModifiable(ProgramStateRef State, const MemRegion *Reg);
-BinaryOperator::Opcode getOpcode(const SymExpr *SE);
-const RegionOrSymbol getRegionOrSymbol(const SVal &Val);
-const ProgramStateRef processComparison(ProgramStateRef State,
-RegionOrSymbol LVal,
-RegionOrSymbol RVal, bool Equal);
-const ProgramStateRef saveComparison(ProgramStateRef State,
- const SymExpr *Condition, const SVal &LVal,
- const SVal &RVal, bool Eq);
-const IteratorComparison *loadComparison(ProgramStateRef State,
- const SymExpr *Condition);
 SymbolRef getContainerBegin(ProgramStateRef State, const MemRegion *Cont);
 SymbolRef getContainerEnd(ProgramStateRef State, const MemRegion *Cont);
 ProgramStateRef createContainerBegin(ProgramStateRef State,
@@ -343,21 +306,9 @@
const SymbolRef Sym);
 const IteratorPosition *getIteratorPosition(ProgramStateRef State,
 const SVal &Val);
-const IteratorPosition *getIteratorPosition(ProgramStateRef State,
-RegionOrSymbol RegOrSym);
 ProgramStateRef setIteratorPosition(ProgramStateRef State, const SVal &Val,
 const IteratorPosition &Pos);
-ProgramState

[PATCH] D58292: Add support for importing ChooseExpr AST nodes.

2019-02-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/AST/ASTImporter.cpp:6140
+ExpectedStmt ASTNodeImporter::VisitChooseExpr(ChooseExpr *E) {
+  auto Imp = importSeq(E->getCond(), E->getLHS(), E->getRHS(),
+   E->getBuiltinLoc(), E->getRParenLoc(), E->getType());

Please don't use `auto` here; the type isn't spelled out in the initialization.



Comment at: lib/AST/ASTImporter.cpp:6160-6162
+  bool CondIsTrue = false;
+  if (!E->isConditionDependent())
+CondIsTrue = E->isConditionTrue();

`bool CondIsTrue = E->isConditionDependent() ? false : E->isConditionTrue();`


Repository:
  rC Clang

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

https://reviews.llvm.org/D58292



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


[PATCH] D58365: [attributes] Add a MIG server routine attribute.

2019-02-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8702
+def warn_mig_server_routine_does_not_return_kern_return_t : Warning<
+  "'%0' attribute only applies to functions that return a kernel return code">,
+  InGroup;

NoQ wrote:
> aaron.ballman wrote:
> > Will users understand "kernel return code"? Should this say `kern_return_t` 
> > explicitly?
> > 
> > No need to use %0 here, just spell out the attribute name directly (unless 
> > you expect this to be used by multiple attributes, in which case the name 
> > of the diagnostic should be changed).
> It should say either `kern_return_t` or `IOReturn` depending on the specific 
> framework that's being used (the latter is a typedef for the former). I guess 
> i could scan the AST to for a `typedef kern_return_t IOReturn` and display 
> the appropriate message, but this sort of stuff always sounds like an 
> overkill. For now i change the wording to an exact "a kern_return_t". I could 
> also say "a kern_return_t or an IOReturn", do you have any preference here?
Yeah, I think that scanning the AST would be overkill. This seems sufficiently 
clear, and we can always improve it if users wind up being confused in practice.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:6407
+ASTContext &ACtx = S.getASTContext();
+QualType T = AnyCall::forDecl(D)->getReturnType(ACtx);
+bool IsKernReturnT = false;

I'd prefer this to use `getFunctionOrMethodResultType()`.



Comment at: clang/test/Sema/attr-mig.c:6
+
+__attribute__((mig_server_routine)) kern_return_t var = KERN_SUCCESS; // 
expected-warning-re{{'mig_server_routine' attribute only applies to functions, 
Objective-C methods, and blocks{{$
+

What's the purpose of the `{{$}}`?



Comment at: clang/test/Sema/attr-mig.c:17
+}
+
+kern_return_t bar_forward() { // no-warning

NoQ wrote:
> aaron.ballman wrote:
> > Here's an edge case to consider:
> > ```
> > __attribute__((mig_server_routine)) int foo(void);
> > 
> > typedef int kern_return_t;
> > 
> > kern_return_t foo(void) { ... }
> > ```
> > Do you have to care about situations like that?
> > Do you have to care about situations like that?
> 
> I hope i not :) `kern_return_t` is available pretty much everywhere and most 
> likely it's not a problem to update the first declaration of `foo()` with 
> `kern_return_t`. Ok if i add a relaxing code later if it turns out that i 
> have to?
That's what I was hoping to hear. :-)



Comment at: clang/test/Sema/attr-mig.cpp:10
+public:
+  virtual __attribute__((mig_server_routine)) IOReturn externalMethod();
+  virtual __attribute__((mig_server_routine)) void anotherMethod(); // 
expected-warning{{'mig_server_routine' attribute only applies to functions that 
return a kernel return code}}

NoQ wrote:
> aaron.ballman wrote:
> > Can you use the C++ spelling for the attribute, so we have a bit of 
> > coverage for that?
> Is there a vision that i should also provide a namespaced C++ attribute, eg. 
> `[[mig::server_routine]]`?
I think this should continue to use `[[clang::mig_server_routine]]`.



Comment at: clang/test/Sema/attr-mig.m:21
+
+  // TODO: Warn that this block doesn't return a kern_return_t.
+  void (^invalid_block)() = ^ __attribute__((mig_server_routine)) {};

I'd change this to use FIXME instead of TODO.


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

https://reviews.llvm.org/D58365



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


[PATCH] D58463: [CUDA]Delayed diagnostics for the asm instructions.

2019-02-20 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added reviewers: tra, jlebar.
Herald added a subscriber: jdoerfert.
Herald added a project: clang.

Adapted targetDiag for the CUDA and used for the delayed diagnostics in
asm constructs. Works for both host and device compilation sides.


Repository:
  rC Clang

https://reviews.llvm.org/D58463

Files:
  lib/Sema/Sema.cpp
  lib/Sema/SemaStmtAsm.cpp
  test/SemaCUDA/asm_delayed_diags.cu

Index: test/SemaCUDA/asm_delayed_diags.cu
===
--- /dev/null
+++ test/SemaCUDA/asm_delayed_diags.cu
@@ -0,0 +1,118 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DHOST -triple x86_64-unknown-linux-gnu
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DHOST -DHOST_USED -triple x86_64-unknown-linux-gnu
+// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -verify %s -DDEVICE_NOT_USED -triple nvptx-unknown-cuda
+// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -verify %s -DDEVICE -triple nvptx-unknown-cuda
+// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -verify %s -DDEVICE -DDEVICE_USED -triple nvptx-unknown-cuda
+
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+#if (defined(HOST) && !defined(HOST_USED)) || defined(DEVICE_NOT_USED)
+// expected-no-diagnostics
+#endif
+
+#include "Inputs/cuda.h"
+
+static __device__ __host__ void t1(int r) {
+  __asm__("PR3908 %[lf] %[xx] %[li] %[r]"
+  : [ r ] "+r"(r)
+  : [ lf ] "mx"(0), [ li ] "mr"(0), [ xx ] "x"((double)(0)));
+}
+
+static __device__ __host__ unsigned t2(signed char input) {
+  unsigned output;
+  __asm__("xyz"
+  : "=a"(output)
+  : "0"(input));
+  return output;
+}
+
+static __device__ __host__ double t3(double x) {
+  register long double result;
+  __asm __volatile("frndint"
+   : "=t"(result)
+   : "0"(x));
+  return result;
+}
+
+static __device__ __host__ unsigned char t4(unsigned char a, unsigned char b) {
+  unsigned int la = a;
+  unsigned int lb = b;
+  unsigned int bigres;
+  unsigned char res;
+  __asm__("0:\n1:\n"
+  : [ bigres ] "=la"(bigres)
+  : [ la ] "0"(la), [ lb ] "c"(lb)
+  : "edx", "cc");
+  res = bigres;
+  return res;
+}
+
+static __device__ __host__ void t5(void) {
+  __asm__ __volatile__(
+  "finit"
+  :
+  :
+  : "st", "st(1)", "st(2)", "st(3)",
+"st(4)", "st(5)", "st(6)", "st(7)",
+"fpsr", "fpcr");
+}
+
+typedef long long __m256i __attribute__((__vector_size__(32)));
+static __device__ __host__ void t6(__m256i *p) {
+  __asm__ volatile("vmovaps  %0, %%ymm0" ::"m"(*(__m256i *)p)
+   : "ymm0");
+}
+
+static __device__ __host__ void t7(__m256i *p) {
+  __asm__ volatile("vmovaps  %0, %%ymm0" ::"m"(*(__m256i *)p)
+   : "r0");
+}
+
+#ifdef DEVICE
+__device__ int m() {
+  t1(0);
+  t2(0);
+  t3(0);
+  t4(0, 0);
+  t5();
+  t6(0);
+#ifdef DEVICE_USED
+  t7(0);
+#endif // DEVICE_USED
+  return 0;
+}
+#endif // DEVICE
+
+#ifdef HOST
+__host__ int main() {
+  t1(0);
+  t2(0);
+  t3(0);
+  t4(0, 0);
+  t5();
+  t6(0);
+#ifdef HOST_USED
+  t7(0);
+#endif // HOST_USED
+  return 0;
+}
+#endif // HOST
+
+#if defined(HOST_USED)
+// expected-error@69 {{unknown register name 'r0' in asm}}
+// expected-note@96 {{called by 'main'}}
+#elif defined(DEVICE)
+// expected-error@19 {{invalid input constraint 'mx' in asm}}
+// expected-error@25 {{invalid output constraint '=a' in asm}}
+// expected-error@33 {{invalid output constraint '=t' in asm}}
+// expected-error@44 {{invalid output constraint '=la' in asm}}
+// expected-error@56 {{unknown register name 'st' in asm}}
+// expected-error@64 {{unknown register name 'ymm0' in asm}}
+// expected-note@74 {{called by 'm'}}
+// expected-note@75 {{called by 'm'}}
+// expected-note@76 {{called by 'm'}}
+// expected-note@77 {{called by 'm'}}
+// expected-note@78 {{called by 'm'}}
+// expected-note@79 {{called by 'm'}}
+#endif
Index: lib/Sema/SemaStmtAsm.cpp
===
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -253,15 +253,6 @@
   // The parser verifies that there is a string literal here.
   assert(AsmString->isAscii());
 
-  // If we're compiling CUDA file and function attributes indicate that it's not
-  // for this compilation side, skip all the checks.
-  if (!DeclAttrsMatchCUDAMode(getLangOpts(), getCurFunctionDecl())) {
-GCCAsmStmt *NS = new (Context) GCCAsmStmt(
-Context, AsmLoc, IsSimple, IsVolatile, NumOutputs, NumInputs, Names,
-Constraints, Exprs.data(), AsmString, NumClobbers, Clobbers, RParenLoc);
-return NS;
-  }
-
   for (unsigned i = 0; i != NumOutputs; i++) {
 StringLiteral *Literal = Constraints[i];
 assert(Literal->isAscii());
Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -1487,10 +1487,14 @@
   }
 }
 
-Sema::DeviceDiagBuilder Sema::targ

[PATCH] D58440: [clangd] Store index in '.clangd/index' instead of '.clangd-index'

2019-02-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 187622.
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.

- Remove trailing slash from the path


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58440

Files:
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
  clang-tools-extra/test/clangd/background-index.test


Index: clang-tools-extra/test/clangd/background-index.test
===
--- clang-tools-extra/test/clangd/background-index.test
+++ clang-tools-extra/test/clangd/background-index.test
@@ -13,7 +13,7 @@
 # RUN: clangd -background-index -background-index-rebuild-period=0 -lit-test < 
%t/definition.jsonrpc | FileCheck %t/definition.jsonrpc
 
 # Test that the index is writing files in the expected location.
-# RUN: ls %t/.clangd-index/foo.cpp.*.idx
+# RUN: ls %t/.clangd/index/foo.cpp.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
 # RUN: rm %t/foo.cpp
Index: clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
===
--- clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
+++ clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
@@ -63,19 +63,19 @@
 }
 
 // Uses disk as a storage for index shards. Creates a directory called
-// ".clangd-index/" under the path provided during construction.
+// ".clangd/index/" under the path provided during construction.
 class DiskBackedIndexStorage : public BackgroundIndexStorage {
   std::string DiskShardRoot;
 
 public:
-  // Sets DiskShardRoot to (Directory + ".clangd-index/") which is the base
+  // Sets DiskShardRoot to (Directory + ".clangd/index/") which is the base
   // directory for all shard files.
   DiskBackedIndexStorage(llvm::StringRef Directory) {
 llvm::SmallString<128> CDBDirectory(Directory);
-llvm::sys::path::append(CDBDirectory, ".clangd-index/");
+llvm::sys::path::append(CDBDirectory, ".clangd", "index");
 DiskShardRoot = CDBDirectory.str();
 std::error_code OK;
-std::error_code EC = llvm::sys::fs::create_directory(DiskShardRoot);
+std::error_code EC = llvm::sys::fs::create_directories(DiskShardRoot);
 if (EC != OK) {
   elog("Failed to create directory {0} for index storage: {1}",
DiskShardRoot, EC.message());
Index: clang-tools-extra/clangd/index/Background.h
===
--- clang-tools-extra/clangd/index/Background.h
+++ clang-tools-extra/clangd/index/Background.h
@@ -54,7 +54,7 @@
   llvm::unique_function;
 
   // Creates an Index Storage that saves shards into disk. Index storage uses
-  // CDBDirectory + ".clangd-index/" as the folder to save shards.
+  // CDBDirectory + ".clangd/index/" as the folder to save shards.
   static Factory createDiskBackedStorageFactory();
 };
 


Index: clang-tools-extra/test/clangd/background-index.test
===
--- clang-tools-extra/test/clangd/background-index.test
+++ clang-tools-extra/test/clangd/background-index.test
@@ -13,7 +13,7 @@
 # RUN: clangd -background-index -background-index-rebuild-period=0 -lit-test < %t/definition.jsonrpc | FileCheck %t/definition.jsonrpc
 
 # Test that the index is writing files in the expected location.
-# RUN: ls %t/.clangd-index/foo.cpp.*.idx
+# RUN: ls %t/.clangd/index/foo.cpp.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
 # RUN: rm %t/foo.cpp
Index: clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
===
--- clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
+++ clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
@@ -63,19 +63,19 @@
 }
 
 // Uses disk as a storage for index shards. Creates a directory called
-// ".clangd-index/" under the path provided during construction.
+// ".clangd/index/" under the path provided during construction.
 class DiskBackedIndexStorage : public BackgroundIndexStorage {
   std::string DiskShardRoot;
 
 public:
-  // Sets DiskShardRoot to (Directory + ".clangd-index/") which is the base
+  // Sets DiskShardRoot to (Directory + ".clangd/index/") which is the base
   // directory for all shard files.
   DiskBackedIndexStorage(llvm::StringRef Directory) {
 llvm::SmallString<128> CDBDirectory(Directory);
-llvm::sys::path::append(CDBDirectory, ".clangd-index/");
+llvm::sys::path::append(CDBDirectory, ".clangd", "index");
 DiskShardRoot = CDBDirectory.str();
 std::error_code OK;
-std::error_code EC = llvm::sys::fs::create_directory(DiskShardRoot);
+std::error_code EC = llvm::sys::fs::create_directories(DiskShardRoot);
 if (EC != OK) {
   elog("Failed to create directory {0} for index storage: {1}",
DiskS

[PATCH] D58440: [clangd] Store index in '.clangd/index' instead of '.clangd-index'

2019-02-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp:75
 llvm::SmallString<128> CDBDirectory(Directory);
-llvm::sys::path::append(CDBDirectory, ".clangd-index/");
+llvm::sys::path::append(CDBDirectory, ".clangd", "index/");
 DiskShardRoot = CDBDirectory.str();

kadircet wrote:
> NIT: it looks like we don't need the "/" at the end of "index/"
Done.
I was not sure if it is important or not. Everything appears to work without 
it, so removing it now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58440



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


[PATCH] D58418: [clang][DirectoryWatcher] Upstream DirectoryWatcher

2019-02-20 Thread Jan Korous via Phabricator via cfe-commits
jkorous updated this revision to Diff 187623.
jkorous added a comment.

[DirectoryWatcher] Fix detection of FSEvents for iOS
[DirectoryWatcher][NFC] Doxygen


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

https://reviews.llvm.org/D58418

Files:
  clang/include/clang/DirectoryWatcher/DirectoryWatcher.h
  clang/lib/CMakeLists.txt
  clang/lib/DirectoryWatcher/CMakeLists.txt
  clang/lib/DirectoryWatcher/DirectoryWatcher-linux.inc.h
  clang/lib/DirectoryWatcher/DirectoryWatcher-mac.inc.h
  clang/lib/DirectoryWatcher/DirectoryWatcher.cpp
  clang/unittests/CMakeLists.txt
  clang/unittests/DirectoryWatcher/CMakeLists.txt
  clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Index: clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
===
--- /dev/null
+++ clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -0,0 +1,333 @@
+//===- unittests/DirectoryWatcher/DirectoryWatcherTest.cpp ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/DirectoryWatcher/DirectoryWatcher.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+using namespace llvm;
+using namespace llvm::sys;
+using namespace llvm::sys::fs;
+using namespace clang;
+
+namespace {
+
+class EventCollection {
+  SmallVector Events;
+
+public:
+  EventCollection() = default;
+  explicit EventCollection(ArrayRef events) {
+append(events);
+  }
+
+  void append(ArrayRef events) {
+Events.append(events.begin(), events.end());
+  }
+
+  bool empty() const { return Events.empty(); }
+  size_t size() const { return Events.size(); }
+  void clear() { Events.clear(); }
+
+  bool hasEvents(ArrayRef filenames,
+ ArrayRef kinds,
+ ArrayRef stats) const {
+assert(filenames.size() == kinds.size());
+assert(filenames.size() == stats.size());
+SmallVector evts = Events;
+bool hadError = false;
+for (unsigned i = 0, e = filenames.size(); i < e; ++i) {
+  StringRef fname = filenames[i];
+  DirectoryWatcher::EventKind kind = kinds[i];
+  file_status stat = stats[i];
+  auto it = std::find_if(evts.begin(), evts.end(),
+ [&](const DirectoryWatcher::Event &evt) -> bool {
+   return path::filename(evt.Filename) == fname;
+ });
+  if (it == evts.end()) {
+hadError = err(Twine("expected filename '" + fname + "' not found"));
+continue;
+  }
+  if (it->Kind != kind) {
+hadError = err(Twine("filename '" + fname + "' has event kind " +
+ std::to_string((int)it->Kind) + ", expected ") +
+   std::to_string((int)kind));
+  }
+  if (it->Kind != DirectoryWatcher::EventKind::Removed &&
+  it->ModTime != stat.getLastModificationTime())
+hadError =
+err(Twine("filename '" + fname + "' has different mod time"));
+  evts.erase(it);
+}
+for (const auto &evt : evts) {
+  hadError = err(Twine("unexpected filename '" +
+   path::filename(evt.Filename) + "' found"));
+}
+return !hadError;
+  }
+
+  bool hasAdded(ArrayRef filenames,
+ArrayRef stats) const {
+std::vector kinds{
+filenames.size(), DirectoryWatcher::EventKind::Added};
+return hasEvents(filenames, kinds, stats);
+  }
+
+  bool hasRemoved(ArrayRef filenames) const {
+std::vector kinds{
+filenames.size(), DirectoryWatcher::EventKind::Removed};
+std::vector stats{filenames.size(), file_status{}};
+return hasEvents(filenames, kinds, stats);
+  }
+
+private:
+  bool err(Twine msg) const {
+SmallString<128> buf;
+llvm::errs() << msg.toStringRef(buf) << '\n';
+return true;
+  }
+};
+
+struct EventOccurrence {
+  std::vector Events;
+  bool IsInitial;
+};
+
+class DirectoryWatcherTest
+: public std::enable_shared_from_this {
+  std::string WatchedDir;
+  std::string TempDir;
+  std::unique_ptr DirWatcher;
+
+  std::condition_variable Condition;
+  std::mutex Mutex;
+  std::deque EvtOccurs;
+
+public:
+  void init() {
+SmallString<128> pathBuf;
+std::error_code EC = createUniqueDirectory("dirwatcher", pathBuf);
+ASSERT_FALSE(EC);
+TempDir = pathBuf.str();
+path::append(pathBuf, "watch");
+WatchedDir = pathBuf.str();
+EC = create_directory(WatchedDir);
+ASSERT_FALSE(EC);
+  }
+
+  ~DirectoryWatcherTest() {
+stopWatching();
+remove_directories(TempDir);
+  }
+
+public:
+  StringRef getWatchedDir() const { return WatchedDir; }
+
+  void addFile(StringRef filename, file_status &stat) {
+Sma

[PATCH] D58440: [clangd] Store index in '.clangd/index' instead of '.clangd-index'

2019-02-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 187627.
ilya-biryukov added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

- Update .gitignore


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58440

Files:
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
  clang-tools-extra/test/clangd/background-index.test
  llvm/.gitignore


Index: llvm/.gitignore
===
--- llvm/.gitignore
+++ llvm/.gitignore
@@ -72,8 +72,8 @@
 # VS2017 and VSCode config files.
 .vscode
 .vs
-# clangd background index
-.clangd-index
+# clangd index
+.clangd
 
 
#==#
 # Files created in tree by the Go bindings.
Index: clang-tools-extra/test/clangd/background-index.test
===
--- clang-tools-extra/test/clangd/background-index.test
+++ clang-tools-extra/test/clangd/background-index.test
@@ -13,7 +13,7 @@
 # RUN: clangd -background-index -background-index-rebuild-period=0 -lit-test < 
%t/definition.jsonrpc | FileCheck %t/definition.jsonrpc
 
 # Test that the index is writing files in the expected location.
-# RUN: ls %t/.clangd-index/foo.cpp.*.idx
+# RUN: ls %t/.clangd/index/foo.cpp.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
 # RUN: rm %t/foo.cpp
Index: clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
===
--- clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
+++ clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
@@ -63,19 +63,19 @@
 }
 
 // Uses disk as a storage for index shards. Creates a directory called
-// ".clangd-index/" under the path provided during construction.
+// ".clangd/index/" under the path provided during construction.
 class DiskBackedIndexStorage : public BackgroundIndexStorage {
   std::string DiskShardRoot;
 
 public:
-  // Sets DiskShardRoot to (Directory + ".clangd-index/") which is the base
+  // Sets DiskShardRoot to (Directory + ".clangd/index/") which is the base
   // directory for all shard files.
   DiskBackedIndexStorage(llvm::StringRef Directory) {
 llvm::SmallString<128> CDBDirectory(Directory);
-llvm::sys::path::append(CDBDirectory, ".clangd-index/");
+llvm::sys::path::append(CDBDirectory, ".clangd", "index");
 DiskShardRoot = CDBDirectory.str();
 std::error_code OK;
-std::error_code EC = llvm::sys::fs::create_directory(DiskShardRoot);
+std::error_code EC = llvm::sys::fs::create_directories(DiskShardRoot);
 if (EC != OK) {
   elog("Failed to create directory {0} for index storage: {1}",
DiskShardRoot, EC.message());
Index: clang-tools-extra/clangd/index/Background.h
===
--- clang-tools-extra/clangd/index/Background.h
+++ clang-tools-extra/clangd/index/Background.h
@@ -54,7 +54,7 @@
   llvm::unique_function;
 
   // Creates an Index Storage that saves shards into disk. Index storage uses
-  // CDBDirectory + ".clangd-index/" as the folder to save shards.
+  // CDBDirectory + ".clangd/index/" as the folder to save shards.
   static Factory createDiskBackedStorageFactory();
 };
 


Index: llvm/.gitignore
===
--- llvm/.gitignore
+++ llvm/.gitignore
@@ -72,8 +72,8 @@
 # VS2017 and VSCode config files.
 .vscode
 .vs
-# clangd background index
-.clangd-index
+# clangd index
+.clangd
 
 #==#
 # Files created in tree by the Go bindings.
Index: clang-tools-extra/test/clangd/background-index.test
===
--- clang-tools-extra/test/clangd/background-index.test
+++ clang-tools-extra/test/clangd/background-index.test
@@ -13,7 +13,7 @@
 # RUN: clangd -background-index -background-index-rebuild-period=0 -lit-test < %t/definition.jsonrpc | FileCheck %t/definition.jsonrpc
 
 # Test that the index is writing files in the expected location.
-# RUN: ls %t/.clangd-index/foo.cpp.*.idx
+# RUN: ls %t/.clangd/index/foo.cpp.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
 # RUN: rm %t/foo.cpp
Index: clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
===
--- clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
+++ clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
@@ -63,19 +63,19 @@
 }
 
 // Uses disk as a storage for index shards. Creates a directory called
-// ".clangd-index/" under the path provided during construction.
+// ".clangd/index/" under the path provided during construction.
 class DiskBackedIndexStorage : public Ba

r354502 - [Clang Driver] Add support for "-static-pie" argument to the Clang driver.

2019-02-20 Thread Siva Chandra via cfe-commits
Author: sivachandra
Date: Wed Feb 20 11:07:04 2019
New Revision: 354502

URL: http://llvm.org/viewvc/llvm-project?rev=354502&view=rev
Log:
[Clang Driver] Add support for "-static-pie" argument to the Clang driver.

Summary: This change mimics GCC's support for the "-static-pie" argument.

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/linux-ld.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=354502&r1=354501&r2=354502&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Feb 20 11:07:04 2019
@@ -2508,6 +2508,7 @@ def pthread : Flag<["-"], "pthread">, Fl
 def no_pthread : Flag<["-"], "no-pthread">, Flags<[CC1Option]>;
 def p : Flag<["-"], "p">;
 def pie : Flag<["-"], "pie">;
+def static_pie : Flag<["-"], "static-pie">;
 def read__only__relocs : Separate<["-"], "read_only_relocs">;
 def remap : Flag<["-"], "remap">;
 def rewrite_objc : Flag<["-"], "rewrite-objc">, 
Flags<[DriverOption,CC1Option]>,

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=354502&r1=354501&r2=354502&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Wed Feb 20 11:07:04 2019
@@ -1137,19 +1137,22 @@ static void AddLibgcc(const llvm::Triple
   bool isCygMing = Triple.isOSCygMing();
   bool IsIAMCU = Triple.isOSIAMCU();
   bool StaticLibgcc = Args.hasArg(options::OPT_static_libgcc) ||
-  Args.hasArg(options::OPT_static);
+  Args.hasArg(options::OPT_static) ||
+  Args.hasArg(options::OPT_static_pie);
 
   bool SharedLibgcc = Args.hasArg(options::OPT_shared_libgcc);
   bool UnspecifiedLibgcc = !StaticLibgcc && !SharedLibgcc;
 
   // Gcc adds libgcc arguments in various ways:
   //
-  // gcc : -lgcc --as-needed -lgcc_s --no-as-needed
-  // g++ :   -lgcc_s   -lgcc
-  // gcc shared:   -lgcc_s   -lgcc
-  // g++ shared:   -lgcc_s   -lgcc
-  // gcc static: -lgcc -lgcc_eh
-  // g++ static: -lgcc -lgcc_eh
+  // gcc : -lgcc --as-needed -lgcc_s --no-as-needed
+  // g++ :   -lgcc_s   -lgcc
+  // gcc shared:   -lgcc_s   -lgcc
+  // g++ shared:   -lgcc_s   -lgcc
+  // gcc static: -lgcc -lgcc_eh
+  // g++ static: -lgcc -lgcc_eh
+  // gcc static-pie: -lgcc -lgcc_eh
+  // g++ static-pie: -lgcc -lgcc_eh
   //
   // Also, certain targets need additional adjustments.
 

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=354502&r1=354501&r2=354502&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Wed Feb 20 11:07:04 2019
@@ -333,6 +333,7 @@ void tools::gnutools::Linker::ConstructJ
   const bool isAndroid = ToolChain.getTriple().isAndroid();
   const bool IsIAMCU = ToolChain.getTriple().isOSIAMCU();
   const bool IsPIE = getPIE(Args, ToolChain);
+  const bool IsStaticPIE = Args.hasArg(options::OPT_static_pie);
   const bool HasCRTBeginEndFiles =
   ToolChain.getTriple().hasEnvironment() ||
   (ToolChain.getTriple().getVendor() != llvm::Triple::MipsTechnologies);
@@ -353,6 +354,12 @@ void tools::gnutools::Linker::ConstructJ
   if (IsPIE)
 CmdArgs.push_back("-pie");
 
+  if (IsStaticPIE) {
+CmdArgs.push_back("-static");
+CmdArgs.push_back("-pie");
+CmdArgs.push_back("--no-dynamic-linker");
+  }
+
   if (Args.hasArg(options::OPT_rdynamic))
 CmdArgs.push_back("-export-dynamic");
 
@@ -402,7 +409,7 @@ void tools::gnutools::Linker::ConstructJ
 if (Args.hasArg(options::OPT_rdynamic))
   CmdArgs.push_back("-export-dynamic");
 
-if (!Args.hasArg(options::OPT_shared)) {
+if (!Args.hasArg(options::OPT_shared) && !IsStaticPIE) {
   const std::string Loader =
   D.DyldPrefix + ToolChain.getDynamicLinker(Args);
   CmdArgs.push_back("-dynamic-linker");
@@ -421,6 +428,8 @@ void tools::gnutools::Linker::ConstructJ
   crt1 = "gcrt1.o";
 else if (IsPIE)
   crt1 = "Scrt1.o";
+else if (IsStaticPIE)
+  crt1 = "rcrt1.o";
 else
   crt

r354503 - Fix remaining semicolon pedantic errors for intel

2019-02-20 Thread Gabor Marton via cfe-commits
Author: martong
Date: Wed Feb 20 11:07:36 2019
New Revision: 354503

URL: http://llvm.org/viewvc/llvm-project?rev=354503&view=rev
Log:
Fix remaining semicolon pedantic errors for intel

Modified:
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=354503&r1=354502&r2=354503&view=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Wed Feb 20 11:07:36 2019
@@ -4240,10 +4240,10 @@ ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 ImportPrototypeAfterImportedDefinition)
 
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Function, ,
-ImportPrototypes);
+ImportPrototypes)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Class, , ImportPrototypes)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Variable, ,
-ImportPrototypes);
+ImportPrototypes)
 // FIXME Enable this test, once we import function templates chains correctly.
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate,
 DISABLED_, ImportPrototypes)


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


[clang-tools-extra] r354505 - [clangd] Store index in '.clangd/index' instead of '.clangd-index'

2019-02-20 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Feb 20 11:08:06 2019
New Revision: 354505

URL: http://llvm.org/viewvc/llvm-project?rev=354505&view=rev
Log:
[clangd] Store index in '.clangd/index' instead of '.clangd-index'

Summary: To take up the .clangd folder for other potential uses in the future.

Reviewers: kadircet, sammccall

Reviewed By: kadircet

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/index/Background.h
clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
clang-tools-extra/trunk/test/clangd/background-index.test

Modified: clang-tools-extra/trunk/clangd/index/Background.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Background.h?rev=354505&r1=354504&r2=354505&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Background.h (original)
+++ clang-tools-extra/trunk/clangd/index/Background.h Wed Feb 20 11:08:06 2019
@@ -54,7 +54,7 @@ public:
   llvm::unique_function;
 
   // Creates an Index Storage that saves shards into disk. Index storage uses
-  // CDBDirectory + ".clangd-index/" as the folder to save shards.
+  // CDBDirectory + ".clangd/index/" as the folder to save shards.
   static Factory createDiskBackedStorageFactory();
 };
 

Modified: clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp?rev=354505&r1=354504&r2=354505&view=diff
==
--- clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp Wed Feb 20 
11:08:06 2019
@@ -63,19 +63,19 @@ writeAtomically(llvm::StringRef OutPath,
 }
 
 // Uses disk as a storage for index shards. Creates a directory called
-// ".clangd-index/" under the path provided during construction.
+// ".clangd/index/" under the path provided during construction.
 class DiskBackedIndexStorage : public BackgroundIndexStorage {
   std::string DiskShardRoot;
 
 public:
-  // Sets DiskShardRoot to (Directory + ".clangd-index/") which is the base
+  // Sets DiskShardRoot to (Directory + ".clangd/index/") which is the base
   // directory for all shard files.
   DiskBackedIndexStorage(llvm::StringRef Directory) {
 llvm::SmallString<128> CDBDirectory(Directory);
-llvm::sys::path::append(CDBDirectory, ".clangd-index/");
+llvm::sys::path::append(CDBDirectory, ".clangd", "index");
 DiskShardRoot = CDBDirectory.str();
 std::error_code OK;
-std::error_code EC = llvm::sys::fs::create_directory(DiskShardRoot);
+std::error_code EC = llvm::sys::fs::create_directories(DiskShardRoot);
 if (EC != OK) {
   elog("Failed to create directory {0} for index storage: {1}",
DiskShardRoot, EC.message());

Modified: clang-tools-extra/trunk/test/clangd/background-index.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/background-index.test?rev=354505&r1=354504&r2=354505&view=diff
==
--- clang-tools-extra/trunk/test/clangd/background-index.test (original)
+++ clang-tools-extra/trunk/test/clangd/background-index.test Wed Feb 20 
11:08:06 2019
@@ -13,7 +13,7 @@
 # RUN: clangd -background-index -background-index-rebuild-period=0 -lit-test < 
%t/definition.jsonrpc | FileCheck %t/definition.jsonrpc
 
 # Test that the index is writing files in the expected location.
-# RUN: ls %t/.clangd-index/foo.cpp.*.idx
+# RUN: ls %t/.clangd/index/foo.cpp.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
 # RUN: rm %t/foo.cpp


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


[PATCH] D58440: [clangd] Store index in '.clangd/index' instead of '.clangd-index'

2019-02-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354505: [clangd] Store index in '.clangd/index' 
instead of '.clangd-index' (authored by ibiryukov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58440?vs=187627&id=187629#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58440

Files:
  clang-tools-extra/trunk/clangd/index/Background.h
  clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
  clang-tools-extra/trunk/test/clangd/background-index.test
  llvm/trunk/.gitignore


Index: llvm/trunk/.gitignore
===
--- llvm/trunk/.gitignore
+++ llvm/trunk/.gitignore
@@ -72,8 +72,8 @@
 # VS2017 and VSCode config files.
 .vscode
 .vs
-# clangd background index
-.clangd-index
+# clangd index
+.clangd
 
 
#==#
 # Files created in tree by the Go bindings.
Index: clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
===
--- clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
+++ clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
@@ -63,19 +63,19 @@
 }
 
 // Uses disk as a storage for index shards. Creates a directory called
-// ".clangd-index/" under the path provided during construction.
+// ".clangd/index/" under the path provided during construction.
 class DiskBackedIndexStorage : public BackgroundIndexStorage {
   std::string DiskShardRoot;
 
 public:
-  // Sets DiskShardRoot to (Directory + ".clangd-index/") which is the base
+  // Sets DiskShardRoot to (Directory + ".clangd/index/") which is the base
   // directory for all shard files.
   DiskBackedIndexStorage(llvm::StringRef Directory) {
 llvm::SmallString<128> CDBDirectory(Directory);
-llvm::sys::path::append(CDBDirectory, ".clangd-index/");
+llvm::sys::path::append(CDBDirectory, ".clangd", "index");
 DiskShardRoot = CDBDirectory.str();
 std::error_code OK;
-std::error_code EC = llvm::sys::fs::create_directory(DiskShardRoot);
+std::error_code EC = llvm::sys::fs::create_directories(DiskShardRoot);
 if (EC != OK) {
   elog("Failed to create directory {0} for index storage: {1}",
DiskShardRoot, EC.message());
Index: clang-tools-extra/trunk/clangd/index/Background.h
===
--- clang-tools-extra/trunk/clangd/index/Background.h
+++ clang-tools-extra/trunk/clangd/index/Background.h
@@ -54,7 +54,7 @@
   llvm::unique_function;
 
   // Creates an Index Storage that saves shards into disk. Index storage uses
-  // CDBDirectory + ".clangd-index/" as the folder to save shards.
+  // CDBDirectory + ".clangd/index/" as the folder to save shards.
   static Factory createDiskBackedStorageFactory();
 };
 
Index: clang-tools-extra/trunk/test/clangd/background-index.test
===
--- clang-tools-extra/trunk/test/clangd/background-index.test
+++ clang-tools-extra/trunk/test/clangd/background-index.test
@@ -13,7 +13,7 @@
 # RUN: clangd -background-index -background-index-rebuild-period=0 -lit-test < 
%t/definition.jsonrpc | FileCheck %t/definition.jsonrpc
 
 # Test that the index is writing files in the expected location.
-# RUN: ls %t/.clangd-index/foo.cpp.*.idx
+# RUN: ls %t/.clangd/index/foo.cpp.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
 # RUN: rm %t/foo.cpp


Index: llvm/trunk/.gitignore
===
--- llvm/trunk/.gitignore
+++ llvm/trunk/.gitignore
@@ -72,8 +72,8 @@
 # VS2017 and VSCode config files.
 .vscode
 .vs
-# clangd background index
-.clangd-index
+# clangd index
+.clangd
 
 #==#
 # Files created in tree by the Go bindings.
Index: clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
===
--- clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
+++ clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
@@ -63,19 +63,19 @@
 }
 
 // Uses disk as a storage for index shards. Creates a directory called
-// ".clangd-index/" under the path provided during construction.
+// ".clangd/index/" under the path provided during construction.
 class DiskBackedIndexStorage : public BackgroundIndexStorage {
   std::string DiskShardRoot;
 
 public:
-  // Sets DiskShardRoot to (Directory + ".clangd-index/") which is the base
+  // Sets DiskShardRoot to (Directory + ".clangd/index/") which is the base
   // directory for all shard files.
   DiskBackedIndexStorage(llvm::StringRef Directory) {
 llvm::SmallString<128> CDBDirectory(Directory);
-llvm::sys::path::append(CDBDirectory,

[PATCH] D58307: [Clang Driver] Add support for "-static-pie" argument to the Clang driver.

2019-02-20 Thread Siva Chandra via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354502: [Clang Driver] Add support for 
"-static-pie" argument to the Clang driver. (authored by sivachandra, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58307?vs=187091&id=187628#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58307

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
  cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
  cfe/trunk/test/Driver/linux-ld.c

Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -2508,6 +2508,7 @@
 def no_pthread : Flag<["-"], "no-pthread">, Flags<[CC1Option]>;
 def p : Flag<["-"], "p">;
 def pie : Flag<["-"], "pie">;
+def static_pie : Flag<["-"], "static-pie">;
 def read__only__relocs : Separate<["-"], "read_only_relocs">;
 def remap : Flag<["-"], "remap">;
 def rewrite_objc : Flag<["-"], "rewrite-objc">, Flags<[DriverOption,CC1Option]>,
Index: cfe/trunk/test/Driver/linux-ld.c
===
--- cfe/trunk/test/Driver/linux-ld.c
+++ cfe/trunk/test/Driver/linux-ld.c
@@ -176,6 +176,19 @@
 // CHECK-CLANG-NO-LIBGCC-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-CLANG-NO-LIBGCC-STATIC: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group"
 //
+// RUN: %clang -static-pie -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=platform \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANG-LD-STATIC-PIE %s
+// CHECK-CLANG-LD-STATIC-PIE: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-CLANG-LD-STATIC-PIE: "-static"
+// CHECK-CLANG-LD-STATIC-PIE: "-pie"
+// CHECK-CLANG-LD-STATIC-PIE: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE: "-m" "elf_x86_64"
+// CHECK-CLANG-LD-STATIC-PIE: "{{.*}}rcrt1.o"
+// CHECK-CLANG-LD-STATIC-PIE: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group"
+//
 // RUN: %clang -dynamic -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=x86_64-unknown-linux -rtlib=platform \
 // RUN: --gcc-toolchain="" \
Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
@@ -333,6 +333,7 @@
   const bool isAndroid = ToolChain.getTriple().isAndroid();
   const bool IsIAMCU = ToolChain.getTriple().isOSIAMCU();
   const bool IsPIE = getPIE(Args, ToolChain);
+  const bool IsStaticPIE = Args.hasArg(options::OPT_static_pie);
   const bool HasCRTBeginEndFiles =
   ToolChain.getTriple().hasEnvironment() ||
   (ToolChain.getTriple().getVendor() != llvm::Triple::MipsTechnologies);
@@ -353,6 +354,12 @@
   if (IsPIE)
 CmdArgs.push_back("-pie");
 
+  if (IsStaticPIE) {
+CmdArgs.push_back("-static");
+CmdArgs.push_back("-pie");
+CmdArgs.push_back("--no-dynamic-linker");
+  }
+
   if (Args.hasArg(options::OPT_rdynamic))
 CmdArgs.push_back("-export-dynamic");
 
@@ -402,7 +409,7 @@
 if (Args.hasArg(options::OPT_rdynamic))
   CmdArgs.push_back("-export-dynamic");
 
-if (!Args.hasArg(options::OPT_shared)) {
+if (!Args.hasArg(options::OPT_shared) && !IsStaticPIE) {
   const std::string Loader =
   D.DyldPrefix + ToolChain.getDynamicLinker(Args);
   CmdArgs.push_back("-dynamic-linker");
@@ -421,6 +428,8 @@
   crt1 = "gcrt1.o";
 else if (IsPIE)
   crt1 = "Scrt1.o";
+else if (IsStaticPIE)
+  crt1 = "rcrt1.o";
 else
   crt1 = "crt1.o";
   }
@@ -438,14 +447,14 @@
 crtbegin = isAndroid ? "crtbegin_static.o" : "crtbeginT.o";
   else if (Args.hasArg(options::OPT_shared))
 crtbegin = isAndroid ? "crtbegin_so.o" : "crtbeginS.o";
-  else if (IsPIE)
+  else if (IsPIE || IsStaticPIE)
 crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbeginS.o";
   else
 crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbegin.o";
 
   if (HasCRTBeginEndFiles)
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
-}
+	}
 
 // Add crtfastmath.o if available and fast math is enabled.
 ToolChain.AddFastMathRuntimeIfAvailable(Args, CmdArgs);
@@ -489,7 +498,7 @@
 
   if (!Args.hasArg(options::OPT_nostdlib)) {
 if (!Args.hasArg(options::OPT_nodefaultlibs)) {
-  if (Args.hasArg(options::OPT_static))
+  if (Args.hasArg(options::OPT_static) || IsStaticPIE)
 CmdArgs.push_back("--start-group");
 
   if (NeedsSanitizerDeps)
@@ -525,7 +534,7 @@
   if (IsIAMCU)

[PATCH] D58345: [clangd] Using symbol name to map includes for STL symbols.

2019-02-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked 2 inline comments as done.
hokein added inline comments.



Comment at: clangd/index/CanonicalIncludes.cpp:47
+  // headers (e.g. std::move from  and ), using
+  // qualified name can not disambiguate headers. Instead we should return all
+  // headers and do the disambiguation in clangd side.

sammccall wrote:
> Looking at the actual data, I'm not sure this is the right strategy. (and 
> it's not clear what "the clangd side" is :-)
> 
> The ambiguous cases seem to break down into:
>  - cases where we should just pick one, e.g. cstdlib vs cmath for std::abs
>  - cases where a function is overloaded for a particular type (e.g. complex), 
> where passing more information in here (strawman: "the signature as a 
> string") would let us get this correct. Alternatively (and easier), I believe 
> always using the "primary" version of this function is going to be correct if 
> not *strictly* iwyu, as the type comes from the same header. So In the short 
> term I'd suggest just blacklisting the variants.
>  - cases like std::move and... maybe one or two more? In the short term 
> always returning `` seems good enough. In the long term, passing in 
> the signature again would let us disambiguate here.
> Looking at the actual data, I'm not sure this is the right strategy. (and 
> it's not clear what "the clangd side" is :-)

`clangd side` I mean the consumer side.

> cases where we should just pick one, e.g. cstdlib vs cmath for std::abs

For these cases, I think we can address them in generator side by using a 
hardcoded whitelist.

> cases where a function is overloaded for a particular type (e.g. complex), 
> where passing more information in here (strawman: "the signature as a 
> string") would let us get this correct. Alternatively (and easier), I believe 
> always using the "primary" version of this function is going to be correct if 
> not *strictly* iwyu, as the type comes from the same header. So In the short 
> term I'd suggest just blacklisting the variants.

Using primary version seems promising, and our indexer doesn't index the 
template specification symbols.

> cases like std::move and... maybe one or two more? In the short term always 
> returning  seems good enough. In the long term, passing in the 
> signature again would let us disambiguate here.

For std::move this particular case, I don't think using signature (as a string) 
really helps to disambiguate, since both of them are templates, the signature 
string doesn't contain any word specific to the header names 
/. The best way to disambiguate them is to use the number 
of parameters IMO.

I'm +1 on returning `utility`, since `std::move` in `utility` is more 
widely-used.


Or another way to disambiguate: use symbol name => header for symbols with 
unique headers; otherwise fallback to use header  mapping.



Comment at: clangd/index/CanonicalIncludes.cpp:123
 
   static const std::vector>
   SystemHeaderMap = {

sammccall wrote:
> hokein wrote:
> > ioeric wrote:
> > > Can we remove the suffix header mapping now? Is it for the 
> > > `std::chrono::` symbols? What are the reasons not to include them in this 
> > > patch? 
> > Ideally, we could remove it once we get a perfect symbol mapping but I'd 
> > prefer to keep it (it serves as a fallback when we don't find symbols in 
> > the symbol mapping), so that we could add new symbol mapping increasingly 
> > without changing the current behavior.
> > 
> > Removing it should be done carefully without introducing regression, and is 
> > outside the scope of this patch.
> We do need fallback heuristics. We should conisder cases:
>  - for known `std::` symbols mapped to one system header, we don't need a 
> fallback
>  - for known `std::` mapped to multiple system headers (`std::move`), we need 
> some fallback. There are probably few enough of these that it doesn't justify 
> listing *all* system header paths.
>  - for known `std::` symbols with a primary template in one file and 
> specializations/overloads in another (swap?) always inserting the primary 
> seems fine 
>  - For "random" unknown symbols from system header `foo/bits/_bar.h`, we can 
> not insert, correct to ``, or use the full path name. I don't have a 
> strong preference here, maybe we should do what's easiest.
>  - for c standard library (`::printf` --> `` etc) we probably want 
> mappings just like in this patch, I think cppreference has them.
>  - other "standardish" headers (POSIX etc) - hmm, unclear.
> 
> Thinking about all these cases, I'm thinking the nicest solution would be 
> having the symbol -> header mapping, having a small (symbol,header) -> header 
> mapping **only** for ambiguous cases, and not inserting "system" headers that 
> aren't in the main mapping at all. Then we can improve coverage of posix, 
> windows etc headers over time.
> Question is, how can we recognize "system" headers?
I think we were talking about C++ std symbols.

>

[PATCH] D58320: [Darwin] Introduce a new flag, -flink-builtins-rt that forces linking of the builtins library.

2019-02-20 Thread Amara Emerson via Phabricator via cfe-commits
aemerson abandoned this revision.
aemerson added a comment.

After discussion on the thread, we can implement this requirement with -nolibc 
-nostdlib++ -nostartfiles


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58320



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


[clang-tools-extra] r354507 - [clangd] Fix a crash in Selection

2019-02-20 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Feb 20 11:26:39 2019
New Revision: 354507

URL: http://llvm.org/viewvc/llvm-project?rev=354507&view=rev
Log:
[clangd] Fix a crash in Selection

Summary:
The assertion checking that a range of a node is a token range does
not hold in case of "split" tokens, e.g. between two closing template
argument lists (`vector>`).

Reviewers: kadircet, sammccall

Reviewed By: kadircet

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

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

Modified: clang-tools-extra/trunk/clangd/Selection.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Selection.cpp?rev=354507&r1=354506&r2=354507&view=diff
==
--- clang-tools-extra/trunk/clangd/Selection.cpp (original)
+++ clang-tools-extra/trunk/clangd/Selection.cpp Wed Feb 20 11:26:39 2019
@@ -198,11 +198,10 @@ private:
   auto E = SM.getDecomposedLoc(R.getEnd());
   if (B.first != SelFile || E.first != SelFile)
 continue;
-  assert(R.isTokenRange());
   // Try to cover up to the next token, spaces between children don't 
count.
   if (auto Tok = Lexer::findNextToken(R.getEnd(), SM, LangOpts))
 E.second = SM.getFileOffset(Tok->getLocation());
-  else
+  else if (R.isTokenRange())
 E.second += Lexer::MeasureTokenLength(R.getEnd(), SM, LangOpts);
   ChildRanges.push_back({B.second, E.second});
 }

Modified: clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp?rev=354507&r1=354506&r2=354507&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp Wed Feb 20 
11:26:39 2019
@@ -232,6 +232,11 @@ TEST(SelectionTest, Selected) {
   }
 }
   )cpp",
+  R"cpp(
+  template 
+  struct unique_ptr {};
+  void foo(^$C[[unique_ptr>]]^ a) {}
+  )cpp",
   };
   for (const char *C : Cases) {
 Annotations Test(C);


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


[PATCH] D58447: [clangd] Fix a crash in Selection

2019-02-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354507: [clangd] Fix a crash in Selection (authored by 
ibiryukov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58447?vs=187569&id=187632#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58447

Files:
  clang-tools-extra/trunk/clangd/Selection.cpp
  clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp


Index: clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp
@@ -232,6 +232,11 @@
   }
 }
   )cpp",
+  R"cpp(
+  template 
+  struct unique_ptr {};
+  void foo(^$C[[unique_ptr>]]^ a) {}
+  )cpp",
   };
   for (const char *C : Cases) {
 Annotations Test(C);
Index: clang-tools-extra/trunk/clangd/Selection.cpp
===
--- clang-tools-extra/trunk/clangd/Selection.cpp
+++ clang-tools-extra/trunk/clangd/Selection.cpp
@@ -198,11 +198,10 @@
   auto E = SM.getDecomposedLoc(R.getEnd());
   if (B.first != SelFile || E.first != SelFile)
 continue;
-  assert(R.isTokenRange());
   // Try to cover up to the next token, spaces between children don't 
count.
   if (auto Tok = Lexer::findNextToken(R.getEnd(), SM, LangOpts))
 E.second = SM.getFileOffset(Tok->getLocation());
-  else
+  else if (R.isTokenRange())
 E.second += Lexer::MeasureTokenLength(R.getEnd(), SM, LangOpts);
   ChildRanges.push_back({B.second, E.second});
 }


Index: clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp
@@ -232,6 +232,11 @@
   }
 }
   )cpp",
+  R"cpp(
+  template 
+  struct unique_ptr {};
+  void foo(^$C[[unique_ptr>]]^ a) {}
+  )cpp",
   };
   for (const char *C : Cases) {
 Annotations Test(C);
Index: clang-tools-extra/trunk/clangd/Selection.cpp
===
--- clang-tools-extra/trunk/clangd/Selection.cpp
+++ clang-tools-extra/trunk/clangd/Selection.cpp
@@ -198,11 +198,10 @@
   auto E = SM.getDecomposedLoc(R.getEnd());
   if (B.first != SelFile || E.first != SelFile)
 continue;
-  assert(R.isTokenRange());
   // Try to cover up to the next token, spaces between children don't count.
   if (auto Tok = Lexer::findNextToken(R.getEnd(), SM, LangOpts))
 E.second = SM.getFileOffset(Tok->getLocation());
-  else
+  else if (R.isTokenRange())
 E.second += Lexer::MeasureTokenLength(R.getEnd(), SM, LangOpts);
   ChildRanges.push_back({B.second, E.second});
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58418: [clang][DirectoryWatcher] Upstream DirectoryWatcher

2019-02-20 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Also, don't forget that `inotify()` is not 100% reliable on Linux, and it can 
miss events under high loads. So technically you should probably include 
periodic directory scans if you are going to rely on this actually reporting 
every file added.




Comment at: clang/lib/DirectoryWatcher/DirectoryWatcher-linux.inc.h:101
+if (numRead == -1) {
+  return; // watcher is stopped.
+}

Looks like you're not handling `EINTR`.



Comment at: clang/lib/DirectoryWatcher/DirectoryWatcher-linux.inc.h:106
+for (char *p = buf; p < buf + numRead;) {
+  struct inotify_event *ievt = (struct inotify_event *)p;
+  p += sizeof(struct inotify_event) + ievt->len;

Maybe use C++ casts.

Also, I'd add some asserts for whether you've got enough data read.



Comment at: clang/lib/DirectoryWatcher/DirectoryWatcher-linux.inc.h:116
+
+  DirectoryWatcher::EventKind K = DirectoryWatcher::EventKind::Added;
+  if (ievt->mask & IN_MODIFY) {

I don't think I understand this assumption. Have you any specific event in mind 
that is supposed to be treated as added here? If not, maybe it'd be better to 
have no default and instead assert that one of the conditions below matched.



Comment at: clang/lib/DirectoryWatcher/DirectoryWatcher-linux.inc.h:135
+if (!statusOpt.hasValue())
+  K = DirectoryWatcher::EventKind::Removed;
+  }

Why? I suppose this deserves a comment.



Comment at: clang/lib/DirectoryWatcher/DirectoryWatcher-linux.inc.h:154
+errorMsg += llvm::sys::StrError();
+return true;
+  };

The return values seem to be confusing. Any reason not to use `true` for 
success?



Comment at: clang/lib/DirectoryWatcher/DirectoryWatcher-linux.inc.h:193
+return;
+  close(inotifyFD);
+  inotifyFD = -1;

You're ignoring return value.



Comment at: clang/lib/DirectoryWatcher/DirectoryWatcher.cpp:95
+
+#if !defined(__has_include)
+#define __has_include(x) 0

Why not use CMake checks? You're already partially using them for frameworks.


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

https://reviews.llvm.org/D58418



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


[PATCH] D57883: [clang-tidy] refactor ExceptionAnalyzer further to give ternary answer

2019-02-20 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 187634.
JonasToth marked 2 inline comments as done.
JonasToth added a comment.

- [Refactor] move support classes into the analyzer
- [Refactor] move bigger methods into implementation file
- minor adjustments


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57883

Files:
  clang-tidy/bugprone/ExceptionEscapeCheck.cpp
  clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tidy/utils/ExceptionAnalyzer.h

Index: clang-tidy/utils/ExceptionAnalyzer.h
===
--- clang-tidy/utils/ExceptionAnalyzer.h
+++ clang-tidy/utils/ExceptionAnalyzer.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_EXCEPTION_ANALYZER_H
 
 #include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringSet.h"
 
@@ -17,29 +18,131 @@
 namespace tidy {
 namespace utils {
 
-/// This class analysis if a `FunctionDecl` can in principle throw an exception,
-/// either directly or indirectly.
-/// It can be configured to ignore custom exception types.
+/// This class analysis if a `FunctionDecl` can in principle throw an
+/// exception, either directly or indirectly. It can be configured to ignore
+/// custom exception types.
 class ExceptionAnalyzer {
 public:
+  enum class State : std::int8_t {
+Throwing,///< The function can definitly throw given an AST.
+NotThrowing, ///< This function can not throw, given an AST.
+Unknown, ///< This can happen for extern functions without available
+ ///< definition.
+  };
+
+  /// Bundle the gathered information about an entity like a function regarding
+  /// it's exception behaviour. The 'NonThrowing'-state can be considered as the
+  /// neutral element in terms of information propagation.
+  /// In the case of 'Throwing' state it is possible that 'getExceptionTypes'
+  /// does not include *ALL* possible types as there is the possibility that
+  /// an 'Unknown' function is called that might throw a previously unknown
+  /// exception at runtime.
+  class ExceptionInfo {
+  public:
+using Throwables = llvm::SmallSet;
+static ExceptionInfo createUnknown() {
+  return ExceptionInfo(State::Unknown);
+}
+static ExceptionInfo createNonThrowing() {
+  return ExceptionInfo(State::Throwing);
+}
+
+/// By default the exception situation is unknown and must be
+/// clarified step-wise.
+ExceptionInfo() : Behaviour(State::NotThrowing), ContainsUnknown(false) {}
+ExceptionInfo(State S)
+: Behaviour(S), ContainsUnknown(S == State::Unknown) {}
+
+ExceptionInfo(const ExceptionInfo &) = default;
+ExceptionInfo &operator=(const ExceptionInfo &) = default;
+ExceptionInfo(ExceptionInfo &&) = default;
+ExceptionInfo &operator=(ExceptionInfo &&) = default;
+
+State getBehaviour() const { return Behaviour; }
+
+/// Register a single exception type as recognized potential exception to be
+/// thrown.
+void registerException(const Type *ExceptionType);
+
+/// Registers a `SmallVector` of exception types as recognized potential
+/// exceptions to be thrown.
+void registerExceptions(const Throwables &Exceptions);
+
+/// Updates the local state according to the other state. That means if
+/// for example a function contains multiple statements the 'ExceptionInfo'
+/// for the final function is the merged result of each statement.
+/// If one of these statements throws the whole function throws and if one
+/// part is unknown and the rest is non-throwing the result will be
+/// unknown.
+ExceptionInfo &merge(const ExceptionInfo &Other);
+
+/// This method is useful in case 'catch' clauses are analyzed as it is
+/// possible to catch multiple exception types by one 'catch' if they
+/// are a subclass of the 'catch'ed exception type.
+/// Returns 'true' if some exceptions were filtered, otherwise 'false'.
+bool filterByCatch(const Type *BaseClass);
+
+/// Filter the set of thrown exception type against a set of ignored
+/// types that shall not be considered in the exception analysis.
+/// This includes explicit `std::bad_alloc` ignoring as separate option.
+ExceptionInfo &
+filterIgnoredExceptions(const llvm::StringSet<> &IgnoredTypes,
+bool IgnoreBadAlloc);
+
+/// Clear the state to 'NonThrowing' to make the corresponding entity
+/// neutral.
+void clear();
+
+/// References the set of known exception types that can escape from the
+/// corresponding entity.
+const Throwables &getExceptionTypes() const { return ThrownExceptions; }
+
+/// Signal if the there is any 'Unknown' element within the scope of
+/// the related entity. This might be relevant if the entity is 'Throwing'
+/// and to ensure that no othe

[PATCH] D57883: [clang-tidy] refactor ExceptionAnalyzer further to give ternary answer

2019-02-20 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth marked 3 inline comments as done.
JonasToth added a comment.

all comments resolved. I will land this now.




Comment at: clang-tidy/utils/ExceptionAnalyzer.h:26-31
+  enum class State : std::int8_t {
+Throwing,///< The function can definitly throw given an AST.
+NotThrowing, ///< This function can not throw, given an AST.
+Unknown, ///< This can happen for extern functions without available
+ ///< definition.
+  };

lebedev.ri wrote:
> Since this is later used in a bit field, it might be better to be explicit 
> ```
>   enum class State : std::int8_t {
> Throwing = 0,///< The function can definitly throw given an AST.
> NotThrowing = 1, ///< This function can not throw, given an AST.
> Unknown = 2, ///< This can happen for extern functions without 
> available
>  ///< definition.
>   };
> ```
> and indeed, only 2 bits needed.
Done.



Comment at: clang-tidy/utils/ExceptionAnalyzer.h:128
+/// throw, if it's unknown or if it won't throw.
+enum State Behaviour : 4;
+

baloghadamsoftware wrote:
> Why 4 bits, not just 2? Can we expect additional states?
True, math not so strong in me :D


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57883



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


[PATCH] D57883: [clang-tidy] refactor ExceptionAnalyzer further to give ternary answer

2019-02-20 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 187635.
JonasToth marked an inline comment as done.
JonasToth added a comment.

- be explicit about the State enumerator values


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57883

Files:
  clang-tidy/bugprone/ExceptionEscapeCheck.cpp
  clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tidy/utils/ExceptionAnalyzer.h

Index: clang-tidy/utils/ExceptionAnalyzer.h
===
--- clang-tidy/utils/ExceptionAnalyzer.h
+++ clang-tidy/utils/ExceptionAnalyzer.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_EXCEPTION_ANALYZER_H
 
 #include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringSet.h"
 
@@ -17,29 +18,131 @@
 namespace tidy {
 namespace utils {
 
-/// This class analysis if a `FunctionDecl` can in principle throw an exception,
-/// either directly or indirectly.
-/// It can be configured to ignore custom exception types.
+/// This class analysis if a `FunctionDecl` can in principle throw an
+/// exception, either directly or indirectly. It can be configured to ignore
+/// custom exception types.
 class ExceptionAnalyzer {
 public:
+  enum class State : std::int8_t {
+Throwing = 0,///< The function can definitly throw given an AST.
+NotThrowing = 1, ///< This function can not throw, given an AST.
+Unknown = 2, ///< This can happen for extern functions without available
+ ///< definition.
+  };
+
+  /// Bundle the gathered information about an entity like a function regarding
+  /// it's exception behaviour. The 'NonThrowing'-state can be considered as the
+  /// neutral element in terms of information propagation.
+  /// In the case of 'Throwing' state it is possible that 'getExceptionTypes'
+  /// does not include *ALL* possible types as there is the possibility that
+  /// an 'Unknown' function is called that might throw a previously unknown
+  /// exception at runtime.
+  class ExceptionInfo {
+  public:
+using Throwables = llvm::SmallSet;
+static ExceptionInfo createUnknown() {
+  return ExceptionInfo(State::Unknown);
+}
+static ExceptionInfo createNonThrowing() {
+  return ExceptionInfo(State::Throwing);
+}
+
+/// By default the exception situation is unknown and must be
+/// clarified step-wise.
+ExceptionInfo() : Behaviour(State::NotThrowing), ContainsUnknown(false) {}
+ExceptionInfo(State S)
+: Behaviour(S), ContainsUnknown(S == State::Unknown) {}
+
+ExceptionInfo(const ExceptionInfo &) = default;
+ExceptionInfo &operator=(const ExceptionInfo &) = default;
+ExceptionInfo(ExceptionInfo &&) = default;
+ExceptionInfo &operator=(ExceptionInfo &&) = default;
+
+State getBehaviour() const { return Behaviour; }
+
+/// Register a single exception type as recognized potential exception to be
+/// thrown.
+void registerException(const Type *ExceptionType);
+
+/// Registers a `SmallVector` of exception types as recognized potential
+/// exceptions to be thrown.
+void registerExceptions(const Throwables &Exceptions);
+
+/// Updates the local state according to the other state. That means if
+/// for example a function contains multiple statements the 'ExceptionInfo'
+/// for the final function is the merged result of each statement.
+/// If one of these statements throws the whole function throws and if one
+/// part is unknown and the rest is non-throwing the result will be
+/// unknown.
+ExceptionInfo &merge(const ExceptionInfo &Other);
+
+/// This method is useful in case 'catch' clauses are analyzed as it is
+/// possible to catch multiple exception types by one 'catch' if they
+/// are a subclass of the 'catch'ed exception type.
+/// Returns 'true' if some exceptions were filtered, otherwise 'false'.
+bool filterByCatch(const Type *BaseClass);
+
+/// Filter the set of thrown exception type against a set of ignored
+/// types that shall not be considered in the exception analysis.
+/// This includes explicit `std::bad_alloc` ignoring as separate option.
+ExceptionInfo &
+filterIgnoredExceptions(const llvm::StringSet<> &IgnoredTypes,
+bool IgnoreBadAlloc);
+
+/// Clear the state to 'NonThrowing' to make the corresponding entity
+/// neutral.
+void clear();
+
+/// References the set of known exception types that can escape from the
+/// corresponding entity.
+const Throwables &getExceptionTypes() const { return ThrownExceptions; }
+
+/// Signal if the there is any 'Unknown' element within the scope of
+/// the related entity. This might be relevant if the entity is 'Throwing'
+/// and to ensure that no other exception then 'getExceptionTypes' can
+/// occur. If there 

r354509 - [OPENMP] Use targetDiag for diagnostics of unsupported exceptions, NFC.

2019-02-20 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Feb 20 11:37:17 2019
New Revision: 354509

URL: http://llvm.org/viewvc/llvm-project?rev=354509&view=rev
Log:
[OPENMP] Use targetDiag for diagnostics of unsupported exceptions, NFC.

Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=354509&r1=354508&r2=354509&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Feb 20 11:37:17 2019
@@ -752,10 +752,7 @@ ExprResult Sema::BuildCXXThrow(SourceLoc
   if (!getLangOpts().CXXExceptions &&
   !getSourceManager().isInSystemHeader(OpLoc)) {
 // Delay error emission for the OpenMP device code.
-if (LangOpts.OpenMP && LangOpts.OpenMPIsDevice)
-  diagIfOpenMPDeviceCode(OpLoc, diag::err_exceptions_disabled) << "throw";
-else
-  Diag(OpLoc, diag::err_exceptions_disabled) << "throw";
+targetDiag(OpLoc, diag::err_exceptions_disabled) << "throw";
   }
 
   // Exceptions aren't allowed in CUDA device code.

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=354509&r1=354508&r2=354509&view=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Feb 20 11:37:17 2019
@@ -3995,10 +3995,7 @@ StmtResult Sema::ActOnCXXTryBlock(Source
   if (!getLangOpts().CXXExceptions &&
   !getSourceManager().isInSystemHeader(TryLoc)) {
 // Delay error emission for the OpenMP device code.
-if (LangOpts.OpenMP && LangOpts.OpenMPIsDevice)
-  diagIfOpenMPDeviceCode(TryLoc, diag::err_exceptions_disabled) << "try";
-else
-  Diag(TryLoc, diag::err_exceptions_disabled) << "try";
+targetDiag(TryLoc, diag::err_exceptions_disabled) << "try";
   }
 
   // Exceptions aren't allowed in CUDA device code.


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


[PATCH] D57577: Make predefined FLT16 macros conditional on support for the type

2019-02-20 Thread Nemanja Ivanovic via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354512: Make predefined FLT16 macros conditional on support 
for the type (authored by nemanjai, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57577?vs=185088&id=187648#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57577

Files:
  cfe/trunk/lib/Frontend/InitPreprocessor.cpp
  cfe/trunk/test/Headers/float16.c
  cfe/trunk/test/Preprocessor/init.c


Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -9166,20 +9166,20 @@
 // WEBASSEMBLY-NOT:#define __ELF__
 // WEBASSEMBLY-NEXT:#define __FINITE_MATH_ONLY__ 0
 // WEBASSEMBLY-NEXT:#define __FLOAT128__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_DECIMAL_DIG__ 5
-// WEBASSEMBLY-NEXT:#define __FLT16_DENORM_MIN__ 5.9604644775390625e-8F16
-// WEBASSEMBLY-NEXT:#define __FLT16_DIG__ 3
-// WEBASSEMBLY-NEXT:#define __FLT16_EPSILON__ 9.765625e-4F16
-// WEBASSEMBLY-NEXT:#define __FLT16_HAS_DENORM__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_HAS_INFINITY__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_HAS_QUIET_NAN__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_MANT_DIG__ 11
-// WEBASSEMBLY-NEXT:#define __FLT16_MAX_10_EXP__ 4
-// WEBASSEMBLY-NEXT:#define __FLT16_MAX_EXP__ 15
-// WEBASSEMBLY-NEXT:#define __FLT16_MAX__ 6.5504e+4F16
-// WEBASSEMBLY-NEXT:#define __FLT16_MIN_10_EXP__ (-13)
-// WEBASSEMBLY-NEXT:#define __FLT16_MIN_EXP__ (-14)
-// WEBASSEMBLY-NEXT:#define __FLT16_MIN__ 6.103515625e-5F16
+// WEBASSEMBLY-NOT:#define __FLT16_DECIMAL_DIG__
+// WEBASSEMBLY-NOT:#define __FLT16_DENORM_MIN__
+// WEBASSEMBLY-NOT:#define __FLT16_DIG__
+// WEBASSEMBLY-NOT:#define __FLT16_EPSILON__
+// WEBASSEMBLY-NOT:#define __FLT16_HAS_DENORM__
+// WEBASSEMBLY-NOT:#define __FLT16_HAS_INFINITY__
+// WEBASSEMBLY-NOT:#define __FLT16_HAS_QUIET_NAN__
+// WEBASSEMBLY-NOT:#define __FLT16_MANT_DIG__
+// WEBASSEMBLY-NOT:#define __FLT16_MAX_10_EXP__
+// WEBASSEMBLY-NOT:#define __FLT16_MAX_EXP__
+// WEBASSEMBLY-NOT:#define __FLT16_MAX__
+// WEBASSEMBLY-NOT:#define __FLT16_MIN_10_EXP__
+// WEBASSEMBLY-NOT:#define __FLT16_MIN_EXP__
+// WEBASSEMBLY-NOT:#define __FLT16_MIN__
 // WEBASSEMBLY-NEXT:#define __FLT_DECIMAL_DIG__ 9
 // WEBASSEMBLY-NEXT:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // WEBASSEMBLY-NEXT:#define __FLT_DIG__ 6
Index: cfe/trunk/test/Headers/float16.c
===
--- cfe/trunk/test/Headers/float16.c
+++ cfe/trunk/test/Headers/float16.c
@@ -1,7 +1,11 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -ffreestanding %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -ffreestanding %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -ffreestanding %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -x c++ -ffreestanding %s
+// RUN: %clang_cc1 -triple=aarch64-none-none -fsyntax-only -verify -std=c89 \
+// RUN:   -ffreestanding %s
+// RUN: %clang_cc1 -triple=aarch64-none-none -fsyntax-only -verify \
+// RUN:   -std=c99 -ffreestanding %s
+// RUN: %clang_cc1 -triple=aarch64-none-none -fsyntax-only -verify -std=c11 \
+// RUN:   -ffreestanding %s
+// RUN: %clang_cc1 -triple=aarch64-none-none -fsyntax-only -verify \
+// RUN:   -std=c++11 -x c++ -ffreestanding %s
 // expected-no-diagnostics
 
 #define __STDC_WANT_IEC_60559_TYPES_EXT__
Index: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
===
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp
@@ -830,7 +830,8 @@
   DefineFmt("__UINTPTR", TI.getUIntPtrType(), TI, Builder);
   DefineTypeWidth("__UINTPTR_WIDTH__", TI.getUIntPtrType(), TI, Builder);
 
-  DefineFloatMacros(Builder, "FLT16", &TI.getHalfFormat(), "F16");
+  if (TI.hasFloat16Type())
+DefineFloatMacros(Builder, "FLT16", &TI.getHalfFormat(), "F16");
   DefineFloatMacros(Builder, "FLT", &TI.getFloatFormat(), "F");
   DefineFloatMacros(Builder, "DBL", &TI.getDoubleFormat(), "");
   DefineFloatMacros(Builder, "LDBL", &TI.getLongDoubleFormat(), "L");


Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -9166,20 +9166,20 @@
 // WEBASSEMBLY-NOT:#define __ELF__
 // WEBASSEMBLY-NEXT:#define __FINITE_MATH_ONLY__ 0
 // WEBASSEMBLY-NEXT:#define __FLOAT128__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_DECIMAL_DIG__ 5
-// WEBASSEMBLY-NEXT:#define __FLT16_DENORM_MIN__ 5.9604644775390625e-8F16
-// WEBASSEMBLY-NEXT:#define __FLT16_DIG__ 3
-// WEBASSEMBLY-NEXT:#define __FLT16_EPSILON__ 9.765625e-4F16
-// WEBASSEMBLY-NEXT:#define __FLT16_HAS_DENORM__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_HAS_INFINITY__ 1
-// WEBASSEMBLY-NEXT:#defi

r354512 - Make predefined FLT16 macros conditional on support for the type

2019-02-20 Thread Nemanja Ivanovic via cfe-commits
Author: nemanjai
Date: Wed Feb 20 12:27:33 2019
New Revision: 354512

URL: http://llvm.org/viewvc/llvm-project?rev=354512&view=rev
Log:
Make predefined FLT16 macros conditional on support for the type

We unconditionally predefine these macros. However, they may be used to
determine if the type is supported. In that case, there are unnecessary
failures to compile the code.

This is the proposed fix for https://bugs.llvm.org/show_bug.cgi?id=40559

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

Modified:
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Headers/float16.c
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=354512&r1=354511&r2=354512&view=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Wed Feb 20 12:27:33 2019
@@ -830,7 +830,8 @@ static void InitializePredefinedMacros(c
   DefineFmt("__UINTPTR", TI.getUIntPtrType(), TI, Builder);
   DefineTypeWidth("__UINTPTR_WIDTH__", TI.getUIntPtrType(), TI, Builder);
 
-  DefineFloatMacros(Builder, "FLT16", &TI.getHalfFormat(), "F16");
+  if (TI.hasFloat16Type())
+DefineFloatMacros(Builder, "FLT16", &TI.getHalfFormat(), "F16");
   DefineFloatMacros(Builder, "FLT", &TI.getFloatFormat(), "F");
   DefineFloatMacros(Builder, "DBL", &TI.getDoubleFormat(), "");
   DefineFloatMacros(Builder, "LDBL", &TI.getLongDoubleFormat(), "L");

Modified: cfe/trunk/test/Headers/float16.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/float16.c?rev=354512&r1=354511&r2=354512&view=diff
==
--- cfe/trunk/test/Headers/float16.c (original)
+++ cfe/trunk/test/Headers/float16.c Wed Feb 20 12:27:33 2019
@@ -1,7 +1,11 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -ffreestanding %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -ffreestanding %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -ffreestanding %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -x c++ -ffreestanding %s
+// RUN: %clang_cc1 -triple=aarch64-none-none -fsyntax-only -verify -std=c89 \
+// RUN:   -ffreestanding %s
+// RUN: %clang_cc1 -triple=aarch64-none-none -fsyntax-only -verify \
+// RUN:   -std=c99 -ffreestanding %s
+// RUN: %clang_cc1 -triple=aarch64-none-none -fsyntax-only -verify -std=c11 \
+// RUN:   -ffreestanding %s
+// RUN: %clang_cc1 -triple=aarch64-none-none -fsyntax-only -verify \
+// RUN:   -std=c++11 -x c++ -ffreestanding %s
 // expected-no-diagnostics
 
 #define __STDC_WANT_IEC_60559_TYPES_EXT__

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=354512&r1=354511&r2=354512&view=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Wed Feb 20 12:27:33 2019
@@ -9166,20 +9166,20 @@
 // WEBASSEMBLY-NOT:#define __ELF__
 // WEBASSEMBLY-NEXT:#define __FINITE_MATH_ONLY__ 0
 // WEBASSEMBLY-NEXT:#define __FLOAT128__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_DECIMAL_DIG__ 5
-// WEBASSEMBLY-NEXT:#define __FLT16_DENORM_MIN__ 5.9604644775390625e-8F16
-// WEBASSEMBLY-NEXT:#define __FLT16_DIG__ 3
-// WEBASSEMBLY-NEXT:#define __FLT16_EPSILON__ 9.765625e-4F16
-// WEBASSEMBLY-NEXT:#define __FLT16_HAS_DENORM__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_HAS_INFINITY__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_HAS_QUIET_NAN__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_MANT_DIG__ 11
-// WEBASSEMBLY-NEXT:#define __FLT16_MAX_10_EXP__ 4
-// WEBASSEMBLY-NEXT:#define __FLT16_MAX_EXP__ 15
-// WEBASSEMBLY-NEXT:#define __FLT16_MAX__ 6.5504e+4F16
-// WEBASSEMBLY-NEXT:#define __FLT16_MIN_10_EXP__ (-13)
-// WEBASSEMBLY-NEXT:#define __FLT16_MIN_EXP__ (-14)
-// WEBASSEMBLY-NEXT:#define __FLT16_MIN__ 6.103515625e-5F16
+// WEBASSEMBLY-NOT:#define __FLT16_DECIMAL_DIG__
+// WEBASSEMBLY-NOT:#define __FLT16_DENORM_MIN__
+// WEBASSEMBLY-NOT:#define __FLT16_DIG__
+// WEBASSEMBLY-NOT:#define __FLT16_EPSILON__
+// WEBASSEMBLY-NOT:#define __FLT16_HAS_DENORM__
+// WEBASSEMBLY-NOT:#define __FLT16_HAS_INFINITY__
+// WEBASSEMBLY-NOT:#define __FLT16_HAS_QUIET_NAN__
+// WEBASSEMBLY-NOT:#define __FLT16_MANT_DIG__
+// WEBASSEMBLY-NOT:#define __FLT16_MAX_10_EXP__
+// WEBASSEMBLY-NOT:#define __FLT16_MAX_EXP__
+// WEBASSEMBLY-NOT:#define __FLT16_MAX__
+// WEBASSEMBLY-NOT:#define __FLT16_MIN_10_EXP__
+// WEBASSEMBLY-NOT:#define __FLT16_MIN_EXP__
+// WEBASSEMBLY-NOT:#define __FLT16_MIN__
 // WEBASSEMBLY-NEXT:#define __FLT_DECIMAL_DIG__ 9
 // WEBASSEMBLY-NEXT:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // WEBASSEMBLY-NEXT:#define __FLT_DIG__ 6


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

[PATCH] D58365: [attributes] Add a MIG server routine attribute.

2019-02-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 187656.
NoQ marked 5 inline comments as done.
NoQ added a comment.

Fxd.


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

https://reviews.llvm.org/D58365

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-mig.c
  clang/test/Sema/attr-mig.cpp
  clang/test/Sema/attr-mig.m

Index: clang/test/Sema/attr-mig.m
===
--- /dev/null
+++ clang/test/Sema/attr-mig.m
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
+
+typedef int kern_return_t;
+#define KERN_SUCCESS 0
+
+@interface NSObject
+@end
+
+@interface I: NSObject
+- (kern_return_t)foo __attribute__((mig_server_routine)); // no-warning
+- (void) bar_void __attribute__((mig_server_routine)); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
+- (int) bar_int __attribute__((mig_server_routine)); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
+@end
+
+@implementation I
+- (kern_return_t)foo {
+  kern_return_t (^block)() = ^ __attribute__((mig_server_routine)) { // no-warning
+return KERN_SUCCESS;
+  };
+
+  // FIXME: Warn that this block doesn't return a kern_return_t.
+  void (^invalid_block)() = ^ __attribute__((mig_server_routine)) {};
+
+  return block();
+}
+- (void)bar_void {
+}
+- (int)bar_int {
+  return 0;
+}
+@end
Index: clang/test/Sema/attr-mig.cpp
===
--- /dev/null
+++ clang/test/Sema/attr-mig.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef int kern_return_t;
+typedef kern_return_t IOReturn;
+#define KERN_SUCCESS 0
+#define kIOReturnSuccess KERN_SUCCESS
+
+class MyServer {
+public:
+  virtual __attribute__((mig_server_routine)) IOReturn externalMethod();
+  virtual __attribute__((mig_server_routine)) void anotherMethod(); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
+  virtual __attribute__((mig_server_routine)) int yetAnotherMethod(); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
+  [[clang::mig_server_routine]] virtual IOReturn cppAnnotatedMethod();
+  [[clang::mig_server_routine("arg")]] virtual IOReturn cppAnnotatedMethodWithInvalidArgs(); // expected-error{{'mig_server_routine' attribute takes no arguments}}
+  [[clang::mig_server_routine]] virtual int cppInvalidAnnotatedMethod(); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
+};
+
+IOReturn MyServer::externalMethod() {
+  return kIOReturnSuccess;
+}
Index: clang/test/Sema/attr-mig.c
===
--- /dev/null
+++ clang/test/Sema/attr-mig.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef int kern_return_t;
+#define KERN_SUCCESS 0
+
+__attribute__((mig_server_routine)) kern_return_t var = KERN_SUCCESS; // expected-warning{{'mig_server_routine' attribute only applies to functions, Objective-C methods, and blocks}}
+
+__attribute__((mig_server_routine)) void foo_void(); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
+__attribute__((mig_server_routine)) int foo_int(); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
+
+__attribute__((mig_server_routine)) kern_return_t bar_extern(); // no-warning
+__attribute__((mig_server_routine)) kern_return_t bar_forward(); // no-warning
+
+__attribute__((mig_server_routine)) kern_return_t bar_definition() { // no-warning
+  return KERN_SUCCESS;
+}
+
+kern_return_t bar_forward() { // no-warning
+  return KERN_SUCCESS;
+}
+
+__attribute__((mig_server_routine(123))) kern_return_t bar_with_argument(); // expected-error{{'mig_server_routine' attribute takes no arguments}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -60,6 +60,7 @@
 // CHECK-NEXT: InternalLinkage (SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_record)
 // CHECK-NEXT: LTOVisibilityPublic (SubjectMatchRule_record)
 // CHECK-NEXT: Lockable (SubjectMatchRule_record)
+// CHECK-NEXT: MIGServerRoutine (SubjectMatchRule_function)
 // CHECK-NEXT: MSStruct (SubjectMatchRule_record)
 // CHECK-NEXT: MicroMips (SubjectMatchRule_function)
 // CHECK-NEXT: MinSize (SubjectMatchRule_function, SubjectMatchRule_objc_method)
Index: clang/lib/Sema/Sem

[PATCH] D58365: [attributes] Add a MIG server routine attribute.

2019-02-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/test/Sema/attr-mig.c:6
+
+__attribute__((mig_server_routine)) kern_return_t var = KERN_SUCCESS; // 
expected-warning-re{{'mig_server_routine' attribute only applies to functions, 
Objective-C methods, and blocks{{$
+

aaron.ballman wrote:
> What's the purpose of the `{{$}}`?
Hmm, right. In the previous, emm, revision of this revision i felt the urge to 
force the end-ofline check in order to discriminate between the two warnings 
that i introduced, out of which one is an initial segment of the other. But 
now, given that we have ", and", i guess it's no longer necessary.


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

https://reviews.llvm.org/D58365



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


[PATCH] D58367: [analyzer] NFC: Improve upon the concept of BugReporterVisitor.

2019-02-20 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso requested changes to this revision.
Charusso added a comment.
This revision now requires changes to proceed.

First of all, thanks you for working on this, as I wanted to do the same, but I 
did not know how to. I did not know also that 15 of the checkers already 
implements `BugReporterVisitors`, but I completely shocked it took 10 years of 
pain to rewrite it. It feels like this patch a little-bit brute-force, and I 
believe this should be the future direction of reporting. Also I believe in 
that we could hook a lot more useful information from *all* the checkers, and 
we do not care that much about the core `BugReporterVisitors` as they do their 
job enough well. So with that, I would out-chain this patch from the 
MIG-patches because it is a lot more serious problem-set. I also would like to 
ask you to take it more serious, as all your mentioned benefits will rely on 
this simple and cool approach, so it has to be flexible as possible. I am not 
into the internal stuff that much, so I cannot argue about the lack of 
`CheckerContext` functions, but I think this is a huge problem and breaks the 
flexibility a lot.

I tried out the patch and saw the very recommended source code of 
`MallocChecker`'s so lightweight `BugReporterVisitor` implementation and I 
think your API is too strict about having a lambda function, so here is my 
ideas:

- `CheckerContext.h`: As I see we only work with a `string`, nothing else, so I 
would extend that class:

  ExplodedNode *addNote(ProgramStateRef State, StringRef Message) {
return addTransitionImpl(State, false, nullptr, setNoteTag(Message)); // 
Note the 'setNoteTag()'
  }

`getNoteTag()`: you could differentiate a setter with the true getter what you 
only use in `TagVisitor::VisitNode()` (where you truly hook your `Callback` to 
get extra information later on):

  const NoteTag *setNoteTag(StringRef Message) {
return Eng.getNoteTags().setNoteTag(Message);
  }



- `BugReporterVisitors.h`: basically a `NoteTag` is a string, nothing else, I 
think you would like to hook the `Callback` only when you are about to obtain 
the message:

  class NoteTag {
std::string Msg;
NoteTag(StringRef Message) : ProgramPointTag(&Kind), Msg(Message)
  
class Factory {
  const NoteTag *getNoteTag(Callback &&Cb)
  const NoteTag *setNoteTag(StringRef Message)
};
  };



- Documentation: if we are about the rewrite the entire bug-reporting business, 
it worth some long doxygen comments.

The outcome is that cool I have to be the reviewer in two patches, and I hope 
it helps you creating a better API, even if I got something wrong.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:364
+
+  Optional getNote(BugReporterContext &BRC, BugReport &R) const {
+std::string Note = Cb(BRC, R);

It feels like it returns the `NoteTag`, so I would rename it as `getMessage()`.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h:223
+  /// Produce a program point tag that displays an additional path note
+  /// to the user. This is a lightweirght alternative to the
+  /// BugReporterVisitor mechanism: instead of visiting the bug report

It is very randomly spaced, `lightweight`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58367



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


[PATCH] D58368: [analyzer] MIGChecker: Implement bug reporter visitors.

2019-02-20 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a reviewer: Charusso.
Charusso requested changes to this revision.
Charusso added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp:113
+  });
+  C.addTransition(C.getState()->set(true), T);
 }

This is a cool approach, but it is difficult to use this API in other checkers. 
If you do not out-chain D58367 I would like to see something like that here:

```
  SmallString<64> Str;
  llvm::raw_svector_ostream OS(Str);
  OS << "Deallocating object passed through parameter '" << PVD->getName()
 << '\'';

  C.addNote(C.getState()->set(true), OS.str());
```


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

https://reviews.llvm.org/D58368



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


[PATCH] D57883: [clang-tidy] refactor ExceptionAnalyzer further to give ternary answer

2019-02-20 Thread Jonas Toth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE354517: [clang-tidy] refactor ExceptionAnalyzer further to 
give ternary answer (authored by JonasToth, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D57883?vs=187635&id=187662#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57883

Files:
  clang-tidy/bugprone/ExceptionEscapeCheck.cpp
  clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tidy/utils/ExceptionAnalyzer.h

Index: clang-tidy/utils/ExceptionAnalyzer.h
===
--- clang-tidy/utils/ExceptionAnalyzer.h
+++ clang-tidy/utils/ExceptionAnalyzer.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_EXCEPTION_ANALYZER_H
 
 #include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringSet.h"
 
@@ -17,29 +18,131 @@
 namespace tidy {
 namespace utils {
 
-/// This class analysis if a `FunctionDecl` can in principle throw an exception,
-/// either directly or indirectly.
-/// It can be configured to ignore custom exception types.
+/// This class analysis if a `FunctionDecl` can in principle throw an
+/// exception, either directly or indirectly. It can be configured to ignore
+/// custom exception types.
 class ExceptionAnalyzer {
 public:
+  enum class State : std::int8_t {
+Throwing = 0,///< The function can definitly throw given an AST.
+NotThrowing = 1, ///< This function can not throw, given an AST.
+Unknown = 2, ///< This can happen for extern functions without available
+ ///< definition.
+  };
+
+  /// Bundle the gathered information about an entity like a function regarding
+  /// it's exception behaviour. The 'NonThrowing'-state can be considered as the
+  /// neutral element in terms of information propagation.
+  /// In the case of 'Throwing' state it is possible that 'getExceptionTypes'
+  /// does not include *ALL* possible types as there is the possibility that
+  /// an 'Unknown' function is called that might throw a previously unknown
+  /// exception at runtime.
+  class ExceptionInfo {
+  public:
+using Throwables = llvm::SmallSet;
+static ExceptionInfo createUnknown() {
+  return ExceptionInfo(State::Unknown);
+}
+static ExceptionInfo createNonThrowing() {
+  return ExceptionInfo(State::Throwing);
+}
+
+/// By default the exception situation is unknown and must be
+/// clarified step-wise.
+ExceptionInfo() : Behaviour(State::NotThrowing), ContainsUnknown(false) {}
+ExceptionInfo(State S)
+: Behaviour(S), ContainsUnknown(S == State::Unknown) {}
+
+ExceptionInfo(const ExceptionInfo &) = default;
+ExceptionInfo &operator=(const ExceptionInfo &) = default;
+ExceptionInfo(ExceptionInfo &&) = default;
+ExceptionInfo &operator=(ExceptionInfo &&) = default;
+
+State getBehaviour() const { return Behaviour; }
+
+/// Register a single exception type as recognized potential exception to be
+/// thrown.
+void registerException(const Type *ExceptionType);
+
+/// Registers a `SmallVector` of exception types as recognized potential
+/// exceptions to be thrown.
+void registerExceptions(const Throwables &Exceptions);
+
+/// Updates the local state according to the other state. That means if
+/// for example a function contains multiple statements the 'ExceptionInfo'
+/// for the final function is the merged result of each statement.
+/// If one of these statements throws the whole function throws and if one
+/// part is unknown and the rest is non-throwing the result will be
+/// unknown.
+ExceptionInfo &merge(const ExceptionInfo &Other);
+
+/// This method is useful in case 'catch' clauses are analyzed as it is
+/// possible to catch multiple exception types by one 'catch' if they
+/// are a subclass of the 'catch'ed exception type.
+/// Returns 'true' if some exceptions were filtered, otherwise 'false'.
+bool filterByCatch(const Type *BaseClass);
+
+/// Filter the set of thrown exception type against a set of ignored
+/// types that shall not be considered in the exception analysis.
+/// This includes explicit `std::bad_alloc` ignoring as separate option.
+ExceptionInfo &
+filterIgnoredExceptions(const llvm::StringSet<> &IgnoredTypes,
+bool IgnoreBadAlloc);
+
+/// Clear the state to 'NonThrowing' to make the corresponding entity
+/// neutral.
+void clear();
+
+/// References the set of known exception types that can escape from the
+/// corresponding entity.
+const Throwables &getExceptionTypes() const { return ThrownExceptions; }
+
+/// Signal if the there is any 'Unknown' element within the scope of
+/// the related entity. This might be relevant

[clang-tools-extra] r354517 - [clang-tidy] refactor ExceptionAnalyzer further to give ternary answer

2019-02-20 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Wed Feb 20 13:04:36 2019
New Revision: 354517

URL: http://llvm.org/viewvc/llvm-project?rev=354517&view=rev
Log:
[clang-tidy] refactor ExceptionAnalyzer further to give ternary answer

Summary:
The analsis on the throwing behvaiour on functions and statements gave only
a binary answer whether an exception could occur and if yes which types are
thrown.
This refactoring allows keeping track if there is a unknown factor, because the
code calls to some functions with unavailable source code with no `noexcept`
information.
This 'potential Unknown' information is propagated properly and can be queried
separately.

Reviewers: lebedev.ri, aaron.ballman, baloghadamsoftware, alexfh

Reviewed By: lebedev.ri, baloghadamsoftware

Subscribers: xazax.hun, rnkovacs, a.sidorin, Szelethus, donat.nagy, dkrupp, 
cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp
clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp?rev=354517&r1=354516&r2=354517&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp Wed 
Feb 20 13:04:36 2019
@@ -42,6 +42,7 @@ ExceptionEscapeCheck::ExceptionEscapeChe
   IgnoredExceptions.insert(IgnoredExceptionsVec.begin(),
IgnoredExceptionsVec.end());
   Tracer.ignoreExceptions(std::move(IgnoredExceptions));
+  Tracer.ignoreBadAlloc(true);
 }
 
 void ExceptionEscapeCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
@@ -70,7 +71,8 @@ void ExceptionEscapeCheck::check(const M
   if (!MatchedDecl)
 return;
 
-  if (Tracer.throwsException(MatchedDecl))
+  if (Tracer.analyze(MatchedDecl).getBehaviour() ==
+  utils::ExceptionAnalyzer::State::Throwing)
 // FIXME: We should provide more information about the exact location where
 // the exception is thrown, maybe the full path the exception escapes
 diag(MatchedDecl->getLocation(),

Modified: clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp?rev=354517&r1=354516&r2=354517&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp Wed Feb 20 
13:04:36 2019
@@ -8,10 +8,44 @@
 
 #include "ExceptionAnalyzer.h"
 
-#include "clang/AST/ASTContext.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-
 namespace clang {
+namespace tidy {
+namespace utils {
+
+void ExceptionAnalyzer::ExceptionInfo::registerException(
+const Type *ExceptionType) {
+  assert(ExceptionType != nullptr && "Only valid types are accepted");
+  Behaviour = State::Throwing;
+  ThrownExceptions.insert(ExceptionType);
+}
+
+void ExceptionAnalyzer::ExceptionInfo::registerExceptions(
+const Throwables &Exceptions) {
+  if (Exceptions.size() == 0)
+return;
+  Behaviour = State::Throwing;
+  ThrownExceptions.insert(Exceptions.begin(), Exceptions.end());
+}
+
+ExceptionAnalyzer::ExceptionInfo &ExceptionAnalyzer::ExceptionInfo::merge(
+const ExceptionAnalyzer::ExceptionInfo &Other) {
+  // Only the following two cases require an update to the local
+  // 'Behaviour'. If the local entity is already throwing there will be no
+  // change and if the other entity is throwing the merged entity will throw
+  // as well.
+  // If one of both entities is 'Unknown' and the other one does not throw
+  // the merged entity is 'Unknown' as well.
+  if (Other.Behaviour == State::Throwing)
+Behaviour = State::Throwing;
+  else if (Other.Behaviour == State::Unknown && Behaviour == 
State::NotThrowing)
+Behaviour = State::Unknown;
+
+  ContainsUnknown = ContainsUnknown || Other.ContainsUnknown;
+  ThrownExceptions.insert(Other.ThrownExceptions.begin(),
+  Other.ThrownExceptions.end());
+  return *this;
+}
+
 static bool isBaseOf(const Type *DerivedType, const Type *BaseType) {
   const auto *DerivedClass = DerivedType->getAsCXXRecordDecl();
   const auto *BaseClass = BaseType->getAsCXXRecordDecl();
@@ -22,36 +56,87 @@ static bool isBaseOf(const Type *Derived
   [BaseClass](const CXXRecordDecl *Cur) { return Cur != BaseClass; });
 }
 
-namespace tidy {
-namespace utils {
+bool ExceptionAnalyzer::ExceptionInfo::filterByCatch(const Type *BaseClass) {
+  llvm::SmallVector TypesToDelete;
+  for (const Type *T : ThrownExceptions) {
+if (T == BaseClass

[PATCH] D53076: [analyzer] Enhance ConditionBRVisitor to write out more information

2019-02-20 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

In D53076#1403436 , @NoQ wrote:

> I'll take a closer look in a few days, sorry for the delays! The progress 
> you're making is fantastic and i really appreciate your work, but i have an 
> urgent piece of work of my own to deal with this week.


@NoQ, please take your time, that new bug-report logic is the end of my work on 
reporting business (as I mentioned I wanted to create the same patch), so that 
is more important than this.


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

https://reviews.llvm.org/D53076



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


[PATCH] D58368: [analyzer] MIGChecker: Implement bug reporter visitors.

2019-02-20 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp:47
 
 REGISTER_TRAIT_WITH_PROGRAMSTATE(ReleasedParameter, bool);
 

`;` is not necessary.


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

https://reviews.llvm.org/D58368



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


[PATCH] D58314: [Driver] Sync ARM behavior between clang-as and gas.

2019-02-20 Thread Dan Albert via Phabricator via cfe-commits
danalbert updated this revision to Diff 187670.
danalbert marked 6 inline comments as done.
danalbert added a comment.

Updated to address some review comments:

- Additional tests for gnueabi/gnueabihf
- Fixed behavior for `-mfpu=neon -mfloat-abi=soft`, added test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58314

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/linux-as.c

Index: clang/test/Driver/linux-as.c
===
--- clang/test/Driver/linux-as.c
+++ clang/test/Driver/linux-as.c
@@ -3,17 +3,17 @@
 // RUN: %clang -target arm-linux -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM %s
-// CHECK-ARM: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft"
+// CHECK-ARM: as{{(.exe)?}}" "-EL" "-march=armv4t" "-mfloat-abi=soft"
 //
 // RUN: %clang -target arm-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MCPU %s
-// CHECK-ARM-MCPU: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-ARM-MCPU: as{{(.exe)?}}" "-EL" "-march=armv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target arm-linux -mfpu=neon -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MFPU %s
-// CHECK-ARM-MFPU: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft" "-mfpu=neon"
+// CHECK-ARM-MFPU: as{{(.exe)?}}" "-EL" "-march=armv4t" "-mfloat-abi=soft" "-mfpu=neon"
 //
 // RUN: %clang -target arm-linux -march=armv7-a -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
@@ -63,62 +63,97 @@
 // RUN: %clang -target armv7-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-TARGET %s
-// CHECK-ARM-TARGET: as{{(.exe)?}}" "-EL" "-mfpu=neon" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-ARM-TARGET: as{{(.exe)?}}" "-EL" "-march=armv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target armebv7-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARMEB-TARGET %s
-// CHECK-ARMEB-TARGET: as{{(.exe)?}}" "-EB" "-mfpu=neon" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-ARMEB-TARGET: as{{(.exe)?}}" "-EB" "-march=armebv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target thumbv7-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-THUMB-TARGET %s
-// CHECK-THUMB-TARGET: as{{(.exe)?}}" "-EL" "-mfpu=neon" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-THUMB-TARGET: as{{(.exe)?}}" "-EL" "-march=armv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target thumbebv7-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-THUMBEB-TARGET %s
-// CHECK-THUMBEB-TARGET: as{{(.exe)?}}" "-EB" "-mfpu=neon" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-THUMBEB-TARGET: as{{(.exe)?}}" "-EB" "-march=armebv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target armv8-linux -mcpu=cortex-a53 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-TARGET-V8 %s
-// CHECK-ARM-TARGET-V8: as{{(.exe)?}}" "-EL" "-mfpu=crypto-neon-fp-armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
+// CHECK-ARM-TARGET-V8: as{{(.exe)?}}" "-EL" "-march=armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
 //
 // RUN: %clang -target armebv8-linux -mcpu=cortex-a53 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARMEB-TARGET-V8 %s
-// CHECK-ARMEB-TARGET-V8: as{{(.exe)?}}" "-EB" "-mfpu=crypto-neon-fp-armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
+// CHECK-ARMEB-TARGET-V8: as{{(.exe)?}}" "-EB" "-march=armebv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
 //
 // RUN: %clang -target thumbv8-linux -mcpu=cortex-a53 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-THUMB-TARGET-V8 %s
-// CHECK-THUMB-TARGET-V8: as{{(.exe)?}}" "-EL" "-mfpu=crypto-neon-fp-armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
+// CHECK-THUMB-TARGET-V8: as{{(.exe)?}}" "-EL" "-march=armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
 //
 // RUN: %clang -target thumbebv8-linux -mcpu=cortex-a53 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-THUMBEB-TARGET-V8 %s
-// CHECK-THUMBEB-TARGET-V8: as{{(.exe)?}}" "-EB" "-mfpu=crypto-neon-fp-armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
+// CHECK-THUMBEB-TARGET-V8: as{{(.exe)?}}" "-EB" "-march=armebv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
 //
 // RUN: %clang -target arm-linux -mfloat-abi=hard -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MFLOAT-ABI %s
-// CHECK-ARM-MFLOAT-ABI: as{{(.exe)?}}" "-EL" "-mfloat-abi=hard"
+// CHE

[PATCH] D58314: [Driver] Sync ARM behavior between clang-as and gas.

2019-02-20 Thread Dan Albert via Phabricator via cfe-commits
danalbert added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/ARM.cpp:277
+  }
+  return "";
+}

peter.smith wrote:
> I'm a bit worried that we've changed the default behaviour for gnueabi[hf] 
> targets here. 
> For example with:
> ```
> .text
> vmov.32 d13[1], r6 ; Needs VFPv2
> vadd.i32 d0, d0, d0 ; Needs Neon
> ```
> I get with --target=armv7a-linux (no environment, -mfloat-abi will disable 
> floating point, and neon)
> ```
> clang: warning: unknown platform, assuming -mfloat-abi=soft
> neon.s:2:9: error: instruction requires: VFP2
> vmov.32 d13[1],r6
> ^
> neon.s:3:9: error: instruction requires: NEON
> vadd.i32 d0, d0, d0
> ^
> ```
> With the target=armv7a-linux-gnueabi armv7a-linux-gnueabihf or explicitly 
> adding -mfloat-abi=softfp the integrated assembler will happily assemble it.
> GNU needs -mfpu=neon to assemble the file:
> 
> ```
> arm-linux-gnueabihf-as -march=armv7-a neon.s 
> neon.s: Assembler messages:
> neon.s:2: Error: selected processor does not support ARM mode `vmov.32 
> d13[1],r6'
> neon.s:3: Error: selected processor does not support ARM mode `vadd.i32 
> d0,d0,d0'
> ```
> It is a similar story for armv8 and crypto.
> 
> I think we should have something like:
> ```
> if (Triple.isLinux() && getARMSubArchVersionNumber(Triple) >= 8)
>return "crypto-neon-fp-armv8";
> if (Triple.isAndroid() || Triple.isLinux() && 
> getARMSubArchVersionNumber(Triple) >= 7)
> return "neon";
> return "";
> ```
I suppose it depends on which direction you want the behavior change to go. I 
assumed those samples _shouldn't_ assemble since they're not enabling NEON. The 
fact that the direct `arm-linux-gnueabihf-as` doesn't enable NEON by default 
makes me assume that NEON is not an assumed feature of the gnueabihf 
environment.

It's not up to me whether NEON is available by default for ARMv7 for 
non-Android, but I do think that the behavior should be consistent regardless 
of the assembler being used. Right now we have no FPU by default with the 
integrated assembler and NEON by default with GAS. This change makes GAS have 
the same behavior as the integrated assembler, since I assume that is the 
better traveled path and afaict is the one that has had more effort put in to 
it.

If that's not right, I can change this so that the integrated assembler _also_ 
gets FPU features that are not necessarily available for the given 
architecture, but I wanted to clarify that that is what you're asking for first.



Comment at: clang/lib/Driver/ToolChains/Arch/ARM.cpp:389
+std::string DefaultFPU = getDefaultFPUName(Triple);
+if (DefaultFPU != "") {
+  if (!llvm::ARM::getFPUFeatures(llvm::ARM::parseFPU(DefaultFPU), 
Features))

peter.smith wrote:
> I'm wondering whether you need this bit of code anymore? In D53121 there 
> needed to be a switch between vfpv3-d16 and neon based on Android version. 
> With --target=armv7a-linux-android or --target=arm-linux-android 
> -march=armv7a or any v7a -mcpu applicable to Android then you'll get feature 
> Neon by default and won't need to do this? We could then move 
> getDefaultFPUName out of ARM.cpp
I don't understand. This bit of code is the piece that provides the NEON 
default. If I remove this then Android ARMv7 targets revert to no FPU features.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:692
+}
+if (!hasMOrWaMArg(Args, options::OPT_mfpu_EQ, "-mfpu=")) {
+std::string DefaultFPU = arm::getDefaultFPUName(Triple);

peter.smith wrote:
> I think we'd not want to do this for -mfloat-abi=soft as this disables the 
> FPU in the integrated assembler. It seems like -mfloat-abi has no effect at 
> all on the gnu assembler, it will happily assemble neon instructions with 
> -mfloat-abi=soft -mfpu=neon.
>  
Added a check for soft float ABI and added a test to match.



Comment at: clang/test/Driver/linux-as.c:3
 //
 // RUN: %clang -target arm-linux -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \

peter.smith wrote:
> the target arm-linux (effectively arm-linux-unknown) defaults to 
> -mfloat-abi=soft which disables the FPU for the integrated assembler. While 
> these test cases are not wrong, the number of v7a + linux targets without an 
> FPU using entirely software floating point is likely to be very small. We 
> should have some more that have arm-linux-gnueabi and arm-linux-gnueabihf.
Added a handful. Not really sure what needs to be tested here, but I covered 
the basic cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58314



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


[PATCH] D58463: [CUDA]Delayed diagnostics for the asm instructions.

2019-02-20 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

Thank you.




Comment at: lib/Sema/Sema.cpp:1494-1496
+if (getLangOpts().CUDAIsDevice)
+  return CUDADiagIfDeviceCode(Loc, DiagID);
+return CUDADiagIfHostCode(Loc, DiagID);

Nit: i'd use ternary op here or explicit if/else to indicate that 
CUDADiagIfDeviceCode/CUDADiagIfHostCode are treated the same and that 
CUDADiagIfHostCode() is *not* a catch-all of some kind.

```
return getLangOpts().CUDAIsDevice 
   ? CUDADiagIfDeviceCode(Loc, DiagID) 
   : CUDADiagIfHostCode(Loc, DiagID)

```


Repository:
  rC Clang

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

https://reviews.llvm.org/D58463



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


[PATCH] D58477: [Driver] Fix float ABI default for Android ARMv8.

2019-02-20 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added reviewers: srhines, pirama.
Herald added subscribers: kristof.beyls, javed.absar.
Herald added a project: clang.

Android doesn't regress back to soft float after ARMv7 :)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58477

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/Driver/arm-float-abi.c


Index: clang/test/Driver/arm-float-abi.c
===
--- clang/test/Driver/arm-float-abi.c
+++ clang/test/Driver/arm-float-abi.c
@@ -4,3 +4,13 @@
 
 // ARMV7-ERROR: unsupported option '-mfloat-abi=hard' for target 'thumbv7'
 // NOERROR-NOT: unsupported option
+
+// RUN: %clang -target armv7-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM7-ANDROID %s
+// CHECK-ARM7-ANDROID-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM7-ANDROID: "-target-feature" "+soft-float-abi"
+
+// RUN: %clang -target armv8-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM8-ANDROID %s
+// CHECK-ARM8-ANDROID-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM8-ANDROID: "-target-feature" "+soft-float-abi"
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -248,7 +248,7 @@
 ABI = FloatABI::SoftFP;
 break;
   case llvm::Triple::Android:
-ABI = (SubArch == 7) ? FloatABI::SoftFP : FloatABI::Soft;
+ABI = (SubArch >= 7) ? FloatABI::SoftFP : FloatABI::Soft;
 break;
   default:
 // Assume "soft", but warn the user we are guessing.


Index: clang/test/Driver/arm-float-abi.c
===
--- clang/test/Driver/arm-float-abi.c
+++ clang/test/Driver/arm-float-abi.c
@@ -4,3 +4,13 @@
 
 // ARMV7-ERROR: unsupported option '-mfloat-abi=hard' for target 'thumbv7'
 // NOERROR-NOT: unsupported option
+
+// RUN: %clang -target armv7-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM7-ANDROID %s
+// CHECK-ARM7-ANDROID-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM7-ANDROID: "-target-feature" "+soft-float-abi"
+
+// RUN: %clang -target armv8-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM8-ANDROID %s
+// CHECK-ARM8-ANDROID-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM8-ANDROID: "-target-feature" "+soft-float-abi"
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -248,7 +248,7 @@
 ABI = FloatABI::SoftFP;
 break;
   case llvm::Triple::Android:
-ABI = (SubArch == 7) ? FloatABI::SoftFP : FloatABI::Soft;
+ABI = (SubArch >= 7) ? FloatABI::SoftFP : FloatABI::Soft;
 break;
   default:
 // Assume "soft", but warn the user we are guessing.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58478: [index-while-building] FileIndexRecord

2019-02-20 Thread Jan Korous via Phabricator via cfe-commits
jkorous created this revision.
jkorous added reviewers: dexonsmith, nathawes, akyrtzi, arphaman, ioeric, 
malaperle.
Herald added subscribers: cfe-commits, jdoerfert, mgorny.
Herald added a project: clang.

Basic data structures for index

Tests are missing from this patch - will be covered properly by tests for the 
whole feature.
I'm just trying to split it into smaller patches to make it easier for 
reviewers.

This (with minor changes) was LGTM'ed here https://reviews.llvm.org/D39050. 
Adding original reviewers.


Repository:
  rC Clang

https://reviews.llvm.org/D58478

Files:
  clang/include/clang/Index/DeclOccurrence.h
  clang/lib/Index/CMakeLists.txt
  clang/lib/Index/FileIndexRecord.cpp
  clang/lib/Index/FileIndexRecord.h

Index: clang/lib/Index/FileIndexRecord.h
===
--- /dev/null
+++ clang/lib/Index/FileIndexRecord.h
@@ -0,0 +1,58 @@
+//===--- FileIndexRecord.h - Index data per file --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_INDEX_FILEINDEXRECORD_H
+#define LLVM_CLANG_LIB_INDEX_FILEINDEXRECORD_H
+
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Index/DeclOccurrence.h"
+#include "clang/Index/IndexSymbol.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/SmallVector.h"
+#include 
+
+namespace clang {
+class IdentifierInfo;
+
+namespace index {
+
+/// Stores the declaration occurrences seen in a particular source or header
+/// file of a translation unit
+class FileIndexRecord {
+private:
+  FileID FID;
+  bool IsSystem;
+  std::vector Decls;
+
+public:
+  FileIndexRecord(FileID FID, bool IsSystem) : FID(FID), IsSystem(IsSystem) {}
+
+  ArrayRef getDeclOccurrencesSortedByOffset() const {
+return Decls;
+  }
+
+  FileID getFileID() const { return FID; }
+  bool isSystem() const { return IsSystem; }
+
+  /// Adds an occurrence of the canonical declaration \c D at the supplied
+  /// \c Offset
+  ///
+  /// \param Roles the roles the occurrence fulfills in this position.
+  /// \param Offset the offset in the file of this occurrence.
+  /// \param D the canonical declaration this is an occurrence of.
+  /// \param Relations the set of symbols related to this occurrence.
+  void addDeclOccurence(SymbolRoleSet Roles, unsigned Offset, const Decl *D,
+ArrayRef Relations);
+  void print(llvm::raw_ostream &OS) const;
+};
+
+} // end namespace index
+} // end namespace clang
+
+#endif
Index: clang/lib/Index/FileIndexRecord.cpp
===
--- /dev/null
+++ clang/lib/Index/FileIndexRecord.cpp
@@ -0,0 +1,59 @@
+//===--- FileIndexRecord.cpp - Index data per file ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FileIndexRecord.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclTemplate.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/Path.h"
+
+using namespace clang;
+using namespace clang::index;
+
+void FileIndexRecord::addDeclOccurence(SymbolRoleSet Roles, unsigned Offset,
+   const Decl *D,
+   ArrayRef Relations) {
+  assert(D->isCanonicalDecl() &&
+ "Occurrences should be associated with their canonical decl");
+
+  auto IsNextOccurence = [&]() -> bool {
+if (Decls.empty())
+  return true;
+auto &Last = Decls.back();
+return Last.Offset < Offset;
+  };
+
+  if (IsNextOccurence()) {
+Decls.emplace_back(Roles, Offset, D, Relations);
+return;
+  }
+
+  DeclOccurrence NewInfo(Roles, Offset, D, Relations);
+  auto It = std::upper_bound(Decls.begin(), Decls.end(), NewInfo);
+  Decls.insert(It, std::move(NewInfo));
+}
+
+void FileIndexRecord::print(llvm::raw_ostream &OS) const {
+  OS << "DECLS BEGIN ---\n";
+  for (auto &DclInfo : Decls) {
+auto D = DclInfo.Dcl;
+SourceManager &SM = D->getASTContext().getSourceManager();
+SourceLocation Loc = SM.getFileLoc(D->getLocation());
+PresumedLoc PLoc = SM.getPresumedLoc(Loc);
+OS << llvm::sys::path::filename(PLoc.getFilename()) << ':' << PLoc.getLine()
+   << ':' << PLoc.getColumn();
+
+if (auto ND = dyn_cast(D)) {
+  OS << ' ' << ND->getNameAsString();
+}
+
+OS << '\n';
+  }
+  OS << "DECLS END ---\n";
+}
Index: clang/lib/Index/CMakeLists.txt
===
--- clang/lib/Index/CMakeLists.txt
+++ clang/lib/Index/CMakeLists.txt
@@ -6,6 +6,7 @@
 add_clang_library(c

[PATCH] D58480: [clang] Add CMake target for installing clang's CMake exports

2019-02-20 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
smeenai added reviewers: beanz, phosek.
Herald added a subscriber: mgorny.
Herald added a project: clang.
smeenai retitled this revision from "[clang] Add CMake target for clang's CMake 
exports" to "[clang] Add CMake target for installing clang's CMake exports".

This mirrors LLVM's install-cmake-exports target.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58480

Files:
  clang/cmake/modules/CMakeLists.txt


Index: clang/cmake/modules/CMakeLists.txt
===
--- clang/cmake/modules/CMakeLists.txt
+++ clang/cmake/modules/CMakeLists.txt
@@ -55,10 +55,19 @@
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   get_property(clang_has_exports GLOBAL PROPERTY CLANG_HAS_EXPORTS)
   if(clang_has_exports)
-install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR})
+install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}
+COMPONENT clang-cmake-exports)
   endif()
 
   install(FILES
 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfig.cmake
-DESTINATION ${CLANG_INSTALL_PACKAGE_DIR})
+DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}
+COMPONENT clang-cmake-exports)
+
+  if(NOT LLVM_ENABLE_IDE)
+# Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS
+add_custom_target(clang-cmake-exports)
+add_llvm_install_targets(install-clang-cmake-exports
+ COMPONENT clang-cmake-exports)
+  endif()
 endif()


Index: clang/cmake/modules/CMakeLists.txt
===
--- clang/cmake/modules/CMakeLists.txt
+++ clang/cmake/modules/CMakeLists.txt
@@ -55,10 +55,19 @@
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   get_property(clang_has_exports GLOBAL PROPERTY CLANG_HAS_EXPORTS)
   if(clang_has_exports)
-install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR})
+install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}
+COMPONENT clang-cmake-exports)
   endif()
 
   install(FILES
 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfig.cmake
-DESTINATION ${CLANG_INSTALL_PACKAGE_DIR})
+DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}
+COMPONENT clang-cmake-exports)
+
+  if(NOT LLVM_ENABLE_IDE)
+# Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS
+add_custom_target(clang-cmake-exports)
+add_llvm_install_targets(install-clang-cmake-exports
+ COMPONENT clang-cmake-exports)
+  endif()
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58480: [clang] Add CMake target for installing clang's CMake exports

2019-02-20 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek 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/D58480/new/

https://reviews.llvm.org/D58480



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


r354525 - [clang] Switch to LLVM_ENABLE_IDE

2019-02-20 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Wed Feb 20 15:08:43 2019
New Revision: 354525

URL: http://llvm.org/viewvc/llvm-project?rev=354525&view=rev
Log:
[clang] Switch to LLVM_ENABLE_IDE

r344555 switched LLVM to guarding install targets with LLVM_ENABLE_IDE
instead of CMAKE_CONFIGURATION_TYPES, which expresses the intent more
directly and can be overridden by a user. Make the corresponding change
in clang. LLVM_ENABLE_IDE is computed by HandleLLVMOptions, so it should
be available for both standalone and integrated builds.

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

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/cmake/modules/AddClang.cmake
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/tools/c-index-test/CMakeLists.txt
cfe/trunk/tools/diagtool/CMakeLists.txt
cfe/trunk/tools/libclang/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=354525&r1=354524&r2=354525&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Wed Feb 20 15:08:43 2019
@@ -552,7 +552,7 @@ endif()
 add_custom_target(clang-libraries)
 set_target_properties(clang-libraries PROPERTIES FOLDER "Misc")
 
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-clang-libraries
DEPENDS clang-libraries
COMPONENT clang-libraries)
@@ -563,7 +563,7 @@ if(CLANG_LIBS)
   list(REMOVE_DUPLICATES CLANG_LIBS)
   foreach(lib ${CLANG_LIBS})
 add_dependencies(clang-libraries ${lib})
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_dependencies(install-clang-libraries install-${lib})
 endif()
   endforeach()

Modified: cfe/trunk/cmake/modules/AddClang.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/AddClang.cmake?rev=354525&r1=354524&r2=354525&view=diff
==
--- cfe/trunk/cmake/modules/AddClang.cmake (original)
+++ cfe/trunk/cmake/modules/AddClang.cmake Wed Feb 20 15:08:43 2019
@@ -103,7 +103,7 @@ macro(add_clang_library name)
 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
 RUNTIME DESTINATION bin)
 
-  if (NOT CMAKE_CONFIGURATION_TYPES)
+  if (NOT LLVM_ENABLE_IDE)
 add_llvm_install_targets(install-${name}
  DEPENDS ${name}
  COMPONENT ${name})
@@ -147,7 +147,7 @@ macro(add_clang_tool name)
   RUNTIME DESTINATION bin
   COMPONENT ${name})
 
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-${name}
DEPENDS ${name}
COMPONENT ${name})

Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=354525&r1=354524&r2=354525&view=diff
==
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Wed Feb 20 15:08:43 2019
@@ -178,7 +178,7 @@ install(
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
   DESTINATION 
lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include/cuda_wrappers)
 
-if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
+if (NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-clang-headers
DEPENDS clang-headers
COMPONENT clang-headers)

Modified: cfe/trunk/tools/c-index-test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/CMakeLists.txt?rev=354525&r1=354524&r2=354525&view=diff
==
--- cfe/trunk/tools/c-index-test/CMakeLists.txt (original)
+++ cfe/trunk/tools/c-index-test/CMakeLists.txt Wed Feb 20 15:08:43 2019
@@ -61,7 +61,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
 RUNTIME DESTINATION "${INSTALL_DESTINATION}"
 COMPONENT c-index-test)
 
-  if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
+  if (NOT LLVM_ENABLE_IDE)
 add_llvm_install_targets(install-c-index-test
  DEPENDS c-index-test
  COMPONENT c-index-test)

Modified: cfe/trunk/tools/diagtool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/diagtool/CMakeLists.txt?rev=354525&r1=354524&r2=354525&view=diff
==
--- cfe/trunk/tools/diagtool/CMakeLists.txt (original)
+++ cfe/trunk/tools/diagtool/CMakeLists.txt Wed Feb 20 15:08:43 2019
@@ -23,7 +23,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
 COMPONENT diagtool
 RUNTIME DESTINATION bin)
 
-  if (NOT CMAKE_CONFIGURATION_TYPES)
+  if (NOT LLVM_ENABLE_IDE)
 add_llvm_

[PATCH] D58284: [clang] Switch to LLVM_ENABLE_IDE

2019-02-20 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek 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/D58284/new/

https://reviews.llvm.org/D58284



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


[PATCH] D58284: [clang] Switch to LLVM_ENABLE_IDE

2019-02-20 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354525: [clang] Switch to LLVM_ENABLE_IDE (authored by 
smeenai, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58284?vs=187020&id=187686#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58284

Files:
  cfe/trunk/CMakeLists.txt
  cfe/trunk/cmake/modules/AddClang.cmake
  cfe/trunk/lib/Headers/CMakeLists.txt
  cfe/trunk/tools/c-index-test/CMakeLists.txt
  cfe/trunk/tools/diagtool/CMakeLists.txt
  cfe/trunk/tools/libclang/CMakeLists.txt

Index: cfe/trunk/cmake/modules/AddClang.cmake
===
--- cfe/trunk/cmake/modules/AddClang.cmake
+++ cfe/trunk/cmake/modules/AddClang.cmake
@@ -103,7 +103,7 @@
 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
 RUNTIME DESTINATION bin)
 
-  if (NOT CMAKE_CONFIGURATION_TYPES)
+  if (NOT LLVM_ENABLE_IDE)
 add_llvm_install_targets(install-${name}
  DEPENDS ${name}
  COMPONENT ${name})
@@ -147,7 +147,7 @@
   RUNTIME DESTINATION bin
   COMPONENT ${name})
 
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-${name}
DEPENDS ${name}
COMPONENT ${name})
Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -552,7 +552,7 @@
 add_custom_target(clang-libraries)
 set_target_properties(clang-libraries PROPERTIES FOLDER "Misc")
 
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-clang-libraries
DEPENDS clang-libraries
COMPONENT clang-libraries)
@@ -563,7 +563,7 @@
   list(REMOVE_DUPLICATES CLANG_LIBS)
   foreach(lib ${CLANG_LIBS})
 add_dependencies(clang-libraries ${lib})
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_dependencies(install-clang-libraries install-${lib})
 endif()
   endforeach()
Index: cfe/trunk/lib/Headers/CMakeLists.txt
===
--- cfe/trunk/lib/Headers/CMakeLists.txt
+++ cfe/trunk/lib/Headers/CMakeLists.txt
@@ -178,7 +178,7 @@
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
   DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include/cuda_wrappers)
 
-if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
+if (NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-clang-headers
DEPENDS clang-headers
COMPONENT clang-headers)
Index: cfe/trunk/tools/libclang/CMakeLists.txt
===
--- cfe/trunk/tools/libclang/CMakeLists.txt
+++ cfe/trunk/tools/libclang/CMakeLists.txt
@@ -149,7 +149,7 @@
 add_custom_target(libclang-headers)
 set_target_properties(libclang-headers PROPERTIES FOLDER "Misc")
 
-if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
+if (NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-libclang-headers
COMPONENT libclang-headers)
 endif()
@@ -165,7 +165,7 @@
   DESTINATION
 "lib${LLVM_LIBDIR_SUFFIX}/python${PythonVersion}/site-packages")
 endforeach()
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_custom_target(libclang-python-bindings)
   add_llvm_install_targets(install-libclang-python-bindings
COMPONENT
Index: cfe/trunk/tools/c-index-test/CMakeLists.txt
===
--- cfe/trunk/tools/c-index-test/CMakeLists.txt
+++ cfe/trunk/tools/c-index-test/CMakeLists.txt
@@ -61,7 +61,7 @@
 RUNTIME DESTINATION "${INSTALL_DESTINATION}"
 COMPONENT c-index-test)
 
-  if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
+  if (NOT LLVM_ENABLE_IDE)
 add_llvm_install_targets(install-c-index-test
  DEPENDS c-index-test
  COMPONENT c-index-test)
Index: cfe/trunk/tools/diagtool/CMakeLists.txt
===
--- cfe/trunk/tools/diagtool/CMakeLists.txt
+++ cfe/trunk/tools/diagtool/CMakeLists.txt
@@ -23,7 +23,7 @@
 COMPONENT diagtool
 RUNTIME DESTINATION bin)
 
-  if (NOT CMAKE_CONFIGURATION_TYPES)
+  if (NOT LLVM_ENABLE_IDE)
 add_llvm_install_targets(install-diagtool
   DEPENDS diagtool
   COMPONENT diagtool)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >