[PATCH] D61931: [Driver] Use --android-tls for Android ARM/AArch64 when lld is used

2019-05-15 Thread Ryan Prichard via Phabricator via cfe-commits
rprichard added inline comments.



Comment at: lib/Driver/ToolChains/Gnu.cpp:404
+  const Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ);
+  if (A && StringRef(A->getValue()).contains("lld"))
+CmdArgs.push_back("--android-tls");

The logic used for Fuschia is more precise:

  const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
  if (llvm::sys::path::filename(Exec).equals_lower("ld.lld") ||
  llvm::sys::path::stem(Exec).equals_lower("ld.lld")) {
CmdArgs.push_back("-z");
CmdArgs.push_back("rodynamic");
  }



Repository:
  rC Clang

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

https://reviews.llvm.org/D61931



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


[PATCH] D61845: [builtin] Fixed definitions of builtins that rely on the int/long long type is 32/64 bits

2019-05-15 Thread Karl-Johan Karlsson via Phabricator via cfe-commits
Ka-Ka updated this revision to Diff 199559.
Ka-Ka marked 2 inline comments as done.
Ka-Ka added a comment.

Updated according to review comments


Repository:
  rC Clang

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

https://reviews.llvm.org/D61845

Files:
  include/clang/Basic/Builtins.def
  lib/AST/ASTContext.cpp
  test/CodeGen/avr-builtins.c
  test/CodeGen/builtins.cpp

Index: test/CodeGen/builtins.cpp
===
--- /dev/null
+++ test/CodeGen/builtins.cpp
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -ffreestanding -verify %s
+// RUN: %clang_cc1 -std=c++11 -triple i686-pc-linux-gnu -ffreestanding -verify %s
+// RUN: %clang_cc1 -std=c++11 -triple avr-unknown-unknown -ffreestanding -verify %s
+
+// expected-no-diagnostics
+
+// Test that checks that the builtins return the same type as the stdint.h type
+// withe the same witdh. This is done by first declaring a variable of a stdint
+// type of the correct width and the redeclaring the variable with the type that
+// the builting return. If the types are different you should the an error from
+// clang of the form:
+// "redefinition of '' with a different type: '' vs ''
+// (with gcc you get an error message
+// "conflicting declaration ' '").
+
+#include 
+
+extern uint16_t bswap16;
+decltype(__builtin_bswap16(0)) bswap16 = 42;
+extern uint32_t bswap32;
+decltype(__builtin_bswap32(0)) bswap32 = 42;
+extern uint64_t bswap64;
+decltype(__builtin_bswap64(0)) bswap64 = 42;
+
+#ifdef __clang__
+extern uint8_t bitrev8;
+decltype(__builtin_bitreverse8(0)) bitrev8 = 42;
+extern uint16_t bitrev16;
+decltype(__builtin_bitreverse16(0)) bitrev16 = 42;
+extern uint32_t bitrev32;
+decltype(__builtin_bitreverse32(0)) bitrev32 = 42;
+extern uint64_t bitrev64;
+decltype(__builtin_bitreverse64(0)) bitrev64 = 42;
+
+extern uint8_t rotl8;
+decltype(__builtin_rotateleft8(0,0)) rotl8 = 42;
+extern uint16_t rotl16;
+decltype(__builtin_rotateleft16(0,0)) rotl16 = 42;
+extern uint32_t rotl32;
+decltype(__builtin_rotateleft32(0,0)) rotl32 = 42;
+extern uint64_t rotl64;
+decltype(__builtin_rotateleft64(0,0)) rotl64 = 42;
+
+extern uint8_t rotr8;
+decltype(__builtin_rotateright8(0,0)) rotr8 = 42;
+extern uint16_t rotr16;
+decltype(__builtin_rotateright16(0,0)) rotr16 = 42;
+extern uint32_t rotr32;
+decltype(__builtin_rotateright32(0,0)) rotr32 = 42;
+extern uint64_t rotr64;
+decltype(__builtin_rotateright64(0,0)) rotr64 = 42;
+#endif
Index: test/CodeGen/avr-builtins.c
===
--- /dev/null
+++ test/CodeGen/avr-builtins.c
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 -triple avr-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+unsigned char bitrev8(unsigned char data) {
+return __builtin_bitreverse8(data);
+}
+
+// CHECK: define zeroext i8 @bitrev8
+// CHECK: i8 @llvm.bitreverse.i8(i8
+
+unsigned int bitrev16(unsigned int data) {
+return __builtin_bitreverse16(data);
+}
+
+// CHECK: define i16 @bitrev16
+// CHECK: i16 @llvm.bitreverse.i16(i16
+
+unsigned long bitrev32(unsigned long data) {
+return __builtin_bitreverse32(data);
+}
+// CHECK: define i32 @bitrev32
+// CHECK: i32 @llvm.bitreverse.i32(i32
+
+unsigned long long bitrev64(unsigned long long data) {
+return __builtin_bitreverse64(data);
+}
+
+// CHECK: define i64 @bitrev64
+// CHECK: i64 @llvm.bitreverse.i64(i64
+
+unsigned char rotleft8(unsigned char x, unsigned char y) {
+return __builtin_rotateleft8(x, y);
+}
+
+// CHECK: define zeroext i8 @rotleft8
+// CHECK: i8 @llvm.fshl.i8(i8
+
+unsigned int rotleft16(unsigned int x, unsigned int y) {
+return __builtin_rotateleft16(x, y);
+}
+
+// CHECK: define i16 @rotleft16
+// CHECK: i16 @llvm.fshl.i16(i16
+
+unsigned long rotleft32(unsigned long x, unsigned long y) {
+return __builtin_rotateleft32(x, y);
+}
+// CHECK: define i32 @rotleft32
+// CHECK: i32 @llvm.fshl.i32(i32
+
+unsigned long long rotleft64(unsigned long long x, unsigned long long y) {
+return __builtin_rotateleft64(x, y);
+}
+
+// CHECK: define i64 @rotleft64
+// CHECK: i64 @llvm.fshl.i64(i64
+
+unsigned char rotright8(unsigned char x, unsigned char y) {
+return __builtin_rotateright8(x, y);
+}
+
+// CHECK: define zeroext i8 @rotright8
+// CHECK: i8 @llvm.fshr.i8(i8
+
+unsigned int rotright16(unsigned int x, unsigned int y) {
+return __builtin_rotateright16(x, y);
+}
+
+// CHECK: define i16 @rotright16
+// CHECK: i16 @llvm.fshr.i16(i16
+
+unsigned long rotright32(unsigned long x, unsigned long y) {
+return __builtin_rotateright32(x, y);
+}
+// CHECK: define i32 @rotright32
+// CHECK: i32 @llvm.fshr.i32(i32
+
+unsigned long long rotright64(unsigned long long x, unsigned long long y) {
+return __builtin_rotateright64(x, y);
+}
+
+// CHECK: define i64 @rotright64
+// CHECK: i64 @llvm.fshr.i64(i64
+
+unsigned int byteswap16(unsigned int x) {
+return __builtin_bswap16(x);
+}
+
+// CHECK: define i16 @byteswap16
+

Re: r360637 - PR41817: Fix regression in r359260 that caused the MS compatibility

2019-05-15 Thread Hans Wennborg via cfe-commits
On Tue, May 14, 2019 at 6:35 PM Richard Smith  wrote:
>
> On Tue, 14 May 2019, 03:09 Hans Wennborg via cfe-commits, 
>  wrote:
>>
>> Actually, we didn't notice r359260 in Chromium, however this one
>> (r360637) caused Clang to start asserting during our builds
>> (https://bugs.chromium.org/p/chromium/issues/detail?id=962840), here's
>> a reduced test case:
>>
>> --
>> extern int a;
>> static int *use1 = &a;
>> int **use2 = &use1;
>> static int a = 0;
>> --
>>
>> $ clang.bad -cc1 -triple i386-pc-windows-msvc19.11.0 -emit-obj
>> -fms-extensions /tmp/a.cc
>> clang.bad: /work/llvm.monorepo/clang/lib/AST/Decl.cpp:1494:
>> clang::LinkageInfo clang::LinkageComputer::getLVForDecl(const
>> clang::NamedDecl*, clang::LVComputationKind): Assertion
>> `D->getCachedLinkage() == LV.getLinkage()' failed.
>>
>>
>> I've reverted this one in r360657 in the meantime.
>
>
> Yep, I'm not at all surprised. Perhaps we should stop claiming to support 
> this extension, given that it fundamentally violates assumptions made by 
> clang (that linkage doesn't change after the first declaration). Presumably 
> we instead used to miscompile the example you give above (and after the 
> revert, miscompile it again now)?

Maybe rnk has opinions too, but if we can get away with it, I think it
would be nice if we could not claim to support this, maybe not error
but dropping the static redeclaration of 'a' above with a warning. We
could fix Chromium's code, maybe we can poke MS to fix the midl
generated code, and maybe Firefox and others can work around the
duplicate symbol error in PR41871 by passing "/client none" to
midl.exe in the meantime.

For my reduction above, I think we used to:
- in clang 8, emit a with internal linkage (getting it right through
luck somehow?)
- after r359259, emit it with external linkage (causing PR41871,
breaking Firefox)
- after r360637, assert


>> From: Richard Smith via cfe-commits 
>> Date: Tue, May 14, 2019 at 2:24 AM
>> To: 
>>
>> > Author: rsmith
>> > Date: Mon May 13 17:27:16 2019
>> > New Revision: 360637
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=360637&view=rev
>> > Log:
>> > PR41817: Fix regression in r359260 that caused the MS compatibility
>> > extension allowing a "static" declaration to follow an "extern"
>> > declaration to stop working.
>> >
>> > Added:
>> > cfe/trunk/test/CodeGen/ms-compat-extern-static.c
>> > Modified:
>> > cfe/trunk/lib/AST/Decl.cpp
>> >
>> > Modified: cfe/trunk/lib/AST/Decl.cpp
>> > URL: 
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=360637&r1=360636&r2=360637&view=diff
>> > ==
>> > --- cfe/trunk/lib/AST/Decl.cpp (original)
>> > +++ cfe/trunk/lib/AST/Decl.cpp Mon May 13 17:27:16 2019
>> > @@ -613,12 +613,41 @@ static LinkageInfo getExternalLinkageFor
>> >  static StorageClass getStorageClass(const Decl *D) {
>> >if (auto *TD = dyn_cast(D))
>> >  D = TD->getTemplatedDecl();
>> > -  if (D) {
>> > -if (auto *VD = dyn_cast(D))
>> > -  return VD->getStorageClass();
>> > -if (auto *FD = dyn_cast(D))
>> > -  return FD->getStorageClass();
>> > +  if (!D)
>> > +return SC_None;
>> > +
>> > +  if (auto *VD = dyn_cast(D)) {
>> > +// Generally, the storage class is determined by the first 
>> > declaration.
>> > +auto SC = VD->getCanonicalDecl()->getStorageClass();
>> > +
>> > +// ... except that MSVC permits an 'extern' declaration to be 
>> > redeclared
>> > +// 'static' as an extension.
>> > +if (SC == SC_Extern) {
>> > +  for (auto *Redecl : VD->redecls()) {
>> > +if (Redecl->getStorageClass() == SC_Static)
>> > +  return SC_Static;
>> > +if (Redecl->getStorageClass() != SC_Extern &&
>> > +!Redecl->isLocalExternDecl() && 
>> > !Redecl->getFriendObjectKind())
>> > +  break;
>> > +  }
>> > +}
>> > +return SC;
>> >}
>> > +
>> > +  if (auto *FD = dyn_cast(D)) {
>> > +auto SC = FD->getCanonicalDecl()->getStorageClass();
>> > +if (SC == SC_Extern) {
>> > +  for (auto *Redecl : FD->redecls()) {
>> > +if (Redecl->getStorageClass() == SC_Static)
>> > +  return SC_Static;
>> > +if (Redecl->getStorageClass() != SC_Extern &&
>> > +!Redecl->isLocalExternDecl() && 
>> > !Redecl->getFriendObjectKind())
>> > +  break;
>> > +  }
>> > +}
>> > +return SC;
>> > +  }
>> > +
>> >return SC_None;
>> >  }
>> >
>> > @@ -634,7 +663,7 @@ LinkageComputer::getLVForNamespaceScopeD
>> >//   A name having namespace scope (3.3.6) has internal linkage if it
>> >//   is the name of
>> >
>> > -  if (getStorageClass(D->getCanonicalDecl()) == SC_Static) {
>> > +  if (getStorageClass(D) == SC_Static) {
>> >  // - a variable, variable template, function, or function template
>> >  //   that is explicitly declared static; or
>> >  // (This bullet corresponds to C99 6.2.2p3.)
>> >
>> > Added: cfe/trunk/t

[PATCH] D61850: Removed superfluous and slightly annoying newlines in run-clang-tidy's output.

2019-05-15 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

In D61850#1500330 , @svenpanne wrote:

> In D61850#1500298 , @JonasToth wrote:
>
> > [...] please ensure that e.g. clang-analyzer-* output looks proper as well 
> > and `-quiet` does, too.
>
>
> OK, are there any (unit) tests which I should run? If yes, how exactly? I 
> have a successfully built a fork of https://github.com/llvm/llvm-project via 
> ninja locally, but the documentation for the various subprojects is still a 
> bit hard to find to me. Is there a ninja target for `clang-tidy`-related 
> tests? Any hints to get started would be highly appreciated.
>
> This and the other output-related patches are my first submissions here, and 
> they are intentionally simple to get the workflow right. My real intention is 
> trying to improve/fix the `readability-identifier-naming` check/fixer, which 
> still has a few issues.


There are testing targets for clang-tidy and clang-tooling, i believe `ninja 
check-clang-tools` is includes clang-tidy (maybe `ninja check-clang-tooling` 
instead).
If this script is actually covered by testing is not know to me, i believe not.
For testing just run it over a project (e.g. parts of LLVM) with this tool 
instead of e.g. your distribution version of it.

For general development: `clang-tools-extra/test/clang-tidy/*` has the 
test-cases for clang-tidy checks, which are real world code examples that cover 
all representative cases (in theory).

1. Write/adjust test
2. Do changes in code
3. Test with `ninja check-clang-tools` / `ninja check-clang-tooling`

That usually works. If you encounter any issues feel free to ask here/IRC/mail, 
we are happy to help out :)


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61850



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


[PATCH] D61281: [clang-format] Fixed self assignment

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

LGTM


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

https://reviews.llvm.org/D61281



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


[PATCH] D59885: [Lex] Allow to consume tokens while preprocessing

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

Will do. Also think reporting annotation tokens is ok, one can easily tell them 
apart and filter them by looking at the corresponding flags in `clang::Token`, 
will put it into the docs, though


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59885



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


[PATCH] D36357: Added a better diagnostic when using the delete operator with lambdas

2019-05-15 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete updated this revision to Diff 199566.
Rakete added a comment.

- Use TryConsumeToken


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D36357

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/FixIt/fixit-cxx0x.cpp
  clang/test/Parser/cxx0x-lambda-expressions.cpp
  clang/test/SemaCXX/new-delete-0x.cpp

Index: clang/test/SemaCXX/new-delete-0x.cpp
===
--- clang/test/SemaCXX/new-delete-0x.cpp
+++ clang/test/SemaCXX/new-delete-0x.cpp
@@ -34,6 +34,6 @@
 void bad_deletes()
 {
   // 'delete []' is always array delete, per [expr.delete]p1.
-  // FIXME: Give a better diagnostic.
-  delete []{ return (int*)0; }(); // expected-error {{expected expression}}
+  delete []{ return (int*)0; }(); // expected-error {{'[]' after delete interpreted as 'delete[]'}}
 }
+
Index: clang/test/Parser/cxx0x-lambda-expressions.cpp
===
--- clang/test/Parser/cxx0x-lambda-expressions.cpp
+++ clang/test/Parser/cxx0x-lambda-expressions.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify -std=c++2a %s
 
 enum E { e };
 
@@ -43,31 +44,57 @@
 int a4[1] = {[&b] = 1 }; // expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'const int *'}}
 int a5[3] = { []{return 0;}() };
 int a6[1] = {[this] = 1 }; // expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'C *'}}
-int a7[1] = {[d(0)] { return d; } ()}; // expected-warning{{extension}}
-int a8[1] = {[d = 0] { return d; } ()}; // expected-warning{{extension}}
+int a7[1] = {[d(0)] { return d; } ()};
+int a8[1] = {[d = 0] { return d; } ()};
+int a10[1] = {[id(0)] { return id; } ()};
+#if __cplusplus <= 201103L
+// expected-warning@-4{{extension}}
+// expected-warning@-4{{extension}}
+// expected-warning@-4{{extension}}
+#endif
 int a9[1] = {[d = 0] = 1}; // expected-error{{is not an integral constant expression}}
-int a10[1] = {[id(0)] { return id; } ()}; // expected-warning{{extension}}
+#if __cplusplus >= 201402L
+// expected-note@-2{{constant expression cannot modify an object that is visible outside that expression}}
+#endif
 int a11[1] = {[id(0)] = 1};
   }
 
   void delete_lambda(int *p) {
 delete [] p;
 delete [] (int*) { new int }; // ok, compound-literal, not lambda
-delete [] { return new int; } (); // expected-error{{expected expression}}
+delete [] { return new int; } (); // expected-error {{'[]' after delete interpreted as 'delete[]'}}
 delete [&] { return new int; } (); // ok, lambda
+
+delete []() { return new int; }(); // expected-error{{'[]' after delete interpreted as 'delete[]'}}
+delete [](E Enum) { return new int((int)Enum); }(e); // expected-error{{'[]' after delete interpreted as 'delete[]'}}
+#if __cplusplus > 201703L
+delete []() { return new int; }(); // expected-error{{'[]' after delete interpreted as 'delete[]'}}
+#endif
   }
 
   // We support init-captures in C++11 as an extension.
   int z;
   void init_capture() {
-[n(0)] () mutable -> int { return ++n; }; // expected-warning{{extension}}
-[n{0}] { return; }; // expected-warning{{extension}}
-[n = 0] { return ++n; }; // expected-error {{captured by copy in a non-mutable}} expected-warning{{extension}}
-[n = {0}] { return; }; // expected-error {{}} expected-warning{{extension}}
-[a([&b = z]{})](){}; // expected-warning 2{{extension}}
+[n(0)] () mutable -> int { return ++n; };
+[n{0}] { return; };
+[a([&b = z]{})](){};
+[n = 0] { return ++n; }; // expected-error {{captured by copy in a non-mutable}}
+[n = {0}] { return; }; // expected-error {{}}
+#if __cplusplus <= 201103L
+// expected-warning@-6{{extension}}
+// expected-warning@-6{{extension}}
+// expected-warning@-6{{extension}}
+// expected-warning@-7{{extension}}
+// expected-warning@-7{{extension}}
+// expected-warning@-7{{extension}}
+#endif
 
 int x = 4;
-auto y = [&r = x, x = x + 1]() -> int { // expected-warning 2{{extension}}
+auto y = [&r = x, x = x + 1]() -> int {
+#if __cplusplus <= 201103L
+  // expected-warning@-2{{extension}}
+  // expected-warning@-3{{extension}}
+#endif
   r += 2;
   return x + 2;
 } ();
Index: clang/test/FixIt/fixit-cxx0x.cpp
===
--- clang/test/FixIt/fixit-cxx0x.cpp
+++ clang/test/FixIt/fixit-cxx0x.cpp
@@ -58,6 +58,9 @@
   (void)[&, i, i]{ }; // expected-error{{'i' can appear only once in a capture list}}
   (void)[] mutable { }; // expected-error{{lambda requires '()' before 'mutable'}}
   (void)[] -> int { }; // expect

[PATCH] D60953: [clangd] Respect clang-tidy suppression comments

2019-05-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks, this looks good. I think we should avoid the subclassing, but any of 
{generalize in the next patch, different approach for the next patch, subclass 
for now and clean up later} seems fine.




Comment at: clang-tools-extra/clangd/ClangdUnit.cpp:243
+// future).
+class ClangdDiagnosticConsumer : public StoreDiags {
+public:

nridge wrote:
> sammccall wrote:
> > Thanks, this is much cleaner.
> > 
> > I think we don't need the subclass at all though - just a filter function 
> > here, and call setFilter after setting up clang-tidy?
> I rely on the derived class more in the follow-up patch D61841 where I 
> override `HandleDiagnostic()`. Should I still remove it from this patch?
Sorry about not understanding the interaction here, I wasn't aware of the 
warnings-to-errors work.
Yes, I'd prefer to avoid the subclassing for that too.

A couple of options spring to mind here:
 - generalize from `suppressDiagnostics(callback -> bool)` to 
`adjustLevel(callback -> DiagnosticLevel)` or similar, where `Ignored` is the 
current suppression behavior.
 - apply warnings-to-errors at the end, at the clangd::Diag level. This 
captures that a diag came from clang-tidy, and the check name, so seems 
feasible.

(sorry about the churn here, I wasn't aware of the followup patch)



Comment at: clang-tools-extra/clangd/Diagnostics.h:115
 
+/// Check if a diagnostic is inside the main file.
+bool isInsideMainFile(const clang::Diagnostic &D);

nit: this really doesn't seem worth adding to a public interface, is 
`D.hasSourceManager() && 
D.getSourceManager().isWrittenInMainFile(D.getLocation())` really too verbose?

(I don't think the helper function in Diagnostics.cpp is justified either, but 
unrelated to this patch)



Comment at: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp:771
+
+TEST(ClangTidy, SuppressionComment) {
+  Annotations Main(R"cpp(

nit: can we group this with the other ClangTidy test?
`TEST(DiagnosticTest, ClangTidySuppressionComment)` and move it up in the file?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60953



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


[PATCH] D36357: Added a better diagnostic when using the delete operator with lambdas

2019-05-15 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete updated this revision to Diff 199565.
Rakete added a comment.

- Fix crash with invalid postfix expr
- Don't emit FixIt when using <


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D36357

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/FixIt/fixit-cxx0x.cpp
  clang/test/Parser/cxx0x-lambda-expressions.cpp
  clang/test/SemaCXX/new-delete-0x.cpp

Index: clang/test/SemaCXX/new-delete-0x.cpp
===
--- clang/test/SemaCXX/new-delete-0x.cpp
+++ clang/test/SemaCXX/new-delete-0x.cpp
@@ -34,6 +34,6 @@
 void bad_deletes()
 {
   // 'delete []' is always array delete, per [expr.delete]p1.
-  // FIXME: Give a better diagnostic.
-  delete []{ return (int*)0; }(); // expected-error {{expected expression}}
+  delete []{ return (int*)0; }(); // expected-error {{'[]' after delete interpreted as 'delete[]'}}
 }
+
Index: clang/test/Parser/cxx0x-lambda-expressions.cpp
===
--- clang/test/Parser/cxx0x-lambda-expressions.cpp
+++ clang/test/Parser/cxx0x-lambda-expressions.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify -std=c++2a %s
 
 enum E { e };
 
@@ -43,31 +44,57 @@
 int a4[1] = {[&b] = 1 }; // expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'const int *'}}
 int a5[3] = { []{return 0;}() };
 int a6[1] = {[this] = 1 }; // expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'C *'}}
-int a7[1] = {[d(0)] { return d; } ()}; // expected-warning{{extension}}
-int a8[1] = {[d = 0] { return d; } ()}; // expected-warning{{extension}}
+int a7[1] = {[d(0)] { return d; } ()};
+int a8[1] = {[d = 0] { return d; } ()};
+int a10[1] = {[id(0)] { return id; } ()};
+#if __cplusplus <= 201103L
+// expected-warning@-4{{extension}}
+// expected-warning@-4{{extension}}
+// expected-warning@-4{{extension}}
+#endif
 int a9[1] = {[d = 0] = 1}; // expected-error{{is not an integral constant expression}}
-int a10[1] = {[id(0)] { return id; } ()}; // expected-warning{{extension}}
+#if __cplusplus >= 201402L
+// expected-note@-2{{constant expression cannot modify an object that is visible outside that expression}}
+#endif
 int a11[1] = {[id(0)] = 1};
   }
 
   void delete_lambda(int *p) {
 delete [] p;
 delete [] (int*) { new int }; // ok, compound-literal, not lambda
-delete [] { return new int; } (); // expected-error{{expected expression}}
+delete [] { return new int; } (); // expected-error {{'[]' after delete interpreted as 'delete[]'}}
 delete [&] { return new int; } (); // ok, lambda
+
+delete []() { return new int; }(); // expected-error{{'[]' after delete interpreted as 'delete[]'}}
+delete [](E Enum) { return new int((int)Enum); }(e); // expected-error{{'[]' after delete interpreted as 'delete[]'}}
+#if __cplusplus > 201703L
+delete []() { return new int; }(); // expected-error{{'[]' after delete interpreted as 'delete[]'}}
+#endif
   }
 
   // We support init-captures in C++11 as an extension.
   int z;
   void init_capture() {
-[n(0)] () mutable -> int { return ++n; }; // expected-warning{{extension}}
-[n{0}] { return; }; // expected-warning{{extension}}
-[n = 0] { return ++n; }; // expected-error {{captured by copy in a non-mutable}} expected-warning{{extension}}
-[n = {0}] { return; }; // expected-error {{}} expected-warning{{extension}}
-[a([&b = z]{})](){}; // expected-warning 2{{extension}}
+[n(0)] () mutable -> int { return ++n; };
+[n{0}] { return; };
+[a([&b = z]{})](){};
+[n = 0] { return ++n; }; // expected-error {{captured by copy in a non-mutable}}
+[n = {0}] { return; }; // expected-error {{}}
+#if __cplusplus <= 201103L
+// expected-warning@-6{{extension}}
+// expected-warning@-6{{extension}}
+// expected-warning@-6{{extension}}
+// expected-warning@-7{{extension}}
+// expected-warning@-7{{extension}}
+// expected-warning@-7{{extension}}
+#endif
 
 int x = 4;
-auto y = [&r = x, x = x + 1]() -> int { // expected-warning 2{{extension}}
+auto y = [&r = x, x = x + 1]() -> int {
+#if __cplusplus <= 201103L
+  // expected-warning@-2{{extension}}
+  // expected-warning@-3{{extension}}
+#endif
   r += 2;
   return x + 2;
 } ();
Index: clang/test/FixIt/fixit-cxx0x.cpp
===
--- clang/test/FixIt/fixit-cxx0x.cpp
+++ clang/test/FixIt/fixit-cxx0x.cpp
@@ -58,6 +58,9 @@
   (void)[&, i, i]{ }; // expected-error{{'i' can appear only once in a capture list}}
   (void)[] mutable { }; // expected-error{{lambda requires '()' befo

[PATCH] D57858: [analyzer] Add a new frontend flag to display all checker options

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

In D57858#1502052 , @NoQ wrote:

> In D57858#1501065 , @dkrupp wrote:
>
> > These are the alpha checkers that we are testing in Ericsson:
>
>
> Hmm, if you don't mind i'll take this to cfe-dev, as it's an interesting 
> topic :)


Not at all, I started to feel like we're deviating from the patch discuasion 
quite badly anyways :)


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

https://reviews.llvm.org/D57858



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


[PATCH] D61438: [ASTImporter] Use llvm::Expected and Error in the importer API

2019-05-15 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 199569.
martong added a comment.

- Rebase to master


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61438

Files:
  clang/include/clang/AST/ASTImporter.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExternalASTMerger.cpp
  clang/lib/CrossTU/CrossTranslationUnit.cpp
  clang/lib/Frontend/ASTMerge.cpp
  clang/unittests/AST/ASTImporterFixtures.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Symbol/ClangASTContext.cpp
  lldb/source/Symbol/ClangASTImporter.cpp
  lldb/source/Symbol/CxxModuleHandler.cpp

Index: lldb/source/Symbol/CxxModuleHandler.cpp
===
--- lldb/source/Symbol/CxxModuleHandler.cpp
+++ lldb/source/Symbol/CxxModuleHandler.cpp
@@ -9,6 +9,7 @@
 #include "lldb/Symbol/CxxModuleHandler.h"
 
 #include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Utility/Log.h"
 #include "clang/Sema/Lookup.h"
 #include "llvm/Support/Error.h"
 
@@ -214,13 +215,15 @@
   // Import the foreign template arguments.
   llvm::SmallVector imported_args;
 
+  Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+
   // If this logic is changed, also update templateArgsAreSupported.
   for (const TemplateArgument &arg : foreign_args.asArray()) {
 switch (arg.getKind()) {
 case TemplateArgument::Type: {
-  llvm::Expected type = m_importer->Import_New(arg.getAsType());
+  llvm::Expected type = m_importer->Import(arg.getAsType());
   if (!type) {
-llvm::consumeError(type.takeError());
+LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}");
 return {};
   }
   imported_args.push_back(TemplateArgument(*type));
@@ -229,9 +232,9 @@
 case TemplateArgument::Integral: {
   llvm::APSInt integral = arg.getAsIntegral();
   llvm::Expected type =
-  m_importer->Import_New(arg.getIntegralType());
+  m_importer->Import(arg.getIntegralType());
   if (!type) {
-llvm::consumeError(type.takeError());
+LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}");
 return {};
   }
   imported_args.push_back(
Index: lldb/source/Symbol/ClangASTImporter.cpp
===
--- lldb/source/Symbol/ClangASTImporter.cpp
+++ lldb/source/Symbol/ClangASTImporter.cpp
@@ -62,10 +62,18 @@
 
   ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp, dst_ast);
 
-  if (delegate_sp)
-return delegate_sp->Import(type);
-
-  return QualType();
+  if (!delegate_sp)
+return QualType();
+
+  llvm::Expected ret_or_error = delegate_sp->Import(type);
+  if (!ret_or_error) {
+Log *log =
+  lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+LLDB_LOG_ERROR(log, ret_or_error.takeError(),
+"Couldn't import type: {0}");
+return QualType();
+  }
+  return *ret_or_error;
 }
 
 lldb::opaque_compiler_type_t
@@ -105,34 +113,33 @@
 
   ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp, dst_ast);
 
-  if (delegate_sp) {
-clang::Decl *result = delegate_sp->Import(decl);
-
-if (!result) {
-  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+  if (!delegate_sp)
+return nullptr;
 
-  if (log) {
-lldb::user_id_t user_id = LLDB_INVALID_UID;
-ClangASTMetadata *metadata = GetDeclMetadata(decl);
-if (metadata)
-  user_id = metadata->GetUserID();
-
-if (NamedDecl *named_decl = dyn_cast(decl))
-  log->Printf("  [ClangASTImporter] WARNING: Failed to import a %s "
-  "'%s', metadata 0x%" PRIx64,
-  decl->getDeclKindName(),
-  named_decl->getNameAsString().c_str(), user_id);
-else
-  log->Printf("  [ClangASTImporter] WARNING: Failed to import a %s, "
-  "metadata 0x%" PRIx64,
-  decl->getDeclKindName(), user_id);
-  }
+  llvm::Expected result = delegate_sp->Import(decl);
+  if (!result) {
+Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+LLDB_LOG_ERROR(log, result.takeError(), "Couldn't import decl: {0}");
+if (log) {
+  lldb::user_id_t user_id = LLDB_INVALID_UID;
+  ClangASTMetadata *metadata = GetDeclMetadata(decl);
+  if (metadata)
+user_id = metadata->GetUserID();
+
+  if (NamedDecl *named_decl = dyn_cast(decl))
+log->Printf("  [ClangASTImporter] WARNING: Failed to import a %s "
+"'%s', metadata 0x%" PRIx64,
+decl->getDeclKindName(),
+named_decl->getNameAsString().c_str(), user_id);
+  else
+log->Printf("  [ClangASTImporter] WARNING: Failed to import a 

[PATCH] D61634: [clang/llvm] Allow efficient implementation of libc's memory functions in C/C++

2019-05-15 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet added a comment.

In D61634#1502201 , @tejohnson wrote:

> Using function level attributes instead of module flags does provide finer 
> grained control and avoids the conservativeness when merging IR for LTO. The 
> downsides I see, mostly just in terms of the engineering effort to get this 
> to work, are:
>
> - need to prevent inlining with different attributes


IIUC this is needed regardless of the proposed change. Correct?

> - currently the TargetLibraryInfo is constructed on a per-module basis. 
> Presumably it would instead need to be created per Function - this one in 
> particular seems like it would require fairly extensive changes.

Yes this one is a bit worrying.
I think we can discard right away any solution that would mutate or creating a 
TLI on a per function basis.
Another design could be the following:

  auto FunctionTLI = ModuleTLI.createCustomizedTLI(F);

`FunctionTLI` would either return the function customizations or delegate to 
the modules TLI. WDYT?

I'm unsure if we want to support function level attribute right away or if it's 
OK to be in an intermediate state with only module level attributes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61634



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


r360760 - [ASTImporter] Use llvm::Expected and Error in the importer API

2019-05-15 Thread Gabor Marton via cfe-commits
Author: martong
Date: Wed May 15 03:29:48 2019
New Revision: 360760

URL: http://llvm.org/viewvc/llvm-project?rev=360760&view=rev
Log:
[ASTImporter] Use llvm::Expected and Error in the importer API

Summary:
This is the final phase of the refactoring towards using llvm::Expected
and llvm::Error in the ASTImporter API.
This involves the following:
- remove old Import functions which returned with a pointer,
- use the Import_New functions (which return with Err or Expected) everywhere
  and handle their return value
- rename Import_New functions to Import
This affects both Clang and LLDB.

Reviewers: shafik, teemperor, aprantl, a_sidorin, balazske, a.sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits, lldb-commits

Tags: #clang, #lldb

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

Modified:
cfe/trunk/include/clang/AST/ASTImporter.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/ExternalASTMerger.cpp
cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
cfe/trunk/lib/Frontend/ASTMerge.cpp
cfe/trunk/unittests/AST/ASTImporterFixtures.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/include/clang/AST/ASTImporter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTImporter.h?rev=360760&r1=360759&r2=360760&view=diff
==
--- cfe/trunk/include/clang/AST/ASTImporter.h (original)
+++ cfe/trunk/include/clang/AST/ASTImporter.h Wed May 15 03:29:48 2019
@@ -183,7 +183,7 @@ class TypeSourceInfo;
 /// \return Error information (success or error).
 template 
 LLVM_NODISCARD llvm::Error importInto(ImportT &To, const ImportT &From) {
-  auto ToOrErr = Import_New(From);
+  auto ToOrErr = Import(From);
   if (ToOrErr)
 To = *ToOrErr;
   return ToOrErr.takeError();
@@ -193,40 +193,29 @@ class TypeSourceInfo;
 /// context. A null type is imported as a null type (no error).
 ///
 /// \returns The equivalent type in the "to" context, or the import error.
-llvm::Expected Import_New(QualType FromT);
-// FIXME: Remove this version.
-QualType Import(QualType FromT);
+llvm::Expected Import(QualType FromT);
 
 /// Import the given type source information from the
 /// "from" context into the "to" context.
 ///
 /// \returns The equivalent type source information in the "to"
 /// context, or the import error.
-llvm::Expected Import_New(TypeSourceInfo *FromTSI);
-// FIXME: Remove this version.
-TypeSourceInfo *Import(TypeSourceInfo *FromTSI);
+llvm::Expected Import(TypeSourceInfo *FromTSI);
 
 /// Import the given attribute from the "from" context into the
 /// "to" context.
 ///
 /// \returns The equivalent attribute in the "to" context, or the import
 /// error.
-llvm::Expected Import_New(const Attr *FromAttr);
-// FIXME: Remove this version.
-Attr *Import(const Attr *FromAttr);
+llvm::Expected Import(const Attr *FromAttr);
 
 /// Import the given declaration from the "from" context into the
 /// "to" context.
 ///
 /// \returns The equivalent declaration in the "to" context, or the import
 /// error.
-llvm::Expected Import_New(Decl *FromD);
-llvm::Expected Import_New(const Decl *FromD) {
-  return Import_New(const_cast(FromD));
-}
-// FIXME: Remove this version.
-Decl *Import(Decl *FromD);
-Decl *Import(const Decl *FromD) {
+llvm::Expected Import(Decl *FromD);
+llvm::Expected Import(const Decl *FromD) {
   return Import(const_cast(FromD));
 }
 
@@ -251,28 +240,21 @@ class TypeSourceInfo;
 ///
 /// \returns The equivalent expression in the "to" context, or the import
 /// error.
-llvm::Expected Import_New(Expr *FromE);
-// FIXME: Remove this version.
-Expr *Import(Expr *FromE);
+llvm::Expected Import(Expr *FromE);
 
 /// Import the given statement from the "from" context into the
 /// "to" context.
 ///
 /// \returns The equivalent statement in the "to" context, or the import
 /// error.
-llvm::Expected Import_New(Stmt *FromS);
-// FIXME: Remove this version.
-Stmt *Import(Stmt *FromS);
+llvm::Expected Import(Stmt *FromS);
 
 /// Import the given nested-name-specifier from the "from"
 /// context into the "to" context.
 ///
 /// \returns The equivalent nested-name-specifier in the "to"
 /// context, or the import error.
-llvm::Expected
-Import_New(NestedNameSpecifier *FromNNS);
-// FIXME: Remove this version.
-NestedNameSpecifier *Import(NestedNameSpecifier *FromNNS);
+llvm::Expected Import(NestedNameSpecifier *FromNNS);
 
 /// Import the given nested-name-specifier-loc from the "from"
 /// context into the "to" context.
@@ -280,42 +262,32 @@ class TypeSourceInfo;
 /// \returns The equivalent nested-name-specifier-loc in the "to"
 /// context, or the 

[PATCH] D61438: [ASTImporter] Use llvm::Expected and Error in the importer API

2019-05-15 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL360760: [ASTImporter] Use llvm::Expected and Error in the 
importer API (authored by martong, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61438?vs=199569&id=199573#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61438

Files:
  cfe/trunk/include/clang/AST/ASTImporter.h
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/lib/AST/ExternalASTMerger.cpp
  cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
  cfe/trunk/lib/Frontend/ASTMerge.cpp
  cfe/trunk/unittests/AST/ASTImporterFixtures.cpp
  cfe/trunk/unittests/AST/ASTImporterTest.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/trunk/source/Symbol/ClangASTContext.cpp
  lldb/trunk/source/Symbol/ClangASTImporter.cpp
  lldb/trunk/source/Symbol/CxxModuleHandler.cpp

Index: cfe/trunk/include/clang/AST/ASTImporter.h
===
--- cfe/trunk/include/clang/AST/ASTImporter.h
+++ cfe/trunk/include/clang/AST/ASTImporter.h
@@ -183,7 +183,7 @@
 /// \return Error information (success or error).
 template 
 LLVM_NODISCARD llvm::Error importInto(ImportT &To, const ImportT &From) {
-  auto ToOrErr = Import_New(From);
+  auto ToOrErr = Import(From);
   if (ToOrErr)
 To = *ToOrErr;
   return ToOrErr.takeError();
@@ -193,40 +193,29 @@
 /// context. A null type is imported as a null type (no error).
 ///
 /// \returns The equivalent type in the "to" context, or the import error.
-llvm::Expected Import_New(QualType FromT);
-// FIXME: Remove this version.
-QualType Import(QualType FromT);
+llvm::Expected Import(QualType FromT);
 
 /// Import the given type source information from the
 /// "from" context into the "to" context.
 ///
 /// \returns The equivalent type source information in the "to"
 /// context, or the import error.
-llvm::Expected Import_New(TypeSourceInfo *FromTSI);
-// FIXME: Remove this version.
-TypeSourceInfo *Import(TypeSourceInfo *FromTSI);
+llvm::Expected Import(TypeSourceInfo *FromTSI);
 
 /// Import the given attribute from the "from" context into the
 /// "to" context.
 ///
 /// \returns The equivalent attribute in the "to" context, or the import
 /// error.
-llvm::Expected Import_New(const Attr *FromAttr);
-// FIXME: Remove this version.
-Attr *Import(const Attr *FromAttr);
+llvm::Expected Import(const Attr *FromAttr);
 
 /// Import the given declaration from the "from" context into the
 /// "to" context.
 ///
 /// \returns The equivalent declaration in the "to" context, or the import
 /// error.
-llvm::Expected Import_New(Decl *FromD);
-llvm::Expected Import_New(const Decl *FromD) {
-  return Import_New(const_cast(FromD));
-}
-// FIXME: Remove this version.
-Decl *Import(Decl *FromD);
-Decl *Import(const Decl *FromD) {
+llvm::Expected Import(Decl *FromD);
+llvm::Expected Import(const Decl *FromD) {
   return Import(const_cast(FromD));
 }
 
@@ -251,28 +240,21 @@
 ///
 /// \returns The equivalent expression in the "to" context, or the import
 /// error.
-llvm::Expected Import_New(Expr *FromE);
-// FIXME: Remove this version.
-Expr *Import(Expr *FromE);
+llvm::Expected Import(Expr *FromE);
 
 /// Import the given statement from the "from" context into the
 /// "to" context.
 ///
 /// \returns The equivalent statement in the "to" context, or the import
 /// error.
-llvm::Expected Import_New(Stmt *FromS);
-// FIXME: Remove this version.
-Stmt *Import(Stmt *FromS);
+llvm::Expected Import(Stmt *FromS);
 
 /// Import the given nested-name-specifier from the "from"
 /// context into the "to" context.
 ///
 /// \returns The equivalent nested-name-specifier in the "to"
 /// context, or the import error.
-llvm::Expected
-Import_New(NestedNameSpecifier *FromNNS);
-// FIXME: Remove this version.
-NestedNameSpecifier *Import(NestedNameSpecifier *FromNNS);
+llvm::Expected Import(NestedNameSpecifier *FromNNS);
 
 /// Import the given nested-name-specifier-loc from the "from"
 /// context into the "to" context.
@@ -280,42 +262,32 @@
 /// \returns The equivalent nested-name-specifier-loc in the "to"
 /// context, or the import error.
 llvm::Expected
-Import_New(NestedNameSpecifierLoc FromNNS);
-// FIXME: Remove this version.
-NestedNameSpecifierLoc Import(NestedNameSpecifierLoc FromNNS);
+Import(NestedNameSpecifierLoc FromNNS);
 
 /// Import the given template name from the "from" context into the
 /// "to" context, o

[PATCH] D61931: [Driver] Use --android-tls for Android ARM/AArch64 when lld is used

2019-05-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 199574.
MaskRay added a comment.

Use Args.MakeArgString(ToolChain.GetLinkerPath());


Repository:
  rC Clang

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

https://reviews.llvm.org/D61931

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/android-aarch64-link.cpp
  test/Driver/android-arm-link.cpp


Index: test/Driver/android-arm-link.cpp
===
--- /dev/null
+++ test/Driver/android-arm-link.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang -target arm-linux-androideabi -### %s 2>&1 | \
+// RUN:   FileCheck --implicit-check-not=--android-tls /dev/null
+// RUN: %clang -target arm-linux-androideabi -fuse-ld=lld -### %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=TLS %s
+
+// TLS: --android-tls
Index: test/Driver/android-aarch64-link.cpp
===
--- test/Driver/android-aarch64-link.cpp
+++ test/Driver/android-aarch64-link.cpp
@@ -16,7 +16,13 @@
 // RUN:   -### -v %s 2> %t
 // RUN: FileCheck -check-prefix=MAX-PAGE-SIZE < %t %s
 //
+// RUN: %clang -target aarch64-linux-android -### %s 2>&1 | \
+// RUN:   FileCheck --implicit-check-not=--android-tls /dev/null
+// RUN: %clang -target aarch64-linux-android -fuse-ld=lld -### %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=TLS %s
+//
 // GENERIC-ARM: --fix-cortex-a53-843419
 // CORTEX-A53: --fix-cortex-a53-843419
 // CORTEX-A57-NOT: --fix-cortex-a53-843419
 // MAX-PAGE-SIZE: max-page-size=4096
+// TLS: --android-tls
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -390,10 +390,22 @@
   CmdArgs.push_back("--fix-cortex-a53-843419");
   }
 
-  // Android does not allow shared text relocations. Emit a warning if the
-  // user's code contains any.
-  if (isAndroid)
-  CmdArgs.push_back("--warn-shared-textrel");
+  if (isAndroid) {
+// Android does not allow shared text relocations. Emit a warning if the
+// user's code contains any.
+CmdArgs.push_back("--warn-shared-textrel");
+
+// FIXME In lld, --android-tls is a temporary option that makes its TLS
+// layout compatible with Android Bionic on ARM/AArch64. Delete once the
+// reservation of extra TLS slots is done in a proper layer (e.g.
+// crtbegin_{dynamic,static}.o).
+if (Triple.isARM() || Triple.isAArch64()) {
+  const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
+  if (llvm::sys::path::filename(Exec).equals_lower("ld.lld") ||
+  llvm::sys::path::stem(Exec).equals_lower("ld.lld"))
+CmdArgs.push_back("--android-tls");
+}
+  }
 
   for (const auto &Opt : ToolChain.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());


Index: test/Driver/android-arm-link.cpp
===
--- /dev/null
+++ test/Driver/android-arm-link.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang -target arm-linux-androideabi -### %s 2>&1 | \
+// RUN:   FileCheck --implicit-check-not=--android-tls /dev/null
+// RUN: %clang -target arm-linux-androideabi -fuse-ld=lld -### %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=TLS %s
+
+// TLS: --android-tls
Index: test/Driver/android-aarch64-link.cpp
===
--- test/Driver/android-aarch64-link.cpp
+++ test/Driver/android-aarch64-link.cpp
@@ -16,7 +16,13 @@
 // RUN:   -### -v %s 2> %t
 // RUN: FileCheck -check-prefix=MAX-PAGE-SIZE < %t %s
 //
+// RUN: %clang -target aarch64-linux-android -### %s 2>&1 | \
+// RUN:   FileCheck --implicit-check-not=--android-tls /dev/null
+// RUN: %clang -target aarch64-linux-android -fuse-ld=lld -### %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=TLS %s
+//
 // GENERIC-ARM: --fix-cortex-a53-843419
 // CORTEX-A53: --fix-cortex-a53-843419
 // CORTEX-A57-NOT: --fix-cortex-a53-843419
 // MAX-PAGE-SIZE: max-page-size=4096
+// TLS: --android-tls
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -390,10 +390,22 @@
   CmdArgs.push_back("--fix-cortex-a53-843419");
   }
 
-  // Android does not allow shared text relocations. Emit a warning if the
-  // user's code contains any.
-  if (isAndroid)
-  CmdArgs.push_back("--warn-shared-textrel");
+  if (isAndroid) {
+// Android does not allow shared text relocations. Emit a warning if the
+// user's code contains any.
+CmdArgs.push_back("--warn-shared-textrel");
+
+// FIXME In lld, --android-tls is a temporary option that makes its TLS
+// layout compatible with Android Bionic on ARM/AArch64. Delete once the
+// reservation of extra TLS slots is done in a proper layer (e.g.
+// crtbegin_{dynamic,static}.o).
+if (Triple.isARM() || Triple.isAArch64()) {
+  const char *Exec = Args.MakeArgString(ToolChain.Get

[PATCH] D61487: [clang-tidy] Make the plugin honor NOLINT

2019-05-15 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

Ping. alexfh?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61487



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


[PATCH] D61939: AArch64: add support for arm64_23 (ILP32) IR generation

2019-05-15 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover created this revision.
Herald added subscribers: jfb, kristof.beyls, javed.absar, mcrosier.
Herald added a project: clang.

This patch implements the arm64_32 ABI used in watchOS from the Clang side. 
It's mostly pretty straightforward since it's so close to normal AArch64: 
handle the aarch64_32 Triple component and toggle the appropriate ABI flags for 
bitfields and vectors.


Repository:
  rC Clang

https://reviews.llvm.org/D61939

Files:
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/arm64_32-vaarg.c
  clang/test/CodeGen/arm64_32.c
  clang/test/CodeGen/builtins-arm64.c
  clang/test/CodeGen/target-data.c
  clang/test/CodeGenCXX/armv7k.cpp
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm64_32-link.c
  clang/test/Preprocessor/aarch64-target-features.c
  clang/test/Preprocessor/arm64_32.c
  clang/test/Preprocessor/init-v7k-compat.c
  clang/test/Preprocessor/stdint.c
  clang/test/Sema/types.c

Index: clang/test/Sema/types.c
===
--- clang/test/Sema/types.c
+++ clang/test/Sema/types.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 %s -fblocks -pedantic -verify -triple=mips64-linux-gnu
 // RUN: %clang_cc1 %s -fblocks -pedantic -verify -triple=x86_64-unknown-linux
 // RUN: %clang_cc1 %s -fblocks -pedantic -verify -triple=x86_64-unknown-linux-gnux32
+// RUN: %clang_cc1 %s -fblocks -pedantic -pedantic -verify -triple=arm64_32-apple-ios7.0
 
 // rdar://6097662
 typedef int (*T)[2];
Index: clang/test/Preprocessor/stdint.c
===
--- clang/test/Preprocessor/stdint.c
+++ clang/test/Preprocessor/stdint.c
@@ -105,6 +105,113 @@
 // ARM:INTMAX_C_(0) 0LL
 // ARM:UINTMAX_C_(0) 0ULL
 //
+// RUN: %clang_cc1 -E -ffreestanding -triple=arm64_32-apple-ios7.0 %s | FileCheck -check-prefix ARM64_32 %s
+//
+// ARM64_32:typedef long long int int64_t;
+// ARM64_32:typedef long long unsigned int uint64_t;
+// ARM64_32:typedef int64_t int_least64_t;
+// ARM64_32:typedef uint64_t uint_least64_t;
+// ARM64_32:typedef int64_t int_fast64_t;
+// ARM64_32:typedef uint64_t uint_fast64_t;
+//
+// ARM64_32:typedef int int32_t;
+// ARM64_32:typedef unsigned int uint32_t;
+// ARM64_32:typedef int32_t int_least32_t;
+// ARM64_32:typedef uint32_t uint_least32_t;
+// ARM64_32:typedef int32_t int_fast32_t;
+// ARM64_32:typedef uint32_t uint_fast32_t;
+// 
+// ARM64_32:typedef short int16_t;
+// ARM64_32:typedef unsigned short uint16_t;
+// ARM64_32:typedef int16_t int_least16_t;
+// ARM64_32:typedef uint16_t uint_least16_t;
+// ARM64_32:typedef int16_t int_fast16_t;
+// ARM64_32:typedef uint16_t uint_fast16_t;
+//
+// ARM64_32:typedef signed char int8_t;
+// ARM64_32:typedef unsigned char uint8_t;
+// ARM64_32:typedef int8_t int_least8_t;
+// ARM64_32:typedef uint8_t uint_least8_t;
+// ARM64_32:typedef int8_t int_fast8_t;
+// ARM64_32:typedef uint8_t uint_fast8_t;
+//
+// ARM64_32:typedef long int intptr_t;
+// ARM64_32:typedef long unsigned int uintptr_t;
+// 
+// ARM64_32:typedef long long int intmax_t;
+// ARM64_32:typedef long long unsigned int uintmax_t;
+//
+// ARM64_32:INT8_MAX_ 127
+// ARM64_32:INT8_MIN_ (-127 -1)
+// ARM64_32:UINT8_MAX_ 255
+// ARM64_32:INT_LEAST8_MIN_ (-127 -1)
+// ARM64_32:INT_LEAST8_MAX_ 127
+// ARM64_32:UINT_LEAST8_MAX_ 255
+// ARM64_32:INT_FAST8_MIN_ (-127 -1)
+// ARM64_32:INT_FAST8_MAX_ 127
+// ARM64_32:UINT_FAST8_MAX_ 255
+//
+// ARM64_32:INT16_MAX_ 32767
+// ARM64_32:INT16_MIN_ (-32767 -1)
+// ARM64_32:UINT16_MAX_ 65535
+// ARM64_32:INT_LEAST16_MIN_ (-32767 -1)
+// ARM64_32:INT_LEAST16_MAX_ 32767
+// ARM64_32:UINT_LEAST16_MAX_ 65535
+// ARM64_32:INT_FAST16_MIN_ (-32767 -1)
+// ARM64_32:INT_FAST16_MAX_ 32767
+// ARM64_32:UINT_FAST16_MAX_ 65535
+//
+// ARM64_32:INT32_MAX_ 2147483647
+// ARM64_32:INT32_MIN_ (-2147483647 -1)
+// ARM64_32:UINT32_MAX_ 4294967295U
+// ARM64_32:INT_LEAST32_MIN_ (-2147483647 -1)
+// ARM64_32:INT_LEAST32_MAX_ 2147483647
+// ARM64_32:UINT_LEAST32_MAX_ 4294967295U
+// ARM64_32:INT_FAST32_MIN_ (-2147483647 -1)
+// ARM64_32:INT_FAST32_MAX_ 2147483647
+// ARM64_32:UINT_FAST32_MAX_ 4294967295U
+//
+// ARM64_32:INT64_MAX_ 9223372036854775807LL
+// ARM64_32:INT64_MIN_ (-9223372036854775807LL -1)
+// ARM64_32:UINT64_MAX_ 18446744073709551615ULL
+// ARM64_32:INT_LEAST64_MIN_ (-9223372036854775807LL -1)
+// ARM64_32:INT_LEAST64_MAX_ 9223372036854775807LL
+// ARM64_32:UINT_LEAST64_MAX_ 18446744073709551615ULL
+// ARM64_32:INT_FAST64_MIN_ (-9223372036854775807LL -1)
+// ARM64_32:INT_FAST64_MAX_ 9223372036854775807LL
+// ARM64_32:UINT_FAST64_MAX_ 18446744073709551615ULL
+//
+// ARM64_32:INTPTR_MIN_ (-214748364

[PATCH] D59413: Fix isInSystemMacro in presence of macro and pasted token

2019-05-15 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 199585.
serge-sans-paille added a comment.

Updated with clang-formated diff


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

https://reviews.llvm.org/D59413

Files:
  clang/include/clang/Basic/SourceManager.h
  clang/test/Misc/no-warn-in-system-macro.c


Index: clang/test/Misc/no-warn-in-system-macro.c
===
--- clang/test/Misc/no-warn-in-system-macro.c
+++ clang/test/Misc/no-warn-in-system-macro.c
@@ -3,11 +3,16 @@
 
 #include 
 
+#define MACRO(x) x
+
 int main(void)
 {
double foo = 1.0;
 
if (isnan(foo))
return 1;
-   return 0;
+
+MACRO(isnan(foo));
+
+return 0;
 }
Index: clang/include/clang/Basic/SourceManager.h
===
--- clang/include/clang/Basic/SourceManager.h
+++ clang/include/clang/Basic/SourceManager.h
@@ -1466,8 +1466,13 @@
 
 // This happens when the macro is the result of a paste, in that case
 // its spelling is the scratch memory, so we take the parent context.
-if (isWrittenInScratchSpace(getSpellingLoc(loc)))
-  return isInSystemHeader(getSpellingLoc(getImmediateMacroCallerLoc(loc)));
+// There can be several level of token pasting.
+if (isWrittenInScratchSpace(getSpellingLoc(loc))) {
+  do {
+loc = getImmediateMacroCallerLoc(loc);
+  } while (isWrittenInScratchSpace(getSpellingLoc(loc)));
+  return isInSystemMacro(loc);
+}
 
 return isInSystemHeader(getSpellingLoc(loc));
   }


Index: clang/test/Misc/no-warn-in-system-macro.c
===
--- clang/test/Misc/no-warn-in-system-macro.c
+++ clang/test/Misc/no-warn-in-system-macro.c
@@ -3,11 +3,16 @@
 
 #include 
 
+#define MACRO(x) x
+
 int main(void)
 {
 	double foo = 1.0;
 
 	if (isnan(foo))
 		return 1;
-	return 0;
+
+MACRO(isnan(foo));
+
+return 0;
 }
Index: clang/include/clang/Basic/SourceManager.h
===
--- clang/include/clang/Basic/SourceManager.h
+++ clang/include/clang/Basic/SourceManager.h
@@ -1466,8 +1466,13 @@
 
 // This happens when the macro is the result of a paste, in that case
 // its spelling is the scratch memory, so we take the parent context.
-if (isWrittenInScratchSpace(getSpellingLoc(loc)))
-  return isInSystemHeader(getSpellingLoc(getImmediateMacroCallerLoc(loc)));
+// There can be several level of token pasting.
+if (isWrittenInScratchSpace(getSpellingLoc(loc))) {
+  do {
+loc = getImmediateMacroCallerLoc(loc);
+  } while (isWrittenInScratchSpace(getSpellingLoc(loc)));
+  return isInSystemMacro(loc);
+}
 
 return isInSystemHeader(getSpellingLoc(loc));
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61816: [CFG] [analyzer] pr41300: Add a branch to skip virtual base initializers when they are handled by the superclass.

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

Exquisite detective work as always! I read a bit of the standard, your summary, 
the bugreport and the new test cases, and I feel confident that I have a good 
understanding of the problem and your solution, though I didn't dig through the 
details just yet. At a first glance this looks great, and I'll be sure to 
revisit this patch and accept it formally.

> The //expression-list// or //braced-init-list// in a //mem-initializer// is 
> used to initialize the designated subobject (or, in the case of a delegating 
> constructor, the complete class object) according to the initialization rules 
> of 11.6 for direct-initialization. [ //Example://
> 
>   struct B1 { B1(int) ; /* . . . */ };
>   struct B2 { B2(int) ; /* . . . */ };
>   struct D : B1, B2 {
> D(int) ;
> B1 b;
> const int c;
>   };
>   D: : D(int a) : B2(a+1) , B1(a+2) , c(a+3) , b(a+4) { /* . . . */ }
>   D d(10) ;
> 
> //— end example// ] [ //Note:// The initialization performed by each 
> //mem-initializer// constitutes a full-expression (4.6) . Any expression in a 
> //mem-initializer// is evaluated as part of the full-expression that performs 
> the initialization. //— end note// ] **A //mem-initializer// where the 
> //mem-initializer-id// denotes a virtual base class is ignored during 
> execution of a constructor of any class that is not the most derived class.**

I think this part of the standard isn't well known (due mostly the the scarcity 
of virtual bases), and I'd like to see it referenced, maybe even quoted.




Comment at: clang/include/clang/Analysis/CFG.h:567
+/// &&, |||  expression that uses result of && or ||, RHS
+/// vbase inits   |  handled by superclass; not handled by superclass
 ///

In the context of this patch, I understand what you mean, but without that, 
this might not be a good description for a class this important.

How about

```
/// vbase inits   |  initialization handled by superclass;
///   |  initialization not handled by superclass
```
?


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

https://reviews.llvm.org/D61816



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


[PATCH] D60283: [DebugInfo] Don't emit checksums when compiling a preprocessed CPP

2019-05-15 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 199599.
aganea marked an inline comment as done.
aganea added a comment.

Updated again with a different solution. We can't just act on 
`Entry.getFile().hasLineDirectives()` because a directive such as `#line 100` 
simply overrides the `__LINE__`, not `__FILE__` (we need to retain and hash the 
previous `__FILE__` in that case). Please see an example here 

 in the IBM documentation.
Also we can't compare by `FileID` because a `LineEntry` simply stores a string 
(called filename) but the buffer for that file isn't stored in the 
SourceManager.


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

https://reviews.llvm.org/D60283

Files:
  include/clang/Basic/SourceLocation.h
  lib/Basic/SourceManager.cpp
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
  test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
  test/CodeGen/debug-info-file-checksum.c

Index: test/CodeGen/debug-info-file-checksum.c
===
--- test/CodeGen/debug-info-file-checksum.c
+++ test/CodeGen/debug-info-file-checksum.c
@@ -4,3 +4,15 @@
 // Check that "checksum" is created correctly for the compiled file.
 
 // CHECK: !DIFile(filename:{{.*}}, directory:{{.*}}, checksumkind: CSK_MD5, checksum: "a3b7d27af071accdeccaa933fc603608")
+
+// Ensure #line directives (in already pre-processed files) do not emit checksums
+// RUN: %clang -emit-llvm -S -g -gcodeview -x c %S/Inputs/debug-info-file-checksum-pre.cpp -o - | FileCheck %s --check-prefix NOCHECKSUM
+
+// NOCHECKSUM-LABEL: !DIFile(filename: "{{.*}}code-coverage-filter1.h", directory: "{{[^"]*}}")
+// NOCHECKSUM-LABEL: !DIFile(filename: "{{.*}}code-coverage-filter2.h", directory: "{{[^"]*}}")
+// NOCHECKSUM-LABEL: !DIFile(filename: "{{.*}}debug-info-file-checksum.c", directory: "{{[^"]*}}")
+
+// Ensure #line directives without name do emit checksums
+// RUN: %clang -emit-llvm -S -g -gcodeview -x c %S/Inputs/debug-info-file-checksum-line.cpp -o - | FileCheck %s --check-prefix CHECKSUM
+
+// CHECKSUM: !DIFile(filename: "{{.*}}debug-info-file-checksum-line.cpp", directory:{{.*}}, checksumkind: CSK_MD5, checksum: "7b568574d0e3c56c28e5e0234d1f4a06")
Index: test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
===
--- test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
+++ test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
@@ -0,0 +1,10 @@
+#line 1 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+#line 1 "f:\\svn\\clang\\test\\codegen\\inputs\\code-coverage-filter1.h"
+void test1() {}
+#line 2 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+#line 1 "f:\\svn\\clang\\test\\codegen\\inputs\\code-coverage-filter2.h"
+void test2() {}
+#line 3 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+int foo(int x) {
+  return x+1;
+}
Index: test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
===
--- test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
+++ test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
@@ -0,0 +1,10 @@
+int foo(int x) {
+  vprintf("test %d", x);
+  return x+1;
+}
+
+#line 100
+void test1() {}
+
+#line 200
+void test2() {}
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -422,8 +422,13 @@
   }
 
   SmallString<32> Checksum;
+
+  // Don't compute checksums if the location is affected by a #line directive
+  // that refers to a file. We would otherwise end up with the same checksum for
+  // all the files referred by #line. Instead the checksum remains empty,
+  // leaving to the debugger to open the file without checksum validation.
   Optional CSKind =
-  computeChecksum(SM.getFileID(Loc), Checksum);
+  computeChecksum(PLoc.getFileID(), Checksum);
   Optional> CSInfo;
   if (CSKind)
 CSInfo.emplace(*CSKind, Checksum);
Index: lib/Basic/SourceManager.cpp
===
--- lib/Basic/SourceManager.cpp
+++ lib/Basic/SourceManager.cpp
@@ -1430,6 +1430,7 @@
   // To get the source name, first consult the FileEntry (if one exists)
   // before the MemBuffer as this will avoid unnecessarily paging in the
   // MemBuffer.
+  FileID FID = LocInfo.first;
   StringRef Filename;
   if (C->OrigEntry)
 Filename = C->OrigEntry->getName();
@@ -1453,8 +1454,11 @@
 if (const LineEntry *Entry =
   LineTable->FindNearestLineEntry(LocInfo.first, LocInfo.second)) {
   // If the LineEntry indicates a filename, use it.
-  if (Entry->FilenameID != -1)
+  if (Entry->FilenameID != -1) {
 Filename = LineTable->getFilename(Entry->FilenameID);
+FID = FileID::get(0); 

[PATCH] D61945: ftime-trace as a CoreOption

2019-05-15 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea created this revision.
aganea added reviewers: thakis, anton-afanasyev.
aganea added a project: clang.

As suggested here  by @thakis , make 
so that `-ftime-trace` can be used directly in clang-cl without `-Xclang`


Repository:
  rC Clang

https://reviews.llvm.org/D61945

Files:
  include/clang/Driver/Options.td
  test/Driver/cl-options.c


Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -638,6 +638,7 @@
 // RUN: -fno-profile-instr-use \
 // RUN: -fcs-profile-generate \
 // RUN: -fcs-profile-generate=dir \
+// RUN: -ftime-trace \
 // RUN: --version \
 // RUN: -Werror /Zs -- %s 2>&1
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1747,7 +1747,7 @@
 def : Flag<["-"], "fterminated-vtables">, Alias;
 def fthreadsafe_statics : Flag<["-"], "fthreadsafe-statics">, Group;
 def ftime_report : Flag<["-"], "ftime-report">, Group, 
Flags<[CC1Option]>;
-def ftime_trace : Flag<["-"], "ftime-trace">, Group, 
Flags<[CC1Option]>;
+def ftime_trace : Flag<["-"], "ftime-trace">, Group, 
Flags<[CC1Option, CoreOption]>;
 def ftlsmodel_EQ : Joined<["-"], "ftls-model=">, Group, 
Flags<[CC1Option]>;
 def ftrapv : Flag<["-"], "ftrapv">, Group, Flags<[CC1Option]>,
   HelpText<"Trap on integer overflow">;


Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -638,6 +638,7 @@
 // RUN: -fno-profile-instr-use \
 // RUN: -fcs-profile-generate \
 // RUN: -fcs-profile-generate=dir \
+// RUN: -ftime-trace \
 // RUN: --version \
 // RUN: -Werror /Zs -- %s 2>&1
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1747,7 +1747,7 @@
 def : Flag<["-"], "fterminated-vtables">, Alias;
 def fthreadsafe_statics : Flag<["-"], "fthreadsafe-statics">, Group;
 def ftime_report : Flag<["-"], "ftime-report">, Group, Flags<[CC1Option]>;
-def ftime_trace : Flag<["-"], "ftime-trace">, Group, Flags<[CC1Option]>;
+def ftime_trace : Flag<["-"], "ftime-trace">, Group, Flags<[CC1Option, CoreOption]>;
 def ftlsmodel_EQ : Joined<["-"], "ftls-model=">, Group, Flags<[CC1Option]>;
 def ftrapv : Flag<["-"], "ftrapv">, Group, Flags<[CC1Option]>,
   HelpText<"Trap on integer overflow">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61945: ftime-trace as a CoreOption

2019-05-15 Thread Anton Afanasyev via Phabricator via cfe-commits
anton-afanasyev accepted this revision.
anton-afanasyev added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D61945



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


[PATCH] D61923: [GWP-ASan] Mutex implementation [2].

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

In D61923#1502337 , @eugenis wrote:

> I think the idea is that implementing our own spinlock is not much harder 
> than having 3 platform-specific implementations (posix, window, fuchsia).
>  Also, scudo_standalone is doing the same (  @cryptoad, why? ).
>
> As Mitch mentioned, we should move the implementation into a common 
> directory. Why not do this now?


Is the question why do Scudo has its own as opposed to rely on platform 
specific ones?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61923



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


[PATCH] D61634: [clang/llvm] Allow efficient implementation of libc's memory functions in C/C++

2019-05-15 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D61634#1502685 , @gchatelet wrote:

> In D61634#1502201 , @tejohnson wrote:
>
> > Using function level attributes instead of module flags does provide finer 
> > grained control and avoids the conservativeness when merging IR for LTO. 
> > The downsides I see, mostly just in terms of the engineering effort to get 
> > this to work, are:
> >
> > - need to prevent inlining with different attributes
>
>
> IIUC this is needed regardless of the proposed change. Correct?


With the module flags approach, no - because there won't be fine grained enough 
info to do so. Any merged IR will need to use the conservatively set merged 
flag for the whole module. Or did you mean in comparison with the approach in 
this patch? I haven't looked at this one in any detail yet.

> 
> 
>> - currently the TargetLibraryInfo is constructed on a per-module basis. 
>> Presumably it would instead need to be created per Function - this one in 
>> particular seems like it would require fairly extensive changes.
> 
> Yes this one is a bit worrying.
>  I think we can discard right away any solution that would mutate or create a 
> TLI on a per function basis.
>  Another design would be something like the following:
> 
>   auto FunctionTLI = ModuleTLI.createCustomizedTLI(F);
> 
> 
> where `FunctionTLI` is itself a `TargetLibraryInfo` and calls to 
> `FunctionTLI` would either return the function customizations or delegate to 
> the module's TLI. WDYT?

I don't think this makes it much easier - all TLI users still need to be taught 
to get and use this new Function level TLI. I guess for Function (or lower) 
passes it would be fairly straightforward, but for things like Module level or 
SCC passes it will require more wiring to ensure that the FunctionTLI is 
accessed in the appropriate places. Doable just a lot of manual changes.

> I'm unsure if we want to support function level attribute right away or if 
> it's OK to be in an intermediate state with only module level attributes.

I'm interested in thoughts from other developers here. The module flag change 
is straightforward, but unnecessary churn if we want to go the function 
attribute route. Which despite the work seems like the best long term 
approach...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61634



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


[PATCH] D60162: [ThinLTO] Add module flags for TargetLibraryInfoImpl and use in LTO backends

2019-05-15 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

There is discussion of using function attributes to control this instead, see 
https://reviews.llvm.org/D61634.
I'll hold off on making the planned changes here until the overall approach is 
decided.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60162



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


[clang-tools-extra] r360779 - [clang-tidy] new check: bugprone-branch-clone

2019-05-15 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Wed May 15 08:06:25 2019
New Revision: 360779

URL: http://llvm.org/viewvc/llvm-project?rev=360779&view=rev
Log:
[clang-tidy] new check: bugprone-branch-clone

Implement a check for detecting if/else if/else chains where two or more
branches are Type I clones of each other (that is, they contain identical code)
and for detecting switch statements where two or more consecutive branches are
Type I clones of each other.

Patch by Donát Nagy!

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

Added:
clang-tools-extra/trunk/clang-tidy/bugprone/BranchCloneCheck.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/BranchCloneCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-branch-clone.rst
clang-tools-extra/trunk/test/clang-tidy/bugprone-branch-clone.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Added: clang-tools-extra/trunk/clang-tidy/bugprone/BranchCloneCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/BranchCloneCheck.cpp?rev=360779&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/BranchCloneCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/BranchCloneCheck.cpp Wed May 15 
08:06:25 2019
@@ -0,0 +1,226 @@
+//===--- BranchCloneCheck.cpp - clang-tidy 
===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "BranchCloneCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Analysis/CloneDetection.h"
+#include "llvm/Support/Casting.h"
+
+using namespace clang;
+using namespace clang::ast_matchers;
+
+/// Returns true when the statements are Type I clones of each other.
+static bool areStatementsIdentical(const Stmt *LHS, const Stmt *RHS,
+   const ASTContext &Context) {
+  llvm::FoldingSetNodeID DataLHS, DataRHS;
+  LHS->Profile(DataLHS, Context, false);
+  RHS->Profile(DataRHS, Context, false);
+  return (DataLHS == DataRHS);
+}
+
+namespace {
+/// A branch in a switch may consist of several statements; while a branch in
+/// an if/else if/else chain is one statement (which may be a CompoundStmt).
+using SwitchBranch = llvm::SmallVector;
+} // anonymous namespace
+
+/// Determines if the bodies of two branches in a switch statements are Type I
+/// clones of each other. This function only examines the body of the branch
+/// and ignores the `case X:` or `default:` at the start of the branch.
+static bool areSwitchBranchesIdentical(const SwitchBranch LHS,
+   const SwitchBranch RHS,
+   const ASTContext &Context) {
+  if (LHS.size() != RHS.size())
+return false;
+
+  for (size_t i = 0, Size = LHS.size(); i < Size; i++) {
+// NOTE: We strip goto labels and annotations in addition to stripping
+// the `case X:` or `default:` labels, but it is very unlikely that this
+// would casue false positives in real-world code.
+if (!areStatementsIdentical(LHS[i]->stripLabelLikeStatements(),
+RHS[i]->stripLabelLikeStatements(), Context)) {
+  return false;
+}
+  }
+
+  return true;
+}
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+void BranchCloneCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  ifStmt(stmt().bind("if"),
+ hasParent(stmt(unless(ifStmt(hasElse(equalsBoundNode("if")),
+ hasElse(stmt().bind("else"))),
+  this);
+  Finder->addMatcher(switchStmt().bind("switch"), this);
+  Finder->addMatcher(conditionalOperator().bind("condOp"), this);
+}
+
+void BranchCloneCheck::check(const MatchFinder::MatchResult &Result) {
+  const ASTContext &Context = *Result.Context;
+
+  if (const auto *IS = Result.Nodes.getNodeAs("if")) {
+const Stmt *Then = IS->getThen();
+assert(Then && "An IfStmt must have a `then` branch!");
+
+const Stmt *Else = Result.Nodes.getNodeAs("else");
+assert(Else && "We only look for `if` statements with an `else` branch!");
+
+if (!isa(Else)) {
+  // Just a simple if with no `else if` branch.
+  if (areStatementsIdentical(Then->IgnoreContainers(),
+ Else->IgnoreContainers(), Context)) {
+diag(IS->getBeginLoc(), "if with identical then and else branches");
+diag(IS->getElseLoc(), "else branch starts here", DiagnosticIDs::Note);
+  }
+  return;
+}
+
+// This is th

[PATCH] D54757: [clang-tidy] new check: bugprone-branch-clone

2019-05-15 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE360779: [clang-tidy] new check: bugprone-branch-clone 
(authored by Szelethus, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54757?vs=198025&id=199611#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D54757

Files:
  clang-tidy/bugprone/BranchCloneCheck.cpp
  clang-tidy/bugprone/BranchCloneCheck.h
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-branch-clone.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-branch-clone.cpp

Index: test/clang-tidy/bugprone-branch-clone.cpp
===
--- test/clang-tidy/bugprone-branch-clone.cpp
+++ test/clang-tidy/bugprone-branch-clone.cpp
@@ -0,0 +1,1026 @@
+// RUN: %check_clang_tidy %s bugprone-branch-clone %t
+
+void test_basic1(int in, int &out) {
+  if (in > 77)
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if with identical then and else branches [bugprone-branch-clone]
+out++;
+  else
+// CHECK-MESSAGES: :[[@LINE-1]]:3: note: else branch starts here
+out++;
+
+  out++;
+}
+
+void test_basic2(int in, int &out) {
+  if (in > 77) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if with identical then and else branches [bugprone-branch-clone]
+out++;
+  }
+  else {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: note: else branch starts here
+out++;
+  }
+
+  out++;
+}
+
+void test_basic3(int in, int &out) {
+  if (in > 77) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if with identical then and else branches [bugprone-branch-clone]
+out++;
+  }
+  else
+// CHECK-MESSAGES: :[[@LINE-1]]:3: note: else branch starts here
+out++;
+
+  out++;
+}
+
+void test_basic4(int in, int &out) {
+  if (in > 77) {
+out--;
+  }
+  else {
+out++;
+  }
+}
+
+void test_basic5(int in, int &out) {
+  if (in > 77) {
+out++;
+  }
+  else {
+out++;
+out++;
+  }
+}
+
+void test_basic6(int in, int &out) {
+  if (in > 77) {
+out++;
+  }
+  else {
+out++, out++;
+  }
+}
+
+void test_basic7(int in, int &out) {
+  if (in > 77) {
+out++;
+out++;
+  }
+  else
+out++;
+
+  out++;
+}
+
+void test_basic8(int in, int &out) {
+  if (in > 77) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if with identical then and else branches [bugprone-branch-clone]
+out++;
+out++;
+  } else {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: note: else branch starts here
+out++;
+out++;
+  }
+
+  if (in % 2)
+out++;
+}
+
+void test_basic9(int in, int &out) {
+  if (in > 77) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if with identical then and else branches [bugprone-branch-clone]
+if (in % 2)
+  out++;
+else
+  out--;
+  } else {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: note: else branch starts here
+if (in % 2)
+  out++;
+else
+  out--;
+  }
+}
+
+// If we remove the braces from the previous example, the check recognizes it
+// as an `else if`.
+void test_basic10(int in, int &out) {
+  if (in > 77)
+if (in % 2)
+  out++;
+else
+  out--;
+  else
+if (in % 2)
+  out++;
+else
+  out--;
+
+}
+
+void test_basic11(int in, int &out) {
+  if (in > 77) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if with identical then and else branches [bugprone-branch-clone]
+if (in % 2)
+  out++;
+else
+  out--;
+if (in % 3)
+  out++;
+else
+  out--;
+  } else {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: note: else branch starts here
+if (in % 2)
+  out++;
+else
+  out--;
+if (in % 3)
+  out++;
+else
+  out--;
+  }
+}
+
+void test_basic12(int in, int &out) {
+  if (in > 77) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if with identical then and else branches [bugprone-branch-clone]
+  } else {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: note: else branch starts here
+  }
+}
+
+void test_basic13(int in, int &out) {
+  if (in > 77) {
+// Empty compound statement is not identical to null statement.
+  } else;
+}
+
+// We use a comparison that ignores redundant parentheses:
+void test_basic14(int in, int &out) {
+  if (in > 77)
+out += 2;
+  else
+(out) += (2);
+}
+
+void test_basic15(int in, int &out) {
+  if (in > 77)
+((out += 2));
+  else
+out += 2;
+}
+
+// ..but does not apply additional simplifications:
+void test_basic16(int in, int &out) {
+  if (in > 77)
+out += 2;
+  else
+out += 1 + 1;
+}
+
+// ..and does not forget important parentheses:
+int test_basic17(int a, int b, int c, int mode) {
+  if (mode>8)
+return (a + b) * c;
+  else
+return a + b * c;
+}
+
+//===//
+
+#define PASTE_CODE(x) x
+
+void test_macro1(int in, int &out) {
+  PASTE_CODE(
+if (in > 77)
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: if with identical then and el

[PATCH] D61949: [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

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

In OpenMP device offloading we must ensure that unde C++ 17, the inclusion of 
cstdlib will works correctly.


Repository:
  rC Clang

https://reviews.llvm.org/D61949

Files:
  lib/Headers/__clang_cuda_device_functions.h
  lib/Headers/__clang_cuda_math_forward_declares.h
  lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
  test/Headers/Inputs/include/cstdlib
  test/Headers/nvptx_device_cmath_functions_cxx17.cpp
  test/Headers/nvptx_device_math_functions_cxx17.cpp

Index: test/Headers/nvptx_device_math_functions_cxx17.cpp
===
--- /dev/null
+++ test/Headers/nvptx_device_math_functions_cxx17.cpp
@@ -0,0 +1,22 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -std=c++17
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -internal-isystem %S/Inputs/include -include stdlib.h -include limits -include cstdlib -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -std=c++17 -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, &a1);
+  }
+}
Index: test/Headers/nvptx_device_cmath_functions_cxx17.cpp
===
--- /dev/null
+++ test/Headers/nvptx_device_cmath_functions_cxx17.cpp
@@ -0,0 +1,22 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include cmath -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -std=c++17
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -internal-isystem %S/Inputs/include -include stdlib.h -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -std=c++17 -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, &a1);
+  }
+}
Index: test/Headers/Inputs/include/cstdlib
===
--- test/Headers/Inputs/include/cstdlib
+++ test/Headers/Inputs/include/cstdlib
@@ -1,7 +1,12 @@
 #pragma once
 
+#if __cplusplus >= 201703L
+extern int abs (int __x) throw()  __attribute__ ((__const__)) ;
+extern long int labs (long int __x) throw() __attribute__ ((__const__)) ;
+#else
 extern int abs (int __x) __attribute__ ((__const__)) ;
 extern long int labs (long int __x) __attribute__ ((__const__)) ;
+#endif
 
 namespace std
 {
Index: lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
===
--- lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
+++ lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
@@ -20,6 +20,8 @@
 
 #if defined(__cplusplus)
   #include <__clang_cuda_math_forward_declares.h>
+  #include 
+  #include 
 #endif
 
 /// Include declarations for libdevice functions.
Index: lib/Headers/__clang_cuda_math_forward_declares.h
===
--- lib/Headers/__clang_cuda_math_forward_declares.h
+++ lib/Headers/__clang_cuda_math_forward_declares.h
@@ -31,7 +31,11 @@
 __DEVICE__ long abs(long);
 __DEVICE__ long long abs(long long);
 #endif
+#if __cplusplus >= 201703L
+__DEVICE__ int abs(int) noexcept;
+#else
 __DEVICE__ int abs(int);
+#endif
 __DEVICE__ double abs(double);
 __DEVICE__ float abs(float);
 __DEV

[PATCH] D61634: [clang/llvm] Allow efficient implementation of libc's memory functions in C/C++

2019-05-15 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a subscriber: chandlerc.
hfinkel added a comment.

In D61634#1502201 , @tejohnson wrote:

> In D61634#1502138 , @hfinkel wrote:
>
> > In D61634#1502043 , @efriedma 
> > wrote:
> >
> > > > I have a related patch that turns -fno-builtin* options into module 
> > > > flags
> > >
> > > Do you have any opinion on representing -fno-builtin using a module flag 
> > > vs. a function attribute in IR?  It seems generally more flexible and 
> > > easier to reason about a function attribute from my perspective.  But I 
> > > might be missing something about the semantics of -fno-builtin that would 
> > > make that representation awkward.  Or I guess it might just be more work 
> > > to implement, given we have some IPO passes that use TargetLibraryInfo?
> >
> >
> > I think that a function attribute would be better. We generally use these 
> > flags only in the context of certain translation units, and when we use 
> > LTO, it would be sad if we had to take the most-conservative settings 
> > across the entire application. When we insert new function call to a 
> > standard library, we always do it in the context of some function. We'd 
> > probably need to block inlining in some cases, but that's better than a 
> > global conservative setting.
>
>
> Using function level attributes instead of module flags does provide finer 
> grained control and avoids the conservativeness when merging IR for LTO. The 
> downsides I see, mostly just in terms of the engineering effort to get this 
> to work, are:
>
> - need to prevent inlining with different attributes


I think that this should be relatively straightforward. You just need to update 
`AttributeFuncs::areInlineCompatible` and/or 
`AttributeFuncs::mergeAttributesForInlining` by adding a new MergeRule in 
include/llvm/IR/Attributes.td and writing a function like 
adjustCallerStackProbeSize.

> - currently the TargetLibraryInfo is constructed on a per-module basis. 
> Presumably it would instead need to be created per Function - this one in 
> particular seems like it would require fairly extensive changes.

Interesting point. The largest issue I see is that we need TLI available from 
loop passes, etc., and we can't automatically recompute a function-level 
analysis there. We need to make sure that it's always available and not 
invalidated. TLI is one of those analysis passes, being derived only from 
things which don't change (i.e., the target triple), or things that change very 
rarely (e.g., function attributes), that we probably don't want to require all 
passes to explicitly say that they preserve it (not that the mechanical change 
to all existing passes is hard, but it's easy to forget), so I think we'd like 
something like the CFG-only concept in the current passes, but stronger and 
perhaps turned on by default, for this kind of "attributes-only" pass. 
(@chandlerc , thoughts on this?).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61634



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


[PATCH] D61950: [PowerPC64] recognize target triplet with ABI info (i.e. powerpc64-unknown-freebsd13-elfv2)

2019-05-15 Thread Alfredo Dal'Ava Júnior via Phabricator via cfe-commits
adalava created this revision.
Herald added subscribers: llvm-commits, cfe-commits, jsji, dexonsmith, kbarton, 
hiraditya, nemanjai.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61950

Files:
  clang/lib/Basic/Targets/PPC.h
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp
  llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
  llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll


Index: llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
===
--- llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
+++ llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
@@ -5,6 +5,14 @@
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu 
-target-abi elfv1 < %s | FileCheck %s -check-prefix=CHECK-ELFv1
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu 
-target-abi elfv2 < %s | FileCheck %s -check-prefix=CHECK-ELFv2
 
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd < %s | 
FileCheck %s -check-prefix=CHECK-ELFv1
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd 
-target-abi elfv1 < %s | FileCheck %s -check-prefix=CHECK-ELFv1
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd 
-target-abi elfv2 < %s | FileCheck %s -check-prefix=CHECK-ELFv2
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd-elfv1  < 
%s | FileCheck %s -check-prefix=CHECK-ELFv1
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd-elfv2  < 
%s | FileCheck %s -check-prefix=CHECK-ELFv2
+
+
+
 ; CHECK-ELFv2: .abiversion 2
 ; CHECK-ELFv1-NOT: .abiversion 2
 
Index: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
===
--- llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -214,7 +214,11 @@
   case Triple::ppc64le:
 return PPCTargetMachine::PPC_ABI_ELFv2;
   case Triple::ppc64:
-return PPCTargetMachine::PPC_ABI_ELFv1;
+// if ELFv2 on target triple i.e. powerpc64-unknown-freebsd12.0-elfv2
+if (TT.getEnvironment() == llvm::Triple::ELFv2)
+  return PPCTargetMachine::PPC_ABI_ELFv2;
+else
+  return PPCTargetMachine::PPC_ABI_ELFv1;
   default:
 return PPCTargetMachine::PPC_ABI_UNKNOWN;
   }
Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -232,6 +232,8 @@
   case Musl: return "musl";
   case MuslEABI: return "musleabi";
   case MuslEABIHF: return "musleabihf";
+  case ELFv1: return "elfv1";
+  case ELFv2: return "elfv2";
   case MSVC: return "msvc";
   case Itanium: return "itanium";
   case Cygnus: return "cygnus";
@@ -532,6 +534,8 @@
 .StartsWith("musleabihf", Triple::MuslEABIHF)
 .StartsWith("musleabi", Triple::MuslEABI)
 .StartsWith("musl", Triple::Musl)
+.StartsWith("elfv1", Triple::ELFv1)
+.StartsWith("elfv2", Triple::ELFv2)
 .StartsWith("msvc", Triple::MSVC)
 .StartsWith("itanium", Triple::Itanium)
 .StartsWith("cygnus", Triple::Cygnus)
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -206,6 +206,8 @@
 Musl,
 MuslEABI,
 MuslEABIHF,
+ELFv1,
+ELFv2,
 
 MSVC,
 Itanium,
Index: clang/lib/Basic/Targets/PPC.h
===
--- clang/lib/Basic/Targets/PPC.h
+++ clang/lib/Basic/Targets/PPC.h
@@ -379,13 +379,11 @@
 
 if ((Triple.getArch() == llvm::Triple::ppc64le)) {
   resetDataLayout("e-m:e-i64:64-n32:64");
-  ABI = "elfv2";
 } else {
   resetDataLayout("E-m:e-i64:64-n32:64");
-  ABI = "elfv1";
 }
 
-switch (getTriple().getOS()) {
+switch (Triple.getOS()) {
 case llvm::Triple::FreeBSD:
   LongDoubleWidth = LongDoubleAlign = 64;
   LongDoubleFormat = &llvm::APFloat::IEEEdouble();


Index: llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
===
--- llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
+++ llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
@@ -5,6 +5,14 @@
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -target-abi elfv1 < %s | FileCheck %s -check-prefix=CHECK-ELFv1
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -target-abi elfv2 < %s | FileCheck %s -check-prefix=CHECK-ELFv2
 
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd < %s | FileCheck %s -check-prefix=CHECK-ELFv1
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd -target-abi elfv1 < %s | FileCheck %s -check-prefix=CHECK-ELFv1
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd -target-abi elfv2 < %s | FileCheck %s -check-prefix=CHECK-ELFv2
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-free

[PATCH] D61949: [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

2019-05-15 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: lib/Headers/__clang_cuda_device_functions.h:1477
 #endif // CUDA_VERSION >= 9020
+#if __cplusplus >= 201703L
+__DEVICE__ int abs(int __a) noexcept { return __nv_abs(__a); }

If I recall correctly, `__cplusplus` is not defined in C mode, so both GCC and 
Clang will issue a warning with `-Wundef`.

Maybe this can be solved with something similar to:
```lang=c
#ifdef __cplusplus
#define cpp_version __cplusplus
#else
#define cpp_version 0
#endif
```
(to avoid repetition of `#if defined(__cplusplus) && __cplusplus >= 201703L`)


Repository:
  rC Clang

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

https://reviews.llvm.org/D61949



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


[PATCH] D61950: [PowerPC64] adds ABI parsing when specified on target triple

2019-05-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Basic/Targets/PPC.h:382
   resetDataLayout("e-m:e-i64:64-n32:64");
-  ABI = "elfv2";
 } else {

Have you researched how GNU as chooses the default ABI?

I think the change may break some Linux ppc64le users as they expect the 
default elfv2.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61950



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


[PATCH] D61950: [PowerPC64] adds ABI parsing when specified on target triple

2019-05-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Basic/Targets/PPC.h:382
   resetDataLayout("e-m:e-i64:64-n32:64");
-  ABI = "elfv2";
 } else {

MaskRay wrote:
> Have you researched how GNU as chooses the default ABI?
> 
> I think the change may break some Linux ppc64le users as they expect the 
> default elfv2.
Sorry, it won't :) Then I think it is fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61950



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


[PATCH] D61950: [PowerPC64] adds ABI parsing when specified on target triple

2019-05-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:217
   case Triple::ppc64:
-return PPCTargetMachine::PPC_ABI_ELFv1;
+// if ELFv2 on target triple i.e. powerpc64-unknown-freebsd12.0-elfv2
+if (TT.getEnvironment() == llvm::Triple::ELFv2)

The initial word should be capitalized and the sentence should end with a 
period. At least this part of the comment (`if ELFv2 on target triple `) is 
redundant. I don't know if the other half `powerpc64-unknown-freebsd12.0-elfv2` 
is useful...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61950



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


[PATCH] D61949: [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

2019-05-15 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Missing `defined(__cplusplus)` to avoid warnings and we have to resolve the two 
new includes. Otherwise, this looks good. So, if you "fix" both go ahead and 
commit, if not, lets discuss.




Comment at: lib/Headers/__clang_cuda_device_functions.h:1477
 #endif // CUDA_VERSION >= 9020
+#if __cplusplus >= 201703L
+__DEVICE__ int abs(int __a) noexcept { return __nv_abs(__a); }

Hahnfeld wrote:
> If I recall correctly, `__cplusplus` is not defined in C mode, so both GCC 
> and Clang will issue a warning with `-Wundef`.
> 
> Maybe this can be solved with something similar to:
> ```lang=c
> #ifdef __cplusplus
> #define cpp_version __cplusplus
> #else
> #define cpp_version 0
> #endif
> ```
> (to avoid repetition of `#if defined(__cplusplus) && __cplusplus >= 201703L`)
I dislike defining the version and advice to repeating `#if 
defined(__cplusplus) && __cplusplus >= 201703L)`




Comment at: lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h:24
+  #include 
+  #include 
 #endif

I ask this question again and again, do we need them now? Why?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61949



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


Re: r360308 - [c++20] Implement P0846R0: allow (ADL-only) calls to template-ids whose

2019-05-15 Thread Stephan Bergmann via cfe-commits

The below commit started to cause the following failure:


$ cat test.cc
template struct S1 { static int const n = 0; };
template struct S2 { typedef int t; };
template struct S3 { typename S2::n < 0, int>::t n; };

$ clang++ -fsyntax-only test.cc
test.cc:3:53: error: use 'template' keyword to treat 'n' as a dependent
  template name
template struct S3 { typename S2::n < 0, int>::t n; };
^
template 
test.cc:3:46: error: missing 'typename' prior to dependent type name

  'S1::S1::n<0, int>::t'
template struct S3 { typename S2::n < 0, int>::t n; };
 ^
 typename 
test.cc:3:68: error: expected '>'

template struct S3 { typename S2::n < 0, int>::t n; };
   ^
3 errors generated.



On 09/05/2019 05:31, Richard Smith via cfe-commits wrote:

Author: rsmith
Date: Wed May  8 20:31:27 2019
New Revision: 360308

URL: http://llvm.org/viewvc/llvm-project?rev=360308&view=rev
Log:
[c++20] Implement P0846R0: allow (ADL-only) calls to template-ids whose
template name is not visible to unqualified lookup.

In order to support this without a severe degradation in our ability to
diagnose typos in template names, this change significantly restructures
the way we handle template-id-shaped syntax for which lookup of the
template name finds nothing.

Instead of eagerly diagnosing an undeclared template name, we now form a
placeholder template-name representing a name that is known to not find
any templates. When the parser sees such a name, it attempts to
disambiguate whether we have a less-than comparison or a template-id.
Any diagnostics or typo-correction for the name are delayed until its
point of use.

The upshot should be a small improvement of our diagostic quality
overall: we now take more syntactic context into account when trying to
resolve an undeclared identifier on the left hand side of a '<'. In
fact, this works well enough that the backwards-compatible portion (for
an undeclared identifier rather than a lookup that finds functions but
no function templates) is enabled in all language modes.

Added:
 cfe/trunk/test/SemaCXX/cxx2a-adl-only-template-id.cpp
Modified:
 cfe/trunk/include/clang/AST/ASTContext.h
 cfe/trunk/include/clang/AST/DeclarationName.h
 cfe/trunk/include/clang/AST/TemplateName.h
 cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
 cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
 cfe/trunk/include/clang/Basic/TemplateKinds.h
 cfe/trunk/include/clang/Parse/Parser.h
 cfe/trunk/include/clang/Sema/Sema.h
 cfe/trunk/lib/AST/ASTContext.cpp
 cfe/trunk/lib/AST/ASTImporter.cpp
 cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
 cfe/trunk/lib/AST/ItaniumMangle.cpp
 cfe/trunk/lib/AST/ODRHash.cpp
 cfe/trunk/lib/AST/TemplateName.cpp
 cfe/trunk/lib/Parse/ParseDecl.cpp
 cfe/trunk/lib/Parse/ParseDeclCXX.cpp
 cfe/trunk/lib/Parse/ParseExprCXX.cpp
 cfe/trunk/lib/Parse/ParseTemplate.cpp
 cfe/trunk/lib/Parse/ParseTentative.cpp
 cfe/trunk/lib/Parse/Parser.cpp
 cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
 cfe/trunk/lib/Sema/SemaDecl.cpp
 cfe/trunk/lib/Sema/SemaDeclCXX.cpp
 cfe/trunk/lib/Sema/SemaExpr.cpp
 cfe/trunk/lib/Sema/SemaExprCXX.cpp
 cfe/trunk/lib/Sema/SemaOverload.cpp
 cfe/trunk/lib/Sema/SemaTemplate.cpp
 cfe/trunk/lib/Serialization/ASTReader.cpp
 cfe/trunk/lib/Serialization/ASTWriter.cpp
 cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.unqual/p3.cpp
 cfe/trunk/test/CXX/drs/dr2xx.cpp
 cfe/trunk/test/CXX/drs/dr6xx.cpp
 cfe/trunk/test/CXX/temp/temp.spec/temp.explicit/p5.cpp
 cfe/trunk/test/FixIt/typo-crash.cpp
 cfe/trunk/test/Misc/diag-template-diffing.cpp
 cfe/trunk/test/Modules/module-private.cpp
 cfe/trunk/test/Modules/submodules-merge-defs.cpp
 cfe/trunk/test/Parser/cxx-ambig-init-templ.cpp
 cfe/trunk/test/Parser/cxx-template-argument.cpp
 cfe/trunk/test/Parser/cxx-template-decl.cpp
 cfe/trunk/test/SemaCXX/alias-template.cpp
 cfe/trunk/test/SemaCXX/class.cpp
 cfe/trunk/test/SemaCXX/destructor.cpp
 cfe/trunk/test/SemaCXX/invalid-member-expr.cpp
 cfe/trunk/test/SemaCXX/typo-correction.cpp
 cfe/trunk/test/SemaTemplate/dependent-base-classes.cpp
 cfe/trunk/test/SemaTemplate/dependent-template-recover.cpp
 cfe/trunk/test/SemaTemplate/rdar9173693.cpp
 cfe/trunk/test/SemaTemplate/recovery-crash.cpp
 cfe/trunk/tools/libclang/CIndex.cpp
 cfe/trunk/www/cxx_status.html

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


[PATCH] D44100: [ASTImporter] Reorder fields after structure import is finished

2019-05-15 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 199629.
martong marked 13 inline comments as done.
martong added a comment.

- Address Shafik's comments and update assertions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D44100

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

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -1371,7 +1371,7 @@
 }
 
 TEST_P(ASTImporterOptionSpecificTestBase,
-   DISABLED_CXXRecordDeclFieldOrderShouldNotDependOnImportOrder) {
+   CXXRecordDeclFieldOrderShouldNotDependOnImportOrder) {
   Decl *From, *To;
   std::tie(From, To) = getImportedDecl(
   // The original recursive algorithm of ASTImporter first imports 'c' then
@@ -4626,5 +4626,16 @@
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportVariables,
 DefaultTestValuesForRunOptions, );
 
+TEST_P(ImportDecl, ImportFieldOrder) {
+  MatchVerifier Verifier;
+  testImport("struct declToImport {"
+ "  int b = a + 2;"
+ "  int a = 5;"
+ "};",
+ Lang_CXX11, "", Lang_CXX11, Verifier,
+ recordDecl(hasFieldOrder({"b", "a"})));
+}
+
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -1632,13 +1632,77 @@
 auto ToDCOrErr = Importer.ImportContext(FromDC);
 return ToDCOrErr.takeError();
   }
-  llvm::SmallVector ImportedDecls;
+
+  const auto *FromRD = dyn_cast(FromDC);
   for (auto *From : FromDC->decls()) {
 ExpectedDecl ImportedOrErr = import(From);
-if (!ImportedOrErr)
+if (!ImportedOrErr) {
+  // For RecordDecls, failed import of a field will break the layout of the
+  // structure. Handle it as an error.
+  if (FromRD)
+return ImportedOrErr.takeError();
   // Ignore the error, continue with next Decl.
   // FIXME: Handle this case somehow better.
-  consumeError(ImportedOrErr.takeError());
+  else
+consumeError(ImportedOrErr.takeError());
+}
+  }
+
+  if (!FromRD)
+return Error::success();
+
+  // We reorder declarations in RecordDecls because they may have another order
+  // in the "to" context than they have in the "from" context. This may happen
+  // e.g when we import a class like this:
+  //struct declToImport {
+  //int a = c + b;
+  //int b = 1;
+  //int c = 2;
+  //};
+  // During the import of `a` we import first the dependencies in sequence,
+  // thus the order would be `c`, `b`, `a`. We will get the normal order by
+  // first removing the already imported members and then adding them in the
+  // order as they apper in the "from" context.
+  //
+  // Keeping field order is vital because it determines structure layout.
+  //
+  // Here and below, we cannot call field_begin() method and its callers
+  // on ToRD if it has an external storage. Calling field_begin() will
+  // automatically load all the fields by calling
+  // LoadFieldsFromExternalStorage().
+  auto ImportedDC = import(cast(FromDC));
+  assert(ImportedDC);
+  auto *ToRD = cast(*ImportedDC);
+  for (auto *D : FromRD->decls()) {
+if (isa(D) || isa(D)) {
+  assert(D && "DC has a contained decl which is null?");
+  Decl *ToD = Importer.GetAlreadyImportedOrNull(D);
+  assert(ToD && "We already imported all the contained decls of the DC");
+  assert(ToRD == ToD->getLexicalDeclContext() && ToRD->containsDecl(ToD));
+  ToRD->removeDecl(ToD);
+}
+  }
+
+  // We removed only those fields which we have imported from the FromDC. We
+  // did not remove all the decls of ToRD. And we don't want to remove any
+  // fields which may be loaded from an external storage. The reason is that
+  // field_empty would call field_begin which would call
+  // LoadFieldsFromExternalStorage which in turn would call
+  // ASTImporter::Import. This is because the ExternalASTSource interface in
+  // LLDB is implemented by the means of the ASTImporter. However, calling an
+  // import at this point would result in an uncontrolled import, we must avoid
+  // that.
+  if (!ToRD->hasExternalLexicalStorage())
+assert(ToRD->field_empty());
+
+  for (auto *D : FromRD->decls()) {
+if (isa(D) || isa(D)) {
+  Decl *ToD = Importer.GetAlreadyImportedOrNull(D);
+  assert(ToD);
+  assert(ToRD == ToD->getLexicalDeclContext());
+  assert(ToRD->hasExternalLexicalStorage() || !ToRD->containsDecl(ToD));
+  ToRD->addDeclInternal(ToD);
+}
   }
 
   return Error::success();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mail

r360783 - Test commit

2019-05-15 Thread Kevin Petit via cfe-commits
Author: kpet
Date: Wed May 15 09:39:28 2019
New Revision: 360783

URL: http://llvm.org/viewvc/llvm-project?rev=360783&view=rev
Log:
Test commit

Remove stray space.

Signed-off-by: Kevin Petit 

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

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=360783&r1=360782&r2=360783&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed May 15 09:39:28 2019
@@ -7561,7 +7561,7 @@ static void processTypeAttrs(TypeProcess
 state.getDeclarator().isPrototypeContext() &&
 !hasOuterPointerLikeChunk(state.getDeclarator(), endIndex);
 if (checkNullabilityTypeSpecifier(
-  state, 
+  state,
   type,
   attr,
   allowOnArrayType)) {


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


[PATCH] D44100: [ASTImporter] Reorder fields after structure import is finished

2019-05-15 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: lib/AST/ASTImporter.cpp:1643
+if (!ImportedOrErr) {
+  // For RecordDecls, failed import of a field will break the layout of the
+  // structure. Handle it as an error.

shafik wrote:
> What cases are failed import of a field ok? Is that because we will get the 
> field later on by another path?
The decl context of which we import the contained decls (`FromDC`) may be a 
namespace, it is not necessarily a RecordDecl.
I guess it would be too drastic if a whole namespace is rendered as erroneous 
if just one contained decl import failed.



Comment at: lib/AST/ASTImporter.cpp:1655
+  // Reorder declarations in RecordDecls because they may have another
+  // order. Keeping field order is vitable because it determines structure
+  // layout.

shafik wrote:
> vitable?
My guess is `vital`.



Comment at: lib/AST/ASTImporter.cpp:1674
+  Decl *ToD = Importer.GetAlreadyImportedOrNull(D);
+  assert(ToRD == ToD->getDeclContext() && ToRD->containsDecl(ToD));
+  ToRD->removeDecl(ToD);

shafik wrote:
> Are we sure `ToD` is never a `nullptr` b/c you are unconditionally 
> derefenecing it here.
Yes, I agree. Added `assert(ToD)` because we had imported all contained decls 
previously without errors.



Comment at: lib/AST/ASTImporter.cpp:1674
+  Decl *ToD = Importer.GetAlreadyImportedOrNull(D);
+  assert(ToRD == ToD->getDeclContext() && ToRD->containsDecl(ToD));
+  ToRD->removeDecl(ToD);

martong wrote:
> shafik wrote:
> > Are we sure `ToD` is never a `nullptr` b/c you are unconditionally 
> > derefenecing it here.
> Yes, I agree. Added `assert(ToD)` because we had imported all contained decls 
> previously without errors.
`assert(ToRD == ToD->getDeclContext()` is not correct here, because friends 
semantic decl context may not be the befriending class. Changed to compare 
against the lexical DC.



Comment at: lib/AST/ASTImporter.cpp:1679
+
+  if (!ToRD->hasExternalLexicalStorage())
+assert(ToRD->field_empty());

shafik wrote:
> Can you add a comment explaining why if the Decl has ExternalLexicalStorage 
> the fields might not be empty even though we just removed them?
We removed only those fields which we have imported from the `FromDC`. We did 
not remove all the decls of `ToRD`. And we don't want to remove any fields 
which may be loaded from an external storage.
The reason is that `field_empty` would call `field_begin` which would call 
`LoadFieldsFromExternalStorage` which in turn would call `ASTImporter::Import`. 
This is because the ExternalASTSource interface in LLDB is implemented by the 
means of the ASTImporter. However, calling an import at this point would result 
in an uncontrolled import, we must avoid that.



Comment at: lib/AST/ASTImporter.cpp:1686
+  assert(ToD);
+  assert(ToRD == ToD->getDeclContext());
+  assert(ToRD == ToD->getLexicalDeclContext());

I removed this assert, because friends most usually have a different semantic 
context than the befriending class.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D44100



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


[PATCH] D61949: [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

2019-05-15 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/Headers/__clang_cuda_device_functions.h:1477
 #endif // CUDA_VERSION >= 9020
+#if __cplusplus >= 201703L
+__DEVICE__ int abs(int __a) noexcept { return __nv_abs(__a); }

jdoerfert wrote:
> Hahnfeld wrote:
> > If I recall correctly, `__cplusplus` is not defined in C mode, so both GCC 
> > and Clang will issue a warning with `-Wundef`.
> > 
> > Maybe this can be solved with something similar to:
> > ```lang=c
> > #ifdef __cplusplus
> > #define cpp_version __cplusplus
> > #else
> > #define cpp_version 0
> > #endif
> > ```
> > (to avoid repetition of `#if defined(__cplusplus) && __cplusplus >= 
> > 201703L`)
> I dislike defining the version and advice to repeating `#if 
> defined(__cplusplus) && __cplusplus >= 201703L)`
> 
I agree with @jdoerfert.
If that's needed too often, we can move c++-only functions under one global 
`#if defined(__cplusplus)`.




Comment at: lib/Headers/__clang_cuda_device_functions.h:1579-1586
+#if __cplusplus >= 201703L
+__DEVICE__ long labs(long __a) noexcept { return __nv_llabs(__a); };
+#else
 __DEVICE__ long labs(long __a) { return __nv_llabs(__a); };
+#endif
+#else
+#if __cplusplus >= 201703L

This is typically dealt with by defining and using a macro which would expand 
to `noexcept` or to nothing.
E.g. something like [[ 
https://github.com/llvm-mirror/libcxx/blob/dbd4f51025003a7c869c4e5267ab8780e91367d5/include/__config#L848
 | what libcxx does ]].

This should reduce the number of needed `#if`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61949



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


[PATCH] D60283: [DebugInfo] Don't emit checksums when compiling a preprocessed CPP

2019-05-15 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

Minor stuff.  This solution is surprisingly simple, the main question being 
(and I don't have an answer) whether increasing the size of PresumedLoc is okay.




Comment at: lib/Basic/SourceManager.cpp:1460
+FID = FileID::get(0); // contents of files referenced by #line aren't 
in
+  // the SourceManager
+  }

The comment would work better as a proper sentence, and on the line before the 
statement.



Comment at: lib/CodeGen/CGDebugInfo.cpp:429
+  // all the files referred by #line. Instead the checksum remains empty,
+  // leaving to the debugger to open the file without checksum validation.
   Optional CSKind =

While the comment describes the desirable result, it is actually not describing 
what is happening right here.  Maybe something like this:

Compute the checksum if possible.  If the location is affected by a #line 
directive that refers to a file, PLoc will have an invalid FileID, and we will 
correctly get no checksum.



Comment at: test/CodeGen/debug-info-file-checksum.c:13
+// NOCHECKSUM-LABEL: !DIFile(filename: "{{.*}}code-coverage-filter2.h", 
directory: "{{[^"]*}}")
+// NOCHECKSUM-LABEL: !DIFile(filename: "{{.*}}debug-info-file-checksum.c", 
directory: "{{[^"]*}}")
+

These directives don't need the -LABEL suffix.


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

https://reviews.llvm.org/D60283



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


[clang-tools-extra] r360785 - [clang-tidy] modernize-loop-convert: impl const cast iter

2019-05-15 Thread Don Hinton via cfe-commits
Author: dhinton
Date: Wed May 15 09:58:58 2019
New Revision: 360785

URL: http://llvm.org/viewvc/llvm-project?rev=360785&view=rev
Log:
[clang-tidy] modernize-loop-convert: impl const cast iter

Summary:
modernize-loop-convert was not detecting implicit casts to
const_iterator as convertible to range-based loops:

std::vector vec{1,2,3,4}
for(std::vector::const_iterator i = vec.begin();
i != vec.end();
++i) { }

Thanks to Don Hinton for advice.

As well, this change adds a note for this check's applicability to code
targeting OpenMP prior to version 5 as this check will continue breaking
compilation with `-fopenmp`. Thanks to Roman Lebedev for pointing this
out.

Fixes PR#35082

Reviewed By: hintonda

Tags: #clang-tools-extra, #clang

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
clang-tools-extra/trunk/docs/clang-tidy/index.rst
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=360785&r1=360784&r2=360785&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Wed May 
15 09:58:58 2019
@@ -791,11 +791,6 @@ bool LoopConvertCheck::isConvertible(AST
   CanonicalBeginType->getPointeeType(),
   CanonicalInitVarType->getPointeeType()))
 return false;
-} else if (!Context->hasSameType(CanonicalInitVarType,
- CanonicalBeginType)) {
-  // Check for qualified types to avoid conversions from non-const to const
-  // iterator types.
-  return false;
 }
   } else if (FixerKind == LFK_PseudoArray) {
 // This call is required to obtain the container.

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst?rev=360785&r1=360784&r2=360785&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst 
Wed May 15 09:58:58 2019
@@ -253,3 +253,15 @@ below ends up being performed at the `sa
   flag = true;
 }
   }
+
+OpenMP
+^^
+
+As range-based for loops are only available since OpenMP 5, this check should
+not been used on code with a compatibility requirements of OpenMP prior to
+version 5. It is **intentional** that this check does not make any attempts to
+exclude incorrect diagnostics on OpenMP for loops prior to OpenMP 5.
+
+To prevent this check to be applied (and to break) OpenMP for loops but still 
be
+applied to non-OpenMP for loops the usage of ``NOLINT`` (see
+:ref:`clang-tidy-nolint`) on the specific for loops is recommended.

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=360785&r1=360784&r2=360785&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Wed May 15 09:58:58 2019
@@ -258,6 +258,8 @@ An overview of all the command-line opti
   value:   'some value'
   ...
 
+.. _clang-tidy-nolint:
+
 Suppressing Undesired Diagnostics
 =
 

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp?rev=360785&r1=360784&r2=360785&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp 
Wed May 15 09:58:58 2019
@@ -369,7 +369,7 @@ void f() {
 // CHECK-FIXES: for (auto Val_int_ptr : Val_int_ptrs)
   }
 
-  // This container uses an iterator where the derefence type is a typedef of
+  // This container uses an iterator where the dereference type is a typedef of
   // a reference type. Make sure non-const auto & is still used. A failure here
   // means canonical types aren't being tested.
   {
@@ -431,19 +431,22 @@ void different_type() {
   // CHECK-FIXES: for (auto P : *Ps)
   // C

[PATCH] D61827: [clang-tidy] modernize-loop-convert: impl const cast iter

2019-05-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE360785: [clang-tidy] modernize-loop-convert: impl const 
cast iter (authored by dhinton, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61827?vs=199496&id=199631#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61827

Files:
  clang-tidy/modernize/LoopConvertCheck.cpp
  docs/clang-tidy/checks/modernize-loop-convert.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/modernize-loop-convert-basic.cpp
  test/clang-tidy/modernize-loop-convert-extra.cpp

Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -776,17 +776,20 @@
   // CHECK-FIXES: for (auto P : *Ps)
   // CHECK-FIXES-NEXT: printf("s has value %d\n", P.X);
 
-  // V.begin() returns a user-defined type 'iterator' which, since it's
-  // different from const_iterator, disqualifies these loops from
-  // transformation.
   dependent V;
   for (dependent::const_iterator It = V.begin(); It != V.end(); ++It) {
 printf("Fibonacci number is %d\n", *It);
   }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int It : V)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", It);
 
   for (dependent::const_iterator It(V.begin()); It != V.end(); ++It) {
 printf("Fibonacci number is %d\n", *It);
   }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int It : V)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", It);
 }
 
 } // namespace SingleIterator
@@ -991,18 +994,26 @@
   // CHECK-FIXES: for (int & I : Dep)
   // CHECK-FIXES-NEXT: auto H2 = [&]() { int R = I + 2; };
 
-  // FIXME: It doesn't work with const iterators.
   for (dependent::const_iterator I = Dep.begin(), E = Dep.end();
I != E; ++I)
 auto H3 = [I]() { int R = *I; };
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int I : Dep)
+  // CHECK-FIXES-NEXT: auto H3 = [&I]() { int R = I; };
 
   for (dependent::const_iterator I = Dep.begin(), E = Dep.end();
I != E; ++I)
 auto H4 = [&]() { int R = *I + 1; };
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int I : Dep)
+  // CHECK-FIXES-NEXT: auto H4 = [&]() { int R = I + 1; };
 
   for (dependent::const_iterator I = Dep.begin(), E = Dep.end();
I != E; ++I)
 auto H5 = [=]() { int R = *I; };
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int R : Dep)
+  // CHECK-FIXES-NEXT: auto H5 = [=]() { };
 }
 
 void captureByValue() {
Index: test/clang-tidy/modernize-loop-convert-basic.cpp
===
--- test/clang-tidy/modernize-loop-convert-basic.cpp
+++ test/clang-tidy/modernize-loop-convert-basic.cpp
@@ -369,7 +369,7 @@
 // CHECK-FIXES: for (auto Val_int_ptr : Val_int_ptrs)
   }
 
-  // This container uses an iterator where the derefence type is a typedef of
+  // This container uses an iterator where the dereference type is a typedef of
   // a reference type. Make sure non-const auto & is still used. A failure here
   // means canonical types aren't being tested.
   {
@@ -431,19 +431,22 @@
   // CHECK-FIXES: for (auto P : *Ps)
   // CHECK-FIXES-NEXT: printf("s has value %d\n", P.X);
 
-  // V.begin() returns a user-defined type 'iterator' which, since it's
-  // different from const_iterator, disqualifies these loops from
-  // transformation.
   dependent V;
   for (dependent::const_iterator It = V.begin(), E = V.end();
It != E; ++It) {
 printf("Fibonacci number is %d\n", *It);
   }
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int It : V)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", It);
 
   for (dependent::const_iterator It(V.begin()), E = V.end();
It != E; ++It) {
 printf("Fibonacci number is %d\n", *It);
   }
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (int It : V)
+  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", It);
 }
 
 // Tests to ensure that an implicit 'this' is picked up as the container.
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -791,11 +791,6 @@
   CanonicalBeginType->getPointeeType(),
   CanonicalInitVarType->getPointeeType()))
 return false;
-} else if (!Context->hasSameType(CanonicalInitVarType,
- 

[PATCH] D61804: Support building shared and static libraries simultaneously

2019-05-15 Thread Wink Saville via Phabricator via cfe-commits
winksaville abandoned this revision.
winksaville added a comment.

Abandoning, @beanz has proposed a better solution, D61909 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61804



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


[PATCH] D61923: [GWP-ASan] Mutex implementation [2].

2019-05-15 Thread Mitch Phillips via Phabricator via cfe-commits
hctim updated this revision to Diff 199632.
hctim marked 2 inline comments as done.
hctim added a comment.

In D61923#1502988 , @cryptoad wrote:

> Is the question why do Scudo has its own as opposed to rely on platform 
> specific ones?


Yes, I have assumptions about why, but would love to hear right from the 
horse's mouth :)

In D61923#1502404 , @jfb wrote:

> > We can't use `std::mutex` as we must be C-compatible
>
> Can you clarify what you mean by this? I don't understand.
>  Have you asked on libcxx-dev? Is there interest in the libc++ community for 
> a stand-alone base?


Sorry, poor choice of wording. Our archive must be able to be statically linked 
into the supporting allocators. At this stage, the plans are to implement 
GWP-ASan into Scudo and Android's bionic libc. This means we have to be 
compatible with the the most restrictive aspects of each allocator's build 
environment, simultaneously.

In practice, we can't use `std::mutex` because Scudo specifies `-nostdlib++ 
-nodefaultlibs`, and if any part of the implementation of `std::mutex` (and 
likewise `mtx_t`) falls outside of the header file, we will fail to link (as is 
the case with libc++).

>> We also are trying to stay independent of `pthread` for 
>> platform-independentness.
> 
> The code I see is clearly not platform independent. Please clarify your 
> reasoning. I can understand if you don't want pthread for a valid reason, but 
> "platform-independence" doesn't make sense here.

My view was that small stubs to implement the architecture-dependent and 
OS-dependent functionality is much easier to manage. If we use `pthread` on 
unix, and `CreateMutex` on Windows, we still have to have OS-dependent ifdefs, 
but we then pass on the requirement to the supporting allocator to ensure our 
dependencies are there (which could be a huge pain point both for Scudo+fuchsia 
and Android).

>> We also can't use a `sanitizer_common` variant as we don't want to pull in 
>> the entirety `sanitizer_common` as a dependency.
> 
> What's the restriction that makes it unacceptable?

Scudo (standalone) can't pull in the entirety of sanitizer_common (code size + 
maintainability for fuchsia). It's also a much easier track to get Android 
supported if we don't have to pull in and build the entirety of 
sanitizer_common.

>> Basically, the roadmap is to create a shared mutex library for 
>> `sanitizer_common`, `gwp_asan` and `scudo` to all use.
> 
> I'm asking all these question because they should be in the commit message, 
> and would hopefully have surfaced from the RFC about GWP / Scudo. If those 
> weren't in the RFC that's fine, they should still be in the commit message 
> and you'll want to update the RFC with "while reviewing code we realized 
> *stuff*".

Ack.

>> I think the idea is that implementing our own spinlock is not much harder 
>> than having 3 platform-specific implementations (posix, window, fuchsia).
> 
> Your concerns are backwards. Implementation is a one-time thing, maintenance 
> is an ongoing concern and it way overshadows implementation concerns. In 
> particular, a variety of multicore code that does its own locking is much 
> harder to tune at the system-wide level compared to a single thing that's 
> tuned for each application. I'm not saying a separate mutex doesn't make 
> sense, what I'm saying is that experience shows your above reasoning to be 
> generally invalid. I'm totally willing to believe that there's a very good 
> reason to have your own mutex here, but you gotta explain it.

Hopefully above helps to clarify :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61923

Files:
  clang/runtime/CMakeLists.txt
  compiler-rt/lib/gwp_asan/CMakeLists.txt
  compiler-rt/lib/gwp_asan/definitions.h
  compiler-rt/lib/gwp_asan/mutex.h
  compiler-rt/lib/gwp_asan/tests/CMakeLists.txt
  compiler-rt/lib/gwp_asan/tests/driver.cpp
  compiler-rt/lib/gwp_asan/tests/mutex_test.cpp
  compiler-rt/test/gwp_asan/CMakeLists.txt
  compiler-rt/test/gwp_asan/dummy_test.cc
  compiler-rt/test/gwp_asan/lit.cfg
  compiler-rt/test/gwp_asan/lit.site.cfg.in
  compiler-rt/test/gwp_asan/unit/lit.site.cfg.in

Index: compiler-rt/test/gwp_asan/unit/lit.site.cfg.in
===
--- /dev/null
+++ compiler-rt/test/gwp_asan/unit/lit.site.cfg.in
@@ -0,0 +1,9 @@
+@LIT_SITE_CFG_IN_HEADER@
+
+config.name = "GwpAsan-Unittest"
+# Load common config for all compiler-rt unit tests.
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured")
+
+config.test_exec_root = os.path.join("@COMPILER_RT_BINARY_DIR@",
+ "lib", "gwp_asan", "tests")
+config.test_source_root = config.test_exec_root
Index: compiler-rt/test/gwp_asan/lit.site.cfg.in
==

Re: [clang-tools-extra] r360785 - [clang-tidy] modernize-loop-convert: impl const cast iter

2019-05-15 Thread Don Hinton via cfe-commits
Just wanted to note that this patch was contributed by Torbjörn Klatt, and
I failed to add the following line to the commit message:

Patch by Torbjörn Klatt!

Sorry about that Torbjörn.

On Wed, May 15, 2019 at 9:56 AM Don Hinton via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: dhinton
> Date: Wed May 15 09:58:58 2019
> New Revision: 360785
>
> URL: http://llvm.org/viewvc/llvm-project?rev=360785&view=rev
> Log:
> [clang-tidy] modernize-loop-convert: impl const cast iter
>
> Summary:
> modernize-loop-convert was not detecting implicit casts to
> const_iterator as convertible to range-based loops:
>
> std::vector vec{1,2,3,4}
> for(std::vector::const_iterator i = vec.begin();
> i != vec.end();
> ++i) { }
>
> Thanks to Don Hinton for advice.
>
> As well, this change adds a note for this check's applicability to code
> targeting OpenMP prior to version 5 as this check will continue breaking
> compilation with `-fopenmp`. Thanks to Roman Lebedev for pointing this
> out.
>
> Fixes PR#35082
>
> Reviewed By: hintonda
>
> Tags: #clang-tools-extra, #clang
>
> Differential Revision: https://reviews.llvm.org/D61827
>
> Modified:
> clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
>
> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
> clang-tools-extra/trunk/docs/clang-tidy/index.rst
>
> clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
>
> clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp
>
> Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=360785&r1=360784&r2=360785&view=diff
>
> ==
> --- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Wed
> May 15 09:58:58 2019
> @@ -791,11 +791,6 @@ bool LoopConvertCheck::isConvertible(AST
>CanonicalBeginType->getPointeeType(),
>CanonicalInitVarType->getPointeeType()))
>  return false;
> -} else if (!Context->hasSameType(CanonicalInitVarType,
> - CanonicalBeginType)) {
> -  // Check for qualified types to avoid conversions from non-const to
> const
> -  // iterator types.
> -  return false;
>  }
>} else if (FixerKind == LFK_PseudoArray) {
>  // This call is required to obtain the container.
>
> Modified:
> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst?rev=360785&r1=360784&r2=360785&view=diff
>
> ==
> ---
> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
> (original)
> +++
> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
> Wed May 15 09:58:58 2019
> @@ -253,3 +253,15 @@ below ends up being performed at the `sa
>flag = true;
>  }
>}
> +
> +OpenMP
> +^^
> +
> +As range-based for loops are only available since OpenMP 5, this check
> should
> +not been used on code with a compatibility requirements of OpenMP prior to
> +version 5. It is **intentional** that this check does not make any
> attempts to
> +exclude incorrect diagnostics on OpenMP for loops prior to OpenMP 5.
> +
> +To prevent this check to be applied (and to break) OpenMP for loops but
> still be
> +applied to non-OpenMP for loops the usage of ``NOLINT`` (see
> +:ref:`clang-tidy-nolint`) on the specific for loops is recommended.
>
> Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=360785&r1=360784&r2=360785&view=diff
>
> ==
> --- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
> +++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Wed May 15 09:58:58
> 2019
> @@ -258,6 +258,8 @@ An overview of all the command-line opti
>value:   'some value'
>...
>
> +.. _clang-tidy-nolint:
> +
>  Suppressing Undesired Diagnostics
>  =
>
>
> Modified:
> clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp?rev=360785&r1=360784&r2=360785&view=diff
>
> ==
> ---
> clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
> (original)
> +++
> clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
> Wed May 15 

[PATCH] D61950: [PowerPC64] adds ABI parsing when specified on target triple

2019-05-15 Thread Alfredo Dal'Ava Júnior via Phabricator via cfe-commits
adalava marked an inline comment as done.
adalava added inline comments.



Comment at: clang/lib/Basic/Targets/PPC.h:382
   resetDataLayout("e-m:e-i64:64-n32:64");
-  ABI = "elfv2";
 } else {

MaskRay wrote:
> MaskRay wrote:
> > Have you researched how GNU as chooses the default ABI?
> > 
> > I think the change may break some Linux ppc64le users as they expect the 
> > default elfv2.
> Sorry, it won't :) Then I think it is fine.
I didn't look the code, but behavior on GNU is the same as LLVM too:
-  powerpc64-* and elfv2 if "powerpc64le-*" and last

I found setting the ABI value here is useless so I decided to remove to keep it 
consistent with it's  "sister" X86 class and checked that no tests are broken 
after this, but would be nice if someone with more LLVm experience could give 
another look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61950



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


[PATCH] D61923: [GWP-ASan] Mutex implementation [2].

2019-05-15 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

> In D61923#1502404 , @jfb wrote:
> 
>> > We can't use `std::mutex` as we must be C-compatible
>>
>> Can you clarify what you mean by this? I don't understand.
>>  Have you asked on libcxx-dev? Is there interest in the libc++ community for 
>> a stand-alone base?
> 
> 
> Sorry, poor choice of wording. Our archive must be able to be statically 
> linked into the supporting allocators. At this stage, the plans are to 
> implement GWP-ASan into Scudo and Android's bionic libc. This means we have 
> to be compatible with the the most restrictive aspects of each allocator's 
> build environment, simultaneously.
> 
> In practice, we can't use `std::mutex` because Scudo specifies `-nostdlib++ 
> -nodefaultlibs`, and if any part of the implementation of `std::mutex` (and 
> likewise `mtx_t`) falls outside of the header file, we will fail to link (as 
> is the case with libc++).

Have you asked on libcxx-dev whether a stand-alone base is something of 
interest to them?

>>> We also are trying to stay independent of `pthread` for 
>>> platform-independentness.
>> 
>> The code I see is clearly not platform independent. Please clarify your 
>> reasoning. I can understand if you don't want pthread for a valid reason, 
>> but "platform-independence" doesn't make sense here.
> 
> My view was that small stubs to implement the architecture-dependent and 
> OS-dependent functionality is much easier to manage. If we use `pthread` on 
> unix, and `CreateMutex` on Windows, we still have to have OS-dependent 
> ifdefs, but we then pass on the requirement to the supporting allocator to 
> ensure our dependencies are there (which could be a huge pain point both for 
> Scudo+fuchsia and Android).
> 
>>> We also can't use a `sanitizer_common` variant as we don't want to pull in 
>>> the entirety `sanitizer_common` as a dependency.
>> 
>> What's the restriction that makes it unacceptable?
> 
> Scudo (standalone) can't pull in the entirety of sanitizer_common (code size 
> + maintainability for fuchsia). It's also a much easier track to get Android 
> supported if we don't have to pull in and build the entirety of 
> sanitizer_common.
> 
>>> Basically, the roadmap is to create a shared mutex library for 
>>> `sanitizer_common`, `gwp_asan` and `scudo` to all use.
>> 
>> I'm asking all these question because they should be in the commit message, 
>> and would hopefully have surfaced from the RFC about GWP / Scudo. If those 
>> weren't in the RFC that's fine, they should still be in the commit message 
>> and you'll want to update the RFC with "while reviewing code we realized 
>> *stuff*".
> 
> Ack.
> 
>>> I think the idea is that implementing our own spinlock is not much harder 
>>> than having 3 platform-specific implementations (posix, window, fuchsia).
>> 
>> Your concerns are backwards. Implementation is a one-time thing, maintenance 
>> is an ongoing concern and it way overshadows implementation concerns. In 
>> particular, a variety of multicore code that does its own locking is much 
>> harder to tune at the system-wide level compared to a single thing that's 
>> tuned for each application. I'm not saying a separate mutex doesn't make 
>> sense, what I'm saying is that experience shows your above reasoning to be 
>> generally invalid. I'm totally willing to believe that there's a very good 
>> reason to have your own mutex here, but you gotta explain it.
> 
> Hopefully above helps to clarify :)

Kinda... but your answer really sounds like this is a Google-only project, with 
intended uses only for some Google applications. That's not necessarily a bad 
thing, but it's really weird: my impression was that GWP and Scudo were 
intended to be generally usable elsewhere. Is that not the case?

Not that I expect *you* to do any porting work, but the direction you're 
setting just sounds like "well, we're our only users and we'll take the path 
that'll work for us". None of the reasoning seems to be truly technical, it's 
more "these projects we want to integrate into build this way, so we should fit 
in that way". i.e. it's more about implementation convenience than anything 
else. Is that the case? Implementation convenience is sometimes a good reason, 
but as I've outlined above I think you need to provide more thoughtful 
reasoning.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61923



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


[PATCH] D61950: [PowerPC64] adds ABI parsing when specified on target triple

2019-05-15 Thread Alfredo Dal'Ava Júnior via Phabricator via cfe-commits
adalava updated this revision to Diff 199633.
adalava added a comment.

- remove redundant comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61950

Files:
  clang/lib/Basic/Targets/PPC.h
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp
  llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
  llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll


Index: llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
===
--- llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
+++ llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
@@ -5,6 +5,14 @@
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu 
-target-abi elfv1 < %s | FileCheck %s -check-prefix=CHECK-ELFv1
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu 
-target-abi elfv2 < %s | FileCheck %s -check-prefix=CHECK-ELFv2
 
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd < %s | 
FileCheck %s -check-prefix=CHECK-ELFv1
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd 
-target-abi elfv1 < %s | FileCheck %s -check-prefix=CHECK-ELFv1
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd 
-target-abi elfv2 < %s | FileCheck %s -check-prefix=CHECK-ELFv2
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd-elfv1  < 
%s | FileCheck %s -check-prefix=CHECK-ELFv1
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd-elfv2  < 
%s | FileCheck %s -check-prefix=CHECK-ELFv2
+
+
+
 ; CHECK-ELFv2: .abiversion 2
 ; CHECK-ELFv1-NOT: .abiversion 2
 
Index: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
===
--- llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -214,7 +214,10 @@
   case Triple::ppc64le:
 return PPCTargetMachine::PPC_ABI_ELFv2;
   case Triple::ppc64:
-return PPCTargetMachine::PPC_ABI_ELFv1;
+if (TT.getEnvironment() == llvm::Triple::ELFv2)
+  return PPCTargetMachine::PPC_ABI_ELFv2;
+else
+  return PPCTargetMachine::PPC_ABI_ELFv1;
   default:
 return PPCTargetMachine::PPC_ABI_UNKNOWN;
   }
Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -232,6 +232,8 @@
   case Musl: return "musl";
   case MuslEABI: return "musleabi";
   case MuslEABIHF: return "musleabihf";
+  case ELFv1: return "elfv1";
+  case ELFv2: return "elfv2";
   case MSVC: return "msvc";
   case Itanium: return "itanium";
   case Cygnus: return "cygnus";
@@ -532,6 +534,8 @@
 .StartsWith("musleabihf", Triple::MuslEABIHF)
 .StartsWith("musleabi", Triple::MuslEABI)
 .StartsWith("musl", Triple::Musl)
+.StartsWith("elfv1", Triple::ELFv1)
+.StartsWith("elfv2", Triple::ELFv2)
 .StartsWith("msvc", Triple::MSVC)
 .StartsWith("itanium", Triple::Itanium)
 .StartsWith("cygnus", Triple::Cygnus)
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -206,6 +206,8 @@
 Musl,
 MuslEABI,
 MuslEABIHF,
+ELFv1,
+ELFv2,
 
 MSVC,
 Itanium,
Index: clang/lib/Basic/Targets/PPC.h
===
--- clang/lib/Basic/Targets/PPC.h
+++ clang/lib/Basic/Targets/PPC.h
@@ -379,13 +379,11 @@
 
 if ((Triple.getArch() == llvm::Triple::ppc64le)) {
   resetDataLayout("e-m:e-i64:64-n32:64");
-  ABI = "elfv2";
 } else {
   resetDataLayout("E-m:e-i64:64-n32:64");
-  ABI = "elfv1";
 }
 
-switch (getTriple().getOS()) {
+switch (Triple.getOS()) {
 case llvm::Triple::FreeBSD:
   LongDoubleWidth = LongDoubleAlign = 64;
   LongDoubleFormat = &llvm::APFloat::IEEEdouble();


Index: llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
===
--- llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
+++ llvm/test/CodeGen/PowerPC/ppc64-elf-abi.ll
@@ -5,6 +5,14 @@
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -target-abi elfv1 < %s | FileCheck %s -check-prefix=CHECK-ELFv1
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -target-abi elfv2 < %s | FileCheck %s -check-prefix=CHECK-ELFv2
 
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd < %s | FileCheck %s -check-prefix=CHECK-ELFv1
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd -target-abi elfv1 < %s | FileCheck %s -check-prefix=CHECK-ELFv1
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd -target-abi elfv2 < %s | FileCheck %s -check-prefix=CHECK-ELFv2
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-freebsd-elfv1  < %s | FileCheck %s -check-prefix=CHECK-ELFv1
+; RUN: llc -verify-m

[PATCH] D61950: [PowerPC64] adds ABI parsing when specified on target triple

2019-05-15 Thread Alfredo Dal'Ava Júnior via Phabricator via cfe-commits
adalava marked 3 inline comments as done.
adalava added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:217
   case Triple::ppc64:
-return PPCTargetMachine::PPC_ABI_ELFv1;
+// if ELFv2 on target triple i.e. powerpc64-unknown-freebsd12.0-elfv2
+if (TT.getEnvironment() == llvm::Triple::ELFv2)

MaskRay wrote:
> The initial word should be capitalized and the sentence should end with a 
> period. At least this part of the comment (`if ELFv2 on target triple `) is 
> redundant. I don't know if the other half 
> `powerpc64-unknown-freebsd12.0-elfv2` is useful...
yeah, sounds like code clears explains itself. I'm removing the comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61950



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


[PATCH] D61747: [clang-tidy] remove default header-filter for run-clang-tidy

2019-05-15 Thread Don Hinton via Phabricator via cfe-commits
hintonda added a comment.

I've also had issues with this behavior.  It's a bad default, as the PR notes, 
but is there a way to provide a better one and still respect the config file?

Also, could you add a test for this?  Perhaps in 
`clang-tools-extra/test//clang-tidy/run-clang-tidy.cpp`.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61747



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


[clang-tools-extra] r360787 - Revert [clang-tidy] modernize-loop-convert: impl const cast iter

2019-05-15 Thread Don Hinton via cfe-commits
Author: dhinton
Date: Wed May 15 10:36:54 2019
New Revision: 360787

URL: http://llvm.org/viewvc/llvm-project?rev=360787&view=rev
Log:
Revert [clang-tidy] modernize-loop-convert: impl const cast iter

This reverts r360785 (git commit 42d28be802fe5beab18bc1a27f89894c0a290d44)

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
clang-tools-extra/trunk/docs/clang-tidy/index.rst
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=360787&r1=360786&r2=360787&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Wed May 
15 10:36:54 2019
@@ -791,6 +791,11 @@ bool LoopConvertCheck::isConvertible(AST
   CanonicalBeginType->getPointeeType(),
   CanonicalInitVarType->getPointeeType()))
 return false;
+} else if (!Context->hasSameType(CanonicalInitVarType,
+ CanonicalBeginType)) {
+  // Check for qualified types to avoid conversions from non-const to const
+  // iterator types.
+  return false;
 }
   } else if (FixerKind == LFK_PseudoArray) {
 // This call is required to obtain the container.

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst?rev=360787&r1=360786&r2=360787&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst 
Wed May 15 10:36:54 2019
@@ -253,15 +253,3 @@ below ends up being performed at the `sa
   flag = true;
 }
   }
-
-OpenMP
-^^
-
-As range-based for loops are only available since OpenMP 5, this check should
-not been used on code with a compatibility requirements of OpenMP prior to
-version 5. It is **intentional** that this check does not make any attempts to
-exclude incorrect diagnostics on OpenMP for loops prior to OpenMP 5.
-
-To prevent this check to be applied (and to break) OpenMP for loops but still 
be
-applied to non-OpenMP for loops the usage of ``NOLINT`` (see
-:ref:`clang-tidy-nolint`) on the specific for loops is recommended.

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=360787&r1=360786&r2=360787&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Wed May 15 10:36:54 2019
@@ -258,8 +258,6 @@ An overview of all the command-line opti
   value:   'some value'
   ...
 
-.. _clang-tidy-nolint:
-
 Suppressing Undesired Diagnostics
 =
 

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp?rev=360787&r1=360786&r2=360787&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp 
Wed May 15 10:36:54 2019
@@ -369,7 +369,7 @@ void f() {
 // CHECK-FIXES: for (auto Val_int_ptr : Val_int_ptrs)
   }
 
-  // This container uses an iterator where the dereference type is a typedef of
+  // This container uses an iterator where the derefence type is a typedef of
   // a reference type. Make sure non-const auto & is still used. A failure here
   // means canonical types aren't being tested.
   {
@@ -431,22 +431,19 @@ void different_type() {
   // CHECK-FIXES: for (auto P : *Ps)
   // CHECK-FIXES-NEXT: printf("s has value %d\n", P.X);
 
+  // V.begin() returns a user-defined type 'iterator' which, since it's
+  // different from const_iterator, disqualifies these loops from
+  // transformation.
   dependent V;
   for (dependent::const_iterator It = V.begin(), E = V.end();
It != E; ++It) {
 printf("Fibonacci number is %d\n", *It);
   }
-  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (int It : V)
-  // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", It)

[PATCH] D61923: [GWP-ASan] Mutex implementation [2].

2019-05-15 Thread Mitch Phillips via Phabricator via cfe-commits
hctim added a comment.

In D61923#1503272 , @jfb wrote:

> Have you asked on libcxx-dev whether a stand-alone base is something of 
> interest to them?


No, but I will follow up on that.

> Kinda... but your answer really sounds like this is a Google-only project, 
> with intended uses only for some Google applications. That's not necessarily 
> a bad thing, but it's really weird: my impression was that GWP and Scudo were 
> intended to be generally usable elsewhere. Is that not the case?
> 
> Not that I expect *you* to do any porting work, but the direction you're 
> setting just sounds like "well, we're our only users and we'll take the path 
> that'll work for us". None of the reasoning seems to be truly technical, it's 
> more "these projects we want to integrate into build this way, so we should 
> fit in that way". i.e. it's more about implementation convenience than 
> anything else. Is that the case? Implementation convenience is sometimes a 
> good reason, but as I've outlined above I think you need to provide more 
> thoughtful reasoning.

I definitely don't want that to be the case, or to have it come across that 
way. We want a reference implementation that's available for any allocator to 
drop in and use, with minor tweaking. As part of that, our goal is to make the 
requirements to support GWP-ASan as low as possible, preferably as simple as 
"merge this into your codebase somewhere, and you're good to go". We inherit 
the restrictions of each allocator's build system, which means more restrictive 
environment for us, but we can be drop-in supported pretty much everywhere. Our 
plans for this reference implementation is to use it in Android and Fuchsia, 
but we would love to collaborate with other interested projects to hear about 
what their requirements would be as well.

We discussed at length whether to have GWP-ASan be a standalone GitHub project 
(similar to Scudo standalone), or as part of compiler-rt. We decided to put it 
into compiler-rt because we can then exercise LLVM's extensive 
build/test/review infrastructure and open-source licensing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61923



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


[PATCH] D59885: [Lex] Allow to consume tokens while preprocessing

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

I've added a new parameter to `EnterToken` and `EnterTokenStream`. There are a 
bunch of interesting cases.

`Preprocessor::AnnotateCachedTokens` is one. It consumes some `CachedTokens` 
(which are always considered re-injected) and replaces them with a single 
annotation token (which we normally don't consider re-injected).
So we end up with an annotation token that is re-injected (and therefore never 
reported). That's ok for our current use-cases, so I won't try to fix it in 
this change. If this actually turns out important at any moment, can fix in a 
follow-up.

Another interesting case is parser "tweaking" tokens and re-introducing them, 
e.g. `FixDigraph` that turns a digraph token into two or various recoveries 
turning `::` into `:` or introducing ephemeral `;` and `}` tokens.
I've decided to mark those as re-injected for the time being, that is fine for 
now and I'm happy to reconsider later if it turns out we need them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59885



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


[PATCH] D59885: [Lex] Allow to consume tokens while preprocessing

2019-05-15 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 199637.
ilya-biryukov added a comment.
Herald added a subscriber: eraman.

- Properly mark tokens as reinjected where necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59885

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Lex/Token.h
  clang/include/clang/Lex/TokenLexer.h
  clang/include/clang/Parse/Parser.h
  clang/lib/Frontend/PrintPreprocessedOutput.cpp
  clang/lib/Lex/MacroArgs.cpp
  clang/lib/Lex/PPCaching.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Lex/Pragma.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Lex/TokenLexer.cpp
  clang/lib/Parse/ParseCXXInlineMethods.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Rewrite/HTMLRewrite.cpp

Index: clang/lib/Rewrite/HTMLRewrite.cpp
===
--- clang/lib/Rewrite/HTMLRewrite.cpp
+++ clang/lib/Rewrite/HTMLRewrite.cpp
@@ -572,7 +572,7 @@
 
   // Enter the tokens we just lexed.  This will cause them to be macro expanded
   // but won't enter sub-files (because we removed #'s).
-  TmpPP.EnterTokenStream(TokenStream, false);
+  TmpPP.EnterTokenStream(TokenStream, false, /*IsReinject=*/false);
 
   TokenConcatenation ConcatInfo(TmpPP);
 
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1545,7 +1545,7 @@
   if (PP.isBacktrackEnabled())
 PP.RevertCachedTokens(1);
   else
-PP.EnterToken(Tok);
+PP.EnterToken(Tok, /*IsReinject=*/true);
   Tok.setKind(tok::annot_cxxscope);
   Tok.setAnnotationValue(Actions.SaveNestedNameSpecifierAnnotation(SS));
   Tok.setAnnotationRange(SS.getRange());
@@ -1764,7 +1764,7 @@
   Token TypedefToken;
   PP.Lex(TypedefToken);
   bool Result = TryAnnotateTypeOrScopeToken();
-  PP.EnterToken(Tok);
+  PP.EnterToken(Tok, /*IsReinject=*/true);
   Tok = TypedefToken;
   if (!Result)
 Diag(Tok.getLocation(), diag::warn_expected_qualified_after_typename);
Index: clang/lib/Parse/ParseTemplate.cpp
===
--- clang/lib/Parse/ParseTemplate.cpp
+++ clang/lib/Parse/ParseTemplate.cpp
@@ -919,7 +919,7 @@
 PrevTokLocation = RAngleLoc;
   } else {
 PrevTokLocation = TokBeforeGreaterLoc;
-PP.EnterToken(Tok);
+PP.EnterToken(Tok, /*IsReinject=*/true);
 Tok = Greater;
   }
 
@@ -1402,7 +1402,7 @@
   // Append the current token at the end of the new token stream so that it
   // doesn't get lost.
   LPT.Toks.push_back(Tok);
-  PP.EnterTokenStream(LPT.Toks, true);
+  PP.EnterTokenStream(LPT.Toks, true, /*IsReinject*/true);
 
   // Consume the previously pushed token.
   ConsumeAnyToken(/*ConsumeCodeCompletionTok=*/true);
Index: clang/lib/Parse/ParseStmtAsm.cpp
===
--- clang/lib/Parse/ParseStmtAsm.cpp
+++ clang/lib/Parse/ParseStmtAsm.cpp
@@ -213,7 +213,8 @@
   // Also copy the current token over.
   LineToks.push_back(Tok);
 
-  PP.EnterTokenStream(LineToks, /*DisableMacroExpansions*/ true);
+  PP.EnterTokenStream(LineToks, /*DisableMacroExpansions*/ true,
+  /*IsReinject*/ true);
 
   // Clear the current token and advance to the first token in LineToks.
   ConsumeAnyToken();
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -117,7 +117,8 @@
 Toks[0].setAnnotationEndLoc(Tok.getLocation());
 Toks[0].setAnnotationValue(reinterpret_cast(
static_cast(OOS)));
-PP.EnterTokenStream(Toks, /*DisableMacroExpansion=*/true);
+PP.EnterTokenStream(Toks, /*DisableMacroExpansion=*/true,
+/*IsReinject=*/false);
   }
 };
 
@@ -739,7 +740,8 @@
   // Grab the tokens out of the annotation and enter them into the stream.
   auto TheTokens =
   (std::pair, size_t> *)Tok.getAnnotationValue();
-  PP.EnterTokenStream(std::move(TheTokens->first), TheTokens->second, true);
+  PP.EnterTokenStream(std::move(TheTokens->first), TheTokens->second, true,
+  /*IsReinject=*/true);
   SourceLocation PragmaLocation = ConsumeAnnotationToken();
   assert(Tok.isAnyIdentifier());
   StringRef PragmaName = Tok.getIdentifierInfo()->getName();
@@ -,7 +1113,8 @@
 Hint.StateLoc = IdentifierLoc::create(Actions.Context, StateLoc, StateInfo);
   } else {
 // Enter

[clang-tools-extra] r360788 - [clang-tidy] Recommit r360785 "modernize-loop-convert: impl const cast iter" with correct attribution

2019-05-15 Thread Don Hinton via cfe-commits
Author: dhinton
Date: Wed May 15 10:47:51 2019
New Revision: 360788

URL: http://llvm.org/viewvc/llvm-project?rev=360788&view=rev
Log:
[clang-tidy] Recommit r360785 "modernize-loop-convert: impl const cast iter" 
with correct attribution

Summary:
modernize-loop-convert was not detecting implicit casts to
const_iterator as convertible to range-based loops:

std::vector vec{1,2,3,4}
for(std::vector::const_iterator i = vec.begin();
i != vec.end();
++i) { }

Thanks to Don Hinton for advice.

As well, this change adds a note for this check's applicability to code
targeting OpenMP prior version 5 as this check will continue breaking
compilation with `-fopenmp`. Thanks to Roman Lebedev for pointing this
out.

Fixes PR#35082

Patch by Torbjörn Klatt!

Reviewed By: hintonda

Tags: #clang-tools-extra, #clang

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
clang-tools-extra/trunk/docs/clang-tidy/index.rst
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=360788&r1=360787&r2=360788&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Wed May 
15 10:47:51 2019
@@ -791,11 +791,6 @@ bool LoopConvertCheck::isConvertible(AST
   CanonicalBeginType->getPointeeType(),
   CanonicalInitVarType->getPointeeType()))
 return false;
-} else if (!Context->hasSameType(CanonicalInitVarType,
- CanonicalBeginType)) {
-  // Check for qualified types to avoid conversions from non-const to const
-  // iterator types.
-  return false;
 }
   } else if (FixerKind == LFK_PseudoArray) {
 // This call is required to obtain the container.

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst?rev=360788&r1=360787&r2=360788&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst 
Wed May 15 10:47:51 2019
@@ -253,3 +253,15 @@ below ends up being performed at the `sa
   flag = true;
 }
   }
+
+OpenMP
+^^
+
+As range-based for loops are only available since OpenMP 5, this check should
+not been used on code with a compatibility requirements of OpenMP prior to
+version 5. It is **intentional** that this check does not make any attempts to
+exclude incorrect diagnostics on OpenMP for loops prior to OpenMP 5.
+
+To prevent this check to be applied (and to break) OpenMP for loops but still 
be
+applied to non-OpenMP for loops the usage of ``NOLINT`` (see
+:ref:`clang-tidy-nolint`) on the specific for loops is recommended.

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=360788&r1=360787&r2=360788&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Wed May 15 10:47:51 2019
@@ -258,6 +258,8 @@ An overview of all the command-line opti
   value:   'some value'
   ...
 
+.. _clang-tidy-nolint:
+
 Suppressing Undesired Diagnostics
 =
 

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp?rev=360788&r1=360787&r2=360788&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp 
Wed May 15 10:47:51 2019
@@ -369,7 +369,7 @@ void f() {
 // CHECK-FIXES: for (auto Val_int_ptr : Val_int_ptrs)
   }
 
-  // This container uses an iterator where the derefence type is a typedef of
+  // This container uses an iterator where the dereference type is a typedef of
   // a reference type. Make sure non-const auto & is still used. A failure here
   // means canonical types aren't being tested.
   {
@@ -431,19 +431,22 @@ v

[PATCH] D59885: [Lex] Allow to consume tokens while preprocessing

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

- Improve comment, remove redundant braces


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59885

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Lex/Token.h
  clang/include/clang/Lex/TokenLexer.h
  clang/include/clang/Parse/Parser.h
  clang/lib/Frontend/PrintPreprocessedOutput.cpp
  clang/lib/Lex/MacroArgs.cpp
  clang/lib/Lex/PPCaching.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Lex/Pragma.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Lex/TokenLexer.cpp
  clang/lib/Parse/ParseCXXInlineMethods.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Rewrite/HTMLRewrite.cpp

Index: clang/lib/Rewrite/HTMLRewrite.cpp
===
--- clang/lib/Rewrite/HTMLRewrite.cpp
+++ clang/lib/Rewrite/HTMLRewrite.cpp
@@ -572,7 +572,7 @@
 
   // Enter the tokens we just lexed.  This will cause them to be macro expanded
   // but won't enter sub-files (because we removed #'s).
-  TmpPP.EnterTokenStream(TokenStream, false);
+  TmpPP.EnterTokenStream(TokenStream, false, /*IsReinject=*/false);
 
   TokenConcatenation ConcatInfo(TmpPP);
 
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1545,7 +1545,7 @@
   if (PP.isBacktrackEnabled())
 PP.RevertCachedTokens(1);
   else
-PP.EnterToken(Tok);
+PP.EnterToken(Tok, /*IsReinject=*/true);
   Tok.setKind(tok::annot_cxxscope);
   Tok.setAnnotationValue(Actions.SaveNestedNameSpecifierAnnotation(SS));
   Tok.setAnnotationRange(SS.getRange());
@@ -1764,7 +1764,7 @@
   Token TypedefToken;
   PP.Lex(TypedefToken);
   bool Result = TryAnnotateTypeOrScopeToken();
-  PP.EnterToken(Tok);
+  PP.EnterToken(Tok, /*IsReinject=*/true);
   Tok = TypedefToken;
   if (!Result)
 Diag(Tok.getLocation(), diag::warn_expected_qualified_after_typename);
Index: clang/lib/Parse/ParseTemplate.cpp
===
--- clang/lib/Parse/ParseTemplate.cpp
+++ clang/lib/Parse/ParseTemplate.cpp
@@ -919,7 +919,7 @@
 PrevTokLocation = RAngleLoc;
   } else {
 PrevTokLocation = TokBeforeGreaterLoc;
-PP.EnterToken(Tok);
+PP.EnterToken(Tok, /*IsReinject=*/true);
 Tok = Greater;
   }
 
@@ -1402,7 +1402,7 @@
   // Append the current token at the end of the new token stream so that it
   // doesn't get lost.
   LPT.Toks.push_back(Tok);
-  PP.EnterTokenStream(LPT.Toks, true);
+  PP.EnterTokenStream(LPT.Toks, true, /*IsReinject*/true);
 
   // Consume the previously pushed token.
   ConsumeAnyToken(/*ConsumeCodeCompletionTok=*/true);
Index: clang/lib/Parse/ParseStmtAsm.cpp
===
--- clang/lib/Parse/ParseStmtAsm.cpp
+++ clang/lib/Parse/ParseStmtAsm.cpp
@@ -213,7 +213,8 @@
   // Also copy the current token over.
   LineToks.push_back(Tok);
 
-  PP.EnterTokenStream(LineToks, /*DisableMacroExpansions*/ true);
+  PP.EnterTokenStream(LineToks, /*DisableMacroExpansions*/ true,
+  /*IsReinject*/ true);
 
   // Clear the current token and advance to the first token in LineToks.
   ConsumeAnyToken();
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -117,7 +117,8 @@
 Toks[0].setAnnotationEndLoc(Tok.getLocation());
 Toks[0].setAnnotationValue(reinterpret_cast(
static_cast(OOS)));
-PP.EnterTokenStream(Toks, /*DisableMacroExpansion=*/true);
+PP.EnterTokenStream(Toks, /*DisableMacroExpansion=*/true,
+/*IsReinject=*/false);
   }
 };
 
@@ -739,7 +740,8 @@
   // Grab the tokens out of the annotation and enter them into the stream.
   auto TheTokens =
   (std::pair, size_t> *)Tok.getAnnotationValue();
-  PP.EnterTokenStream(std::move(TheTokens->first), TheTokens->second, true);
+  PP.EnterTokenStream(std::move(TheTokens->first), TheTokens->second, true,
+  /*IsReinject=*/true);
   SourceLocation PragmaLocation = ConsumeAnnotationToken();
   assert(Tok.isAnyIdentifier());
   StringRef PragmaName = Tok.getIdentifierInfo()->getName();
@@ -,7 +1113,8 @@
 Hint.StateLoc = IdentifierLoc::create(Actions.Context, StateLoc, StateInfo);
   } else {
 // Ent

[PATCH] D59885: [Lex] Allow to consume tokens while preprocessing

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



Comment at: clang/lib/Lex/Preprocessor.cpp:955
   --LexLevel;
+  if (OnToken && LexLevel == 0 && !Result.getFlag(Token::IsReinjected))
+OnToken(Result);

Could probably remove the `IsReinjected` check from here. It's fine to check 
this on the client side.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59885



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


[PATCH] D61909: Add Clang shared library with C++ exports

2019-05-15 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

In D61909#1502446 , @winksaville wrote:

> Questions:
>
> - Should we only build `libclang_shared.so` if `LLVM_BUILD_LLVM_DYLIB` is ON?


`LLVM_BUILD_LLVM_DYLIB` is actually not the important option to think about 
because it has no impact on this, rather `LLVM_LINK_LLVM_DYLIB`. That really 
depends on what tradeoffs you want. With that option off LLVM will be linked 
statically into the Clang library, which in the common case is fine because you 
can resolve all the LLVM & Clang APIs against it. That will be faster to load, 
but a larger binary distribution. With the option on, libclang_shared will link 
libLLVM, which will result in slower loading times, but smaller distributions. 
Both are workable situations.

> - Should we use link clang-9 to libclang_shared.so when 
> `LLVM_LINK_LLVM_DYLIB` is ON?

No. If we want to support that it should be through its own option which we can 
add in a subsequent patch.

> - Or maybe we should define `BUILD_CLANG_DYLIB` and `LINK_CLANG_DYLIB` or ... 
> ?

I'm not sure there is value in a `BUILD_CLANG_DYLIB` option (and frankly 
`LLVM_BUILD_LLVM_DYLIB` should probably go too). Between when I added the 
support for building libLLVM and now I've shifted my mindset about build system 
functionality. Optimizing the build time of the `all` target seems way less 
worthwhile to me than reducing complication in the build system. Most 
developers iterate by running `check*` targets over and over again rather than 
building `all`, and as long as the dependencies are properly set up adding 
additional targets has little impact on iteration time or perceived build time.

A `CLANG_LINK_CLANG_DYLIB` option probably does make sense to add in order to 
support smaller binary distributions, although I am concerned about 
communicating the impact of that and the `LLVM_LINK_LLVM_DYLIB` options. In the 
past I've seen people do compile-time performance comparisons between GCC and 
Clang using the `BUILD_SHARED_LIBS` option when building Clang, and it leads to 
really misleading results. I would be very frustrated to see a pile of blog 
posts saying that Clang is getting slower just because people are deciding to 
make clang dynamically link its components.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61909



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


[PATCH] D61957: [CodeGenObjC] invoke objc_autorelease, objc_retain when necessary

2019-05-15 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: ahatanak, rjmccall.
Herald added subscribers: dexonsmith, jkorous.
Herald added a project: clang.

Any of these methods can be overridden, so we always need to conservatively 
`invoke` these calls.


Repository:
  rC Clang

https://reviews.llvm.org/D61957

Files:
  clang/lib/CodeGen/CGObjC.cpp
  clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m

Index: clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m
===
--- clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m
+++ clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m
@@ -177,8 +177,8 @@
 
 @class Ety;
 
-// CHECK-LABEL: define {{.*}}void @testException
-void testException(NSObject *a) {
+// CHECK-LABEL: define {{.*}}void @testException_release
+void testException_release(NSObject *a) {
   // MSGS: {{invoke.*@objc_msgSend}}
   // CALLS: invoke{{.*}}void @objc_release(i8* %
   @try {
@@ -186,3 +186,23 @@
   } @catch (Ety *e) {
   }
 }
+
+// CHECK-LABEL: define {{.*}}void @testException_autorelease
+void testException_autorelease(NSObject *a) {
+  @try {
+// MSGS: {{invoke.*@objc_msgSend}}
+// CALLS: invoke{{.*}}objc_autorelease(i8* %
+[a autorelease];
+  } @catch (Ety *e) {
+  }
+}
+
+// CHECK-LABEL: define {{.*}}void @testException_retain
+void testException_retain(NSObject *a) {
+  @try {
+// MSGS: {{invoke.*@objc_msgSend}}
+// CALLS: invoke{{.*}}@objc_retain(i8* %
+[a retain];
+  } @catch (Ety *e) {
+  }
+}
Index: clang/lib/CodeGen/CGObjC.cpp
===
--- clang/lib/CodeGen/CGObjC.cpp
+++ clang/lib/CodeGen/CGObjC.cpp
@@ -2059,7 +2059,7 @@
llvm::Value *value,
llvm::Type *returnType,
llvm::FunctionCallee &fn,
-   StringRef fnName, bool MayThrow) {
+   StringRef fnName) {
   if (isa(value))
 return value;
 
@@ -2080,10 +2080,7 @@
 
   // Call the function.
   llvm::CallBase *Inst = nullptr;
-  if (MayThrow)
-Inst = CGF.EmitCallOrInvoke(fn, value);
-  else
-Inst = CGF.EmitNounwindRuntimeCall(fn, value);
+  Inst = CGF.EmitCallOrInvoke(fn, value);
 
   // Cast the result back to the original type.
   return CGF.Builder.CreateBitCast(Inst, origType);
@@ -2536,7 +2533,7 @@
 llvm::Type *resultType) {
   return emitObjCValueOperation(*this, value, resultType,
 CGM.getObjCEntrypoints().objc_alloc,
-"objc_alloc", /*MayThrow=*/true);
+"objc_alloc");
 }
 
 /// Allocate the given objc object.
@@ -2545,14 +2542,14 @@
 llvm::Type *resultType) {
   return emitObjCValueOperation(*this, value, resultType,
 CGM.getObjCEntrypoints().objc_allocWithZone,
-"objc_allocWithZone", /*MayThrow=*/true);
+"objc_allocWithZone");
 }
 
 llvm::Value *CodeGenFunction::EmitObjCAllocInit(llvm::Value *value,
 llvm::Type *resultType) {
   return emitObjCValueOperation(*this, value, resultType,
 CGM.getObjCEntrypoints().objc_alloc_init,
-"objc_alloc_init", /*MayThrow=*/true);
+"objc_alloc_init");
 }
 
 /// Produce the code to do a primitive release.
@@ -2596,7 +2593,7 @@
   return emitObjCValueOperation(
   *this, value, returnType,
   CGM.getObjCEntrypoints().objc_autoreleaseRuntimeFunction,
-  "objc_autorelease", /*MayThrow=*/false);
+  "objc_autorelease");
 }
 
 /// Retain the given object, with normal retain semantics.
@@ -2605,8 +2602,7 @@
  llvm::Type *returnType) {
   return emitObjCValueOperation(
   *this, value, returnType,
-  CGM.getObjCEntrypoints().objc_retainRuntimeFunction, "objc_retain",
-  /*MayThrow=*/false);
+  CGM.getObjCEntrypoints().objc_retainRuntimeFunction, "objc_retain");
 }
 
 /// Release the given object.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61958: [analyzer] RetainCount: Fix a crash when os_returns_retained_on_zero (_nonzero) is applied to functions that return weird stuff.

2019-05-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added a reviewer: dcoughlin.
Herald added subscribers: cfe-commits, Charusso, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: clang.

The checker crashes when it tries to assume a structure to be null or non-null 
so that to evaluate the effect of the annotation.


Repository:
  rC Clang

https://reviews.llvm.org/D61958

Files:
  clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
  clang/test/Analysis/osobject-retain-release.cpp


Index: clang/test/Analysis/osobject-retain-release.cpp
===
--- clang/test/Analysis/osobject-retain-release.cpp
+++ clang/test/Analysis/osobject-retain-release.cpp
@@ -702,3 +702,16 @@
   // returning from it at +0.
   return table; // no-warning
 }
+
+namespace weird_result {
+struct WeirdResult {
+  int x, y, z;
+};
+
+WeirdResult outParamWithWeirdResult(OS_RETURNS_RETAINED_ON_ZERO OSObject 
**obj);
+
+WeirdResult testOutParamWithWeirdResult() {
+  OSObject *obj;
+  return outParamWithWeirdResult(&obj); // no-warning
+}
+} // namespace weird_result
Index: 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
@@ -537,6 +537,11 @@
   ProgramStateRef AssumeZeroReturn = State;
 
   if (SplitNecessary) {
+if (!CE.getResultType()->isScalarType()) {
+  // Structures cannot be assumed. This probably deserves
+  // a compiler warning for invalid annotations.
+  return {State};
+}
 if (auto DL = L.getAs()) {
   AssumeNonZeroReturn = AssumeNonZeroReturn->assume(*DL, true);
   AssumeZeroReturn = AssumeZeroReturn->assume(*DL, false);


Index: clang/test/Analysis/osobject-retain-release.cpp
===
--- clang/test/Analysis/osobject-retain-release.cpp
+++ clang/test/Analysis/osobject-retain-release.cpp
@@ -702,3 +702,16 @@
   // returning from it at +0.
   return table; // no-warning
 }
+
+namespace weird_result {
+struct WeirdResult {
+  int x, y, z;
+};
+
+WeirdResult outParamWithWeirdResult(OS_RETURNS_RETAINED_ON_ZERO OSObject **obj);
+
+WeirdResult testOutParamWithWeirdResult() {
+  OSObject *obj;
+  return outParamWithWeirdResult(&obj); // no-warning
+}
+} // namespace weird_result
Index: clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
@@ -537,6 +537,11 @@
   ProgramStateRef AssumeZeroReturn = State;
 
   if (SplitNecessary) {
+if (!CE.getResultType()->isScalarType()) {
+  // Structures cannot be assumed. This probably deserves
+  // a compiler warning for invalid annotations.
+  return {State};
+}
 if (auto DL = L.getAs()) {
   AssumeNonZeroReturn = AssumeNonZeroReturn->assume(*DL, true);
   AssumeZeroReturn = AssumeZeroReturn->assume(*DL, false);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59885: [Lex] Allow to consume tokens while preprocessing

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



Comment at: clang/lib/Lex/PPDirectives.cpp:1521
   Tok[0].setAnnotationValue(AnnotationVal);
-  EnterTokenStream(std::move(Tok), 1, true);
+  EnterTokenStream(std::move(Tok), 1, true, /*IsReinject*/ true);
 }

I think it'd be more useful to treat this as a new token. But that's not a 
strong preference.



Comment at: clang/lib/Lex/Pragma.cpp:370
   // Push the tokens onto the stack.
-  EnterTokenStream(TokArray, PragmaToks.size(), true, true);
+  EnterTokenStream(TokArray, PragmaToks.size(), true, true,
+   /*IsReinject*/ false);

I think this case is a reinjection; we've copied some tokens inside __pragma 
out into a duplicate position in the token stream. But I guess it doesn't 
matter because the tokens never escape the outer Lex function anyway.



Comment at: clang/lib/Lex/Preprocessor.cpp:1136
 EnterTokenStream(std::move(ToksCopy), Toks.size(),
- /*DisableMacroExpansion*/ true);
+ /*DisableMacroExpansion*/ true, IsReinject);
   };

I think this should always be `false`: the tokens we're producing here have 
never been emitted at `LexLevel` 0 before.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59885



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


[PATCH] D61958: [analyzer] RetainCount: Fix a crash when os_returns_retained_on_zero (_nonzero) is applied to functions that return weird stuff.

2019-05-15 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

Looks good do me. Thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D61958



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


r360790 - [analyzer] RetainCount: Fix os_returns_retained_on_zero with weird return types.

2019-05-15 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed May 15 11:41:32 2019
New Revision: 360790

URL: http://llvm.org/viewvc/llvm-project?rev=360790&view=rev
Log:
[analyzer] RetainCount: Fix os_returns_retained_on_zero with weird return types.

The checker was crashing when it was trying to assume a structure
to be null or non-null so that to evaluate the effect of the annotation.

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

Modified:

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
cfe/trunk/test/Analysis/osobject-retain-release.cpp

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp?rev=360790&r1=360789&r2=360790&view=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
(original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
Wed May 15 11:41:32 2019
@@ -537,6 +537,11 @@ updateOutParameters(ProgramStateRef Stat
   ProgramStateRef AssumeZeroReturn = State;
 
   if (SplitNecessary) {
+if (!CE.getResultType()->isScalarType()) {
+  // Structures cannot be assumed. This probably deserves
+  // a compiler warning for invalid annotations.
+  return {State};
+}
 if (auto DL = L.getAs()) {
   AssumeNonZeroReturn = AssumeNonZeroReturn->assume(*DL, true);
   AssumeZeroReturn = AssumeZeroReturn->assume(*DL, false);

Modified: cfe/trunk/test/Analysis/osobject-retain-release.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/osobject-retain-release.cpp?rev=360790&r1=360789&r2=360790&view=diff
==
--- cfe/trunk/test/Analysis/osobject-retain-release.cpp (original)
+++ cfe/trunk/test/Analysis/osobject-retain-release.cpp Wed May 15 11:41:32 2019
@@ -702,3 +702,16 @@ OSObject *testSuppressionForMethodsEndin
   // returning from it at +0.
   return table; // no-warning
 }
+
+namespace weird_result {
+struct WeirdResult {
+  int x, y, z;
+};
+
+WeirdResult outParamWithWeirdResult(OS_RETURNS_RETAINED_ON_ZERO OSObject 
**obj);
+
+WeirdResult testOutParamWithWeirdResult() {
+  OSObject *obj;
+  return outParamWithWeirdResult(&obj); // no-warning
+}
+} // namespace weird_result


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


[PATCH] D61958: [analyzer] RetainCount: Fix a crash when os_returns_retained_on_zero (_nonzero) is applied to functions that return weird stuff.

2019-05-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC360790: [analyzer] RetainCount: Fix 
os_returns_retained_on_zero with weird return types. (authored by dergachev, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61958?vs=199647&id=199650#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D61958

Files:
  lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
  test/Analysis/osobject-retain-release.cpp


Index: test/Analysis/osobject-retain-release.cpp
===
--- test/Analysis/osobject-retain-release.cpp
+++ test/Analysis/osobject-retain-release.cpp
@@ -702,3 +702,16 @@
   // returning from it at +0.
   return table; // no-warning
 }
+
+namespace weird_result {
+struct WeirdResult {
+  int x, y, z;
+};
+
+WeirdResult outParamWithWeirdResult(OS_RETURNS_RETAINED_ON_ZERO OSObject 
**obj);
+
+WeirdResult testOutParamWithWeirdResult() {
+  OSObject *obj;
+  return outParamWithWeirdResult(&obj); // no-warning
+}
+} // namespace weird_result
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
@@ -537,6 +537,11 @@
   ProgramStateRef AssumeZeroReturn = State;
 
   if (SplitNecessary) {
+if (!CE.getResultType()->isScalarType()) {
+  // Structures cannot be assumed. This probably deserves
+  // a compiler warning for invalid annotations.
+  return {State};
+}
 if (auto DL = L.getAs()) {
   AssumeNonZeroReturn = AssumeNonZeroReturn->assume(*DL, true);
   AssumeZeroReturn = AssumeZeroReturn->assume(*DL, false);


Index: test/Analysis/osobject-retain-release.cpp
===
--- test/Analysis/osobject-retain-release.cpp
+++ test/Analysis/osobject-retain-release.cpp
@@ -702,3 +702,16 @@
   // returning from it at +0.
   return table; // no-warning
 }
+
+namespace weird_result {
+struct WeirdResult {
+  int x, y, z;
+};
+
+WeirdResult outParamWithWeirdResult(OS_RETURNS_RETAINED_ON_ZERO OSObject **obj);
+
+WeirdResult testOutParamWithWeirdResult() {
+  OSObject *obj;
+  return outParamWithWeirdResult(&obj); // no-warning
+}
+} // namespace weird_result
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
@@ -537,6 +537,11 @@
   ProgramStateRef AssumeZeroReturn = State;
 
   if (SplitNecessary) {
+if (!CE.getResultType()->isScalarType()) {
+  // Structures cannot be assumed. This probably deserves
+  // a compiler warning for invalid annotations.
+  return {State};
+}
 if (auto DL = L.getAs()) {
   AssumeNonZeroReturn = AssumeNonZeroReturn->assume(*DL, true);
   AssumeZeroReturn = AssumeZeroReturn->assume(*DL, false);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61845: [builtin] Fixed definitions of builtins that rely on the int/long long type is 32/64 bits

2019-05-15 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D61845



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


[PATCH] D61949: [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

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

- Refactor.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61949

Files:
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_device_functions.h
  lib/Headers/__clang_cuda_math_forward_declares.h
  lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
  test/Headers/Inputs/include/cstdlib
  test/Headers/nvptx_device_cmath_functions_cxx17.cpp
  test/Headers/nvptx_device_math_functions_cxx17.cpp

Index: test/Headers/nvptx_device_math_functions_cxx17.cpp
===
--- /dev/null
+++ test/Headers/nvptx_device_math_functions_cxx17.cpp
@@ -0,0 +1,22 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -std=c++17
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -internal-isystem %S/Inputs/include -include stdlib.h -include limits -include cstdlib -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -std=c++17 -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, &a1);
+  }
+}
Index: test/Headers/nvptx_device_cmath_functions_cxx17.cpp
===
--- /dev/null
+++ test/Headers/nvptx_device_cmath_functions_cxx17.cpp
@@ -0,0 +1,22 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include cmath -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -std=c++17
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -internal-isystem %S/Inputs/include -include stdlib.h -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -std=c++17 -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, &a1);
+  }
+}
Index: test/Headers/Inputs/include/cstdlib
===
--- test/Headers/Inputs/include/cstdlib
+++ test/Headers/Inputs/include/cstdlib
@@ -1,7 +1,12 @@
 #pragma once
 
+#if __cplusplus >= 201703L
+extern int abs (int __x) throw()  __attribute__ ((__const__)) ;
+extern long int labs (long int __x) throw() __attribute__ ((__const__)) ;
+#else
 extern int abs (int __x) __attribute__ ((__const__)) ;
 extern long int labs (long int __x) __attribute__ ((__const__)) ;
+#endif
 
 namespace std
 {
Index: lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
===
--- lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
+++ lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
@@ -20,6 +20,8 @@
 
 #if defined(__cplusplus)
   #include <__clang_cuda_math_forward_declares.h>
+  #include 
+  #include 
 #endif
 
 /// Include declarations for libdevice functions.
Index: lib/Headers/__clang_cuda_math_forward_declares.h
===
--- lib/Headers/__clang_cuda_math_forward_declares.h
+++ lib/Headers/__clang_cuda_math_forward_declares.h
@@ -27,11 +27,20 @@
   static __inline__ __attribute__((always_inline)) __attribute__((device))
 #endif
 
+// For C++ 17 we need to include noexcept attribute to be compatible
+// with the header-defined version. This may be removed once
+// variant is supported.
+#if defined(_OPENMP) && defined(__cplusplus) && __cplusplus >= 201703L
+#define __NOEXCEPT noexcept
+#el

[PATCH] D61949: [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

2019-05-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked an inline comment as done.
gtbercea added inline comments.



Comment at: lib/Headers/__clang_cuda_device_functions.h:1477
 #endif // CUDA_VERSION >= 9020
+#if __cplusplus >= 201703L
+__DEVICE__ int abs(int __a) noexcept { return __nv_abs(__a); }

tra wrote:
> jdoerfert wrote:
> > Hahnfeld wrote:
> > > If I recall correctly, `__cplusplus` is not defined in C mode, so both 
> > > GCC and Clang will issue a warning with `-Wundef`.
> > > 
> > > Maybe this can be solved with something similar to:
> > > ```lang=c
> > > #ifdef __cplusplus
> > > #define cpp_version __cplusplus
> > > #else
> > > #define cpp_version 0
> > > #endif
> > > ```
> > > (to avoid repetition of `#if defined(__cplusplus) && __cplusplus >= 
> > > 201703L`)
> > I dislike defining the version and advice to repeating `#if 
> > defined(__cplusplus) && __cplusplus >= 201703L)`
> > 
> I agree with @jdoerfert.
> If that's needed too often, we can move c++-only functions under one global 
> `#if defined(__cplusplus)`.
> 
@tra is this closer to what you want?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61949



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


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

2019-05-15 Thread Kit Barton via Phabricator via cfe-commits
kbarton added a comment.

I think this looks straightforward, as long as people agree to have a separate 
CreateConstrained* version of these functions. I'm not qualified to weigh in on 
that as I don't know Clang at all and can't comment about the tradeoffs 
(although I think they have been well articulated in the discussion). From what 
I can see, that is the only thing blocking this from getting approved  (unless 
there is something else I missed while reading the discussion).

The only other comment I have is there was some very good description about the 
intention here from @uweigand, @cameron.mcinally and @andrew.w.kaylor and @kpn. 
I think it would be good if that discussion is extracted from this review and 
put somewhere (perhaps the language ref) to indicate precisely what the 
semantics are we are trying to achieve with FENV_ACCESS ON/OFF.




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

This is a minor quibble, but the method is setIsConstrainedFP, while the member 
is IsFPConstrained. 
I'm not sure if that is intentionally different, or an oversight. 


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

https://reviews.llvm.org/D53157



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


[PATCH] D60956: [Sema] Fix the lookup for a declaration conflicting with an enumerator

2019-05-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

Ping :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D60956



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


[PATCH] D61909: Add Clang shared library with C++ exports

2019-05-15 Thread Wink Saville via Phabricator via cfe-commits
winksaville added a comment.

IMHO "`BUILD_CLANG_DYLIB`" is needed. As you have it now libclang_shared.so is 
always builds on UNIX systems, which I believe means that all linux distros 
would have both increasing their sizes. I think the default should be "always" 
`build libclang*.a` as it is now, and optionally build `libclang_shared.so` 
using some flag.

And adding "`LINK_CLANG_DYLIB`" in a future patch SGTM.




Comment at: clang/tools/CMakeLists.txt:16
 add_clang_subdirectory(clang-refactor)
+if(UNIX)
+  add_clang_subdirectory(clang-shlib)

It seems to me we should put creating clang-shlib in the users control and 
default to off.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61909



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


[PATCH] D61957: [CodeGenObjC] invoke objc_autorelease, objc_retain when necessary

2019-05-15 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak accepted this revision.
ahatanak added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m:208
+  }
+}

Can you add tests for `objc_alloc`, `objc_allocWithZone` and `objc_alloc_init` 
too?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61957



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


[PATCH] D61949: [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

2019-05-15 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

LGTM.




Comment at: lib/Headers/__clang_cuda_cmath.h:42
+// variant is supported.
+#if defined(_OPENMP) && defined(__cplusplus) && __cplusplus >= 201703L
+#define __NOEXCEPT noexcept

I think the change is useful for CUDA, too, but I'm OK keeping it 
OpenMP-specific for now. I can enable it for CUDA later.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61949



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


[PATCH] D61949: [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

2019-05-15 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert requested changes to this revision.
jdoerfert added inline comments.
This revision now requires changes to proceed.



Comment at: lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h:24
+  #include 
+  #include 
 #endif

jdoerfert wrote:
> I ask this question again and again, do we need them now? Why?
Why did you add these includes?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61949



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


[PATCH] D60283: [DebugInfo] Don't emit checksums when compiling a preprocessed CPP

2019-05-15 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 199659.
aganea marked 3 inline comments as done.
aganea added a comment.

In D60283#1503256 , @probinson wrote:

> Minor stuff.  This solution is surprisingly simple, the main question being 
> (and I don't have an answer) whether increasing the size of PresumedLoc is 
> okay.


Thanks Paul! `PresumedLoc` seems to be used only as a temporary (on the stack).


Repository:
  rC Clang

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

https://reviews.llvm.org/D60283

Files:
  include/clang/Basic/SourceLocation.h
  lib/Basic/SourceManager.cpp
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
  test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
  test/CodeGen/debug-info-file-checksum.c

Index: test/CodeGen/debug-info-file-checksum.c
===
--- test/CodeGen/debug-info-file-checksum.c
+++ test/CodeGen/debug-info-file-checksum.c
@@ -4,3 +4,15 @@
 // Check that "checksum" is created correctly for the compiled file.
 
 // CHECK: !DIFile(filename:{{.*}}, directory:{{.*}}, checksumkind: CSK_MD5, checksum: "a3b7d27af071accdeccaa933fc603608")
+
+// Ensure #line directives (in already pre-processed files) do not emit checksums
+// RUN: %clang -emit-llvm -S -g -gcodeview -x c %S/Inputs/debug-info-file-checksum-pre.cpp -o - | FileCheck %s --check-prefix NOCHECKSUM
+
+// NOCHECKSUM: !DIFile(filename: "{{.*}}code-coverage-filter1.h", directory: "{{[^"]*}}")
+// NOCHECKSUM: !DIFile(filename: "{{.*}}code-coverage-filter2.h", directory: "{{[^"]*}}")
+// NOCHECKSUM: !DIFile(filename: "{{.*}}debug-info-file-checksum.c", directory: "{{[^"]*}}")
+
+// Ensure #line directives without name do emit checksums
+// RUN: %clang -emit-llvm -S -g -gcodeview -x c %S/Inputs/debug-info-file-checksum-line.cpp -o - | FileCheck %s --check-prefix CHECKSUM
+
+// CHECKSUM: !DIFile(filename: "{{.*}}debug-info-file-checksum-line.cpp", directory:{{.*}}, checksumkind: CSK_MD5, checksum: "7b568574d0e3c56c28e5e0234d1f4a06")
Index: test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
===
--- test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
+++ test/CodeGen/Inputs/debug-info-file-checksum-pre.cpp
@@ -0,0 +1,10 @@
+#line 1 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+#line 1 "f:\\svn\\clang\\test\\codegen\\inputs\\code-coverage-filter1.h"
+void test1() {}
+#line 2 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+#line 1 "f:\\svn\\clang\\test\\codegen\\inputs\\code-coverage-filter2.h"
+void test2() {}
+#line 3 "F:\\svn\\clang\\test\\CodeGen\\Inputs\\debug-info-file-checksum.c"
+int foo(int x) {
+  return x+1;
+}
Index: test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
===
--- test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
+++ test/CodeGen/Inputs/debug-info-file-checksum-line.cpp
@@ -0,0 +1,9 @@
+int foo(int x) {
+  return x+1;
+}
+
+#line 100
+void test1() {}
+
+#line 200
+void test2() {}
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -422,8 +422,12 @@
   }
 
   SmallString<32> Checksum;
+
+  // Compute the checksum if possible. If the location is affected by a #line
+  // directive that refers to a file, PLoc will have an invalid FileID, and we
+  // will correctly get no checksum.
   Optional CSKind =
-  computeChecksum(SM.getFileID(Loc), Checksum);
+  computeChecksum(PLoc.getFileID(), Checksum);
   Optional> CSInfo;
   if (CSKind)
 CSInfo.emplace(*CSKind, Checksum);
Index: lib/Basic/SourceManager.cpp
===
--- lib/Basic/SourceManager.cpp
+++ lib/Basic/SourceManager.cpp
@@ -1430,6 +1430,7 @@
   // To get the source name, first consult the FileEntry (if one exists)
   // before the MemBuffer as this will avoid unnecessarily paging in the
   // MemBuffer.
+  FileID FID = LocInfo.first;
   StringRef Filename;
   if (C->OrigEntry)
 Filename = C->OrigEntry->getName();
@@ -1453,8 +1454,12 @@
 if (const LineEntry *Entry =
   LineTable->FindNearestLineEntry(LocInfo.first, LocInfo.second)) {
   // If the LineEntry indicates a filename, use it.
-  if (Entry->FilenameID != -1)
+  if (Entry->FilenameID != -1) {
 Filename = LineTable->getFilename(Entry->FilenameID);
+// The contents of files referenced by #line are not in the
+// SourceManager
+FID = FileID::get(0);
+  }
 
   // Use the line number specified by the LineEntry.  This line number may
   // be multiple lines down from the line entry.  Add the difference in
@@ -1473,7 +1478,7 @@
 }
   }
 
-  return PresumedLoc(Filename.data(), LineNo, ColNo, IncludeLoc);
+  return Pre

[PATCH] D61909: Add Clang shared library with C++ exports

2019-05-15 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

In D61909#1503433 , @winksaville wrote:

> IMHO "`BUILD_CLANG_DYLIB`" is needed. As you have it now libclang_shared.so 
> is always builds on UNIX systems, which I believe means that all linux 
> distros would have both increasing their sizes.


Distributions shouldn't be installing `all` unless they really want everything 
and the kitchen sink. We have the `LLVM_DISTRIBUTION_COMPONENTS` so that 
distributions can decide which pieces of the LLVM & Clang distributions they 
want to install. That is the cleanest mechanism for curating an install.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61909



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


r360799 - [analyzer] Add a test for plugins using checker dependencies

2019-05-15 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Wed May 15 12:47:26 2019
New Revision: 360799

URL: http://llvm.org/viewvc/llvm-project?rev=360799&view=rev
Log:
[analyzer] Add a test for plugins using checker dependencies

Also, I moved the existing analyzer plugin to test/ as well, in order not to
give the illusion that the analyzer supports plugins -- it's capable of handling
them, but does not _support_ them.

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


Added:
cfe/trunk/test/Analysis/plugins/
cfe/trunk/test/Analysis/plugins/CMakeLists.txt
cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/
cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt

cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandling.cpp

cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandlingAnalyzerPlugin.exports
cfe/trunk/test/Analysis/plugins/SampleAnalyzer/
cfe/trunk/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
cfe/trunk/test/Analysis/plugins/SampleAnalyzer/MainCallChecker.cpp
cfe/trunk/test/Analysis/plugins/SampleAnalyzer/SampleAnalyzerPlugin.exports
Removed:
cfe/trunk/examples/analyzer-plugin/
Modified:
cfe/trunk/examples/CMakeLists.txt
cfe/trunk/test/Analysis/checker-plugins.c
cfe/trunk/test/Analysis/lit.local.cfg
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/examples/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/CMakeLists.txt?rev=360799&r1=360798&r2=360799&view=diff
==
--- cfe/trunk/examples/CMakeLists.txt (original)
+++ cfe/trunk/examples/CMakeLists.txt Wed May 15 12:47:26 2019
@@ -3,9 +3,6 @@ if(NOT CLANG_BUILD_EXAMPLES)
   set(EXCLUDE_FROM_ALL ON)
 endif()
 
-if(CLANG_ENABLE_STATIC_ANALYZER)
-add_subdirectory(analyzer-plugin)
-endif()
 add_subdirectory(clang-interpreter)
 add_subdirectory(PrintFunctionNames)
 add_subdirectory(AnnotateFunctions)

Modified: cfe/trunk/test/Analysis/checker-plugins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/checker-plugins.c?rev=360799&r1=360798&r2=360799&view=diff
==
--- cfe/trunk/test/Analysis/checker-plugins.c (original)
+++ cfe/trunk/test/Analysis/checker-plugins.c Wed May 15 12:47:26 2019
@@ -1,5 +1,8 @@
-// RUN: %clang_analyze_cc1 -load %llvmshlibdir/SampleAnalyzerPlugin%pluginext 
-analyzer-checker='example.MainCallChecker' -verify %s
-// REQUIRES: plugins, examples
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -load %llvmshlibdir/SampleAnalyzerPlugin%pluginext \
+// RUN:   -analyzer-checker='example.MainCallChecker'
+
+// REQUIRES: plugins
 
 // Test that the MainCallChecker example analyzer plugin loads and runs.
 
@@ -8,3 +11,22 @@ int main();
 void caller() {
   main(); // expected-warning {{call to main}}
 }
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -load 
%llvmshlibdir/CheckerDependencyHandlingAnalyzerPlugin%pluginext\
+// RUN:   -analyzer-checker=example.DependendentChecker \
+// RUN:   -analyzer-list-enabled-checkers \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-IMPLICITLY-ENABLED
+
+// CHECK-IMPLICITLY-ENABLED: example.Dependency
+// CHECK-IMPLICITLY-ENABLED: example.DependendentChecker
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -load 
%llvmshlibdir/CheckerDependencyHandlingAnalyzerPlugin%pluginext\
+// RUN:   -analyzer-checker=example.DependendentChecker \
+// RUN:   -analyzer-disable-checker=example.Dependency \
+// RUN:   -analyzer-list-enabled-checkers \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-IMPLICITLY-DISABLED
+
+// CHECK-IMPLICITLY-DISABLED-NOT: example.Dependency
+// CHECK-IMPLICITLY-DISABLED-NOT: example.DependendentChecker

Modified: cfe/trunk/test/Analysis/lit.local.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/lit.local.cfg?rev=360799&r1=360798&r2=360799&view=diff
==
--- cfe/trunk/test/Analysis/lit.local.cfg (original)
+++ cfe/trunk/test/Analysis/lit.local.cfg Wed May 15 12:47:26 2019
@@ -18,5 +18,7 @@ config.substitutions.append(('%diff_plis
 config.substitutions.append(('%diff_sarif',
 '''diff -U1 -w -I ".*file:.*%basename_t" -I '"version":' -I 
"2\.0\.0\-csd\.[0-9]*\.beta\."'''))
 
+config.excludes.add('plugins')
+
 if not config.root.clang_staticanalyzer:
 config.unsupported = True

Added: cfe/trunk/test/Analysis/plugins/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/plugins/CMakeLists.txt?rev=360799&view=auto
==
--- cfe/trunk/test/Analysis/plugins/CMakeLists.txt (added)
+++ cfe/trunk/test/Analysis/plugins/CMakeLists.txt Wed May 15 12:47:26 2019
@@ -0,0 +1,10 @@
+add_subdirectory(SampleAnalyzer)
+add_subdirectory(CheckerDependencyHandling)
+
+set(CLANG_ANALYZER_PLUGIN_DEPS
+  

[PATCH] D59464: [analyzer] Add an example plugin for checker dependency handling

2019-05-15 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL360799: [analyzer] Add a test for plugins using checker 
dependencies (authored by Szelethus, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59464?vs=196083&id=199663#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59464

Files:
  cfe/trunk/examples/CMakeLists.txt
  cfe/trunk/examples/analyzer-plugin/CMakeLists.txt
  cfe/trunk/examples/analyzer-plugin/MainCallChecker.cpp
  cfe/trunk/examples/analyzer-plugin/SampleAnalyzerPlugin.exports
  cfe/trunk/test/Analysis/checker-plugins.c
  cfe/trunk/test/Analysis/lit.local.cfg
  cfe/trunk/test/Analysis/plugins/CMakeLists.txt
  cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
  
cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandling.cpp
  
cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandlingAnalyzerPlugin.exports
  cfe/trunk/test/Analysis/plugins/SampleAnalyzer/CMakeLists.txt
  cfe/trunk/test/Analysis/plugins/SampleAnalyzer/MainCallChecker.cpp
  cfe/trunk/test/Analysis/plugins/SampleAnalyzer/SampleAnalyzerPlugin.exports
  cfe/trunk/test/CMakeLists.txt

Index: cfe/trunk/test/CMakeLists.txt
===
--- cfe/trunk/test/CMakeLists.txt
+++ cfe/trunk/test/CMakeLists.txt
@@ -139,13 +139,15 @@
   # check-all would launch those tests via check-clang.
   set(EXCLUDE_FROM_ALL ON)
 
+  add_subdirectory(Analysis/plugins)
+  list(APPEND CLANG_TEST_DEPS clang-analyzer-plugin)
+
   add_lit_testsuite(check-clang-analyzer "Running the Clang analyzer tests"
 ${CMAKE_CURRENT_BINARY_DIR}/Analysis
 PARAMS ${ANALYZER_TEST_PARAMS}
 DEPENDS ${CLANG_TEST_DEPS})
   set_target_properties(check-clang-analyzer PROPERTIES FOLDER "Clang tests")
 
-
   if (LLVM_WITH_Z3)
 add_lit_testsuite(check-clang-analyzer-z3 "Running the Clang analyzer tests, using Z3 as a solver"
   ${CMAKE_CURRENT_BINARY_DIR}/Analysis
Index: cfe/trunk/test/Analysis/checker-plugins.c
===
--- cfe/trunk/test/Analysis/checker-plugins.c
+++ cfe/trunk/test/Analysis/checker-plugins.c
@@ -1,5 +1,8 @@
-// RUN: %clang_analyze_cc1 -load %llvmshlibdir/SampleAnalyzerPlugin%pluginext -analyzer-checker='example.MainCallChecker' -verify %s
-// REQUIRES: plugins, examples
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -load %llvmshlibdir/SampleAnalyzerPlugin%pluginext \
+// RUN:   -analyzer-checker='example.MainCallChecker'
+
+// REQUIRES: plugins
 
 // Test that the MainCallChecker example analyzer plugin loads and runs.
 
@@ -8,3 +11,22 @@
 void caller() {
   main(); // expected-warning {{call to main}}
 }
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -load %llvmshlibdir/CheckerDependencyHandlingAnalyzerPlugin%pluginext\
+// RUN:   -analyzer-checker=example.DependendentChecker \
+// RUN:   -analyzer-list-enabled-checkers \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-IMPLICITLY-ENABLED
+
+// CHECK-IMPLICITLY-ENABLED: example.Dependency
+// CHECK-IMPLICITLY-ENABLED: example.DependendentChecker
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -load %llvmshlibdir/CheckerDependencyHandlingAnalyzerPlugin%pluginext\
+// RUN:   -analyzer-checker=example.DependendentChecker \
+// RUN:   -analyzer-disable-checker=example.Dependency \
+// RUN:   -analyzer-list-enabled-checkers \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-IMPLICITLY-DISABLED
+
+// CHECK-IMPLICITLY-DISABLED-NOT: example.Dependency
+// CHECK-IMPLICITLY-DISABLED-NOT: example.DependendentChecker
Index: cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandlingAnalyzerPlugin.exports
===
--- cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandlingAnalyzerPlugin.exports
+++ cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CheckerDependencyHandlingAnalyzerPlugin.exports
@@ -0,0 +1,2 @@
+clang_registerCheckers
+clang_analyzerAPIVersionString
Index: cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
===
--- cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
+++ cfe/trunk/test/Analysis/plugins/CheckerDependencyHandling/CMakeLists.txt
@@ -0,0 +1,11 @@
+set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/CheckerDependencyHandlingAnalyzerPlugin.exports)
+add_llvm_library(CheckerDependencyHandlingAnalyzerPlugin MODULE CheckerDependencyHandling.cpp PLUGIN_TOOL clang)
+
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  target_link_libraries(CheckerDependencyHandlingAnalyzerPlugin PRIVATE
+clangAnalysis
+clangAST
+clangStaticAnalyzerCore
+LLVMSupport
+)
+e

[PATCH] D61949: [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

2019-05-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 199662.
gtbercea marked an inline comment as done.
gtbercea added a comment.

- Remove included headers.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61949

Files:
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_device_functions.h
  lib/Headers/__clang_cuda_math_forward_declares.h
  test/Headers/Inputs/include/cstdlib
  test/Headers/nvptx_device_cmath_functions_cxx17.cpp
  test/Headers/nvptx_device_math_functions_cxx17.cpp

Index: test/Headers/nvptx_device_math_functions_cxx17.cpp
===
--- /dev/null
+++ test/Headers/nvptx_device_math_functions_cxx17.cpp
@@ -0,0 +1,22 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -std=c++17
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -internal-isystem %S/Inputs/include -include stdlib.h -include limits -include cstdlib -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -std=c++17 -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, &a1);
+  }
+}
Index: test/Headers/nvptx_device_cmath_functions_cxx17.cpp
===
--- /dev/null
+++ test/Headers/nvptx_device_cmath_functions_cxx17.cpp
@@ -0,0 +1,22 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include cmath -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -std=c++17
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -internal-isystem %S/Inputs/include -include stdlib.h -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -std=c++17 -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, &a1);
+  }
+}
Index: test/Headers/Inputs/include/cstdlib
===
--- test/Headers/Inputs/include/cstdlib
+++ test/Headers/Inputs/include/cstdlib
@@ -1,7 +1,12 @@
 #pragma once
 
+#if __cplusplus >= 201703L
+extern int abs (int __x) throw()  __attribute__ ((__const__)) ;
+extern long int labs (long int __x) throw() __attribute__ ((__const__)) ;
+#else
 extern int abs (int __x) __attribute__ ((__const__)) ;
 extern long int labs (long int __x) __attribute__ ((__const__)) ;
+#endif
 
 namespace std
 {
Index: lib/Headers/__clang_cuda_math_forward_declares.h
===
--- lib/Headers/__clang_cuda_math_forward_declares.h
+++ lib/Headers/__clang_cuda_math_forward_declares.h
@@ -27,11 +27,20 @@
   static __inline__ __attribute__((always_inline)) __attribute__((device))
 #endif
 
+// For C++ 17 we need to include noexcept attribute to be compatible
+// with the header-defined version. This may be removed once
+// variant is supported.
+#if defined(_OPENMP) && defined(__cplusplus) && __cplusplus >= 201703L
+#define __NOEXCEPT noexcept
+#else
+#define __NOEXCEPT
+#endif
+
 #if !(defined(_OPENMP) && defined(__cplusplus))
 __DEVICE__ long abs(long);
 __DEVICE__ long long abs(long long);
 #endif
-__DEVICE__ int abs(int);
+__DEVICE__ int abs(int) __NOEXCEPT;
 __DEVICE__ double abs(double);
 __DEVICE__ float abs(float);
 __DEVICE__ double acos(double);
@@ -68,8 +77,8 @@
 __DEVICE__ float exp(float);
 __DEVICE__ double expm1(double);
 __DEVICE__ float expm1(float);
-__DEVICE__ double 

[PATCH] D60907: [OpenMP] Add math functions support in OpenMP offloading

2019-05-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea abandoned this revision.
gtbercea marked an inline comment as done.
gtbercea added a comment.

Replaced by: D61399 


Repository:
  rC Clang

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

https://reviews.llvm.org/D60907



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


[PATCH] D61959: [OpenMP][Bugfix] Move double and float versions of abs under c++ macro

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

This is a fix for the reported bug:

41861 

abs functions need to be moved under the c++ macro to avoid conflicts with 
included headers.


Repository:
  rC Clang

https://reviews.llvm.org/D61959

Files:
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_math_forward_declares.h
  test/Headers/Inputs/include/cstdlib
  test/Headers/nvptx_device_cmath_functions.c
  test/Headers/nvptx_device_cmath_functions.cpp
  test/Headers/nvptx_device_cmath_functions_cxx17.cpp
  test/Headers/nvptx_device_math_functions.c
  test/Headers/nvptx_device_math_functions.cpp
  test/Headers/nvptx_device_math_functions_cxx17.cpp

Index: test/Headers/nvptx_device_math_functions_cxx17.cpp
===
--- test/Headers/nvptx_device_math_functions_cxx17.cpp
+++ test/Headers/nvptx_device_math_functions_cxx17.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, &a1);
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_math_functions.cpp
===
--- test/Headers/nvptx_device_math_functions.cpp
+++ test/Headers/nvptx_device_math_functions.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, &a1);
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_math_functions.c
===
--- test/Headers/nvptx_device_math_functions.c
+++ test/Headers/nvptx_device_math_functions.c
@@ -17,5 +17,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, &a1);
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_cmath_functions_cxx17.cpp
===
--- test/Headers/nvptx_device_cmath_functions_cxx17.cpp
+++ test/Headers/nvptx_device_cmath_functions_cxx17.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, &a1);
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_cmath_functions.cpp
===
--- test/Headers/nvptx_device_cmath_functions.cpp
+++ test/Headers/nvptx_device_cmath_functions.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, &a1);
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_cmath_functions.c
===
--- test/Headers/nvptx_device_cmath_functions.c
+++ test/Headers/nvptx_device_cmath_functions.c
@@ -17,5 +17,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, &a1);
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/Inputs/include/cstdlib
===
--- test/Headers/Inputs/include/cstdlib
+++ test/Headers/Inputs/include/cstdlib
@@ -3,9 +3,11 @@
 #if __cplusplus >= 201703L
 extern int abs (int __x) throw()  __attribute__ ((__const__)) ;
 extern long int labs (long int __x) throw() __attribute__ ((__const__)) ;
+extern float fabs (float __x) throw() __attribute__ ((__const__)) ;
 #else
 extern int abs (int __x) __attribute__ ((__const__)) ;
 extern long int labs (long int __x) __attribute__ ((__const__)) ;
+extern float fabs (float __x) __attribute__ ((__const__)) ;
 #endif
 
 namespace std
Index: lib/Headers/__clang_cuda_math_forward_declares.h
===
--- lib/Headers/__clang_cuda_math_forward_declares.h
+++ lib/Headers/__clang_cuda_math_forward_declares.h
@@ -39,10 +39,10 @@
 #if !(defined(_OPENMP) && defined(__cplusplus))
 __DEVICE__ long abs(long);
 __DEVICE__ long long abs(long long);
-#endif
-__DEVICE__ int abs(in

[PATCH] D47849: [OpenMP][Clang][NVPTX] Enable math functions called in an OpenMP NVPTX target device region to be resolved as device-native function calls

2019-05-15 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea abandoned this revision.
gtbercea added a comment.

Replaced by: D61399 


Repository:
  rC Clang

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

https://reviews.llvm.org/D47849



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


r360802 - [CodeGenObjC] invoke objc_autorelease, objc_retain when necessary

2019-05-15 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Wed May 15 13:15:01 2019
New Revision: 360802

URL: http://llvm.org/viewvc/llvm-project?rev=360802&view=rev
Log:
[CodeGenObjC] invoke objc_autorelease, objc_retain when necessary

Any of these methods can be overridden, so we need to invoke these functions.

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

Modified:
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m
cfe/trunk/test/CodeGenObjC/objc-alloc-init.m

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=360802&r1=360801&r2=360802&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Wed May 15 13:15:01 2019
@@ -2059,7 +2059,7 @@ static llvm::Value *emitObjCValueOperati
llvm::Value *value,
llvm::Type *returnType,
llvm::FunctionCallee &fn,
-   StringRef fnName, bool MayThrow) {
+   StringRef fnName) {
   if (isa(value))
 return value;
 
@@ -2079,11 +2079,7 @@ static llvm::Value *emitObjCValueOperati
   value = CGF.Builder.CreateBitCast(value, CGF.Int8PtrTy);
 
   // Call the function.
-  llvm::CallBase *Inst = nullptr;
-  if (MayThrow)
-Inst = CGF.EmitCallOrInvoke(fn, value);
-  else
-Inst = CGF.EmitNounwindRuntimeCall(fn, value);
+  llvm::CallBase *Inst = CGF.EmitCallOrInvoke(fn, value);
 
   // Cast the result back to the original type.
   return CGF.Builder.CreateBitCast(Inst, origType);
@@ -2536,7 +2532,7 @@ llvm::Value *CodeGenFunction::EmitObjCAl
 llvm::Type *resultType) {
   return emitObjCValueOperation(*this, value, resultType,
 CGM.getObjCEntrypoints().objc_alloc,
-"objc_alloc", /*MayThrow=*/true);
+"objc_alloc");
 }
 
 /// Allocate the given objc object.
@@ -2545,14 +2541,14 @@ llvm::Value *CodeGenFunction::EmitObjCAl
 llvm::Type *resultType) {
   return emitObjCValueOperation(*this, value, resultType,
 CGM.getObjCEntrypoints().objc_allocWithZone,
-"objc_allocWithZone", /*MayThrow=*/true);
+"objc_allocWithZone");
 }
 
 llvm::Value *CodeGenFunction::EmitObjCAllocInit(llvm::Value *value,
 llvm::Type *resultType) {
   return emitObjCValueOperation(*this, value, resultType,
 CGM.getObjCEntrypoints().objc_alloc_init,
-"objc_alloc_init", /*MayThrow=*/true);
+"objc_alloc_init");
 }
 
 /// Produce the code to do a primitive release.
@@ -2596,7 +2592,7 @@ llvm::Value *CodeGenFunction::EmitObjCAu
   return emitObjCValueOperation(
   *this, value, returnType,
   CGM.getObjCEntrypoints().objc_autoreleaseRuntimeFunction,
-  "objc_autorelease", /*MayThrow=*/false);
+  "objc_autorelease");
 }
 
 /// Retain the given object, with normal retain semantics.
@@ -2605,8 +2601,7 @@ llvm::Value *CodeGenFunction::EmitObjCRe
  llvm::Type *returnType) {
   return emitObjCValueOperation(
   *this, value, returnType,
-  CGM.getObjCEntrypoints().objc_retainRuntimeFunction, "objc_retain",
-  /*MayThrow=*/false);
+  CGM.getObjCEntrypoints().objc_retainRuntimeFunction, "objc_retain");
 }
 
 /// Release the given object.

Modified: cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m?rev=360802&r1=360801&r2=360802&view=diff
==
--- cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m (original)
+++ cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m Wed May 15 
13:15:01 2019
@@ -177,8 +177,8 @@ float test_cannot_message_return_float(C
 
 @class Ety;
 
-// CHECK-LABEL: define {{.*}}void @testException
-void testException(NSObject *a) {
+// CHECK-LABEL: define {{.*}}void @testException_release
+void testException_release(NSObject *a) {
   // MSGS: {{invoke.*@objc_msgSend}}
   // CALLS: invoke{{.*}}void @objc_release(i8* %
   @try {
@@ -186,3 +186,44 @@ void testException(NSObject *a) {
   } @catch (Ety *e) {
   }
 }
+
+// CHECK-LABEL: define {{.*}}void @testException_autorelease
+void testException_autorelease(NSObject *a) {
+  @try {
+// MSGS: {{invoke.*@objc_msgSend}}
+// CALLS: invoke{{.*}}objc_autorelease(i8* %
+[a autorelease];
+  } @catch (Ety *e) {
+  }

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

2019-05-15 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn marked an inline comment as done.
kpn added a comment.

I'm waiting for a signoff from at least one front-end guy. I hope the mode 
setting that allows us to keep front ends from having to touch every use of the 
IRBuilder is something that works for clang. But I haven't heard anything from 
@rsmith or any other front-end person.




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

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


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

https://reviews.llvm.org/D53157



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


[PATCH] D61957: [CodeGenObjC] invoke objc_autorelease, objc_retain when necessary

2019-05-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC360802: [CodeGenObjC] invoke objc_autorelease, objc_retain 
when necessary (authored by epilk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61957?vs=199640&id=199666#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D61957

Files:
  lib/CodeGen/CGObjC.cpp
  test/CodeGenObjC/convert-messages-to-runtime-calls.m
  test/CodeGenObjC/objc-alloc-init.m

Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -2059,7 +2059,7 @@
llvm::Value *value,
llvm::Type *returnType,
llvm::FunctionCallee &fn,
-   StringRef fnName, bool MayThrow) {
+   StringRef fnName) {
   if (isa(value))
 return value;
 
@@ -2079,11 +2079,7 @@
   value = CGF.Builder.CreateBitCast(value, CGF.Int8PtrTy);
 
   // Call the function.
-  llvm::CallBase *Inst = nullptr;
-  if (MayThrow)
-Inst = CGF.EmitCallOrInvoke(fn, value);
-  else
-Inst = CGF.EmitNounwindRuntimeCall(fn, value);
+  llvm::CallBase *Inst = CGF.EmitCallOrInvoke(fn, value);
 
   // Cast the result back to the original type.
   return CGF.Builder.CreateBitCast(Inst, origType);
@@ -2536,7 +2532,7 @@
 llvm::Type *resultType) {
   return emitObjCValueOperation(*this, value, resultType,
 CGM.getObjCEntrypoints().objc_alloc,
-"objc_alloc", /*MayThrow=*/true);
+"objc_alloc");
 }
 
 /// Allocate the given objc object.
@@ -2545,14 +2541,14 @@
 llvm::Type *resultType) {
   return emitObjCValueOperation(*this, value, resultType,
 CGM.getObjCEntrypoints().objc_allocWithZone,
-"objc_allocWithZone", /*MayThrow=*/true);
+"objc_allocWithZone");
 }
 
 llvm::Value *CodeGenFunction::EmitObjCAllocInit(llvm::Value *value,
 llvm::Type *resultType) {
   return emitObjCValueOperation(*this, value, resultType,
 CGM.getObjCEntrypoints().objc_alloc_init,
-"objc_alloc_init", /*MayThrow=*/true);
+"objc_alloc_init");
 }
 
 /// Produce the code to do a primitive release.
@@ -2596,7 +2592,7 @@
   return emitObjCValueOperation(
   *this, value, returnType,
   CGM.getObjCEntrypoints().objc_autoreleaseRuntimeFunction,
-  "objc_autorelease", /*MayThrow=*/false);
+  "objc_autorelease");
 }
 
 /// Retain the given object, with normal retain semantics.
@@ -2605,8 +2601,7 @@
  llvm::Type *returnType) {
   return emitObjCValueOperation(
   *this, value, returnType,
-  CGM.getObjCEntrypoints().objc_retainRuntimeFunction, "objc_retain",
-  /*MayThrow=*/false);
+  CGM.getObjCEntrypoints().objc_retainRuntimeFunction, "objc_retain");
 }
 
 /// Release the given object.
Index: test/CodeGenObjC/objc-alloc-init.m
===
--- test/CodeGenObjC/objc-alloc-init.m
+++ test/CodeGenObjC/objc-alloc-init.m
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 %s -fobjc-runtime=macosx-10.14.4 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=OPTIMIZED --check-prefix=EITHER
-// RUN: %clang_cc1 %s -fobjc-runtime=macosx-10.14.3 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=NOT_OPTIMIZED --check-prefix=EITHER
-// RUN: %clang_cc1 %s -fobjc-runtime=ios-12.2 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=OPTIMIZED --check-prefix=EITHER
-// RUN: %clang_cc1 %s -fobjc-runtime=ios-12.1 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=NOT_OPTIMIZED --check-prefix=EITHER
+// RUN: %clang_cc1 %s -fobjc-exceptions -fexceptions -fobjc-runtime=macosx-10.14.4 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=OPTIMIZED --check-prefix=EITHER
+// RUN: %clang_cc1 %s -fobjc-exceptions -fexceptions -fobjc-runtime=macosx-10.14.3 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=NOT_OPTIMIZED --check-prefix=EITHER
+// RUN: %clang_cc1 %s -fobjc-exceptions -fexceptions -fobjc-runtime=ios-12.2 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=OPTIMIZED --check-prefix=EITHER
+// RUN: %clang_cc1 %s -fobjc-exceptions -fexceptions -fobjc-runtime=ios-12.1 -emit-llvm -O0 -o - | FileCheck %s --check-prefix=NOT_OPTIMIZED --check-prefix=EITHER
 
 @interface X
 +(X *)alloc;
@@ -12,6 +12,13 @@
   [[X alloc] init];
   // OPTIMIZED: call i8* @objc_alloc_init(
   // NOT_OPTIMIZED: call i8* @objc_alloc(
+
+  @try {
+[[X allo

r360804 - [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

2019-05-15 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Wed May 15 13:18:21 2019
New Revision: 360804

URL: http://llvm.org/viewvc/llvm-project?rev=360804&view=rev
Log:
[OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

Summary: In OpenMP device offloading we must ensure that unde C++ 17, the 
inclusion of cstdlib will works correctly.

Reviewers: ABataev, tra, jdoerfert, hfinkel, caomhin

Reviewed By: jdoerfert

Subscribers: Hahnfeld, guansong, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/Headers/nvptx_device_cmath_functions_cxx17.cpp
cfe/trunk/test/Headers/nvptx_device_math_functions_cxx17.cpp
Modified:
cfe/trunk/lib/Headers/__clang_cuda_cmath.h
cfe/trunk/lib/Headers/__clang_cuda_device_functions.h
cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h
cfe/trunk/test/Headers/Inputs/include/cstdlib

Modified: cfe/trunk/lib/Headers/__clang_cuda_cmath.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_cmath.h?rev=360804&r1=360803&r2=360804&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_cmath.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_cmath.h Wed May 15 13:18:21 2019
@@ -36,6 +36,15 @@
 #define __DEVICE__ static __device__ __inline__ __attribute__((always_inline))
 #endif
 
+// For C++ 17 we need to include noexcept attribute to be compatible
+// with the header-defined version. This may be removed once
+// variant is supported.
+#if defined(_OPENMP) && defined(__cplusplus) && __cplusplus >= 201703L
+#define __NOEXCEPT noexcept
+#else
+#define __NOEXCEPT
+#endif
+
 #if !(defined(_OPENMP) && defined(__cplusplus))
 __DEVICE__ long long abs(long long __n) { return ::llabs(__n); }
 __DEVICE__ long abs(long __n) { return ::labs(__n); }
@@ -50,7 +59,7 @@ __DEVICE__ float ceil(float __x) { retur
 __DEVICE__ float cos(float __x) { return ::cosf(__x); }
 __DEVICE__ float cosh(float __x) { return ::coshf(__x); }
 __DEVICE__ float exp(float __x) { return ::expf(__x); }
-__DEVICE__ float fabs(float __x) { return ::fabsf(__x); }
+__DEVICE__ float fabs(float __x) __NOEXCEPT { return ::fabsf(__x); }
 __DEVICE__ float floor(float __x) { return ::floorf(__x); }
 __DEVICE__ float fmod(float __x, float __y) { return ::fmodf(__x, __y); }
 // TODO: remove when variant is supported
@@ -465,6 +474,7 @@ _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 #endif
 
+#undef __NOEXCEPT
 #undef __DEVICE__
 
 #endif

Modified: cfe/trunk/lib/Headers/__clang_cuda_device_functions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_device_functions.h?rev=360804&r1=360803&r2=360804&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_device_functions.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_device_functions.h Wed May 15 13:18:21 
2019
@@ -37,6 +37,15 @@
 #define __FAST_OR_SLOW(fast, slow) slow
 #endif
 
+// For C++ 17 we need to include noexcept attribute to be compatible
+// with the header-defined version. This may be removed once
+// variant is supported.
+#if defined(_OPENMP) && defined(__cplusplus) && __cplusplus >= 201703L
+#define __NOEXCEPT noexcept
+#else
+#define __NOEXCEPT
+#endif
+
 __DEVICE__ int __all(int __a) { return __nvvm_vote_all(__a); }
 __DEVICE__ int __any(int __a) { return __nvvm_vote_any(__a); }
 __DEVICE__ unsigned int __ballot(int __a) { return __nvvm_vote_ballot(__a); }
@@ -1474,7 +1483,8 @@ __DEVICE__ unsigned int __vsubus4(unsign
   return r;
 }
 #endif // CUDA_VERSION >= 9020
-__DEVICE__ int abs(int __a) { return __nv_abs(__a); }
+__DEVICE__ int abs(int __a) __NOEXCEPT { return __nv_abs(__a); }
+__DEVICE__ double fabs(double __a) __NOEXCEPT { return __nv_fabs(__a); }
 __DEVICE__ double acos(double __a) { return __nv_acos(__a); }
 __DEVICE__ float acosf(float __a) { return __nv_acosf(__a); }
 __DEVICE__ double acosh(double __a) { return __nv_acosh(__a); }
@@ -1533,7 +1543,6 @@ __DEVICE__ float exp2f(float __a) { retu
 __DEVICE__ float expf(float __a) { return __nv_expf(__a); }
 __DEVICE__ double expm1(double __a) { return __nv_expm1(__a); }
 __DEVICE__ float expm1f(float __a) { return __nv_expm1f(__a); }
-__DEVICE__ double fabs(double __a) { return __nv_fabs(__a); }
 __DEVICE__ float fabsf(float __a) { return __nv_fabsf(__a); }
 __DEVICE__ double fdim(double __a, double __b) { return __nv_fdim(__a, __b); }
 __DEVICE__ float fdimf(float __a, float __b) { return __nv_fdimf(__a, __b); }
@@ -1572,15 +1581,15 @@ __DEVICE__ float j1f(float __a) { return
 __DEVICE__ double jn(int __n, double __a) { return __nv_jn(__n, __a); }
 __DEVICE__ float jnf(int __n, float __a) { return __nv_jnf(__n, __a); }
 #if defined(__LP64__) || defined(_WIN64)
-__DEVICE__ long labs(long __a) { return __nv_llabs(__a); };
+__DEVICE__ long labs(long __a) __NOEXCEPT { return __nv_llabs(__a); };
 #else
-__DEVICE__ long labs(long __a) { 

r360805 - Revert "[analyzer] Add a test for plugins using checker dependencies"

2019-05-15 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Wed May 15 13:19:51 2019
New Revision: 360805

URL: http://llvm.org/viewvc/llvm-project?rev=360805&view=rev
Log:
Revert "[analyzer] Add a test for plugins using checker dependencies"

Buildbots don't seem to find the new plugin.

Added:
cfe/trunk/examples/analyzer-plugin/
  - copied from r360798, cfe/trunk/examples/analyzer-plugin/
Removed:
cfe/trunk/test/Analysis/plugins/
Modified:
cfe/trunk/examples/CMakeLists.txt
cfe/trunk/test/Analysis/checker-plugins.c
cfe/trunk/test/Analysis/lit.local.cfg
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/examples/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/CMakeLists.txt?rev=360805&r1=360804&r2=360805&view=diff
==
--- cfe/trunk/examples/CMakeLists.txt (original)
+++ cfe/trunk/examples/CMakeLists.txt Wed May 15 13:19:51 2019
@@ -3,6 +3,9 @@ if(NOT CLANG_BUILD_EXAMPLES)
   set(EXCLUDE_FROM_ALL ON)
 endif()
 
+if(CLANG_ENABLE_STATIC_ANALYZER)
+add_subdirectory(analyzer-plugin)
+endif()
 add_subdirectory(clang-interpreter)
 add_subdirectory(PrintFunctionNames)
 add_subdirectory(AnnotateFunctions)

Modified: cfe/trunk/test/Analysis/checker-plugins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/checker-plugins.c?rev=360805&r1=360804&r2=360805&view=diff
==
--- cfe/trunk/test/Analysis/checker-plugins.c (original)
+++ cfe/trunk/test/Analysis/checker-plugins.c Wed May 15 13:19:51 2019
@@ -1,8 +1,5 @@
-// RUN: %clang_analyze_cc1 -verify %s \
-// RUN:   -load %llvmshlibdir/SampleAnalyzerPlugin%pluginext \
-// RUN:   -analyzer-checker='example.MainCallChecker'
-
-// REQUIRES: plugins
+// RUN: %clang_analyze_cc1 -load %llvmshlibdir/SampleAnalyzerPlugin%pluginext 
-analyzer-checker='example.MainCallChecker' -verify %s
+// REQUIRES: plugins, examples
 
 // Test that the MainCallChecker example analyzer plugin loads and runs.
 
@@ -11,22 +8,3 @@ int main();
 void caller() {
   main(); // expected-warning {{call to main}}
 }
-
-// RUN: %clang_analyze_cc1 %s \
-// RUN:   -load 
%llvmshlibdir/CheckerDependencyHandlingAnalyzerPlugin%pluginext\
-// RUN:   -analyzer-checker=example.DependendentChecker \
-// RUN:   -analyzer-list-enabled-checkers \
-// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-IMPLICITLY-ENABLED
-
-// CHECK-IMPLICITLY-ENABLED: example.Dependency
-// CHECK-IMPLICITLY-ENABLED: example.DependendentChecker
-
-// RUN: %clang_analyze_cc1 %s \
-// RUN:   -load 
%llvmshlibdir/CheckerDependencyHandlingAnalyzerPlugin%pluginext\
-// RUN:   -analyzer-checker=example.DependendentChecker \
-// RUN:   -analyzer-disable-checker=example.Dependency \
-// RUN:   -analyzer-list-enabled-checkers \
-// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-IMPLICITLY-DISABLED
-
-// CHECK-IMPLICITLY-DISABLED-NOT: example.Dependency
-// CHECK-IMPLICITLY-DISABLED-NOT: example.DependendentChecker

Modified: cfe/trunk/test/Analysis/lit.local.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/lit.local.cfg?rev=360805&r1=360804&r2=360805&view=diff
==
--- cfe/trunk/test/Analysis/lit.local.cfg (original)
+++ cfe/trunk/test/Analysis/lit.local.cfg Wed May 15 13:19:51 2019
@@ -18,7 +18,5 @@ config.substitutions.append(('%diff_plis
 config.substitutions.append(('%diff_sarif',
 '''diff -U1 -w -I ".*file:.*%basename_t" -I '"version":' -I 
"2\.0\.0\-csd\.[0-9]*\.beta\."'''))
 
-config.excludes.add('plugins')
-
 if not config.root.clang_staticanalyzer:
 config.unsupported = True

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=360805&r1=360804&r2=360805&view=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Wed May 15 13:19:51 2019
@@ -139,15 +139,13 @@ if (CLANG_ENABLE_STATIC_ANALYZER)
   # check-all would launch those tests via check-clang.
   set(EXCLUDE_FROM_ALL ON)
 
-  add_subdirectory(Analysis/plugins)
-  list(APPEND CLANG_TEST_DEPS clang-analyzer-plugin)
-
   add_lit_testsuite(check-clang-analyzer "Running the Clang analyzer tests"
 ${CMAKE_CURRENT_BINARY_DIR}/Analysis
 PARAMS ${ANALYZER_TEST_PARAMS}
 DEPENDS ${CLANG_TEST_DEPS})
   set_target_properties(check-clang-analyzer PROPERTIES FOLDER "Clang tests")
 
+
   if (LLVM_WITH_Z3)
 add_lit_testsuite(check-clang-analyzer-z3 "Running the Clang analyzer 
tests, using Z3 as a solver"
   ${CMAKE_CURRENT_BINARY_DIR}/Analysis


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


[PATCH] D61949: [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

2019-05-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC360804: [OpenMP][bugfix] Fix issues with C++ 17 compilation 
when handling math functions (authored by gbercea, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61949?vs=199662&id=199668#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D61949

Files:
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_device_functions.h
  lib/Headers/__clang_cuda_math_forward_declares.h
  test/Headers/Inputs/include/cstdlib
  test/Headers/nvptx_device_cmath_functions_cxx17.cpp
  test/Headers/nvptx_device_math_functions_cxx17.cpp

Index: test/Headers/Inputs/include/cstdlib
===
--- test/Headers/Inputs/include/cstdlib
+++ test/Headers/Inputs/include/cstdlib
@@ -1,7 +1,12 @@
 #pragma once
 
+#if __cplusplus >= 201703L
+extern int abs (int __x) throw()  __attribute__ ((__const__)) ;
+extern long int labs (long int __x) throw() __attribute__ ((__const__)) ;
+#else
 extern int abs (int __x) __attribute__ ((__const__)) ;
 extern long int labs (long int __x) __attribute__ ((__const__)) ;
+#endif
 
 namespace std
 {
Index: test/Headers/nvptx_device_cmath_functions_cxx17.cpp
===
--- test/Headers/nvptx_device_cmath_functions_cxx17.cpp
+++ test/Headers/nvptx_device_cmath_functions_cxx17.cpp
@@ -0,0 +1,22 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include cmath -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -std=c++17
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -internal-isystem %S/Inputs/include -include stdlib.h -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -std=c++17 -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, &a1);
+  }
+}
Index: test/Headers/nvptx_device_math_functions_cxx17.cpp
===
--- test/Headers/nvptx_device_math_functions_cxx17.cpp
+++ test/Headers/nvptx_device_math_functions_cxx17.cpp
@@ -0,0 +1,22 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -std=c++17
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -internal-isystem %S/Inputs/include -include stdlib.h -include limits -include cstdlib -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -std=c++17 -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, &a1);
+  }
+}
Index: lib/Headers/__clang_cuda_cmath.h
===
--- lib/Headers/__clang_cuda_cmath.h
+++ lib/Headers/__clang_cuda_cmath.h
@@ -36,6 +36,15 @@
 #define __DEVICE__ static __device__ __inline__ __attribute__((always_inline))
 #endif
 
+// For C++ 17 we need to include noexcept attribute to be compatible
+// with the header-defined version. This may be removed once
+// variant is supported.
+#if defined(_OPENMP) && defined(__cplusplus) && __cplusplus >= 201703L
+#define __NOEXCEPT noexcept
+#else
+#define __NOEXCEPT
+#endif
+
 #if !(defined(_OPENMP) && defined(__cplusplus))
 __DEVICE__ long long abs(long long __n) { return ::llabs(__n); }
 __DEVICE__ long abs(long __n) { return ::labs(__n); }
@@ -50,7 +59,7 @@
 __DEVICE__ float cos(float 

r360806 - [c++20] For P1327R1: support dynamic_cast in constant expression

2019-05-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed May 15 13:22:21 2019
New Revision: 360806

URL: http://llvm.org/viewvc/llvm-project?rev=360806&view=rev
Log:
[c++20] For P1327R1: support dynamic_cast in constant expression
evaluation.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td?rev=360806&r1=360805&r2=360806&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td Wed May 15 13:22:21 2019
@@ -34,8 +34,15 @@ def note_constexpr_virtual_call : Note<
   "cannot evaluate call to virtual function in a constant expression">;
 def note_constexpr_pure_virtual_call : Note<
   "pure virtual function %q0 called">;
-def note_constexpr_virtual_out_of_lifetime : Note<
-  "virtual function called on object '%0' whose dynamic type is not constant">;
+def note_constexpr_polymorphic_unknown_dynamic_type : Note<
+  "%select{virtual function called on|dynamic_cast applied to}0 "
+  "object '%1' whose dynamic type is not constant">;
+def note_constexpr_dynamic_cast_to_reference_failed : Note<
+  "reference dynamic_cast failed: %select{"
+  "static type %1 of operand is a non-public base class of dynamic type %2|"
+  "dynamic type %2 of operand does not have a base class of type %3|"
+  "%3 is an ambiguous base class of dynamic type %2 of operand|"
+  "%3 is a non-public base class of dynamic type %2 of operand}0">;
 def note_constexpr_virtual_base : Note<
   "cannot construct object of type %0 with virtual base class "
   "in a constant expression">;
@@ -100,10 +107,12 @@ def note_constexpr_this : Note<
   "%select{|implicit }0use of 'this' pointer is only allowed within the "
   "evaluation of a call to a 'constexpr' member function">;
 def note_constexpr_lifetime_ended : Note<
-  "%select{read of|assignment to|increment of|decrement of|member call on}0 "
+  "%select{read of|assignment to|increment of|decrement of|member call on|"
+  "dynamic_cast of}0 "
   "%select{temporary|variable}1 whose lifetime has ended">;
 def note_constexpr_access_uninit : Note<
-  "%select{read of|assignment to|increment of|decrement of|member call on}0 "
+  "%select{read of|assignment to|increment of|decrement of|member call on|"
+  "dynamic_cast of}0 "
   "object outside its lifetime is not allowed in a constant expression">;
 def note_constexpr_use_uninit_reference : Note<
   "use of reference outside its lifetime "
@@ -112,11 +121,11 @@ def note_constexpr_modify_const_type : N
   "modification of object of const-qualified type %0 is not allowed "
   "in a constant expression">;
 def note_constexpr_access_volatile_type : Note<
-  "%select{read of|assignment to|increment of|decrement of|}0 "
+  "%select{read of|assignment to|increment of|decrement of||}0 "
   "volatile-qualified type %1 is not allowed in a constant expression">;
 def note_constexpr_access_volatile_obj : Note<
-  "%select{read of|assignment to|increment of|decrement of|}0 volatile "
-  "%select{temporary|object %2|member %2}1 is not allowed in "
+  "%select{read of|assignment to|increment of|decrement of||}0 "
+  "volatile %select{temporary|object %2|member %2}1 is not allowed in "
   "a constant expression">;
 def note_constexpr_volatile_here : Note<
   "volatile %select{temporary created|object declared|member declared}0 here">;
@@ -129,21 +138,26 @@ def note_constexpr_ltor_non_constexpr :
 def note_constexpr_ltor_incomplete_type : Note<
   "read of incomplete type %0 is not allowed in a constant expression">;
 def note_constexpr_access_null : Note<
-  "%select{read of|assignment to|increment of|decrement of|member call on}0 "
+  "%select{read of|assignment to|increment of|decrement of|member call on|"
+  "dynamic_cast of}0 "
   "dereferenced null pointer is not allowed in a constant expression">;
 def note_constexpr_access_past_end : Note<
-  "%select{read of|assignment to|increment of|decrement of|member call on}0 "
+  "%select{read of|assignment to|increment of|decrement of|member call on|"
+  "dynamic_cast of}0 "
   "dereferenced one-past-the-end pointer is not allowed in a constant 
expression">;
 def note_constexpr_access_unsized_array : Note<
-  "%select{read of|assignment to|increment of|decrement of|member call on}0 "
+  "%select{read of|assignment to|increment of|decrement of|member call on|"
+  "dynamic_cast of}0 "
   "element of array without known bound "
   "is not allowed in a constant expression">;
 def note_constexpr_access_inactive_union_member : Note<
-  "%select{read of|assignment to|increment of|decrement of|member call on}0 "
+  "%select{read of|assignment to|increment of|decrement of|member call on|"
+  "dynamic_cast of}0 "
   "member %1 of union with %s

[PATCH] D59464: [analyzer] Add an example plugin for checker dependency handling

2019-05-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus reopened this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

Ugh. Reverted in rC360805 . Buildbots don't 
seem to be able to find the new plugins.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59464



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


r360809 - [OpenMP][Bugfix] Move double and float versions of abs under c++ macro

2019-05-15 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Wed May 15 13:28:23 2019
New Revision: 360809

URL: http://llvm.org/viewvc/llvm-project?rev=360809&view=rev
Log:
[OpenMP][Bugfix] Move double and float versions of abs under c++ macro

Summary:
This is a fix for the reported bug:

[[ https://bugs.llvm.org/show_bug.cgi?id=41861 | 41861 ]]

abs functions need to be moved under the c++ macro to avoid conflicts with 
included headers.

Reviewers: tra, jdoerfert, hfinkel, ABataev, caomhin

Reviewed By: jdoerfert

Subscribers: guansong, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Headers/__clang_cuda_cmath.h
cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h
cfe/trunk/test/Headers/Inputs/include/cstdlib
cfe/trunk/test/Headers/nvptx_device_cmath_functions.c
cfe/trunk/test/Headers/nvptx_device_cmath_functions.cpp
cfe/trunk/test/Headers/nvptx_device_cmath_functions_cxx17.cpp
cfe/trunk/test/Headers/nvptx_device_math_functions.c
cfe/trunk/test/Headers/nvptx_device_math_functions.cpp
cfe/trunk/test/Headers/nvptx_device_math_functions_cxx17.cpp

Modified: cfe/trunk/lib/Headers/__clang_cuda_cmath.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_cmath.h?rev=360809&r1=360808&r2=360809&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_cmath.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_cmath.h Wed May 15 13:28:23 2019
@@ -48,9 +48,9 @@
 #if !(defined(_OPENMP) && defined(__cplusplus))
 __DEVICE__ long long abs(long long __n) { return ::llabs(__n); }
 __DEVICE__ long abs(long __n) { return ::labs(__n); }
-#endif
 __DEVICE__ float abs(float __x) { return ::fabsf(__x); }
 __DEVICE__ double abs(double __x) { return ::fabs(__x); }
+#endif
 __DEVICE__ float acos(float __x) { return ::acosf(__x); }
 __DEVICE__ float asin(float __x) { return ::asinf(__x); }
 __DEVICE__ float atan(float __x) { return ::atanf(__x); }

Modified: cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h?rev=360809&r1=360808&r2=360809&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h Wed May 15 
13:28:23 2019
@@ -39,10 +39,10 @@
 #if !(defined(_OPENMP) && defined(__cplusplus))
 __DEVICE__ long abs(long);
 __DEVICE__ long long abs(long long);
-#endif
-__DEVICE__ int abs(int) __NOEXCEPT;
 __DEVICE__ double abs(double);
 __DEVICE__ float abs(float);
+#endif
+__DEVICE__ int abs(int) __NOEXCEPT;
 __DEVICE__ double acos(double);
 __DEVICE__ float acos(float);
 __DEVICE__ double acosh(double);

Modified: cfe/trunk/test/Headers/Inputs/include/cstdlib
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/Inputs/include/cstdlib?rev=360809&r1=360808&r2=360809&view=diff
==
--- cfe/trunk/test/Headers/Inputs/include/cstdlib (original)
+++ cfe/trunk/test/Headers/Inputs/include/cstdlib Wed May 15 13:28:23 2019
@@ -3,9 +3,11 @@
 #if __cplusplus >= 201703L
 extern int abs (int __x) throw()  __attribute__ ((__const__)) ;
 extern long int labs (long int __x) throw() __attribute__ ((__const__)) ;
+extern float fabs (float __x) throw() __attribute__ ((__const__)) ;
 #else
 extern int abs (int __x) __attribute__ ((__const__)) ;
 extern long int labs (long int __x) __attribute__ ((__const__)) ;
+extern float fabs (float __x) __attribute__ ((__const__)) ;
 #endif
 
 namespace std

Modified: cfe/trunk/test/Headers/nvptx_device_cmath_functions.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/nvptx_device_cmath_functions.c?rev=360809&r1=360808&r2=360809&view=diff
==
--- cfe/trunk/test/Headers/nvptx_device_cmath_functions.c (original)
+++ cfe/trunk/test/Headers/nvptx_device_cmath_functions.c Wed May 15 13:28:23 
2019
@@ -17,5 +17,9 @@ void test_sqrt(double a1) {
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, &a1);
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }

Modified: cfe/trunk/test/Headers/nvptx_device_cmath_functions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/nvptx_device_cmath_functions.cpp?rev=360809&r1=360808&r2=360809&view=diff
==
--- cfe/trunk/test/Headers/nvptx_device_cmath_functions.cpp (original)
+++ cfe/trunk/test/Headers/nvptx_device_cmath_functions.cpp Wed May 15 13:28:23 
2019
@@ -18,5 +18,9 @@ void test_sqrt(double a1) {
 double l2 = pow(a1, a1);

[PATCH] D61959: [OpenMP][Bugfix] Move double and float versions of abs under c++ macro

2019-05-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC360809: [OpenMP][Bugfix] Move double and float versions of 
abs under c++ macro (authored by gbercea, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D61959

Files:
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_math_forward_declares.h
  test/Headers/Inputs/include/cstdlib
  test/Headers/nvptx_device_cmath_functions.c
  test/Headers/nvptx_device_cmath_functions.cpp
  test/Headers/nvptx_device_cmath_functions_cxx17.cpp
  test/Headers/nvptx_device_math_functions.c
  test/Headers/nvptx_device_math_functions.cpp
  test/Headers/nvptx_device_math_functions_cxx17.cpp

Index: test/Headers/nvptx_device_cmath_functions.c
===
--- test/Headers/nvptx_device_cmath_functions.c
+++ test/Headers/nvptx_device_cmath_functions.c
@@ -17,5 +17,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, &a1);
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/Inputs/include/cstdlib
===
--- test/Headers/Inputs/include/cstdlib
+++ test/Headers/Inputs/include/cstdlib
@@ -3,9 +3,11 @@
 #if __cplusplus >= 201703L
 extern int abs (int __x) throw()  __attribute__ ((__const__)) ;
 extern long int labs (long int __x) throw() __attribute__ ((__const__)) ;
+extern float fabs (float __x) throw() __attribute__ ((__const__)) ;
 #else
 extern int abs (int __x) __attribute__ ((__const__)) ;
 extern long int labs (long int __x) __attribute__ ((__const__)) ;
+extern float fabs (float __x) __attribute__ ((__const__)) ;
 #endif
 
 namespace std
Index: test/Headers/nvptx_device_math_functions.c
===
--- test/Headers/nvptx_device_math_functions.c
+++ test/Headers/nvptx_device_math_functions.c
@@ -17,5 +17,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, &a1);
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_cmath_functions_cxx17.cpp
===
--- test/Headers/nvptx_device_cmath_functions_cxx17.cpp
+++ test/Headers/nvptx_device_cmath_functions_cxx17.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, &a1);
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_math_functions_cxx17.cpp
===
--- test/Headers/nvptx_device_math_functions_cxx17.cpp
+++ test/Headers/nvptx_device_math_functions_cxx17.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, &a1);
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_cmath_functions.cpp
===
--- test/Headers/nvptx_device_cmath_functions.cpp
+++ test/Headers/nvptx_device_cmath_functions.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, &a1);
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: test/Headers/nvptx_device_math_functions.cpp
===
--- test/Headers/nvptx_device_math_functions.cpp
+++ test/Headers/nvptx_device_math_functions.cpp
@@ -18,5 +18,9 @@
 double l2 = pow(a1, a1);
 // CHECK-YES: call double @__nv_modf(double
 double l3 = modf(a1 + 3.5, &a1);
+// CHECK-YES: call double @__nv_fabs(double
+double l4 = fabs(a1);
+// CHECK-YES: call i32 @__nv_abs(i32
+double l5 = abs((int)a1);
   }
 }
Index: lib/Headers/__clang_cuda_cmath.h
===
--- lib/Headers/__clang_cuda_cmath.h
+++ lib/Headers/__clang_cuda_cmath.h
@@ -48,9 +48,9 @@
 #if !(defined(_OPENMP) && defined(__cplusplus))
 __DEVICE__ long long abs(long long __n) { return ::llabs(__n); }
 __DEVICE__ long abs(long __n) { return ::labs(__n); }
-#endif
 __DEVICE__ float abs(float __x) { return ::fabsf(__x); }
 __DEVICE__ double abs(double __x) { return ::fab

r360810 - [clang-format] Fixed self assignment

2019-05-15 Thread David Bolvansky via cfe-commits
Author: xbolva00
Date: Wed May 15 13:29:33 2019
New Revision: 360810

URL: http://llvm.org/viewvc/llvm-project?rev=360810&view=rev
Log:
[clang-format] Fixed self assignment

Reviewers: MyDeveloperDay, RKSimon

Reviewed By: MyDeveloperDay

Subscribers: RKSimon, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Format/FormatTokenLexer.cpp

Modified: cfe/trunk/lib/Format/FormatTokenLexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatTokenLexer.cpp?rev=360810&r1=360809&r2=360810&view=diff
==
--- cfe/trunk/lib/Format/FormatTokenLexer.cpp (original)
+++ cfe/trunk/lib/Format/FormatTokenLexer.cpp Wed May 15 13:29:33 2019
@@ -246,7 +246,6 @@ bool FormatTokenLexer::tryMergeCSharpNul
   StringRef(Identifier->TokenText.begin(),
 Question->TokenText.end() - Identifier->TokenText.begin());
   Identifier->ColumnWidth += Question->ColumnWidth;
-  Identifier->Type = Identifier->Type;
   Tokens.erase(Tokens.end() - 1);
   return true;
 }


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


[PATCH] D61281: [clang-format] Fixed self assignment

2019-05-15 Thread Dávid Bolvanský via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC360810: [clang-format] Fixed self assignment (authored by 
xbolva00, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D61281

Files:
  lib/Format/FormatTokenLexer.cpp


Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -246,7 +246,6 @@
   StringRef(Identifier->TokenText.begin(),
 Question->TokenText.end() - Identifier->TokenText.begin());
   Identifier->ColumnWidth += Question->ColumnWidth;
-  Identifier->Type = Identifier->Type;
   Tokens.erase(Tokens.end() - 1);
   return true;
 }


Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -246,7 +246,6 @@
   StringRef(Identifier->TokenText.begin(),
 Question->TokenText.end() - Identifier->TokenText.begin());
   Identifier->ColumnWidth += Question->ColumnWidth;
-  Identifier->Type = Identifier->Type;
   Tokens.erase(Tokens.end() - 1);
   return true;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61333: [ASTImporter] Fix LLDB lookup in transparent ctx and with ext src

2019-05-15 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

I ran `check-lldb` and I hit one regression in `TestFormatters.py`, part of 
what I am seeing is as follows:

  AssertionError: False is not True : FileCheck'ing result of `expression 
--show-types -- *(new foo(47))`
  Error output:
  error: no matching constructor for initialization of 'foo'
  candidate constructor (the implicit copy constructor) not viable: no known 
conversion from 'int' to 'const foo' for 1st argument
  candidate constructor (the implicit move constructor) not viable: no known 
conversion from 'int' to 'foo' for 1st argument




Comment at: clang/lib/AST/ASTImporter.cpp:1818
+  // The class will have DefinitionData, but no members.  Then,
+  // importDefinition is called from LLDB, which tries to get the members, se
+  // when we get here, the class already has the DefinitionData set, so we must

se -> so?



Comment at: lldb/source/Symbol/ClangASTImporter.cpp:922
+
+  Log *log_ast(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_AST));
+  if (log_ast) {

I am going to say that the logging change is an excellent additions and stands 
alone from this change. Although I realize the test depends on this new 
feature. It makes sense to add the logging in a separate PR.

I also say this b/c I found a regression and it would be nice to get the 
logging in while we resolve the regression.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61333



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


[PATCH] D61963: [clang][Darwin] Refactor header search path logic into the driver

2019-05-15 Thread Louis Dionne via Phabricator via cfe-commits
ldionne created this revision.
ldionne added reviewers: jfb, arphaman.
Herald added subscribers: cfe-commits, jsji, dexonsmith, jkorous, christof, 
kbarton, javed.absar, nemanjai.
Herald added a project: clang.

This commit moves the logic for determining system, resource and C++
header search paths from CC1 to the driver. This refactor has already
been made for several platforms, but Darwin had been left behind.

This refactor tries to implement the previous search path logic with
perfect accuracy. In particular, the order of all include paths inside
CC1 and all paths that were skipped because nonexistent are conserved
after the refactor. This change was also tested against a code base
of significant size and revealed no problems.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61963

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/lib/Frontend/InitHeaderSearch.cpp
  
clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_aarch64/usr/include/c++/4.2.1/arm64-apple-darwin10/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_aarch64/usr/lib/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_arm/usr/include/c++/4.2.1/arm-apple-darwin10/v6/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_arm/usr/include/c++/4.2.1/arm-apple-darwin10/v7/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_arm/usr/lib/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/usr/include/c++/4.0.0/powerpc-apple-darwin10/ppc64/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/usr/include/c++/4.2.1/powerpc-apple-darwin10/ppc64/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/usr/lib/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_x86/usr/include/c++/4.0.0/i686-apple-darwin8/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_x86/usr/include/c++/4.2.1/i686-apple-darwin10/x86_64/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_x86/usr/lib/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_no_libcxx/usr/include/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_no_libcxx/usr/lib/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_no_libstdcxx/usr/include/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_no_libstdcxx/usr/lib/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_usr/usr/include/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_usr/usr/lib/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_usr_and_usr_local/usr/include/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_usr_and_usr_local/usr/lib/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_usr_and_usr_local/usr/local/include/.keep
  
clang/test/Driver/Inputs/basic_darwin_sdk_usr_and_usr_local/usr/local/lib/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_usr_local/usr/local/include/.keep
  clang/test/Driver/Inputs/basic_darwin_sdk_usr_local/usr/local/lib/.keep
  clang/test/Driver/Inputs/basic_darwin_toolchain/usr/bin/.keep
  clang/test/Driver/Inputs/basic_darwin_toolchain/usr/include/c++/v1/.keep
  clang/test/Driver/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin/.keep
  clang/test/Driver/darwin-header-search-libcxx.cpp
  clang/test/Driver/darwin-header-search-libstdcxx.cpp
  clang/test/Driver/darwin-header-search-system.cpp
  clang/test/Driver/darwin-stdlib.cpp
  clang/test/Frontend/warning-stdlibcxx-darwin.cpp

Index: clang/test/Frontend/warning-stdlibcxx-darwin.cpp
===
--- clang/test/Frontend/warning-stdlibcxx-darwin.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-// RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist %s 2>&1 | FileCheck %s
-// RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist -stdlib=libc++ %s -verify
-// RUN: %clang -cc1 -x c++-cpp-output -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist %s -verify
-// CHECK: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead
-
-// expected-no-diagnostics
Index: clang/test/Driver/darwin-stdlib.cpp
===
--- clang/test/Driver/darwin-stdlib.cpp
+++ clang/test/Driver/darwin-stdlib.cpp
@@ -9,13 +9,6 @@
 // RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7s -miphoneos-version-min=7.0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX
 // RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7k %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-LIBCXX
 
-// The purpose of this test is that the libc++ headers should be found
-// properly. We also pass -stdlib=libc++ to make sure the logic to add the
-// optional absolute include for libc++ from InitHeaderSearch.cpp also fires.
-
 // CHECK-LIBCXX: "-stdlib=libc++

[PATCH] D61722: Prototype of RecoveryExpr. Here, it's emitted when overload resolution fails.

2019-05-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 199678.
sammccall added a comment.
Herald added a subscriber: arphaman.

This should work for real now: handle types properly, make tests pass, add some 
tests.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61722

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/AST/Expr.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/Stmt.h
  include/clang/AST/TextNodeDumper.h
  include/clang/AST/Type.h
  include/clang/Basic/StmtNodes.td
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprClassification.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Stmt.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/AST/TextNodeDumper.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Index/USRGeneration.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaExprMember.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaPseudoObject.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
  test/CodeCompletion/member-access.cpp
  test/Index/getcursor-recovery.cpp
  test/SemaCXX/constructor-initializer.cpp
  test/SemaCXX/enable_if.cpp
  test/SemaTemplate/dependent-names.cpp
  test/SemaTemplate/instantiate-function-params.cpp
  test/SemaTemplate/instantiate-init.cpp
  tools/libclang/CIndex.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -288,6 +288,7 @@
   case Stmt::ObjCDictionaryLiteralClass:
   case Stmt::ObjCBoxedExprClass:
   case Stmt::ObjCSubscriptRefExprClass:
+  case Stmt::RecoveryExprClass:
 K = CXCursor_UnexposedExpr;
 break;
 
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1516,6 +1516,7 @@
   case BuiltinType::Void:
   case BuiltinType::NullPtr:
   case BuiltinType::Dependent:
+  case BuiltinType::Recovery:
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
   case BuiltinType::Id:
 #include "clang/Basic/OpenCLImageTypes.def"
Index: test/SemaTemplate/instantiate-init.cpp
===
--- test/SemaTemplate/instantiate-init.cpp
+++ test/SemaTemplate/instantiate-init.cpp
@@ -100,9 +100,9 @@
 integral_c<1> ic1 = array_lengthof(Description::data);
 (void)sizeof(array_lengthof(Description::data));
 
-sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
-  Description::data // expected-note{{in instantiation of static data member 'PR7985::Description::data' requested here}}
-  ));
+(void)sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
+Description::data // expected-note{{in instantiation of static data member 'PR7985::Description::data' requested here}}
+));
 
 array_lengthof(Description::data); // expected-error{{no matching function for call to 'array_lengthof'}}
   }
Index: test/SemaTemplate/instantiate-function-params.cpp
===
--- test/SemaTemplate/instantiate-function-params.cpp
+++ test/SemaTemplate/instantiate-function-params.cpp
@@ -3,7 +3,7 @@
 // PR6619
 template struct if_c { };
 template struct if_ {
-  typedef if_c< static_cast(T1::value)> almost_type_; // expected-note 5{{in instantiation}}
+  typedef if_c< static_cast(T1::value)> type; // expected-note 5{{in instantiation}}
 };
 template  struct wrap_constraints { };
 template  
@@ -17,7 +17,9 @@
 template  struct requirement_;
 template  struct instantiate {
 };
-template  struct requirement_   : if_<   not_satisfied >::type { // expected-note 5{{in instantiation}}
+template 
+struct requirement_ : if_>::type { // expected-note 5{{in instantiation}}
+  static void failed();
 };
 template  struct usage_requirements {
 };
Index: test/SemaTemplate/dependent-names.cpp
===
--- test/SemaTemplate/dependent-names.cpp
+++ test/SemaTemplate/dependent-names.cpp
@@ -176,7 +176,7 @@
 void f(char&); // expected-note {{candidate function not viable}}
 
 template struct C {
-  static const int n = f(T()); // expected-er

[PATCH] D61909: Add Clang shared library with C++ exports

2019-05-15 Thread Wink Saville via Phabricator via cfe-commits
winksaville added a comment.

In D61909#1503483 , @beanz wrote:

> In D61909#1503433 , @winksaville 
> wrote:
>
> > IMHO "`BUILD_CLANG_DYLIB`" is needed. As you have it now libclang_shared.so 
> > is always builds on UNIX systems, which I believe means that all linux 
> > distros would have both increasing their sizes.
>
>
> Distributions shouldn't be installing `all` unless they really want 
> everything and the kitchen sink. We have the `LLVM_DISTRIBUTION_COMPONENTS` 
> so that distributions can decide which pieces of the LLVM & Clang 
> distributions they want to install. That is the cleanest mechanism for 
> curating an install.


Sorry, maybe I didn't make myself clear. I didn't mean distros installing "all" 
of LLVM. What I meant was that this change currently uses `if(UNIX)` to 
generate `libclang_shared.so`, which means "all linux distors" will have both 
`libclang*.a` and `libclang_shared.so`. Therefore, I'm suggesting the need for 
something like "`BUILD_CLANG_DYLIB`" so that `libclang_shared.so` is only 
created when "`BUILD_CLANG_DYLIB`" is `ON` and the default is `OFF`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61909



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


[PATCH] D61909: Add Clang shared library with C++ exports

2019-05-15 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

In D61909#1503642 , @winksaville wrote:

> Sorry, maybe I didn't make myself clear.


I understood you fine. I don't think you understand the guidance for building 
distributions of LLVM.

Distributions only get libclang_shared if they run the `install` target which 
installs all of LLVM & Clang. The point of `LLVM_DISTRIBUTION_COMPONENTS` is to 
allow people constructing distributions to choose which pieces they want to 
install without introducing a whole lot of overhead in the build system. The 
old method of passing dozens of flags to enable and disable individual pieces 
of the build resulted in a combinatoric explosion in build settings which are 
confusing and ill understood. The new method is one setting that is much 
cleaner to use.

Anyone constructing a distribution should be specifying 
`LLVM_DISTRIBUTION_COMPONENTS` and running the `install-distribution` target.

Given that your comment:

> What I meant was that this change currently uses `if(UNIX)` to generate 
> `libclang_shared.so`, which means "all linux distors" will have both 
> `libclang*.a` and `libclang_shared.so`.

Is only true if the distribution is choosing to run the `install` target, which 
doesn't grant control over all the individual pieces of LLVM & Clang to 
install, and is not the recommended way to construct a distribution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61909



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


[PATCH] D59702: Unbreak the build of compiler-rt on Linux/mips64el

2019-05-15 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan added a comment.

I hope the rL360825  fixes the problem so 
this patch can be switch to the `abandoned` state.


Repository:
  rCRT Compiler Runtime

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

https://reviews.llvm.org/D59702



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


  1   2   >