[PATCH] D59449: [clang-tidy] Integrate clang-tidy-diff.py machinery into run-clang-tidy.py

2019-03-19 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added a comment.

In D59449#1435032 , @alexfh wrote:

> How is this functionality different from the clang-tidy-diff.py script with 
> the -j option being added in the other patch?


It's the same.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D59449



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


[PATCH] D59573: [analyzer] C++17: PR41142: Ignore transparent InitListExprs when finding construction contexts.

2019-03-19 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D59573



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


Re: r356222 - [analyzer] Support C++17 aggregates with bases without constructors.

2019-03-19 Thread Artem Dergachev via cfe-commits

On 3/19/19 11:10 AM, Richard Smith wrote:
It sounds like there might be a missing check for 
InitListExpr::isTransparent somewhere. (A transparent InitListExpr 
should be treated as equivalent to its one and only subexpression.) 
Either that, or the static analyzer isn't aware that an object of 
class type can be initialized directly from a function call, not via a 
constructor.


Indeed, thanks! And, as usual, more bugs on top of that.
(https://reviews.llvm.org/D59573)

On 3/19/19 11:00 AM, Alexander Kornienko wrote:
just adding -std=c++17 on existing code (LLVM, for example ;) could 
help uncover some of the issues


Hmm, fair enough :D I'm glad i asked :)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59573: [analyzer] C++17: PR41142: Ignore transparent InitListExprs when finding construction contexts.

2019-03-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a_sidorin, rnkovacs, 
mikhail.ramalho, Szelethus, baloghadamsoftware, Charusso, alexfh.
Herald added subscribers: cfe-commits, jdoerfert, dkrupp, donat.nagy, 
a.sidorin, szepet.
Herald added a project: clang.

This addresses a few simplified crashes similar to the one in in 
https://bugs.llvm.org/show_bug.cgi?id=41142 but there's more bug synergy there, 
so more fixes would be necessary.

Here's the crash:

  class A {};
  class B: A {};
  B boo();
  void foo1() {
B b { boo() }; // no-crash
  }

The analyzer evaluates `{ boo() }` (an `InitListExpr`) to a `compoundVal{X}`, 
where `X` is whatever `boo()` evaluates to. The new aggregate initialization 
facility introduced in D59054  would now be 
triggered by the presence of the `compoundVal{}`, even though the object is not 
an aggregate (base classes are allowed in aggregates in C++17, but they aren't 
allowed to be private or virtual).

F8485527: x72r0730bbc11.jpg 

Note that:

1. If we remove the assertion and proceed, what would happen is it'll try to 
bind the whole object `b` to the region of its base class `A` within variable 
`b`, which is incorrect. `RegionStore` would probably not care in this specific 
case, but with multiple inheritance it'll probably also lead to actual 
incorrect bindings.
2. It is in fact irrelevant whether the object is an aggregate - the incorrect 
behavior would happen anyway. The real problem is that the `compoundVal{}` 
doesn't mean what we think: we expected it to describe a big object that is 
composed of (0 or more) smaller objects, but in fact it's transparently 
describing the single object within it, much like the `InitListExpr` it came 
from. I'd prefer to declare such `compoundVal{}`s as ill-formed.
3. The general problem with compound values is that it's unobvious what sort of 
object does it describe. I.e., it's impossible to figure out whether 
`compoundVal{X}` corresponds to an object of type `A` (probably not) or an 
object of type `B` (that's what we've got) or of some other type that contains 
a `B` inside it (that's what we've expected).

This patch fixes neither of these three problems. Instead, what it does is 
makes sure that there's a `ConstructionContext` to the CFG for the 
return-by-value function call `boo()`. As a side effect for this change, even 
though we still produce an ill-formed `compoundVal{}` as the value of 
expression `{ boo() }`, we never experience a need to make a //Store// binding 
out of it. Instead, the call is correctly treated as a constructor that has 
already initialized its target region by the time it ends, so the crashing code 
path is no longer triggered. Another side effect of this change is that the 
value no longer looks like `compoundVal{conj_$2}`, but more like 
`compoundVal{lazyCompoundVal{b}}` - but both are ill-formed anyway.

Now, the original test case in PR41142 is still not fixed. With the same 
definition of `B`, the original test case can be written as follows:

  B recursive() {
B b { recursive() };
  }

The problem here is that we inevitably hit the recursion limit, and then...

4. Well, something weird happens. I'll have to have a closer look, but one 
weird thing i noticed is that the value for `{ boo() }` ends up being 
`compoundVal{Unknown}`, as if `bindReturnValue()` never gets triggered.

Also,

5. Regardless of the recursion, we're still in trouble every time we don't find 
a construction context, and for now there is a more or less indefinite number 
of situations in which this can happen. We should try to be more defensive 
somehow.

I'll think a bit more to see if fixing these ill-formed `compoundVal{}`s fixes 
the problem. In the worst case, i guess we can remove the assertion: we'd 
behave incorrectly incorrect and crashing from time to time (due to multiple 
inheritance), but it'll hopefully happen less often than before we had D59054 
.


Repository:
  rC Clang

https://reviews.llvm.org/D59573

Files:
  clang/lib/Analysis/CFG.cpp
  clang/test/Analysis/cfg-rich-constructors.cpp
  clang/test/Analysis/initializer.cpp


Index: clang/test/Analysis/initializer.cpp
===
--- clang/test/Analysis/initializer.cpp
+++ clang/test/Analysis/initializer.cpp
@@ -242,4 +242,22 @@
   B & = C({{}}); // no-crash
 #endif
 }
+} // namespace CXX17_aggregate_construction
+
+namespace CXX17_transparent_init_list_exprs {
+class A {};
+
+class B: private A {};
+
+B boo();
+void foo1() {
+  B b { boo() }; // no-crash
+}
+
+class C: virtual public A {};
+
+C coo();
+void foo2() {
+  C c { coo() }; // no-crash
 }
+} // namespace CXX17_transparent_init_list_exprs
Index: clang/test/Analysis/cfg-rich-constructors.cpp
===
--- clang/test/Analysis/cfg-rich-constructors.cpp
+++ 

[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-03-19 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

We need to make progress on this, and I'd like to suggest a path forward...

First, we have a fundamental problem here: Using host headers to declare 
functions for the device execution environment isn't sound. Those host headers 
can do anything, and while some platforms might provide a way to make the host 
headers more friendly (e.g., by defining __NO_MATH_INLINES), these mechanisms 
are neither robust nor portable. Thus, we should not rely on host headers to 
define functions that might be available on the device. However, even when 
compiling for the device, code meant only for host execution must be 
semantically analyzable. This, in general, requires the host headers. So we 
have a situation in which we must both use the host headers during device 
compilation (to keep the semantic analysis of the surrounding host code 
working) and also can't use the host headers to provide definitions for use for 
device code (e.g., because those host headers might provide definitions relying 
on host inline asm, intrinsics, using types not lowerable in device code, could 
provide declarations using linkage-affecting attributes not lowerable for the 
device, etc.).

This is, or is very similar to, the problem that the host/device overloading 
addresses in CUDA. It is also the problem, or very similar to the problem, that 
the new OpenMP 5 `declare variant` directive is intended to address. Johannes 
and I discussed this earlier today, and I suggest that we:

1. Add a math.h wrapper to clang/lib/Headers, which generally just does an 
include_next of math.h, but provides us with the ability to customize this 
behavior. Writing a header for OpenMP on NVIDIA GPUs which is essentially 
identical to the math.h functions in __clang_cuda_device_functions.h would be 
unfortunate, and as CUDA does provide the underlying execution environment for 
OpenMP target offload on NVIDIA GPUs, duplicative even in principle. We don't 
need to alter the default global namespace, however, but can include this file 
from the wrapper math.h.
2. We should allow host/device overloading in OpenMP mode. As an extension, we 
could directly reuse the CUDA host/device overloading capability - this also 
has the advantage of allowing us to directly reuse 
__clang_cuda_device_functions.h (and perhaps do a similar thing to pick up the 
device-side printf, etc. from __clang_cuda_runtime_wrapper.h). In the future, 
we can extend these to provide overloading using OpenMP declare variant, if 
desired, when in OpenMP mode.

Thoughts?


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


[PATCH] D59520: [WebAssembly] Address review comments on r352930

2019-03-19 Thread Dan Gohman via Phabricator via cfe-commits
sunfish marked an inline comment as done.
sunfish added inline comments.



Comment at: test/Sema/attr-wasm.c:3
+
+void name_a() {}
+

aaron.ballman wrote:
> Was this intended to be used somewhere? Probably can just be removed if not.
No, you're right that we don't need this (it's copypasta from another test). 
I'll remove it from the patch.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59520



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


[PATCH] D59520: [WebAssembly] Address review comments on r352930

2019-03-19 Thread Dan Gohman via Phabricator via cfe-commits
sunfish added a comment.

In D59520#1434854 , @aaron.ballman 
wrote:

> > Removes errnoneous use of diag::err_alias_is_definition, which turned out 
> > to be ineffective anyway since functions can be defined later in the 
> > translation unit and avoid detection.
>
> If you need to keep the prohibition that these attributes not be applied to 
> functions with definitions, there are ways to accomplish that (we merge 
> declarations and can decide what to do at that point if we see a declaration 
> that is a definition). Given that, do you still want to lift this restriction?


These attributes don't make sense on definitions. So right now, they are 
silently ignored when applied to definitions. That's effectively the current 
behavior too, because the existing check doesn't work as intended, so the 
change here doesn't change anything in practice yet.

A diagnostic would be slightly tidier, but I'm not familiar enough with clang 
to do this quickly and didn't want to delay the rest of the patch while I 
investigated. Do you know the specific places we'd need to change to diagnose 
this?


Repository:
  rC Clang

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

https://reviews.llvm.org/D59520



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


[PATCH] D59523: Thread Safety: also look at ObjC methods

2019-03-19 Thread JF Bastien via Phabricator via cfe-commits
jfb updated this revision to Diff 191417.
jfb added a comment.

- Add test


Repository:
  rC Clang

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

https://reviews.llvm.org/D59523

Files:
  lib/Analysis/ThreadSafetyCommon.cpp
  test/SemaObjCXX/no-crash-thread-safety-analysis.mm


Index: test/SemaObjCXX/no-crash-thread-safety-analysis.mm
===
--- /dev/null
+++ test/SemaObjCXX/no-crash-thread-safety-analysis.mm
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -Wno-objc-root-class 
%s
+
+// expected-no-diagnostics
+
+struct __attribute__((capability("mutex"))) MyLock {
+  void lock() __attribute__((acquire_capability())) {}
+  void unlock() __attribute__((release_capability())) {}
+};
+
+template  struct __attribute__((scoped_lockable)) Locker {
+  T &_l;
+  Locker(T ) __attribute__((acquire_capability(l))) : _l(l) { _l.lock(); }
+  ~Locker() __attribute__((release_capability())) { _l.unlock(); }
+};
+
+struct MyLockable {
+  MyLock lock;
+};
+
+@protocol MyProtocolBase;
+@protocol MyProtocol 
+@end
+
+@interface MyProtocol
+@end
+
+@interface MyProtocol ()
+- (void)doIt:(struct MyLockable *)myLockable;
+@end
+
+@implementation MyProtocol
+- (void)doIt:(struct MyLockable *)myLockable {
+  Locker lock(myLockable->lock);
+}
+@end
Index: lib/Analysis/ThreadSafetyCommon.cpp
===
--- lib/Analysis/ThreadSafetyCommon.cpp
+++ lib/Analysis/ThreadSafetyCommon.cpp
@@ -276,18 +276,23 @@
 
   // Function parameters require substitution and/or renaming.
   if (const auto *PV = dyn_cast_or_null(VD)) {
-const auto *FD =
-cast(PV->getDeclContext())->getCanonicalDecl();
 unsigned I = PV->getFunctionScopeIndex();
-
-if (Ctx && Ctx->FunArgs && FD == Ctx->AttrDecl->getCanonicalDecl()) {
-  // Substitute call arguments for references to function parameters
-  assert(I < Ctx->NumArgs);
-  return translate(Ctx->FunArgs[I], Ctx->Prev);
+const auto *D = PV->getDeclContext();
+if (Ctx && Ctx->FunArgs) {
+  const auto *Canonical = Ctx->AttrDecl->getCanonicalDecl();
+  if (isa(D)
+  ? (cast(D)->getCanonicalDecl() == Canonical)
+  : (cast(D)->getCanonicalDecl() == Canonical)) {
+// Substitute call arguments for references to function parameters
+assert(I < Ctx->NumArgs);
+return translate(Ctx->FunArgs[I], Ctx->Prev);
+  }
 }
 // Map the param back to the param of the original function declaration
 // for consistent comparisons.
-VD = FD->getParamDecl(I);
+VD = isa(D)
+ ? cast(D)->getCanonicalDecl()->getParamDecl(I)
+ : cast(D)->getCanonicalDecl()->getParamDecl(I);
   }
 
   // For non-local variables, treat it as a reference to a named object.


Index: test/SemaObjCXX/no-crash-thread-safety-analysis.mm
===
--- /dev/null
+++ test/SemaObjCXX/no-crash-thread-safety-analysis.mm
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -Wno-objc-root-class %s
+
+// expected-no-diagnostics
+
+struct __attribute__((capability("mutex"))) MyLock {
+  void lock() __attribute__((acquire_capability())) {}
+  void unlock() __attribute__((release_capability())) {}
+};
+
+template  struct __attribute__((scoped_lockable)) Locker {
+  T &_l;
+  Locker(T ) __attribute__((acquire_capability(l))) : _l(l) { _l.lock(); }
+  ~Locker() __attribute__((release_capability())) { _l.unlock(); }
+};
+
+struct MyLockable {
+  MyLock lock;
+};
+
+@protocol MyProtocolBase;
+@protocol MyProtocol 
+@end
+
+@interface MyProtocol
+@end
+
+@interface MyProtocol ()
+- (void)doIt:(struct MyLockable *)myLockable;
+@end
+
+@implementation MyProtocol
+- (void)doIt:(struct MyLockable *)myLockable {
+  Locker lock(myLockable->lock);
+}
+@end
Index: lib/Analysis/ThreadSafetyCommon.cpp
===
--- lib/Analysis/ThreadSafetyCommon.cpp
+++ lib/Analysis/ThreadSafetyCommon.cpp
@@ -276,18 +276,23 @@
 
   // Function parameters require substitution and/or renaming.
   if (const auto *PV = dyn_cast_or_null(VD)) {
-const auto *FD =
-cast(PV->getDeclContext())->getCanonicalDecl();
 unsigned I = PV->getFunctionScopeIndex();
-
-if (Ctx && Ctx->FunArgs && FD == Ctx->AttrDecl->getCanonicalDecl()) {
-  // Substitute call arguments for references to function parameters
-  assert(I < Ctx->NumArgs);
-  return translate(Ctx->FunArgs[I], Ctx->Prev);
+const auto *D = PV->getDeclContext();
+if (Ctx && Ctx->FunArgs) {
+  const auto *Canonical = Ctx->AttrDecl->getCanonicalDecl();
+  if (isa(D)
+  ? (cast(D)->getCanonicalDecl() == Canonical)
+  : (cast(D)->getCanonicalDecl() == Canonical)) {
+// Substitute call arguments for references to function parameters
+assert(I < 

[PATCH] D59523: Thread Safety: also look at ObjC methods

2019-03-19 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

Actually I'm wrong, this repros properly, will send an update with test.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59523



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


[PATCH] D59523: Thread Safety: also look at ObjC methods

2019-03-19 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

I reduced the code I had to this:

  struct __attribute__((capability("mutex"))) MyLock {
void lock() __attribute__((acquire_capability())) {}
void unlock() __attribute__((release_capability())) {}
  };
  
  template  struct __attribute__((scoped_lockable)) Locker {
T &_l;
Locker(T ) __attribute__((acquire_capability(l))) : _l(l) { _l.lock(); }
~Locker() __attribute__((release_capability())) { _l.unlock(); }
  };
  
  struct MyLockable {
MyLock lock;
  };
  
  @protocol MyProtocolBase;
  @protocol MyProtocol 
  @end
  
  @interface MyProtocol
  @end
  
  @interface MyProtocol ()
  - (void)doIt:(struct MyLockable *)myLockable;
  @end
  
  @implementation MyProtocol
  - (void)doIt:(struct MyLockable *)myLockable {
Locker lock(myLockable->lock);
  }
  @end

But now it doesn't repro... I probably missed something important :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D59523



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


[PATCH] D59523: Thread Safety: also look at ObjC methods

2019-03-19 Thread JF Bastien via Phabricator via cfe-commits
jfb updated this revision to Diff 191416.
jfb added a comment.

- Use suggested format.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59523

Files:
  lib/Analysis/ThreadSafetyCommon.cpp


Index: lib/Analysis/ThreadSafetyCommon.cpp
===
--- lib/Analysis/ThreadSafetyCommon.cpp
+++ lib/Analysis/ThreadSafetyCommon.cpp
@@ -276,18 +276,23 @@
 
   // Function parameters require substitution and/or renaming.
   if (const auto *PV = dyn_cast_or_null(VD)) {
-const auto *FD =
-cast(PV->getDeclContext())->getCanonicalDecl();
 unsigned I = PV->getFunctionScopeIndex();
-
-if (Ctx && Ctx->FunArgs && FD == Ctx->AttrDecl->getCanonicalDecl()) {
-  // Substitute call arguments for references to function parameters
-  assert(I < Ctx->NumArgs);
-  return translate(Ctx->FunArgs[I], Ctx->Prev);
+const auto *D = PV->getDeclContext();
+if (Ctx && Ctx->FunArgs) {
+  const auto *Canonical = Ctx->AttrDecl->getCanonicalDecl();
+  if (isa(D)
+  ? (cast(D)->getCanonicalDecl() == Canonical)
+  : (cast(D)->getCanonicalDecl() == Canonical)) {
+// Substitute call arguments for references to function parameters
+assert(I < Ctx->NumArgs);
+return translate(Ctx->FunArgs[I], Ctx->Prev);
+  }
 }
 // Map the param back to the param of the original function declaration
 // for consistent comparisons.
-VD = FD->getParamDecl(I);
+VD = isa(D)
+ ? cast(D)->getCanonicalDecl()->getParamDecl(I)
+ : cast(D)->getCanonicalDecl()->getParamDecl(I);
   }
 
   // For non-local variables, treat it as a reference to a named object.


Index: lib/Analysis/ThreadSafetyCommon.cpp
===
--- lib/Analysis/ThreadSafetyCommon.cpp
+++ lib/Analysis/ThreadSafetyCommon.cpp
@@ -276,18 +276,23 @@
 
   // Function parameters require substitution and/or renaming.
   if (const auto *PV = dyn_cast_or_null(VD)) {
-const auto *FD =
-cast(PV->getDeclContext())->getCanonicalDecl();
 unsigned I = PV->getFunctionScopeIndex();
-
-if (Ctx && Ctx->FunArgs && FD == Ctx->AttrDecl->getCanonicalDecl()) {
-  // Substitute call arguments for references to function parameters
-  assert(I < Ctx->NumArgs);
-  return translate(Ctx->FunArgs[I], Ctx->Prev);
+const auto *D = PV->getDeclContext();
+if (Ctx && Ctx->FunArgs) {
+  const auto *Canonical = Ctx->AttrDecl->getCanonicalDecl();
+  if (isa(D)
+  ? (cast(D)->getCanonicalDecl() == Canonical)
+  : (cast(D)->getCanonicalDecl() == Canonical)) {
+// Substitute call arguments for references to function parameters
+assert(I < Ctx->NumArgs);
+return translate(Ctx->FunArgs[I], Ctx->Prev);
+  }
 }
 // Map the param back to the param of the original function declaration
 // for consistent comparisons.
-VD = FD->getParamDecl(I);
+VD = isa(D)
+ ? cast(D)->getCanonicalDecl()->getParamDecl(I)
+ : cast(D)->getCanonicalDecl()->getParamDecl(I);
   }
 
   // For non-local variables, treat it as a reference to a named object.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59135: Add check for matching HeaderFilter before emitting Diagnostic

2019-03-19 Thread Thorsten via Phabricator via cfe-commits
thorsten-klein updated this revision to Diff 191415.

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

https://reviews.llvm.org/D59135

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp


Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -449,8 +449,12 @@
   FullSourceLoc Loc;
   if (Info.getLocation().isValid() && Info.hasSourceManager())
 Loc = FullSourceLoc(Info.getLocation(), Info.getSourceManager());
-  Converter.emitDiagnostic(Loc, DiagLevel, Message, Info.getRanges(),
+
+  StringRef FileName(Loc.printToString(Loc.getManager()));
+  if(getHeaderFilter()->match(FileName)) {
+Converter.emitDiagnostic(Loc, DiagLevel, Message, Info.getRanges(),
Info.getFixItHints());
+  }
 
   if (Info.hasSourceManager())
 checkFilters(Info.getLocation(), Info.getSourceManager());


Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -449,8 +449,12 @@
   FullSourceLoc Loc;
   if (Info.getLocation().isValid() && Info.hasSourceManager())
 Loc = FullSourceLoc(Info.getLocation(), Info.getSourceManager());
-  Converter.emitDiagnostic(Loc, DiagLevel, Message, Info.getRanges(),
+
+  StringRef FileName(Loc.printToString(Loc.getManager()));
+  if(getHeaderFilter()->match(FileName)) {
+Converter.emitDiagnostic(Loc, DiagLevel, Message, Info.getRanges(),
Info.getFixItHints());
+  }
 
   if (Info.hasSourceManager())
 checkFilters(Info.getLocation(), Info.getSourceManager());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59135: Add check for matching HeaderFilter before emitting Diagnostic

2019-03-19 Thread Thorsten via Phabricator via cfe-commits
thorsten-klein added a comment.

Hello, 
can you please support with this Pull-Request? You really have better knowledge 
about source code. 
For our case this solution was working fine and I wanted to share with you. 
Maybe it will help you if I create an examplary project which reproduces the 
mentioned issue?




Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:454
+  StringRef FileName(Loc.printToString(Loc.getManager()));
+  if(getHeaderFilter()->match(FileName))
+  {

alexfh wrote:
> aaron.ballman wrote:
> > Formatting is incorrect here -- you should run the patch through 
> > clang-format 
> > (https://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting),
> >  and elide the braces.
> I believe, this will break the handling of notes. If the notes attached to 
> the diagnostic are in the "interesting" part of the code (see the 
> checkFilters method below), the whole diagnostic should be treated as such.
Hello,
Unfortunately the emitDiagnostic method is called also for files, which should 
be actually excluded (since the FileName does not match the HeaderFilter 
regex). This results in diagnostic output, also if there should not be any. For 
this purpose I added this check here at this point. If the FileName is matching 
the HeaderFilter regex, then all diagnostic is emitted as before. 

Did you know about any issue regarding this? If this is not a working solution 
for you: do you have any other proposal?

PS: I have also read about this issue in another project: 
https://fuchsia.googlesource.com/peridot/+/HEAD/docs/lint.md
--> They say that they disable some clang-tidy checks as workaround


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

https://reviews.llvm.org/D59135



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


[PATCH] D59467: [clang] Adding the Likely Attribute from C++2a to AST

2019-03-19 Thread Gauthier via Phabricator via cfe-commits
Tyker updated this revision to Diff 191408.
Tyker added a comment.
Herald added a subscriber: jdoerfert.

added diagnostics for contradictory attributes like for if:

  if (...) [[likely]]
return 1;
  else [[likely]]
return 2;

handled the codegen for If to generate builtin_expect but i probably didn't do 
it the canonical way. i am awaiting advice of how to do it right.


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

https://reviews.llvm.org/D59467

Files:
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/ScopeInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/SemaCXX/cxx2a-likelihood-attr.cpp

Index: clang/test/SemaCXX/cxx2a-likelihood-attr.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx2a-likelihood-attr.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++2a
+
+int f(int i) {
+  if (i == 1) [[unlikely]]
+{
+  return 0;
+}
+  else if (i == 2) [[likely]]
+return 1;
+  return 3;
+}
+
+[[likely]] typedef int n1; // expected-error {{'likely' attribute cannot be applied to a declaration}}
+typedef int [[likely]] n2; // expected-error {{'likely' attribute cannot be applied to types}}
+typedef int n3 [[likely]]; // expected-error {{'likely' attribute cannot be applied to a declaration}}
+
+enum [[likely]] E { // expected-error {{'likely' attribute cannot be applied to a declaration}}
+  One
+};
+
+[[likely]] // expected-error {{'likely' attribute cannot be applied to a declaration}}
+
+void test(int i) {
+  [[likely]] // expected-error {{'likely' attribute can only appear in if, while, switch and for}}
+if (1) [[likely, likely]] {
+  // expected-error@-1 {{there can only be one likely attribue in any attribute list}}
+  // expected-note@-2 {{previously used likely attribue}}
+  [[unlikely]] return ; // expected-error {{'unlikely' attribute can only appear in if, while, switch and for}}
+}
+  else [[unlikely]] if (1) {
+  while (1) [[likely]] {
+  switch (i) {
+[[likely]] case 1:
+  default: [[likely]]
+return ;
+  }
+}
+  for (;;) [[likely, unlikely]]
+  // expected-error@-1 {{unlikely and likely are mutually exclusive}}
+  // expected-note@-2 {{previously used likely attribue}}
+[[likely]] return ;
+  // expected-error@-1 {{likely and unlikely are mutually exclusive}}
+  // expected-note@-5 {{previously used unlikely attribue}}
+}
+  try { // expected-error {{cannot use 'try' with exceptions disabled}}
+[[likely]]; // expected-error {{'likely' attribute can only appear in if, while, switch and for}}
+  } catch (int) {
+  [[likely]] test: // expected-error {{'likely' attribute cannot be applied to a declaration}}
+  [[unlikely]] return ;
+  }
+}
\ No newline at end of file
Index: clang/lib/Sema/SemaStmtAttr.cpp
===
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -51,6 +51,50 @@
   return ::new (S.Context) auto(Attr);
 }
 
+static Attr *handleLikelihoodAttr(Sema , Stmt *St, const ParsedAttr ,
+   SourceRange Range) {
+  LikelihoodAttr Attribute(A.getRange(), S.Context,
+   A.getAttributeSpellingListIndex());
+
+  Scope* scope = S.getCurScope();
+  Scope* previousScope = nullptr;
+
+  if (scope)
+previousScope = scope->getParent();
+
+  //check that ths attribute is used in an if, while, for, switch or catch
+  if (!previousScope || 
+  !(previousScope->getFlags() & Scope::ControlScope) ||
+   previousScope->getFlags() & Scope::SEHExceptScope ||
+   previousScope->getFlags() & Scope::SEHTryScope ||
+   previousScope->getFlags() & Scope::FnTryCatchScope)
+ S.Diag(A.getLoc(), diag::err_likelihood_outside_control_scope) << A.getName();
+
+  if (!S.getLangOpts().CPlusPlus2a)
+S.Diag(A.getLoc(), diag::ext_cxx2a_attr) << A.getName();
+
+  clang::Attr* result = ::new (S.Context) auto(Attribute);
+
+  auto* FnScope = S.getCurFunction();
+
+  /// don't need to emit any diagnostics if we aren't in a function or the stack is empty as this is already covered by the checks above
+  if (FnScope && !FnScope->PathLikelyhoodAttrStack.empty()) {
+Attr*& TopStackAttr = FnScope->PathLikelyhoodAttrStack.back();
+if (TopStackAttr) {
+  /// only need to compare first character to differenciate between 'likely' and 'unlikely'
+  if (result->getSpelling()[0] == TopStackAttr->getSpelling()[0])
+S.Diag(result->getLocation(), 

[PATCH] D59567: [X86] Add __popcntd and __popcntq to ia32intrin.h to match gcc and icc. Remove popcnt feature flag from _popcnt32/_popcnt64 and move to ia32intrin.h to match gcc

2019-03-19 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: RKSimon, spatel, andreadb.

gcc and icc both implement __popcntd and __popcntq which we did not. gcc 
doesn't seem to require a feature flag for the _popcnt32/_popcnt64 spelling and 
will use a libcall if its not supported.


https://reviews.llvm.org/D59567

Files:
  clang/lib/Headers/ia32intrin.h
  clang/lib/Headers/popcntintrin.h
  clang/test/CodeGen/popcnt-builtins.c

Index: clang/test/CodeGen/popcnt-builtins.c
===
--- clang/test/CodeGen/popcnt-builtins.c
+++ clang/test/CodeGen/popcnt-builtins.c
@@ -1,24 +1,39 @@
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +popcnt -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +popcnt -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-POPCNT
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
 
 
-#include 
+#include 
 
-unsigned int test_mm_popcnt_u32(unsigned int __X) {
-  //CHECK: call i32 @llvm.ctpop.i32
+#ifdef __POPCNT__
+int test_mm_popcnt_u32(unsigned int __X) {
+  //CHECK-POPCNT: call i32 @llvm.ctpop.i32
   return _mm_popcnt_u32(__X);
 }
+#endif
 
-unsigned int test_popcnt_32(int __X) {
+int test_popcnt32(unsigned int __X) {
   //CHECK: call i32 @llvm.ctpop.i32
   return _popcnt32(__X);
 }
 
-unsigned long long test_mm_popcnt_u64(unsigned long long __X) {
-  //CHECK: call i64 @llvm.ctpop.i64
+int test__popcntd(unsigned int __X) {
+  //CHECK: call i32 @llvm.ctpop.i32
+  return __popcntd(__X);
+}
+
+#ifdef __POPCNT__
+long long test_mm_popcnt_u64(unsigned long long __X) {
+  //CHECK-POPCNT: call i64 @llvm.ctpop.i64
   return _mm_popcnt_u64(__X);
 }
+#endif
 
-unsigned long long test_popcnt_64(long long __X) {
+long long test_popcnt64(unsigned long long __X) {
   //CHECK: call i64 @llvm.ctpop.i64
   return _popcnt64(__X);
 }
+
+long long test__popcntq(unsigned long long __X) {
+  //CHECK: call i64 @llvm.ctpop.i64
+  return __popcntq(__X);
+}
Index: clang/lib/Headers/popcntintrin.h
===
--- clang/lib/Headers/popcntintrin.h
+++ clang/lib/Headers/popcntintrin.h
@@ -43,22 +43,6 @@
   return __builtin_popcount(__A);
 }
 
-/// Counts the number of bits in the source operand having a value of 1.
-///
-/// \headerfile 
-///
-/// This intrinsic corresponds to the  POPCNT  instruction.
-///
-/// \param __A
-///A signed 32-bit integer operand.
-/// \returns A 32-bit integer containing the number of bits with value 1 in the
-///source operand.
-static __inline__ int __DEFAULT_FN_ATTRS
-_popcnt32(int __A)
-{
-  return __builtin_popcount(__A);
-}
-
 #ifdef __x86_64__
 /// Counts the number of bits in the source operand having a value of 1.
 ///
@@ -75,22 +59,6 @@
 {
   return __builtin_popcountll(__A);
 }
-
-/// Counts the number of bits in the source operand having a value of 1.
-///
-/// \headerfile 
-///
-/// This intrinsic corresponds to the  POPCNT  instruction.
-///
-/// \param __A
-///A signed 64-bit integer operand.
-/// \returns A 64-bit integer containing the number of bits with value 1 in the
-///source operand.
-static __inline__ long long __DEFAULT_FN_ATTRS
-_popcnt64(long long __A)
-{
-  return __builtin_popcountll(__A);
-}
 #endif /* __x86_64__ */
 
 #undef __DEFAULT_FN_ATTRS
Index: clang/lib/Headers/ia32intrin.h
===
--- clang/lib/Headers/ia32intrin.h
+++ clang/lib/Headers/ia32intrin.h
@@ -28,6 +28,44 @@
 #ifndef __IA32INTRIN_H
 #define __IA32INTRIN_H
 
+/// Counts the number of bits in the source operand having a value of 1.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  POPCNT  instruction.
+///
+/// \param __A
+///An unsigned 32-bit integer operand.
+/// \returns A 32-bit integer containing the number of bits with value 1 in the
+///source operand.
+static __inline__ int __attribute__((__always_inline__, __nodebug__))
+__popcntd(unsigned int __A)
+{
+  return __builtin_popcount(__A);
+}
+
+#define _popcnt32(A) __popcntd((A))
+
+#ifdef __x86_64__
+/// Counts the number of bits in the source operand having a value of 1.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  POPCNT  instruction.
+///
+/// \param __A
+///An unsigned 64-bit integer operand.
+/// \returns A 64-bit integer containing the number of bits with value 1 in the
+///source operand.
+static __inline__ long long __attribute__((__always_inline__, __nodebug__))
+__popcntq(unsigned long long __A)
+{
+  return __builtin_popcountll(__A);
+}
+
+#define _popcnt64(A) __popcntq((A))
+#endif /* __x86_64__ */
+
 #ifdef __x86_64__
 static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
 __readeflags(void)
___
cfe-commits mailing list

[PATCH] D59440: add steps to preprocess file and reduce command line args

2019-03-19 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 191409.
akhuang added a comment.

style things


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

https://reviews.llvm.org/D59440

Files:
  clang/utils/creduce-clang-crash.py

Index: clang/utils/creduce-clang-crash.py
===
--- clang/utils/creduce-clang-crash.py
+++ clang/utils/creduce-clang-crash.py
@@ -1,7 +1,5 @@
 #!/usr/bin/env python
 """Calls C-Reduce to create a minimal reproducer for clang crashes.
-
-Requires C-Reduce and not (part of LLVM utils) to be installed.
 """
 
 from argparse import ArgumentParser
@@ -11,108 +9,238 @@
 import sys
 import subprocess
 import pipes
+import shlex
+import tempfile
+import shutil
 from distutils.spawn import find_executable
 
-def create_test(build_script, llvm_not):
+verbose = False
+llvm_bin = None
+creduce_cmd = None
+not_cmd = None
+
+def check_file(fname):
+  if not os.path.isfile(fname):
+sys.exit("ERROR: %s does not exist" % (fname))
+  return fname
+
+def check_cmd(cmd_name, cmd_dir, cmd_path=None):
   """
-  Create an interestingness test from the crash output.
-  Return as a string.
+  Returns absolute path to cmd_path if it is given,
+  or absolute path to cmd_dir/cmd_name.
   """
-  # Get clang call from build script
-  # Assumes the call is the last line of the script
-  with open(build_script) as f:
-cmd = f.readlines()[-1].rstrip('\n\r')
-
-  # Get crash output
-  p = subprocess.Popen(build_script,
+  if cmd_path:
+cmd = find_executable(cmd_path)
+if cmd:
+  return cmd
+sys.exit("ERROR: executable %s not found" % (cmd_path))
+
+  cmd = find_executable(cmd_name, path=cmd_dir)
+  if cmd:
+return cmd
+  sys.exit("ERROR: %s not found in %s" % (cmd_name, cmd_dir))
+
+def quote_cmd(cmd):
+  return ' '.join(arg if arg.startswith('$') else pipes.quote(arg)
+  for arg in cmd)
+
+def get_crash_cmd(crash_script):
+  with open(crash_script) as f:
+# Assume clang call is on the last line of the script
+line = f.readlines()[-1]
+cmd = shlex.split(line)
+
+# Overwrite the script's clang with the user's clang path
+clang_name = os.path.basename(cmd[0])
+new_clang = check_cmd(clang_name, llvm_bin)
+cmd[0] = pipes.quote(new_clang)
+return cmd
+
+def has_expected_output(crash_cmd, expected_output):
+  p = subprocess.Popen(crash_cmd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
   crash_output, _ = p.communicate()
+  for msg in expected_output:
+if msg not in crash_output:
+  return False
+  return True
 
-  output = ['#!/bin/bash']
-  output.append('%s --crash %s >& t.log || exit 1' % (pipes.quote(llvm_not),
-  cmd))
+def get_expected_output(crash_cmd):
+  p = subprocess.Popen(crash_cmd,
+   stdout=subprocess.PIPE,
+   stderr=subprocess.STDOUT)
+  crash_output, _ = p.communicate()
 
-  # Add messages from crash output to the test
-  # If there is an Assertion failure, use that; otherwise use the
-  # last five stack trace functions
+  # If there is an assertion failure, use that;
+  # otherwise use the last five stack trace functions
   assertion_re = r'Assertion `([^\']+)\' failed'
   assertion_match = re.search(assertion_re, crash_output)
   if assertion_match:
-msg = assertion_match.group(1)
-output.append('grep %s t.log || exit 1' % pipes.quote(msg))
+return [assertion_match.group(1)]
   else:
 stacktrace_re = r'#[0-9]+\s+0[xX][0-9a-fA-F]+\s*([^(]+)\('
 matches = re.findall(stacktrace_re, crash_output)
-del matches[:-5]
-output += ['grep %s t.log || exit 1' % pipes.quote(msg) for msg in matches]
+return matches[-5:]
+
+def write_interestingness_test(testfile, crash_cmd, expected_output,
+   file_to_reduce):
+  filename = os.path.basename(file_to_reduce)
+  if filename not in crash_cmd:
+sys.exit("ERROR: expected %s to be in the crash command" % filename)
+
+  # Replace all instances of file_to_reduce with a command line variable
+  output = ['#!/bin/bash',
+'if [ -z "$1" ] ; then',
+'  f=%s' % (pipes.quote(filename)),
+'else',
+'  f="$1"',
+'fi']
+  cmd = ['$f' if s == filename else s for s in crash_cmd]
+
+  output.append('%s --crash %s >& t.log || exit 1' % (pipes.quote(not_cmd),
+  quote_cmd(cmd)))
+
+  for msg in expected_output:
+output.append('grep %s t.log || exit 1' % pipes.quote(msg))
+
+  with open(testfile, 'w') as f:
+f.write('\n'.join(output))
+  os.chmod(testfile, os.stat(testfile).st_mode | stat.S_IEXEC)
 
-  return output
+def check_interestingness(testfile, file_to_reduce):
+  testfile = os.path.abspath(testfile)
+
+  # Check that the test considers the original file interesting
+  with open(os.devnull, 'w') as devnull:
+   

r356530 - Replace tok::angle_string_literal with new tok::header_name.

2019-03-19 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Mar 19 15:09:55 2019
New Revision: 356530

URL: http://llvm.org/viewvc/llvm-project?rev=356530=rev
Log:
Replace tok::angle_string_literal with new tok::header_name.

Use the new kind for both angled header-name tokens and for
double-quoted header-name tokens.

This is in preparation for C++20's context-sensitive header-name token
formation rules.

Modified:
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/include/clang/Basic/TokenKinds.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/include/clang/Lex/PreprocessorLexer.h
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/lib/Lex/Pragma.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp
cfe/trunk/test/Preprocessor/_Pragma-dependency.c

Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=356530=356529=356530=diff
==
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Tue Mar 19 15:09:55 2019
@@ -154,7 +154,9 @@ TOK(utf32_char_constant) // U'a'
 // C99 6.4.5: String Literals.
 TOK(string_literal)  // "foo"
 TOK(wide_string_literal) // L"foo"
-TOK(angle_string_literal)// 
+
+// C11 6.4.7: Header Names
+TOK(header_name) // , or "foo" lexed as a header-name
 
 // C++11 String Literals.
 TOK(utf8_string_literal) // u8"foo"

Modified: cfe/trunk/include/clang/Basic/TokenKinds.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.h?rev=356530=356529=356530=diff
==
--- cfe/trunk/include/clang/Basic/TokenKinds.h (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.h Tue Mar 19 15:09:55 2019
@@ -86,7 +86,7 @@ inline bool isLiteral(TokenKind K) {
   return K == tok::numeric_constant || K == tok::char_constant ||
  K == tok::wide_char_constant || K == tok::utf8_char_constant ||
  K == tok::utf16_char_constant || K == tok::utf32_char_constant ||
- isStringLiteral(K) || K == tok::angle_string_literal;
+ isStringLiteral(K) || K == tok::header_name;
 }
 
 /// Return true if this is any of tok::annot_* kinds.

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=356530=356529=356530=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Tue Mar 19 15:09:55 2019
@@ -1274,7 +1274,7 @@ public:
   void Lex(Token );
 
   /// Lex a token, forming a header-name token if possible.
-  bool LexHeaderName(Token , bool AllowConcatenation = true);
+  bool LexHeaderName(Token , bool AllowMacroExpansion = true);
 
   void LexAfterModuleImport(Token );
 

Modified: cfe/trunk/include/clang/Lex/PreprocessorLexer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessorLexer.h?rev=356530=356529=356530=diff
==
--- cfe/trunk/include/clang/Lex/PreprocessorLexer.h (original)
+++ cfe/trunk/include/clang/Lex/PreprocessorLexer.h Tue Mar 19 15:09:55 2019
@@ -48,8 +48,7 @@ protected:
   /// True when parsing \#XXX; turns '\\n' into a tok::eod token.
   bool ParsingPreprocessorDirective = false;
 
-  /// True after \#include; turns \ into a tok::angle_string_literal
-  /// token.
+  /// True after \#include; turns \ or "xxx" into a tok::header_name token.
   bool ParsingFilename = false;
 
   /// True if in raw mode.

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=356530=356529=356530=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Tue Mar 19 15:09:55 2019
@@ -2072,7 +2072,7 @@ bool Lexer::LexAngledStringLiteral(Token
 
   // Update the location of token as well as BufferPtr.
   const char *TokStart = BufferPtr;
-  FormTokenWithChars(Result, CurPtr, tok::angle_string_literal);
+  FormTokenWithChars(Result, CurPtr, tok::header_name);
   Result.setLiteralData(TokStart);
   return true;
 }
@@ -3465,7 +3465,9 @@ LexNextToken:
   case '"':
 // Notify MIOpt that we read a non-whitespace/non-comment token.
 MIOpt.ReadToken();
-return LexStringLiteral(Result, CurPtr, tok::string_literal);
+return LexStringLiteral(Result, CurPtr,
+ParsingFilename ? tok::header_name
+: tok::string_literal);
 
   // C99 6.4.6: Punctuators.
   case '?':

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 

[PATCH] D59560: Permit redeclarations of a builtin to specify calling convention.

2019-03-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 191403.
erichkeane added a comment.

As @rnk suggested, switch to an enum.  SemaType.cpp unfortunately has Sema as a 
forward declaration, so it has to use integers.


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

https://reviews.llvm.org/D59560

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaType.cpp
  test/CodeGen/aarch64-vpcs.c
  test/Sema/callingconv-iamcu.c
  test/Sema/callingconv.c
  test/Sema/pr25786.c
  test/Sema/stdcall-fastcall-x64.c
  test/SemaCUDA/cuda-inherits-calling-conv.cu
  test/SemaCXX/borland-extensions.cpp
  test/SemaCXX/cxx11-gnu-attrs.cpp
  test/SemaCXX/virtual-override-x64.cpp
  test/SemaTemplate/instantiate-function-params.cpp

Index: test/SemaTemplate/instantiate-function-params.cpp
===
--- test/SemaTemplate/instantiate-function-params.cpp
+++ test/SemaTemplate/instantiate-function-params.cpp
@@ -88,7 +88,7 @@
 __attribute__((stdcall)) functype stdfunc1;
 stdfunctype stdfunc2;
 
-__attribute__((pcs("aapcs"))) functype pcsfunc; // expected-warning {{calling convention 'pcs' ignored for this target}}
+__attribute__((pcs("aapcs"))) functype pcsfunc; // expected-warning {{'pcs' calling convention ignored for this target}}
   };
 
   void f(X x) {
Index: test/SemaCXX/virtual-override-x64.cpp
===
--- test/SemaCXX/virtual-override-x64.cpp
+++ test/SemaCXX/virtual-override-x64.cpp
@@ -6,7 +6,7 @@
 namespace PR14339 {
   class A {
   public:
-virtual void __attribute__((thiscall)) f();	// expected-warning {{calling convention 'thiscall' ignored for this target}}
+virtual void __attribute__((thiscall)) f();	// expected-warning {{'thiscall' calling convention ignored for this target}}
   };
 
   class B : public A {
@@ -16,7 +16,7 @@
 
   class C : public A {
   public:
-void __attribute__((thiscall)) f();  // expected-warning {{calling convention 'thiscall' ignored for this target}}
+void __attribute__((thiscall)) f();  // expected-warning {{'thiscall' calling convention ignored for this target}}
   };
 
   class D : public A {
@@ -26,7 +26,7 @@
 
   class E {
   public:
-virtual void __attribute__((stdcall)) g();  // expected-warning {{calling convention 'stdcall' ignored for this target}}
+virtual void __attribute__((stdcall)) g();  // expected-warning {{'stdcall' calling convention ignored for this target}}
   };
 
   class F : public E {
Index: test/SemaCXX/cxx11-gnu-attrs.cpp
===
--- test/SemaCXX/cxx11-gnu-attrs.cpp
+++ test/SemaCXX/cxx11-gnu-attrs.cpp
@@ -9,18 +9,18 @@
 int *[[gnu::unused]] attr_on_ptr;
 // expected-warning@-1 {{attribute 'unused' ignored, because it cannot be applied to a type}}
 [[gnu::fastcall]] void pr17424_1();
-// expected-warning@-1 {{calling convention 'fastcall' ignored for this target}}
+// expected-warning@-1 {{'fastcall' calling convention ignored for this target}}
 [[gnu::fastcall]] [[gnu::stdcall]] void pr17424_2();
-// expected-warning@-1 {{calling convention 'fastcall' ignored for this target}}
-// expected-warning@-2 {{calling convention 'stdcall' ignored for this target}}
+// expected-warning@-1 {{'fastcall' calling convention ignored for this target}}
+// expected-warning@-2 {{'stdcall' calling convention ignored for this target}}
 [[gnu::fastcall]] __stdcall void pr17424_3();
-// expected-warning@-1 {{calling convention 'fastcall' ignored for this target}}
-// expected-warning@-2 {{calling convention '__stdcall' ignored for this target}}
+// expected-warning@-1 {{'fastcall' calling convention ignored for this target}}
+// expected-warning@-2 {{'__stdcall' calling convention ignored for this target}}
 [[gnu::fastcall]] void pr17424_4() [[gnu::stdcall]];
-// expected-warning@-1 {{calling convention 'fastcall' ignored for this target}}
-// expected-warning@-2 {{calling convention 'stdcall' ignored for this target}}
+// expected-warning@-1 {{'fastcall' calling convention ignored for this target}}
+// expected-warning@-2 {{'stdcall' calling convention ignored for this target}}
 void pr17424_5 [[gnu::fastcall]]();
-// expected-warning@-1 {{calling convention 'fastcall' ignored for this target}}
+// expected-warning@-1 {{'fastcall' calling convention ignored for this target}}
 
 // Valid cases.
 
Index: test/SemaCXX/borland-extensions.cpp
===
--- test/SemaCXX/borland-extensions.cpp
+++ test/SemaCXX/borland-extensions.cpp
@@ -7,21 +7,21 @@
 int dummy_function() { return 0; }
 
 // 2. test __pascal
-// expected-warning@+1 {{calling convention '_pascal' ignored for this target}}
+// expected-warning@+1 {{'_pascal' calling convention ignored for this target}}
 int _pascal f2();
 
-// expected-warning@+1 {{calling convention '__pascal' 

[PATCH] D28213: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

2019-03-19 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Patch here https://reviews.llvm.org/D59566


Repository:
  rL LLVM

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

https://reviews.llvm.org/D28213



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


[PATCH] D57978: [CodeGen] Generate follow-up metadata for loops with more than one transformation.

2019-03-19 Thread Hideki Saito via Phabricator via cfe-commits
hsaito added a comment.

In D57978#1435473 , @Meinersbur wrote:

> ping


This is a good follow up for rL348944 , but 
I have no familiarity to the code under Clang. So, let me thank you for doing 
this work and move myself to the subscriber.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57978



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


[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2019-03-19 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I see! I only took a quick look, but this looks exactly like what @rsmith has 
been asking for in discussions for a long time now: a more explicit AST 
representation of uuid of uuidof in template arguments. I'll make an effort to 
get his attention and see if this addresses his concerns.


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

https://reviews.llvm.org/D43576



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


[PATCH] D28213: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

2019-03-19 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D28213#1435542 , @efriedma wrote:

> It's kind of awkward to use ">=" on a CPU enum, but yes, that's the right 
> idea.


I agree, but we do the same thing on the "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8" 
define in X86.cpp.

Applying that diff does cause 3 tests to fail. I'll try to work through that.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D28213



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


[PATCH] D28213: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

2019-03-19 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

It's kind of awkward to use ">=" on a CPU enum, but yes, that's the right idea.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D28213



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


[PATCH] D59560: Permit redeclarations of a builtin to specify calling convention.

2019-03-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked an inline comment as done.
erichkeane added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:3144
+  << FunctionType::getNameForCallConv(NewTypeInfo.getCC())
+  << 3 /*on builtin function*/;
+  NewTypeInfo = NewTypeInfo.withCallingConv(OldTypeInfo.getCC());

rnk wrote:
> You can make these self-documenting with an enum, and then reference the enum 
> name in a comment in the .td file. It seems the existing convention is to put 
> these types of enums directly into the Sema class.
Ah, great!  I didn't realize there was a convention for how to do these.


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

https://reviews.llvm.org/D59560



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


[PATCH] D28213: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

2019-03-19 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

It's still wrong. I think this might fix it?

  --- a/clang/lib/Basic/Targets/X86.h
  +++ b/clang/lib/Basic/Targets/X86.h
  @@ -346,9 +346,8 @@ public:
(1 << TargetInfo::LongDouble));
  
   // x86-32 has atomics up to 8 bytes
  -// FIXME: Check that we actually have cmpxchg8b before setting
  -// MaxAtomicInlineWidth. (cmpxchg8b is an i586 instruction.)
  -MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
  +MaxAtomicPromoteWidth = 64;
  +MaxAtomicInlineWidth = 32;
 }
  
 BuiltinVaListKind getBuiltinVaListKind() const override {
  @@ -384,6 +383,11 @@ public:
   return X86TargetInfo::validateOperandSize(Constraint, Size);
 }
  
  +  void setMaxAtomicWidth() override {
  +if (CPU >= CK_i586)
  +  MaxAtomicInlineWidth = 64;
  +  }
  +
 ArrayRef getTargetBuiltins() const override;
   };


Repository:
  rL LLVM

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

https://reviews.llvm.org/D28213



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


[PATCH] D59560: Permit redeclarations of a builtin to specify calling convention.

2019-03-19 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:3144
+  << FunctionType::getNameForCallConv(NewTypeInfo.getCC())
+  << 3 /*on builtin function*/;
+  NewTypeInfo = NewTypeInfo.withCallingConv(OldTypeInfo.getCC());

You can make these self-documenting with an enum, and then reference the enum 
name in a comment in the .td file. It seems the existing convention is to put 
these types of enums directly into the Sema class.


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

https://reviews.llvm.org/D59560



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


[PATCH] D59557: Fix CodeGen/arm64-microsoft-status-reg.cpp test

2019-03-19 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Usually no... I wasn't think about it the last time I reviewed a change to this 
file.  Patch welcome to just zap it, assuming we have appropriate coverage in 
llvm/test/CodeGen/AArch64.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59557



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


[PATCH] D28213: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

2019-03-19 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> Do we care about cases where it *might* be available? i.e. can we say it's 
> never available instead?

That doesn't really help here... the fundamental issue is that 
getMaxAtomicInlineWidth() is wrong (or at least, was wrong at the time this was 
initially merged; I haven't checked whether it was fixed since).


Repository:
  rL LLVM

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

https://reviews.llvm.org/D28213



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


[PATCH] D59557: Fix CodeGen/arm64-microsoft-status-reg.cpp test

2019-03-19 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

I thought we weren't supposed to reference asm codegen in clang tests? (PR24580)


Repository:
  rC Clang

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

https://reviews.llvm.org/D59557



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


[PATCH] D28213: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

2019-03-19 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In D28213#1435485 , @efriedma wrote:

> It looks like it was reverted because it was breaking i386 BSD, where 
> __GCC_ATOMIC_LLONG_LOCK_FREE is in fact supposed to be "1" (because cmpxchg8b 
> isn't always available).


Do we care about cases where it *might* be available? i.e. can we say it's 
never available instead?

We're playing with ABI here, it's not great, but at the same time we're bending 
over backwards for pretty old CPUs... all of that to get bad code generation...


Repository:
  rL LLVM

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

https://reviews.llvm.org/D28213



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


[PATCH] D59557: Fix CodeGen/arm64-microsoft-status-reg.cpp test

2019-03-19 Thread Jordan Rupprecht via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC356517: Fix CodeGen/arm64-microsoft-status-reg.cpp test 
(authored by rupprecht, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D59557?vs=191379=191390#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D59557

Files:
  test/CodeGen/arm64-microsoft-status-reg.cpp

Index: test/CodeGen/arm64-microsoft-status-reg.cpp
===
--- test/CodeGen/arm64-microsoft-status-reg.cpp
+++ test/CodeGen/arm64-microsoft-status-reg.cpp
@@ -30,103 +30,103 @@
 void check_ReadWriteStatusReg(__int64 v) {
   __int64 ret;
   ret = _ReadStatusReg(ARM64_CNTVCT);
-// CHECK-ASM: mrs x0, CNTVCT_EL0
+// CHECK-ASM: mrs x8, CNTVCT_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_PMCCNTR_EL0);
-// CHECK-ASM: mrs x0, PMCCNTR_EL0
+// CHECK-ASM: mrs x8, PMCCNTR_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD3:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_PMSELR_EL0);
-// CHECK-ASM: mrs x0, PMSELR_EL0
+// CHECK-ASM: mrs x8, PMSELR_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD4:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_PMXEVCNTR_EL0);
-// CHECK-ASM: mrs x0, PMXEVCNTR_EL0
+// CHECK-ASM: mrs x8, PMXEVCNTR_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD5:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_PMXEVCNTRn_EL0(0));
-// CHECK-ASM: mrs x0, PMEVCNTR0_EL0
+// CHECK-ASM: mrs x8, PMEVCNTR0_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD6:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_PMXEVCNTRn_EL0(1));
-// CHECK-ASM: mrs x0, PMEVCNTR1_EL0
+// CHECK-ASM: mrs x8, PMEVCNTR1_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD7:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_PMXEVCNTRn_EL0(30));
-// CHECK-ASM: mrs x0, PMEVCNTR30_EL0
+// CHECK-ASM: mrs x8, PMEVCNTR30_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD8:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_TPIDR_EL0);
-// CHECK-ASM: mrs x0, TPIDR_EL0
+// CHECK-ASM: mrs x8, TPIDR_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD9:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_TPIDRRO_EL0);
-// CHECK-ASM: mrs x0, TPIDRRO_EL0
+// CHECK-ASM: mrs x8, TPIDRRO_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD10:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_TPIDR_EL1);
-// CHECK-ASM: mrs x0, TPIDR_EL1
+// CHECK-ASM: mrs x8, TPIDR_EL1
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD11:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
 
   _WriteStatusReg(ARM64_CNTVCT, v);
-// CHECK-ASM: msr S3_3_C14_C0_2, x0
+// CHECK-ASM: msr S3_3_C14_C0_2, x8
 // CHECK-IR: %[[VAR:.*]] = load i64,
 // CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD2:.*]], i64 %[[VAR]])
 
   _WriteStatusReg(ARM64_PMCCNTR_EL0, v);
-// CHECK-ASM: msr PMCCNTR_EL0, x0
+// CHECK-ASM: msr PMCCNTR_EL0, x8
 // CHECK-IR: %[[VAR:.*]] = load i64,
 // CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD3:.*]], i64 %[[VAR]])
 
   _WriteStatusReg(ARM64_PMSELR_EL0, v);
-// CHECK-ASM: msr PMSELR_EL0, x0
+// CHECK-ASM: msr PMSELR_EL0, x8
 // CHECK-IR: %[[VAR:.*]] = load i64,
 // CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD4:.*]], i64 %[[VAR]])
 
   _WriteStatusReg(ARM64_PMXEVCNTR_EL0, v);
-// CHECK-ASM: msr PMXEVCNTR_EL0, x0
+// CHECK-ASM: msr PMXEVCNTR_EL0, x8
 // CHECK-IR: %[[VAR:.*]] = load i64,
 // CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD5:.*]], i64 %[[VAR]])
 
   _WriteStatusReg(ARM64_PMXEVCNTRn_EL0(0), v);
-// CHECK-ASM: msr PMEVCNTR0_EL0, x0
+// CHECK-ASM: msr PMEVCNTR0_EL0, x8
 // CHECK-IR: %[[VAR:.*]] = load i64,
 // CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD6:.*]], i64 %[[VAR]])
 
   _WriteStatusReg(ARM64_PMXEVCNTRn_EL0(1), v);
-// CHECK-ASM: msr PMEVCNTR1_EL0, x0
+// CHECK-ASM: msr PMEVCNTR1_EL0, x8
 // CHECK-IR: %[[VAR:.*]] = load i64,
 // CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD7:.*]], i64 %[[VAR]])
 
   _WriteStatusReg(ARM64_PMXEVCNTRn_EL0(30), v);
-// CHECK-ASM: msr PMEVCNTR30_EL0, x0
+// CHECK-ASM: msr PMEVCNTR30_EL0, x8
 // CHECK-IR: %[[VAR:.*]] = load i64,
 // CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD8:.*]], i64 

r356517 - Fix CodeGen/arm64-microsoft-status-reg.cpp test

2019-03-19 Thread Jordan Rupprecht via cfe-commits
Author: rupprecht
Date: Tue Mar 19 13:55:14 2019
New Revision: 356517

URL: http://llvm.org/viewvc/llvm-project?rev=356517=rev
Log:
Fix CodeGen/arm64-microsoft-status-reg.cpp test

Summary: This test is failing after r356499 (verified with `ninja 
check-clang-codegen`). Update the register selection used in the test from x0 
to x8.

Reviewers: arsenm, MatzeB, efriedma

Reviewed By: efriedma

Subscribers: efriedma, wdng, javed.absar, kristof.beyls, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/test/CodeGen/arm64-microsoft-status-reg.cpp

Modified: cfe/trunk/test/CodeGen/arm64-microsoft-status-reg.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm64-microsoft-status-reg.cpp?rev=356517=356516=356517=diff
==
--- cfe/trunk/test/CodeGen/arm64-microsoft-status-reg.cpp (original)
+++ cfe/trunk/test/CodeGen/arm64-microsoft-status-reg.cpp Tue Mar 19 13:55:14 
2019
@@ -30,103 +30,103 @@ void _WriteStatusReg(int, __int64);
 void check_ReadWriteStatusReg(__int64 v) {
   __int64 ret;
   ret = _ReadStatusReg(ARM64_CNTVCT);
-// CHECK-ASM: mrs x0, CNTVCT_EL0
+// CHECK-ASM: mrs x8, CNTVCT_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata 
![[MD2:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_PMCCNTR_EL0);
-// CHECK-ASM: mrs x0, PMCCNTR_EL0
+// CHECK-ASM: mrs x8, PMCCNTR_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata 
![[MD3:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_PMSELR_EL0);
-// CHECK-ASM: mrs x0, PMSELR_EL0
+// CHECK-ASM: mrs x8, PMSELR_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata 
![[MD4:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_PMXEVCNTR_EL0);
-// CHECK-ASM: mrs x0, PMXEVCNTR_EL0
+// CHECK-ASM: mrs x8, PMXEVCNTR_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata 
![[MD5:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_PMXEVCNTRn_EL0(0));
-// CHECK-ASM: mrs x0, PMEVCNTR0_EL0
+// CHECK-ASM: mrs x8, PMEVCNTR0_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata 
![[MD6:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_PMXEVCNTRn_EL0(1));
-// CHECK-ASM: mrs x0, PMEVCNTR1_EL0
+// CHECK-ASM: mrs x8, PMEVCNTR1_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata 
![[MD7:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_PMXEVCNTRn_EL0(30));
-// CHECK-ASM: mrs x0, PMEVCNTR30_EL0
+// CHECK-ASM: mrs x8, PMEVCNTR30_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata 
![[MD8:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_TPIDR_EL0);
-// CHECK-ASM: mrs x0, TPIDR_EL0
+// CHECK-ASM: mrs x8, TPIDR_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata 
![[MD9:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_TPIDRRO_EL0);
-// CHECK-ASM: mrs x0, TPIDRRO_EL0
+// CHECK-ASM: mrs x8, TPIDRRO_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata 
![[MD10:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_TPIDR_EL1);
-// CHECK-ASM: mrs x0, TPIDR_EL1
+// CHECK-ASM: mrs x8, TPIDR_EL1
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata 
![[MD11:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
 
   _WriteStatusReg(ARM64_CNTVCT, v);
-// CHECK-ASM: msr S3_3_C14_C0_2, x0
+// CHECK-ASM: msr S3_3_C14_C0_2, x8
 // CHECK-IR: %[[VAR:.*]] = load i64,
 // CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD2:.*]], i64 
%[[VAR]])
 
   _WriteStatusReg(ARM64_PMCCNTR_EL0, v);
-// CHECK-ASM: msr PMCCNTR_EL0, x0
+// CHECK-ASM: msr PMCCNTR_EL0, x8
 // CHECK-IR: %[[VAR:.*]] = load i64,
 // CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD3:.*]], i64 
%[[VAR]])
 
   _WriteStatusReg(ARM64_PMSELR_EL0, v);
-// CHECK-ASM: msr PMSELR_EL0, x0
+// CHECK-ASM: msr PMSELR_EL0, x8
 // CHECK-IR: %[[VAR:.*]] = load i64,
 // CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD4:.*]], i64 
%[[VAR]])
 
   _WriteStatusReg(ARM64_PMXEVCNTR_EL0, v);
-// CHECK-ASM: msr PMXEVCNTR_EL0, x0
+// CHECK-ASM: msr PMXEVCNTR_EL0, x8
 // CHECK-IR: %[[VAR:.*]] = load i64,
 // CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD5:.*]], i64 
%[[VAR]])
 
   _WriteStatusReg(ARM64_PMXEVCNTRn_EL0(0), v);
-// CHECK-ASM: msr PMEVCNTR0_EL0, x0
+// CHECK-ASM: msr PMEVCNTR0_EL0, x8
 // CHECK-IR: %[[VAR:.*]] = load i64,
 // CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD6:.*]], i64 
%[[VAR]])
 
   _WriteStatusReg(ARM64_PMXEVCNTRn_EL0(1), v);
-// CHECK-ASM: msr PMEVCNTR1_EL0, x0
+// CHECK-ASM: 

[PATCH] D59560: Permit redeclarations of a builtin to specify calling convention.

2019-03-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added a reviewer: rnk.
Herald added a subscriber: javed.absar.

After https://reviews.llvm.org/rL355317 we noticed that quite a decent
amount of code redeclares builtins (memcpy in particular, I believe
reduced from an MSVC header) with a calling convention specified.
This gets particularly troublesome when the user specifies a new
'default' calling convention on the command line.

  

When looking to add a diagnostic for this case, it was noticed that we
had 3 other diagnostics that differed only slightly.  This patch ALSO
unifies those under a 'select'.  Unfortunately, the order of words in
ONE of these diagnostics was reversed ("'thiscall' calling convention"
vs "calling convention 'thiscall'"), so this patch also standardizes on
the former.


https://reviews.llvm.org/D59560

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaType.cpp
  test/CodeGen/aarch64-vpcs.c
  test/Sema/callingconv-iamcu.c
  test/Sema/callingconv.c
  test/Sema/pr25786.c
  test/Sema/stdcall-fastcall-x64.c
  test/SemaCUDA/cuda-inherits-calling-conv.cu
  test/SemaCXX/borland-extensions.cpp
  test/SemaCXX/cxx11-gnu-attrs.cpp
  test/SemaCXX/virtual-override-x64.cpp
  test/SemaTemplate/instantiate-function-params.cpp

Index: test/SemaTemplate/instantiate-function-params.cpp
===
--- test/SemaTemplate/instantiate-function-params.cpp
+++ test/SemaTemplate/instantiate-function-params.cpp
@@ -88,7 +88,7 @@
 __attribute__((stdcall)) functype stdfunc1;
 stdfunctype stdfunc2;
 
-__attribute__((pcs("aapcs"))) functype pcsfunc; // expected-warning {{calling convention 'pcs' ignored for this target}}
+__attribute__((pcs("aapcs"))) functype pcsfunc; // expected-warning {{'pcs' calling convention ignored for this target}}
   };
 
   void f(X x) {
Index: test/SemaCXX/virtual-override-x64.cpp
===
--- test/SemaCXX/virtual-override-x64.cpp
+++ test/SemaCXX/virtual-override-x64.cpp
@@ -6,7 +6,7 @@
 namespace PR14339 {
   class A {
   public:
-virtual void __attribute__((thiscall)) f();	// expected-warning {{calling convention 'thiscall' ignored for this target}}
+virtual void __attribute__((thiscall)) f();	// expected-warning {{'thiscall' calling convention ignored for this target}}
   };
 
   class B : public A {
@@ -16,7 +16,7 @@
 
   class C : public A {
   public:
-void __attribute__((thiscall)) f();  // expected-warning {{calling convention 'thiscall' ignored for this target}}
+void __attribute__((thiscall)) f();  // expected-warning {{'thiscall' calling convention ignored for this target}}
   };
 
   class D : public A {
@@ -26,7 +26,7 @@
 
   class E {
   public:
-virtual void __attribute__((stdcall)) g();  // expected-warning {{calling convention 'stdcall' ignored for this target}}
+virtual void __attribute__((stdcall)) g();  // expected-warning {{'stdcall' calling convention ignored for this target}}
   };
 
   class F : public E {
Index: test/SemaCXX/cxx11-gnu-attrs.cpp
===
--- test/SemaCXX/cxx11-gnu-attrs.cpp
+++ test/SemaCXX/cxx11-gnu-attrs.cpp
@@ -9,18 +9,18 @@
 int *[[gnu::unused]] attr_on_ptr;
 // expected-warning@-1 {{attribute 'unused' ignored, because it cannot be applied to a type}}
 [[gnu::fastcall]] void pr17424_1();
-// expected-warning@-1 {{calling convention 'fastcall' ignored for this target}}
+// expected-warning@-1 {{'fastcall' calling convention ignored for this target}}
 [[gnu::fastcall]] [[gnu::stdcall]] void pr17424_2();
-// expected-warning@-1 {{calling convention 'fastcall' ignored for this target}}
-// expected-warning@-2 {{calling convention 'stdcall' ignored for this target}}
+// expected-warning@-1 {{'fastcall' calling convention ignored for this target}}
+// expected-warning@-2 {{'stdcall' calling convention ignored for this target}}
 [[gnu::fastcall]] __stdcall void pr17424_3();
-// expected-warning@-1 {{calling convention 'fastcall' ignored for this target}}
-// expected-warning@-2 {{calling convention '__stdcall' ignored for this target}}
+// expected-warning@-1 {{'fastcall' calling convention ignored for this target}}
+// expected-warning@-2 {{'__stdcall' calling convention ignored for this target}}
 [[gnu::fastcall]] void pr17424_4() [[gnu::stdcall]];
-// expected-warning@-1 {{calling convention 'fastcall' ignored for this target}}
-// expected-warning@-2 {{calling convention 'stdcall' ignored for this target}}
+// expected-warning@-1 {{'fastcall' calling convention ignored for this target}}
+// expected-warning@-2 {{'stdcall' calling convention ignored for this target}}
 void pr17424_5 [[gnu::fastcall]]();
-// expected-warning@-1 {{calling convention 'fastcall' ignored for this target}}
+// expected-warning@-1 {{'fastcall' calling convention ignored for this target}}
 

[PATCH] D28213: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

2019-03-19 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

It looks like it was reverted because it was breaking i386 BSD, where 
__GCC_ATOMIC_LLONG_LOCK_FREE is in fact supposed to be "1" (because cmpxchg8b 
isn't always available).


Repository:
  rL LLVM

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

https://reviews.llvm.org/D28213



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


[PATCH] D58514: Avoid needlessly copying blocks that initialize or are assigned to local auto variables to the heap

2019-03-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D58514#1435431 , @wuhao5 wrote:

> In D58514#1435296 , @rjmccall wrote:
>
> > In D58514#1435228 , @wuhao5 wrote:
> >
> > > > Okay, so really just a block self-reference.  We could really just add 
> > > > a feature for that that would avoid both the complexity and the expense 
> > > > of the self-capture dance.
> > >
> > > Is there a plan to cover this case? or is it a legitimate use case that 
> > > Clang should handle?
> >
> >
> > You are currently relying on something that ARC doesn't guarantee, so the 
> > client code should be fixed to explicitly copy the block.  I think we would 
> > be happy to consider a proposal in the long run to allow blocks to 
> > self-reference more easily, which will effectively bypass the problem.
>
>
> I am not sure if I follow here - is it not that the weak pointer holds a 
> block that's in the stack but is supposed to be in the heap?


In your code, ARC does not guarantee that the block pointer you're assigning to 
the weak reference will point to a heap copy of the block.  ARC could force a 
copy of the block as part of the assignment, but it would be pointless because 
that copy would be immediately destroyed, leaving the weak reference holding 
`nil`, which is not what you want dynamically in your code.  You need to force 
the block to be copied first.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58514



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


[PATCH] D57978: [CodeGen] Generate follow-up metadata for loops with more than one transformation.

2019-03-19 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

ping


Repository:
  rC Clang

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

https://reviews.llvm.org/D57978



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


[PATCH] D59557: Fix CodeGen/arm64-microsoft-status-reg.cpp test

2019-03-19 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:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59557



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


[PATCH] D58757: Add a version of the pass_object_size attribute that works with builtin_dynamic_object_size

2019-03-19 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC356515: Add a spelling of pass_object_size that uses 
__builtin_dynamic_object_size (authored by epilk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58757?vs=190917=191386#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D58757

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/CodeGen/CGCall.cpp
  lib/Sema/SemaDecl.cpp
  test/CodeGen/pass-object-size.c
  test/CodeGenCXX/mangle-ms.cpp
  test/Sema/pass-object-size.c

Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -698,6 +698,15 @@
 * It is an error to apply the ``pass_object_size`` attribute to parameters that
   are not pointers. Additionally, any parameter that ``pass_object_size`` is
   applied to must be marked ``const`` at its function's definition.
+
+Clang also supports the ``pass_dynamic_object_size`` attribute, which behaves
+identically to ``pass_object_size``, but evaluates a call to
+``__builtin_dynamic_object_size`` at the callee instead of
+``__builtin_object_size``. ``__builtin_dynamic_object_size`` provides some extra
+runtime checks when the object size can't be determined at compile-time. You can
+read more about ``__builtin_dynamic_object_size`` `here
+`_.
+
   }];
 }
 
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -1560,7 +1560,9 @@
 // pass_object_size(N) indicates that the parameter should have
 // __builtin_object_size with Type=N evaluated on the parameter at the callsite.
 def PassObjectSize : InheritableParamAttr {
-  let Spellings = [Clang<"pass_object_size">];
+  let Spellings = [Clang<"pass_object_size">,
+   Clang<"pass_dynamic_object_size">];
+  let Accessors = [Accessor<"isDynamic", [Clang<"pass_dynamic_object_size">]>];
   let Args = [IntArgument<"Type">];
   let Subjects = SubjectList<[ParmVar]>;
   let Documentation = [PassObjectSizeDocs];
Index: test/CodeGenCXX/mangle-ms.cpp
===
--- test/CodeGenCXX/mangle-ms.cpp
+++ test/CodeGenCXX/mangle-ms.cpp
@@ -457,6 +457,8 @@
 int qux(int *const i __attribute__((pass_object_size(1))), int *const j __attribute__((pass_object_size(0 { return 0; }
 // CHECK-DAG: define dso_local i32 @"?zot@PassObjectSize@@YAHQAHW4__pass_object_size1@__clang@@01@Z"
 int zot(int *const i __attribute__((pass_object_size(1))), int *const j __attribute__((pass_object_size(1 { return 0; }
+// CHECK-DAG: define dso_local i32 @"?silly_word@PassObjectSize@@YAHQAHW4__pass_dynamic_object_size1@__clang@@@Z"
+int silly_word(int *const i __attribute__((pass_dynamic_object_size(1 { return 0; }
 }
 
 namespace Atomic {
Index: test/Sema/pass-object-size.c
===
--- test/Sema/pass-object-size.c
+++ test/Sema/pass-object-size.c
@@ -17,6 +17,9 @@
 void i(char *p __attribute__((pass_object_size(0; // OK -- const is only necessary on definitions, not decls.
 void j(char *p __attribute__((pass_object_size(0), pass_object_size(1; //expected-error{{'pass_object_size' attribute can only be applied once per parameter}}
 
+void k(char *p __attribute__((pass_dynamic_object_size))); // expected-error {{'pass_dynamic_object_size' attribute takes one argument}}
+void l(int p __attribute__((pass_dynamic_object_size(0; // expected-error {{'pass_dynamic_object_size' attribute only applies to constant pointer arguments}}
+
 #define PS(N) __attribute__((pass_object_size(N)))
 #define overloaded __attribute__((overloadable))
 void Overloaded(void *p PS(0)) overloaded; //expected-note{{previous declaration is here}}
@@ -32,14 +35,17 @@
 void TakeFnOvl(void (*)(int *)) overloaded;
 
 void NotOverloaded(void *p PS(0));
-void IsOverloaded(void *p PS(0)) overloaded;
-void IsOverloaded(char *p) overloaded; // char* inestead of void* is intentional
+void IsOverloaded(void *p PS(0)) overloaded; // expected-note 2 {{candidate address cannot be taken because parameter 1 has pass_object_size attribute}}
+
+// char* inestead of void* is intentional
+void IsOverloaded(char *p) overloaded; // expected-note{{passing argument to parameter 'p' here}} expected-note 2 {{type mismatch}}
+
 void FunctionPtrs() {
   void (*p)(void *) = NotOverloaded; //expected-error{{cannot take address of function 'NotOverloaded' because parameter 1 has pass_object_size attribute}}
   void (*p2)(void *) =  //expected-error{{cannot take address of function 'NotOverloaded' because parameter 1 has 

r356515 - Add a spelling of pass_object_size that uses __builtin_dynamic_object_size

2019-03-19 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Tue Mar 19 13:44:18 2019
New Revision: 356515

URL: http://llvm.org/viewvc/llvm-project?rev=356515=rev
Log:
Add a spelling of pass_object_size that uses __builtin_dynamic_object_size

The attribute pass_dynamic_object_size(n) behaves exactly like
pass_object_size(n), but instead of evaluating __builtin_object_size on calls,
it evaluates __builtin_dynamic_object_size, which has the potential to produce
runtime code when the object size can't be determined statically.

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

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CodeGen/pass-object-size.c
cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
cfe/trunk/test/Sema/pass-object-size.c

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=356515=356514=356515=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Mar 19 13:44:18 2019
@@ -1560,7 +1560,9 @@ def ReturnsNonNull : InheritableAttr {
 // pass_object_size(N) indicates that the parameter should have
 // __builtin_object_size with Type=N evaluated on the parameter at the 
callsite.
 def PassObjectSize : InheritableParamAttr {
-  let Spellings = [Clang<"pass_object_size">];
+  let Spellings = [Clang<"pass_object_size">,
+   Clang<"pass_dynamic_object_size">];
+  let Accessors = [Accessor<"isDynamic", [Clang<"pass_dynamic_object_size">]>];
   let Args = [IntArgument<"Type">];
   let Subjects = SubjectList<[ParmVar]>;
   let Documentation = [PassObjectSizeDocs];

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=356515=356514=356515=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Tue Mar 19 13:44:18 2019
@@ -698,6 +698,15 @@ Currently, ``pass_object_size`` is a bit
 * It is an error to apply the ``pass_object_size`` attribute to parameters that
   are not pointers. Additionally, any parameter that ``pass_object_size`` is
   applied to must be marked ``const`` at its function's definition.
+
+Clang also supports the ``pass_dynamic_object_size`` attribute, which behaves
+identically to ``pass_object_size``, but evaluates a call to
+``__builtin_dynamic_object_size`` at the callee instead of
+``__builtin_object_size``. ``__builtin_dynamic_object_size`` provides some 
extra
+runtime checks when the object size can't be determined at compile-time. You 
can
+read more about ``__builtin_dynamic_object_size`` `here
+`_.
+
   }];
 }
 

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=356515=356514=356515=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Tue Mar 19 13:44:18 2019
@@ -2833,7 +2833,10 @@ void CXXNameMangler::mangleBareFunctionT
   if (auto *Attr = FD->getParamDecl(I)->getAttr()) {
 // Attr can only take 1 character, so we can hardcode the length below.
 assert(Attr->getType() <= 9 && Attr->getType() >= 0);
-Out << "U17pass_object_size" << Attr->getType();
+if (Attr->isDynamic())
+  Out << "U25pass_dynamic_object_size" << Attr->getType();
+else
+  Out << "U17pass_object_size" << Attr->getType();
   }
 }
   }

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=356515=356514=356515=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Tue Mar 19 13:44:18 2019
@@ -267,7 +267,7 @@ class MicrosoftCXXNameMangler {
   typedef llvm::DenseMap ArgBackRefMap;
   ArgBackRefMap TypeBackReferences;
 
-  typedef std::set PassObjectSizeArgsSet;
+  typedef std::set> PassObjectSizeArgsSet;
   PassObjectSizeArgsSet PassObjectSizeArgs;
 
   ASTContext () const { return Context.getASTContext(); }
@@ -1761,14 +1761,16 @@ void MicrosoftCXXNameMangler::mangleArgu
 void MicrosoftCXXNameMangler::manglePassObjectSizeArg(
 const PassObjectSizeAttr *POSA) {
   int Type = POSA->getType();
+  bool Dynamic = POSA->isDynamic();
 
-  auto Iter = PassObjectSizeArgs.insert(Type).first;
+  auto Iter = PassObjectSizeArgs.insert({Type, 

[PATCH] D58514: Avoid needlessly copying blocks that initialize or are assigned to local auto variables to the heap

2019-03-19 Thread Hao Wu via Phabricator via cfe-commits
wuhao5 added a comment.

In D58514#1435296 , @rjmccall wrote:

> In D58514#1435228 , @wuhao5 wrote:
>
> > > Okay, so really just a block self-reference.  We could really just add a 
> > > feature for that that would avoid both the complexity and the expense of 
> > > the self-capture dance.
> >
> > Is there a plan to cover this case? or is it a legitimate use case that 
> > Clang should handle?
>
>
> You are currently relying on something that ARC doesn't guarantee, so the 
> client code should be fixed to explicitly copy the block.  I think we would 
> be happy to consider a proposal in the long run to allow blocks to 
> self-reference more easily, which will effectively bypass the problem.


I am not sure if I follow here - is it not that the weak pointer holds a block 
that's in the stack but is supposed to be in the heap?


Repository:
  rC Clang

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

https://reviews.llvm.org/D58514



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


r356513 - [OPENMP]Warn if the different allocator is used for the variable.

2019-03-19 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Mar 19 13:33:44 2019
New Revision: 356513

URL: http://llvm.org/viewvc/llvm-project?rev=356513=rev
Log:
[OPENMP]Warn if the different allocator is used for the variable.

If the allocator was specified for the variable and next one is found
with the different allocator, the warning is emitted, and the allocator
is ignored.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/allocate_allocator_ast_print.cpp
cfe/trunk/test/OpenMP/allocate_allocator_messages.cpp
cfe/trunk/test/OpenMP/allocate_codegen.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=356513=356512=356513=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Mar 19 13:33:44 
2019
@@ -9146,6 +9146,12 @@ def err_omp_expected_predefined_allocato
   "storage: 'omp_default_mem_alloc', 'omp_large_cap_mem_alloc', "
   "'omp_const_mem_alloc', 'omp_high_bw_mem_alloc', 'omp_low_lat_mem_alloc', "
   "'omp_cgroup_mem_alloc', 'omp_pteam_mem_alloc' or 'omp_thread_mem_alloc'">;
+def warn_omp_used_different_allocator : Warning<
+  "allocate directive specifies %select{default|'%1'}0 allocator while "
+  "previously used %select{default|'%3'}2">,
+  InGroup;
+def note_omp_previous_allocator : Note<
+  "previous allocator is specified here">;
 } // end of OpenMP category
 
 let CategoryName = "Related Result Type Issue" in {

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=356513=356512=356513=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Mar 19 13:33:44 2019
@@ -2216,6 +2216,61 @@ Sema::DeclGroupPtrTy Sema::ActOnOpenMPAl
 if (isa(VD))
   continue;
 
+// If the used several times in the allocate directive, the same allocator
+// must be used.
+if (VD->hasAttr()) {
+  const auto *A = VD->getAttr();
+  const Expr *PrevAllocator = A->getAllocator();
+  bool AllocatorsMatch = false;
+  if (Allocator && PrevAllocator) {
+const Expr *AE = Allocator->IgnoreParenImpCasts();
+const Expr *PAE = PrevAllocator->IgnoreParenImpCasts();
+llvm::FoldingSetNodeID AEId, PAEId;
+AE->Profile(AEId, Context, /*Canonical=*/true);
+PAE->Profile(PAEId, Context, /*Canonical=*/true);
+AllocatorsMatch = AEId == PAEId;
+  } else if (!Allocator && !PrevAllocator) {
+AllocatorsMatch = true;
+  } else {
+const Expr *AE = Allocator ? Allocator : PrevAllocator;
+// In this case the specified allocator must be the default one.
+AE = AE->IgnoreParenImpCasts();
+if (const auto *DRE = dyn_cast(AE)) {
+  DeclarationName DN = DRE->getDecl()->getDeclName();
+  AllocatorsMatch =
+  DN.isIdentifier() &&
+  DN.getAsIdentifierInfo()->isStr("omp_default_mem_alloc");
+}
+  }
+  if (!AllocatorsMatch) {
+SmallString<256> AllocatorBuffer;
+llvm::raw_svector_ostream AllocatorStream(AllocatorBuffer);
+if (Allocator)
+  Allocator->printPretty(AllocatorStream, nullptr, 
getPrintingPolicy());
+SmallString<256> PrevAllocatorBuffer;
+llvm::raw_svector_ostream PrevAllocatorStream(PrevAllocatorBuffer);
+if (PrevAllocator)
+  PrevAllocator->printPretty(PrevAllocatorStream, nullptr,
+ getPrintingPolicy());
+
+SourceLocation AllocatorLoc =
+Allocator ? Allocator->getExprLoc() : RefExpr->getExprLoc();
+SourceRange AllocatorRange =
+Allocator ? Allocator->getSourceRange() : 
RefExpr->getSourceRange();
+SourceLocation PrevAllocatorLoc =
+PrevAllocator ? PrevAllocator->getExprLoc() : A->getLocation();
+SourceRange PrevAllocatorRange =
+PrevAllocator ? PrevAllocator->getSourceRange() : A->getRange();
+Diag(AllocatorLoc, diag::warn_omp_used_different_allocator)
+<< (Allocator ? 1 : 0) << AllocatorStream.str()
+<< (PrevAllocator ? 1 : 0) << PrevAllocatorStream.str()
+<< AllocatorRange;
+Diag(PrevAllocatorLoc, diag::note_omp_previous_allocator)
+<< PrevAllocatorRange;
+continue;
+  }
+}
+
 // OpenMP, 2.11.3 allocate Directive, Restrictions, C / C++
 // If a list item has a static storage type, the allocator expression in 
the
 // allocator clause must be a constant expression that evaluates to one of
@@ -2254,11 +2309,17 @@ Sema::DeclGroupPtrTy Sema::ActOnOpenMPAl
 }
 
 

[PATCH] D28213: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

2019-03-19 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

Why was it reverted?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D28213



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


[PATCH] D59557: Fix CodeGen/arm64-microsoft-status-reg.cpp test

2019-03-19 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht created this revision.
rupprecht added reviewers: arsenm, MatzeB.
Herald added subscribers: cfe-commits, kristof.beyls, javed.absar, wdng.
Herald added a project: clang.

This test is failing after r356499. Update the register selection used in the 
test.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D59557

Files:
  clang/test/CodeGen/arm64-microsoft-status-reg.cpp

Index: clang/test/CodeGen/arm64-microsoft-status-reg.cpp
===
--- clang/test/CodeGen/arm64-microsoft-status-reg.cpp
+++ clang/test/CodeGen/arm64-microsoft-status-reg.cpp
@@ -30,103 +30,103 @@
 void check_ReadWriteStatusReg(__int64 v) {
   __int64 ret;
   ret = _ReadStatusReg(ARM64_CNTVCT);
-// CHECK-ASM: mrs x0, CNTVCT_EL0
+// CHECK-ASM: mrs x8, CNTVCT_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_PMCCNTR_EL0);
-// CHECK-ASM: mrs x0, PMCCNTR_EL0
+// CHECK-ASM: mrs x8, PMCCNTR_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD3:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_PMSELR_EL0);
-// CHECK-ASM: mrs x0, PMSELR_EL0
+// CHECK-ASM: mrs x8, PMSELR_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD4:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_PMXEVCNTR_EL0);
-// CHECK-ASM: mrs x0, PMXEVCNTR_EL0
+// CHECK-ASM: mrs x8, PMXEVCNTR_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD5:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_PMXEVCNTRn_EL0(0));
-// CHECK-ASM: mrs x0, PMEVCNTR0_EL0
+// CHECK-ASM: mrs x8, PMEVCNTR0_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD6:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_PMXEVCNTRn_EL0(1));
-// CHECK-ASM: mrs x0, PMEVCNTR1_EL0
+// CHECK-ASM: mrs x8, PMEVCNTR1_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD7:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_PMXEVCNTRn_EL0(30));
-// CHECK-ASM: mrs x0, PMEVCNTR30_EL0
+// CHECK-ASM: mrs x8, PMEVCNTR30_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD8:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_TPIDR_EL0);
-// CHECK-ASM: mrs x0, TPIDR_EL0
+// CHECK-ASM: mrs x8, TPIDR_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD9:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_TPIDRRO_EL0);
-// CHECK-ASM: mrs x0, TPIDRRO_EL0
+// CHECK-ASM: mrs x8, TPIDRRO_EL0
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD10:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
   ret = _ReadStatusReg(ARM64_TPIDR_EL1);
-// CHECK-ASM: mrs x0, TPIDR_EL1
+// CHECK-ASM: mrs x8, TPIDR_EL1
 // CHECK-IR: %[[VAR:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD11:.*]])
 // CHECK-IR-NEXT: store i64 %[[VAR]]
 
 
   _WriteStatusReg(ARM64_CNTVCT, v);
-// CHECK-ASM: msr S3_3_C14_C0_2, x0
+// CHECK-ASM: msr S3_3_C14_C0_2, x8
 // CHECK-IR: %[[VAR:.*]] = load i64,
 // CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD2:.*]], i64 %[[VAR]])
 
   _WriteStatusReg(ARM64_PMCCNTR_EL0, v);
-// CHECK-ASM: msr PMCCNTR_EL0, x0
+// CHECK-ASM: msr PMCCNTR_EL0, x8
 // CHECK-IR: %[[VAR:.*]] = load i64,
 // CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD3:.*]], i64 %[[VAR]])
 
   _WriteStatusReg(ARM64_PMSELR_EL0, v);
-// CHECK-ASM: msr PMSELR_EL0, x0
+// CHECK-ASM: msr PMSELR_EL0, x8
 // CHECK-IR: %[[VAR:.*]] = load i64,
 // CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD4:.*]], i64 %[[VAR]])
 
   _WriteStatusReg(ARM64_PMXEVCNTR_EL0, v);
-// CHECK-ASM: msr PMXEVCNTR_EL0, x0
+// CHECK-ASM: msr PMXEVCNTR_EL0, x8
 // CHECK-IR: %[[VAR:.*]] = load i64,
 // CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD5:.*]], i64 %[[VAR]])
 
   _WriteStatusReg(ARM64_PMXEVCNTRn_EL0(0), v);
-// CHECK-ASM: msr PMEVCNTR0_EL0, x0
+// CHECK-ASM: msr PMEVCNTR0_EL0, x8
 // CHECK-IR: %[[VAR:.*]] = load i64,
 // CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD6:.*]], i64 %[[VAR]])
 
   _WriteStatusReg(ARM64_PMXEVCNTRn_EL0(1), v);
-// CHECK-ASM: msr PMEVCNTR1_EL0, x0
+// CHECK-ASM: msr PMEVCNTR1_EL0, x8
 // CHECK-IR: %[[VAR:.*]] = load i64,
 // CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD7:.*]], i64 %[[VAR]])
 
   _WriteStatusReg(ARM64_PMXEVCNTRn_EL0(30), v);
-// CHECK-ASM: msr PMEVCNTR30_EL0, x0
+// CHECK-ASM: msr PMEVCNTR30_EL0, x8
 // CHECK-IR: %[[VAR:.*]] = load i64,
 // CHECK-IR-NEXT: call void @llvm.write_register.i64(metadata ![[MD8:.*]], i64 %[[VAR]])
 
   

[PATCH] D28213: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

2019-03-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added subscribers: jyknight, eli.friedman, erichkeane.
erichkeane added a comment.
Herald added a reviewer: jfb.
Herald added subscribers: llvm-commits, jfb.
Herald added a project: LLVM.

@mgorny @hfinkel @eli.friedman @jyknight @dim
Is there any chance we can get this in any time soon?  It fixes a couple of 
header issues that we've noticed.  Others added, since it appears this 
dependent on https://reviews.llvm.org/D29542 ?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D28213



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


r356508 - Add --unwindlib=[libgcc|compiler-rt] to parallel --rtlib= [take 2]

2019-03-19 Thread Sterling Augustine via cfe-commits
Author: saugustine
Date: Tue Mar 19 13:01:59 2019
New Revision: 356508

URL: http://llvm.org/viewvc/llvm-project?rev=356508=rev
Log:
Add --unwindlib=[libgcc|compiler-rt] to parallel --rtlib= [take 2]

"clang++ hello.cc --rtlib=compiler-rt"

now can works without specifying additional unwind or exception
handling libraries.

This reworked version of the feature no longer modifies today's default
unwind library for compiler-rt: which is nothing. Rather, a user
can specify -DCLANG_DEFAULT_UNWINDLIB=libunwind when configuring
the compiler.

This should address the issues from the previous version.

Update tests for new --unwindlib semantics.

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

Added:
cfe/trunk/test/Driver/compiler-rt-unwind.c
Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Config/config.h.cmake
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=356508=356507=356508=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Tue Mar 19 13:01:59 2019
@@ -266,6 +266,24 @@ if (NOT(CLANG_DEFAULT_RTLIB STREQUAL ""
 "Default runtime library to use (\"libgcc\" or \"compiler-rt\", empty for 
platform default)" FORCE)
 endif()
 
+set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING
+  "Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", empty 
to match runtime library.)")
+if (CLANG_DEFAULT_UNWINDLIB STREQUAL "")
+  if (CLANG_DEFAULT_RTLIB STREQUAL "libgcc")
+set (CLANG_DEFAULT_UNWINDLIB "libgcc" CACHE STRING "" FORCE)
+  elseif (CLANG_DEFAULT_RTLIBS STREQUAL "libunwind")
+set (CLANG_DEFAULT_UNWINDLIB "none" CACHE STRING "" FORCE)
+  endif()
+endif()
+
+if (NOT(CLANG_DEFAULT_UNWINDLIB STREQUAL "none" OR
+CLANG_DEFAULT_UNWINDLIB STREQUAL "libgcc" OR
+CLANG_DEFAULT_UNWINDLIB STREQUAL "libunwind"))
+  message(WARNING "Resetting default unwindlib to use platform default")
+  set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING
+"Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", 
empty for none)" FORCE)
+endif()
+
 set(CLANG_DEFAULT_OBJCOPY "objcopy" CACHE STRING
   "Default objcopy executable to use.")
 

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=356508=356507=356508=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Mar 19 13:01:59 
2019
@@ -51,6 +51,10 @@ def err_drv_invalid_rtlib_name : Error<
   "invalid runtime library name in argument '%0'">;
 def err_drv_unsupported_rtlib_for_platform : Error<
   "unsupported runtime library '%0' for platform '%1'">;
+def err_drv_invalid_unwindlib_name : Error<
+  "invalid unwind library name in argument '%0'">;
+def err_drv_incompatible_unwindlib : Error<
+  "--rtlib=libgcc requires --unwindlib=libgcc">;
 def err_drv_invalid_stdlib_name : Error<
   "invalid library name in argument '%0'">;
 def err_drv_invalid_output_with_multiple_archs : Error<

Modified: cfe/trunk/include/clang/Config/config.h.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Config/config.h.cmake?rev=356508=356507=356508=diff
==
--- cfe/trunk/include/clang/Config/config.h.cmake (original)
+++ cfe/trunk/include/clang/Config/config.h.cmake Tue Mar 19 13:01:59 2019
@@ -23,6 +23,9 @@
 /* Default runtime library to use. */
 #define CLANG_DEFAULT_RTLIB "${CLANG_DEFAULT_RTLIB}"
 
+/* Default unwind library to use. */
+#define CLANG_DEFAULT_UNWINDLIB "${CLANG_DEFAULT_UNWINDLIB}"
+
 /* Default objcopy to use */
 #define CLANG_DEFAULT_OBJCOPY "${CLANG_DEFAULT_OBJCOPY}"
 

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=356508=356507=356508=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Mar 19 13:01:59 2019
@@ -2591,6 +2591,8 @@ def std_EQ : Joined<["-", "--"], "std=">
   }]>;
 def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>,
   HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">;
+def unwindlib_EQ : Joined<["-", "--"], "unwindlib=">, Flags<[CC1Option]>,
+  HelpText<"Unwind library to use">, Values<"libgcc,unwindlib,platform">;
 def sub__library : JoinedOrSeparate<["-"], "sub_library">;
 def 

[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2019-03-19 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 191371.
Herald added a subscriber: jdoerfert.

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

https://reviews.llvm.org/D43576

Files:
  include/clang/AST/Decl.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/Attr.td
  include/clang/Basic/DeclNodes.td
  include/clang/Sema/ParsedAttr.h
  include/clang/Sema/Sema.h
  lib/AST/Decl.cpp
  lib/AST/DeclBase.cpp
  lib/AST/DeclCXX.cpp
  lib/CodeGen/CGDecl.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTCommon.cpp
  test/Parser/MicrosoftExtensions.cpp
  test/Parser/ms-square-bracket-attributes.mm
  test/Sema/ms-uuid-1.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -321,12 +321,15 @@
 OS << "\" << get" << getUpperName() << "().getAsString() << \"";
   else if (type == "ParamIdx")
 OS << "\" << get" << getUpperName() << "().getSourceIndex() << \"";
-  else
+  else if (type == "DeclSpecUuidDecl *") {
+OS << "\" << get" << getUpperName() << "() << \"";
+  } else
 OS << "\" << get" << getUpperName() << "() << \"";
 }
 
 void writeDump(raw_ostream ) const override {
-  if (type == "FunctionDecl *" || type == "NamedDecl *") {
+  if (type == "FunctionDecl *" || type == "NamedDecl *" ||
+	  (type == "DeclSpecUuidDecl *")) {
 OS << "OS << \" \";\n";
 OS << "dumpBareDeclRef(SA->get" << getUpperName() << "());\n"; 
   } else if (type == "IdentifierInfo *") {
@@ -1296,6 +1299,8 @@
 Ptr = llvm::make_unique(Arg, Attr);
   else if (ArgName == "VersionArgument")
 Ptr = llvm::make_unique(Arg, Attr);
+  else if (ArgName == "DeclSpecUuidDeclArgument")
+Ptr = llvm::make_unique(Arg, Attr, "DeclSpecUuidDecl *");
 
   if (!Ptr) {
 // Search in reverse order so that the most-derived type is handled first.
Index: test/Sema/ms-uuid-1.cpp
===
--- /dev/null
+++ test/Sema/ms-uuid-1.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fms-extensions -fms-compatibility -std=c++14 -emit-obj -fdiagnostics-show-option %s
+// expected-no-diagnostics
+typedef struct _GUID {
+  int i;
+} IID;
+template 
+class A {};
+
+struct
+__declspec(uuid("{DDB47A6A-0F23-11D5-9109-00E0296B75D3}"))
+S1 {};
+
+struct
+__declspec(uuid("{DDB47A6A-0F23-11D5-9109-00E0296B75D3}"))
+S2 {};
+
+struct __declspec(dllexport)
+C1 : public A<&__uuidof(S1)> {};
+
+struct __declspec(dllexport)
+C2 : public A<&__uuidof(S2)> {};
+int printf(const char *, ...);
+int main() {
+
+  if (&__uuidof(S1) == &__uuidof(S2))
+printf("OK\n");
+  else
+printf("ERROR\n");
+
+  return 0;
+}
Index: test/Parser/ms-square-bracket-attributes.mm
===
--- test/Parser/ms-square-bracket-attributes.mm
+++ test/Parser/ms-square-bracket-attributes.mm
@@ -19,7 +19,7 @@
 // uuids must be ascii string literals.
 // expected-error@+1 {{uuid attribute contains a malformed GUID}}
 [uuid(u8"00A0---C000-0049")] struct struct_with_uuid_u8;
-// expected-error@+1 {{uuid attribute contains a malformed GUID}}
+// expected-error@+1 {{attribute requires a string}}
 [uuid(L"00A0---C000-0049")] struct struct_with_uuid_L;
 
 // cl.exe doesn't allow raw string literals in []-style attributes, but does
Index: test/Parser/MicrosoftExtensions.cpp
===
--- test/Parser/MicrosoftExtensions.cpp
+++ test/Parser/MicrosoftExtensions.cpp
@@ -76,7 +76,7 @@
struct_with_uuid var_with_uuid[1];
struct_without_uuid var_without_uuid[1];
 
-   __uuidof(struct_with_uuid);
+   __uuidof(struct_with_uuid); // expected-error {{non-type template argument of type 'const _GUID' is not a constant expression}}
__uuidof(struct_with_uuid2);
__uuidof(struct_with_uuid3);
__uuidof(struct_without_uuid); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
@@ -137,7 +137,7 @@
 
 COM_CLASS_TEMPLATE_REF good_template_arg;
 
-COM_CLASS_TEMPLATE bad_template_arg; // expected-error {{non-type template argument of type 'const _GUID' is not a constant expression}}
+COM_CLASS_TEMPLATE bad_template_arg;
 
 namespace PR16911 {
 struct __declspec(uuid("{12345678-1234-1234-1234-1234567890aB}")) uuid;
Index: lib/Serialization/ASTCommon.cpp
===
--- lib/Serialization/ASTCommon.cpp
+++ lib/Serialization/ASTCommon.cpp
@@ -348,6 +348,7 @@
   case Decl::ObjCProtocol:
   case Decl::ObjCInterface:
   case Decl::Empty:
+  case Decl::DeclSpecUuid:
 return true;
 
   // Never 

[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2019-03-19 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

It would be nice to have a review for this year old (updated) patch. Thanks.


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

https://reviews.llvm.org/D43576



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


[PATCH] D59394: [Sema] De-duplicate some availability checking logic

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

This seems reasonable to me.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59394



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


[PATCH] D58757: Add a version of the pass_object_size attribute that works with builtin_dynamic_object_size

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

LGTM!


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

https://reviews.llvm.org/D58757



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


r356507 - Move options to separate checks that do not need to immediately follow the previous option. NFCI

2019-03-19 Thread Douglas Yung via cfe-commits
Author: dyung
Date: Tue Mar 19 12:34:15 2019
New Revision: 356507

URL: http://llvm.org/viewvc/llvm-project?rev=356507=rev
Log:
Move options to separate checks that do not need to immediately follow the 
previous option. NFCI

Modified:
cfe/trunk/test/Driver/hip-toolchain-mllvm.hip

Modified: cfe/trunk/test/Driver/hip-toolchain-mllvm.hip
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hip-toolchain-mllvm.hip?rev=356507=356506=356507=diff
==
--- cfe/trunk/test/Driver/hip-toolchain-mllvm.hip (original)
+++ cfe/trunk/test/Driver/hip-toolchain-mllvm.hip Tue Mar 19 12:34:15 2019
@@ -8,7 +8,8 @@
 // RUN:   %s 2>&1 | FileCheck %s
 
 // CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
-// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc"
+// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
+// CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-target-cpu" "gfx803"
 // CHECK-SAME: {{.*}} "-mllvm" "-amdgpu-function-calls=0" {{.*}}
 
@@ -22,7 +23,8 @@
 // CHECK-SAME: "-amdgpu-function-calls=0" "-o" {{".*-gfx803-.*o"}}
 
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
-// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc"
+// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
+// CHECK-SAME: "-emit-llvm-bc"
 // CHECK-SAME: {{.*}} "-target-cpu" "gfx900"
 // CHECK-SAME: {{.*}} "-mllvm" "-amdgpu-function-calls=0" {{.*}}
 


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


[PATCH] D59555: [analyzer] Add yaml parser to GenericTaintChecker

2019-03-19 Thread Borsik Gábor via Phabricator via cfe-commits
boga95 created this revision.
boga95 added reviewers: Szelethus, xazax.hun, dkrupp, NoQ.
Herald added subscribers: cfe-commits, Charusso, donat.nagy, mikhail.ramalho, 
a.sidorin, rnkovacs, szepet, baloghadamsoftware, whisperity.
Herald added a project: clang.

Parse the yaml configuration file and store it in static variables. The user 
can define taint propagation rules, custom sink, and filter functions. E.g:

  # A list of source/propagation function
  Propagations:
# int x = mySource1(); // x is tainted
- Name: mySource1
  DstArgs:  [4294967294] # Index for return value
  
# int x;
# mySource2(); // x is tainted
- Name: mySource2
  DstArgs:  [0]
  
# int x, y;
# myScanf("%d %d", , ); // x and y are tainted
- Name: myScanf
  VarType:  Dst
  VarIndex: 1
  
# int x; // x is tainted
# int y;
# myPropagator(x, ); // y is tainted
- Name: myPropagator
  SrcArgs:  [0]
  DstArgs:  [1]
  
# const unsigned size = 100;
# char buf[size];
# int x, y;
# int n = mySprintf(buf, size, "%d %d", x, y); // If size, x or y is tainted
# // the return value and the buf will be tainted
- Name: mySnprintf
  SrcArgs:  [1]
  DstArgs:  [0, 4294967294]
  VarType:  Src
  VarIndex: 3
  
  # A list of filter functions
  Filters:
# int x; // x is tainted
# myFilter(); // x is not tainted anymore
- Name: myFilter
  Args: [0]
  
  # A list of sink functions
  Sinks:
# int x, y; // x and y are tainted
# mySink(x, 0, 1); // It will warn
# mySink(0, 1, y); // It will warn
# mySink(0, x, 1); // It won't warn
- Name: mySink
  Args: [0, 2]


Repository:
  rC Clang

https://reviews.llvm.org/D59555

Files:
  lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp

Index: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -13,14 +13,16 @@
 // aggressively, even if the involved symbols are under constrained.
 //
 //===--===//
-#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/AST/Attr.h"
 #include "clang/Basic/Builtins.h"
+#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/Support/YAMLTraits.h"
 #include 
 #include 
 #include 
@@ -41,11 +43,38 @@
 
   void checkPreStmt(const CallExpr *CE, CheckerContext ) const;
 
-private:
+  using ArgVector = SmallVector;
+
+  enum class VariadicType { None, Src, Dst };
+
+  /// The ``TaintConfiguration`` is used to parse configuration file.
+  struct TaintConfiguration {
+using NameArgsPair = std::pair;
+
+struct Propagation {
+  std::string Name;
+  ArgVector SrcArgs;
+  ArgVector DstArgs;
+  VariadicType VarType;
+  unsigned VarIndex;
+};
+
+std::vector Propagations;
+std::vector Filters;
+std::vector Sinks;
+  };
+
+  /// Get and read the config file.
+  static void getConfiguration(StringRef ConfigFile);
+
+  /// Parse the config.
+  static void parseConfiguration(TaintConfiguration &);
+
   static const unsigned InvalidArgIndex = UINT_MAX;
   /// Denotes the return vale.
   static const unsigned ReturnValueIndex = UINT_MAX - 1;
 
+private:
   mutable std::unique_ptr BT;
   void initBugType() const {
 if (!BT)
@@ -91,8 +120,6 @@
   bool generateReportIfTainted(const Expr *E, const char Msg[],
CheckerContext ) const;
 
-  using ArgVector = SmallVector;
-
   /// A struct used to specify taint propagation rules for a function.
   ///
   /// If any of the possible taint source arguments is tainted, all of the
@@ -103,8 +130,6 @@
   /// ReturnValueIndex is added to the dst list, the return value will be
   /// tainted.
   struct TaintPropagationRule {
-enum class VariadicType { None, Src, Dst };
-
 using PropagationFuncType = bool (*)(bool IsTainted, const CallExpr *,
  CheckerContext );
 
@@ -125,8 +150,7 @@
 : VariadicIndex(InvalidArgIndex), VarType(VariadicType::None),
   PropagationFunc(nullptr) {}
 
-TaintPropagationRule(std::initializer_list &,
- std::initializer_list &,
+TaintPropagationRule(ArgVector &, ArgVector &,
  VariadicType Var = VariadicType::None,
  unsigned VarIndex = InvalidArgIndex,
  PropagationFuncType Func = nullptr)
@@ -170,6 

[PATCH] D58514: Avoid needlessly copying blocks that initialize or are assigned to local auto variables to the heap

2019-03-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D58514#1435228 , @wuhao5 wrote:

> > Okay, so really just a block self-reference.  We could really just add a 
> > feature for that that would avoid both the complexity and the expense of 
> > the self-capture dance.
>
> Is there a plan to cover this case? or is it a legitimate use case that Clang 
> should handle?


You are currently relying on something that ARC doesn't guarantee, so the 
client code should be fixed to explicitly copy the block.  I think we would be 
happy to consider a proposal in the long run to allow blocks to self-reference 
more easily, which will effectively bypass the problem.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58514



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


[PATCH] D59492: [OpenCL] Allow variadic macros as Clang feature

2019-03-19 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 191366.
Anastasia added a comment.

Instead of removing the diagnostic completely change into a warning in pedantic 
mode.


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

https://reviews.llvm.org/D59492

Files:
  include/clang/Basic/DiagnosticLexKinds.td
  lib/Lex/PPDirectives.cpp
  test/Misc/warning-flags.c
  test/Preprocessor/macro_variadic.cl


Index: test/Preprocessor/macro_variadic.cl
===
--- test/Preprocessor/macro_variadic.cl
+++ test/Preprocessor/macro_variadic.cl
@@ -1,3 +1,20 @@
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify %s -cl-std=CL1.2
+// RUN: %clang_cc1 -verify %s -pedantic -DPEDANTIC -cl-std=CL1.2
 
-#define X(...) 1 // expected-error {{variadic macros not supported in OpenCL}}
+
+#define NO_VAR_FUNC(...)  5
+#define VAR_FUNC(...) func(__VA_ARGS__);
+#define VAR_PRINTF(str, ...) printf(str, __VA_ARGS__);
+#ifdef PEDANTIC
+// expected-warning@-4{{variadic macros not supported in OpenCL}}
+// expected-warning@-4{{variadic macros not supported in OpenCL}}
+// expected-warning@-4{{variadic macros not supported in OpenCL}}
+#endif
+
+int printf(__constant const char *st, ...);
+
+void foo() {
+  NO_VAR_FUNC(1, 2, 3);
+  VAR_FUNC(1, 2, 3); //expected-error{{implicit declaration of function 'func' 
is invalid in OpenCL}}
+  VAR_PRINTF("%i", 1);
+}
Index: test/Misc/warning-flags.c
===
--- test/Misc/warning-flags.c
+++ test/Misc/warning-flags.c
@@ -96,4 +96,4 @@
 
 The list of warnings in -Wpedantic should NEVER grow.
 
-CHECK: Number in -Wpedantic (not covered by other -W flags): 27
+CHECK: Number in -Wpedantic (not covered by other -W flags): 28
Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -2235,8 +2235,7 @@
 
   // OpenCL v1.2 s6.9.e: variadic macros are not supported.
   if (LangOpts.OpenCL) {
-Diag(Tok, diag::err_pp_opencl_variadic_macros);
-return true;
+Diag(Tok, diag::ext_pp_opencl_variadic_macros);
   }
 
   // Lex the token after the identifier.
Index: include/clang/Basic/DiagnosticLexKinds.td
===
--- include/clang/Basic/DiagnosticLexKinds.td
+++ include/clang/Basic/DiagnosticLexKinds.td
@@ -393,8 +393,8 @@
 def note_macro_here : Note<"macro %0 defined here">;
 def note_macro_expansion_here : Note<"expansion of macro %0 requested here">;
 
-def err_pp_opencl_variadic_macros :
-  Error<"variadic macros not supported in OpenCL">;
+def ext_pp_opencl_variadic_macros : Extension<
+  "variadic macros not supported in OpenCL">;
 
 def err_pp_invalid_directive : Error<"invalid preprocessing directive">;
 def err_pp_directive_required : Error<


Index: test/Preprocessor/macro_variadic.cl
===
--- test/Preprocessor/macro_variadic.cl
+++ test/Preprocessor/macro_variadic.cl
@@ -1,3 +1,20 @@
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify %s -cl-std=CL1.2
+// RUN: %clang_cc1 -verify %s -pedantic -DPEDANTIC -cl-std=CL1.2
 
-#define X(...) 1 // expected-error {{variadic macros not supported in OpenCL}}
+
+#define NO_VAR_FUNC(...)  5
+#define VAR_FUNC(...) func(__VA_ARGS__);
+#define VAR_PRINTF(str, ...) printf(str, __VA_ARGS__);
+#ifdef PEDANTIC
+// expected-warning@-4{{variadic macros not supported in OpenCL}}
+// expected-warning@-4{{variadic macros not supported in OpenCL}}
+// expected-warning@-4{{variadic macros not supported in OpenCL}}
+#endif
+
+int printf(__constant const char *st, ...);
+
+void foo() {
+  NO_VAR_FUNC(1, 2, 3);
+  VAR_FUNC(1, 2, 3); //expected-error{{implicit declaration of function 'func' is invalid in OpenCL}}
+  VAR_PRINTF("%i", 1);
+}
Index: test/Misc/warning-flags.c
===
--- test/Misc/warning-flags.c
+++ test/Misc/warning-flags.c
@@ -96,4 +96,4 @@
 
 The list of warnings in -Wpedantic should NEVER grow.
 
-CHECK: Number in -Wpedantic (not covered by other -W flags): 27
+CHECK: Number in -Wpedantic (not covered by other -W flags): 28
Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -2235,8 +2235,7 @@
 
   // OpenCL v1.2 s6.9.e: variadic macros are not supported.
   if (LangOpts.OpenCL) {
-Diag(Tok, diag::err_pp_opencl_variadic_macros);
-return true;
+Diag(Tok, diag::ext_pp_opencl_variadic_macros);
   }
 
   // Lex the token after the identifier.
Index: include/clang/Basic/DiagnosticLexKinds.td
===
--- include/clang/Basic/DiagnosticLexKinds.td
+++ include/clang/Basic/DiagnosticLexKinds.td
@@ -393,8 +393,8 @@
 def 

[PATCH] D59492: [OpenCL] Allow variadic macros as Clang feature

2019-03-19 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D59492#1434822 , @arsenm wrote:

> In D59492#1434636 , @Anastasia wrote:
>
> > In D59492#1433796 , @arsenm wrote:
> >
> > > Should it be downgraded to a warning about an extension instead of just 
> > > removing it?
> >
> >
> > What would you suggest to put in a warning message? Clang normally doesn't 
> > warn about extensions...
>
>
> Isn't that what -pedantic is for?


Yes, indeed I think it's a better approach now since it's still in the spec...


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

https://reviews.llvm.org/D59492



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


[PATCH] D56924: Special case ObjCPropertyDecl for printing

2019-03-19 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

ping


Repository:
  rC Clang

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

https://reviews.llvm.org/D56924



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


[PATCH] D57965: Clean up ObjCPropertyDecl printing

2019-03-19 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

friendly ping


Repository:
  rC Clang

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

https://reviews.llvm.org/D57965



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


[PATCH] D57896: Variable names rule

2019-03-19 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

In D57896#1435245 , @lattner wrote:

> FWIW, my suggestion is *not* to expand names like DRE to decl_ref_expr, I 
> agree that doesn't add clarity to the code.  Two possibilities: "dre", or 
> "decl" which is what I would write today.


I totally agree with you, wherever I can I write that out for clarification. 
Please note that in my example there is two `Expr` and that is why I pointed 
out we need acronyms so we cannot really use `expr` and acronyms usually 
capital, that is why we went back to the default CamelCase standard. It was a 
little brainstorming and ping for you guys because I believe you would put 
those polls out and create a better code-base.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57896



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


[PATCH] D59540: [clang-tidy] [PR41119] readability-identifier-naming incorrectly fixes lambda capture

2019-03-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay marked 5 inline comments as done.
MyDeveloperDay added inline comments.



Comment at: test/clang-tidy/readability-identifier-naming.cpp:509
+// CHECK-FIXES: {{^}}  bool columns=false;
+  auto ptr=[&]{return Columns;}();
+// CHECK-FIXES: {{^}}  auto ptr=[&]{return columns;}();

alexfh wrote:
> Please add more tests with
>   1) by value automatic captures
>   2) manual captures by value
>   3) manual captures by reference
>   4) nested lambdas capturing the same variable
> 
> A bit more nested code inside the lambda would also be interesting (where the 
> use of the variable would be wrapped in a couple of compound statements).
Think i've covered the cases you wanted here, if you can think of another drop 
the code into a comment and I'll add it.


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

https://reviews.llvm.org/D59540



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


[PATCH] D59540: [clang-tidy] [PR41119] readability-identifier-naming incorrectly fixes lambda capture

2019-03-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 191365.
MyDeveloperDay added a comment.

Address review comments
This may not be a more satisfactory solution  but it at least now covers the 
other cases raised by @JonasToth 
Add more tests around this area.


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

https://reviews.llvm.org/D59540

Files:
  clang-tidy/readability/IdentifierNamingCheck.cpp
  test/clang-tidy/readability-identifier-naming.cpp

Index: test/clang-tidy/readability-identifier-naming.cpp
===
--- test/clang-tidy/readability-identifier-naming.cpp
+++ test/clang-tidy/readability-identifier-naming.cpp
@@ -501,3 +501,159 @@
 // CHECK-FIXES: {{^}}int * const lc_PointerB = nullptr;{{$}}
 }
 
+
+bool LambdaCaptureTest() {
+  bool Columns=false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns=false;
+  auto ptr = [&]{
+return Columns;
+// CHECK-FIXES: {{^}}return columns;
+  }();
+
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool LambdaCaptureTest1() {
+  bool Columns=false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns=false;
+  auto ptr = [=]{
+return Columns;
+  // CHECK-FIXES: {{^}}return columns;
+  }();
+
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool LambdaCaptureTest2() {
+  bool Columns = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns = false;
+  auto ptr = []{
+// CHECK-FIXES: {{^}}  auto ptr = []{
+return Columns;
+// CHECK-FIXES: {{^}}return columns;
+  }();
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool LambdaCaptureTest3() {
+  bool Columns = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns = false;
+  auto ptr = [Columns]{
+// CHECK-FIXES: {{^}}  auto ptr = [columns]{
+return Columns;
+// CHECK-FIXES: {{^}}return columns;
+  }();
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool LambdaCaptureTest4() {
+  bool Columns = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns = false;
+  auto ptr = [&]{
+if (true)
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+  }();
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool LambdaCaptureTest5() {
+  bool Columns = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns = false;
+  auto ptr = [](bool Columns) {
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: invalid case style for parameter 'Columns'
+// CHECK-FIXES: {{^}}  auto ptr = [](bool a_columns) {
+return Columns;
+// CHECK-FIXES: {{^}}return a_columns;
+  };
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool LambdaCaptureTest6() {
+  bool Columns = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns = false;
+  auto ptr = [Columns]() ->bool {
+// CHECK-FIXES: {{^}}  auto ptr = [columns]() ->bool {
+  [=]() -> bool {
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+};
+return Columns;
+// CHECK-FIXES: {{^}}return columns;
+  };
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool LambdaCaptureTest7() {
+  int  a;
+  bool Columns = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns = false;
+  auto ptr = [, a]{
+// CHECK-FIXES: {{^}}  auto ptr = [, a]{
+return Columns;
+// CHECK-FIXES: {{^}}return columns;
+  }();
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool LambdaCaptureTest8() {
+  int a;
+  bool Columns = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns = false;
+  auto ptr = [a, Columns]{
+// CHECK-FIXES: {{^}}  auto ptr = [a, columns]{
+return Columns;
+// CHECK-FIXES: {{^}}return columns;
+  }();
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool LambdaCaptureTest9() {
+  int Rows;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for local variable 'Rows'
+// CHECK-FIXES: {{^}}  int rows;
+  bool Columns = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns = false;
+  auto ptr = [Rows, Columns]{
+// CHECK-FIXES: {{^}}  auto ptr = [rows, columns]{
+return Columns;
+// CHECK-FIXES: {{^}}return columns;
+  }();
+  return Columns;
+// 

[PATCH] D57896: Variable names rule

2019-03-19 Thread Chris Lattner via Phabricator via cfe-commits
lattner added a comment.

In D57896#1434877 , @Charusso wrote:

> static Optional
>  getConcreteIntegerValue(const Expr *CondVarExpr, const ExplodedNode *N) {
>  //...
>
>   if (const auto *DRE = dyn_cast_or_null(CondVarExpr)) {
> if (const auto *VD = dyn_cast_or_null(DRE->getDecl())) {
>
> //...
>  }
>
>   would be:
>  
>
>
> static Optional 
>   |
>  getConcreteIntegerValue(const Expr *cond_var_expr, const ExplodedNode *node) 
> {  |
>  //...
>|
>
>   if (const auto *decl_ref_expr = 
> dyn_cast_or_null(cond_var_expr)) {
> if (const auto *var_decl = 
> dyn_cast_or_null(decl_ref_expr->getDecl())) {
>
> //... 
>   |
>  } whoops 
> column-81 ~^
>
>   Hungarian notation on members and globals are cool idea. However, the 
> notation is made without the `_` part, so I think `mMember` is better than 
> `m_member` as we used to 80-column standard and it is waste of space and 
> hurts your C-developer eyes. I would recommend `b` prefix to booleans as 
> Unreal Engine 4 styling is used to do that (`bIsCoolStyle`) and it is handy. 
> It is useful because booleans usually has multiple prefixes: `has, have, is` 
> and you would list all the booleans together in autocompletion. Yes, there is 
> a problem: if the notation is not capital like the pure Hungarian notation 
> then it is problematic to list and we are back to the `BIsCapitalLetter` and 
> `MMember` CamelCase-world where we started (except one project). I think 
> @lattner could say if it is useful as all the Apple projects based on those 
> notations and could be annoying.


FWIW, my suggestion is *not* to expand names like DRE to decl_ref_expr, I agree 
that doesn't add clarity to the code.  Two possibilities: "dre", or "decl" 
which is what I would write today.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57896



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


r356497 - Fix unused variable warning. NFCI.

2019-03-19 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue Mar 19 11:39:46 2019
New Revision: 356497

URL: http://llvm.org/viewvc/llvm-project?rev=356497=rev
Log:
Fix unused variable warning. NFCI.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=356497=356496=356497=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue Mar 19 11:39:46 2019
@@ -9744,7 +9744,7 @@ Address CGOpenMPRuntime::getAddressOfLoc
   llvm::Value *ThreadID = getThreadID(CGF, CVD->getBeginLoc());
   llvm::Value *Allocator;
   if (const Expr *AllocExpr = AA->getAllocator()) {
-Allocator = CGF.EmitScalarExpr(AA->getAllocator());
+Allocator = CGF.EmitScalarExpr(AllocExpr);
   } else {
 // Default allocator in libomp is nullptr.
 Allocator = llvm::ConstantPointerNull::get(CGM.VoidPtrPtrTy);


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


r356496 - [OPENMP]Check that global vars require predefined allocator.

2019-03-19 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Mar 19 11:39:11 2019
New Revision: 356496

URL: http://llvm.org/viewvc/llvm-project?rev=356496=rev
Log:
[OPENMP]Check that global vars require predefined allocator.

According to OpenMP, 2.11.3 allocate Directive, Restrictions, C / C++,
if a list item has a static storage type, the allocator expression in
  the allocator clause must be a constant expression that evaluates to
  one of the predefined memory allocator values. Added check for this
  restriction.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/allocate_allocator_messages.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=356496=356495=356496=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Mar 19 11:39:11 
2019
@@ -9141,6 +9141,11 @@ def err_omp_invalid_map_this_expr : Erro
   "invalid 'this' expression on 'map' clause">;
 def err_implied_omp_allocator_handle_t_not_found : Error<
   "omp_allocator_handle_t type not found; include ">;
+def err_omp_expected_predefined_allocator : Error<
+  "expected one of the predefined allocators for the variables with the static 
"
+  "storage: 'omp_default_mem_alloc', 'omp_large_cap_mem_alloc', "
+  "'omp_const_mem_alloc', 'omp_high_bw_mem_alloc', 'omp_low_lat_mem_alloc', "
+  "'omp_cgroup_mem_alloc', 'omp_pteam_mem_alloc' or 'omp_thread_mem_alloc'">;
 } // end of OpenMP category
 
 let CategoryName = "Related Result Type Issue" in {

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=356496=356495=356496=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Mar 19 11:39:11 2019
@@ -2216,6 +2216,43 @@ Sema::DeclGroupPtrTy Sema::ActOnOpenMPAl
 if (isa(VD))
   continue;
 
+// OpenMP, 2.11.3 allocate Directive, Restrictions, C / C++
+// If a list item has a static storage type, the allocator expression in 
the
+// allocator clause must be a constant expression that evaluates to one of
+// the predefined memory allocator values.
+if (Allocator && VD->hasGlobalStorage()) {
+  bool IsPredefinedAllocator = false;
+  if (const auto *DRE =
+  dyn_cast(Allocator->IgnoreParenImpCasts())) {
+if (DRE->getType().isConstant(getASTContext())) {
+  DeclarationName DN = DRE->getDecl()->getDeclName();
+  if (DN.isIdentifier()) {
+StringRef PredefinedAllocators[] = {
+"omp_default_mem_alloc", "omp_large_cap_mem_alloc",
+"omp_const_mem_alloc",   "omp_high_bw_mem_alloc",
+"omp_low_lat_mem_alloc", "omp_cgroup_mem_alloc",
+"omp_pteam_mem_alloc",   "omp_thread_mem_alloc",
+};
+IsPredefinedAllocator =
+llvm::any_of(PredefinedAllocators, [](StringRef S) {
+  return DN.getAsIdentifierInfo()->isStr(S);
+});
+  }
+}
+  }
+  if (!IsPredefinedAllocator) {
+Diag(Allocator->getExprLoc(),
+ diag::err_omp_expected_predefined_allocator)
+<< Allocator->getSourceRange();
+bool IsDecl = VD->isThisDeclarationADefinition(Context) ==
+  VarDecl::DeclarationOnly;
+Diag(VD->getLocation(),
+ IsDecl ? diag::note_previous_decl : diag::note_defined_here)
+<< VD;
+continue;
+  }
+}
+
 Vars.push_back(RefExpr);
 Attr *A = OMPAllocateDeclAttr::CreateImplicit(Context, Allocator,
   DE->getSourceRange());

Modified: cfe/trunk/test/OpenMP/allocate_allocator_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/allocate_allocator_messages.cpp?rev=356496=356495=356496=diff
==
--- cfe/trunk/test/OpenMP/allocate_allocator_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/allocate_allocator_messages.cpp Tue Mar 19 11:39:11 
2019
@@ -20,8 +20,10 @@ struct St1{
  int a;
  static int b;
 #pragma omp allocate(b) allocator(sss) // expected-error {{initializing 
'omp_allocator_handle_t' (aka 'void *') with an expression of incompatible type 
'int'}}
-} d;
+} d; // expected-note 2 {{'d' defined here}}
 
+// expected-error@+1 {{expected one of the predefined allocators for the 
variables with the static storage: 'omp_default_mem_alloc', 
'omp_large_cap_mem_alloc', 'omp_const_mem_alloc', 'omp_high_bw_mem_alloc', 
'omp_low_lat_mem_alloc', 'omp_cgroup_mem_alloc', 'omp_pteam_mem_alloc' or 

[PATCH] D58514: Avoid needlessly copying blocks that initialize or are assigned to local auto variables to the heap

2019-03-19 Thread Hao Wu via Phabricator via cfe-commits
wuhao5 added a comment.



> Okay, so really just a block self-reference.  We could really just add a 
> feature for that that would avoid both the complexity and the expense of the 
> self-capture dance.

Is there a plan to cover this case? or is it a legitimate use case that Clang 
should handle?


Repository:
  rC Clang

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

https://reviews.llvm.org/D58514



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


[PATCH] D59388: Basic: Return a reference from FileManager::getVirtualFileSystem, NFC

2019-03-19 Thread Jan Korous via Phabricator via cfe-commits
jkorous accepted this revision.
jkorous added a comment.
This revision is now accepted and ready to land.

In D59388#1433233 , @dexonsmith wrote:

> Yes, it's safe.  The reference count is "intrusive", meaning it's stored in 
> the object itself (via inheritance from `RefCountedBase`).  As a result, all 
> the instances of `IntrusiveRefCntPtr` that reference at the same object will 
> implicitly share their count.


I missed that `llvm::vfs::FileSystem` inherits from `ThreadSafeRefCountedBase`.

LGTM.


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

https://reviews.llvm.org/D59388



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


Re: r356222 - [analyzer] Support C++17 aggregates with bases without constructors.

2019-03-19 Thread Richard Smith via cfe-commits
On Tue, 19 Mar 2019 at 10:24, Artem Dergachev via cfe-commits
 wrote:
>
> Hi,
>
> I'll try to fix this ASAP!

It sounds like there might be a missing check for
InitListExpr::isTransparent somewhere. (A transparent InitListExpr
should be treated as equivalent to its one and only subexpression.)
Either that, or the static analyzer isn't aware that an object of
class type can be initialized directly from a function call, not via a
constructor.

> It sounds as if i don't have nearly enough C++17 codebases for testing,
> are there any obvious open-source projects that you could recommend? I'd
> love to try to reincarnate
> http://green.lab.llvm.org/green/view/Experimental/job/StaticAnalyzerBenchmarks/
> with those.
>
> On 3/19/19 9:37 AM, Alexander Kornienko wrote:
> > Filed this as https://bugs.llvm.org/show_bug.cgi?id=41142. Any hope
> > for a prompt fix here?
> >
> > On Tue, Mar 19, 2019 at 5:34 PM Alexander Kornienko  > > wrote:
> >
> > A reduced test case:
> > $ cat test-RegionStoreManager__bindStruct.cc
> > struct a {};
> > class b : a {};
> > b c() { b d{c()}; }
> > $ ./clang-tidy -checks="-*,clang-analyzer*"
> > test-RegionStoreManager__bindStruct.cc -- -std=c++17
> > assert.h assertion failed at
> > tools/clang/lib/StaticAnalyzer/Core/RegionStore.cpp:2362 in
> > (anonymous namespace)::RegionBindingsRef (anonym
> > ous
> > namespace)::RegionStoreManager::bindStruct(RegionBindingsConstRef,
> > const clang::ento::TypedValueRegion *, clang::ento::SVal):
> > CRD->isAggregate() && "Non-aggregates are constructed with a
> > constructor!"
> > @ 0x559908170326  __assert_fail
> > @ 0x5599068d4854  (anonymous
> > namespace)::RegionStoreManager::bindStruct()
> > @ 0x5599068c93c8  (anonymous
> > namespace)::RegionStoreManager::Bind()
> > @ 0x5599068b409f clang::ento::ProgramState::bindLoc()
> > @ 0x559906865935
> > clang::ento::ExprEngine::processPointerEscapedOnBind()
> > @ 0x55990685d4b3 clang::ento::ExprEngine::evalBind()
> > @ 0x559906872a43 clang::ento::ExprEngine::VisitDeclStmt()
> > @ 0x55990685c16f clang::ento::ExprEngine::Visit()
> > @ 0x559906858b1f clang::ento::ExprEngine::ProcessStmt()
> > @ 0x559906858808 clang::ento::ExprEngine::processCFGElement()
> > @ 0x55990684cb65 clang::ento::CoreEngine::HandlePostStmt()
> > @ 0x55990684bf5c clang::ento::CoreEngine::ExecuteWorkList()
> > @ 0x5599065b635b  (anonymous
> > namespace)::AnalysisConsumer::HandleCode()
> > @ 0x5599065a0135  (anonymous
> > namespace)::AnalysisConsumer::HandleTranslationUnit()
> > @ 0x559906bb7cbc
> > clang::MultiplexConsumer::HandleTranslationUnit()
> > @ 0x559906d226d4  clang::ParseAST()
> > @ 0x559906b98a83 clang::FrontendAction::Execute()
> > @ 0x559906b31cd1 clang::CompilerInstance::ExecuteAction()
> > @ 0x559906a9cf61
> > clang::tooling::FrontendActionFactory::runInvocation()
> > @ 0x55990620cc07
> > clang::tidy::runClangTidy()::ActionFactory::runInvocation()
> > @ 0x559906a9ccca
> > clang::tooling::ToolInvocation::runInvocation()
> > @ 0x559906a9c646 clang::tooling::ToolInvocation::run()
> > @ 0x559906a9ef22 clang::tooling::ClangTool::run()
> > @ 0x559906207ecf  clang::tidy::runClangTidy()
> > @ 0x559902d47c45  main
> >
> > On Tue, Mar 19, 2019 at 1:14 AM Alexander Kornienko
> > mailto:ale...@google.com>> wrote:
> >
> > On Fri, Mar 15, 2019 at 1:21 AM Artem Dergachev via
> > cfe-commits  > > wrote:
> >
> > Author: dergachev
> > Date: Thu Mar 14 17:22:59 2019
> > New Revision: 356222
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=356222=rev
> > Log:
> > [analyzer] Support C++17 aggregates with bases without
> > constructors.
> >
> > RegionStore now knows how to bind a nonloc::CompoundVal
> > that represents the
> > value of an aggregate initializer when it has its initial
> > segment of sub-values
> > correspond to base classes.
> >
> > Additionally, fixes the crash from pr40022.
> >
> > Differential Revision: https://reviews.llvm.org/D59054
> >
> > Modified:
> > cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
> > cfe/trunk/test/Analysis/array-struct-region.cpp
> >
> > Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
> > URL:
> > 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=356222=356221=356222=diff
> > 
> > 

[PATCH] D59376: [LibTooling] Add Transformer, a library for source-to-source transformations.

2019-03-19 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 4 inline comments as done.
ymandel added inline comments.



Comment at: clang/include/clang/Tooling/Refactoring/Transformer.h:54
+/// boolean expression language for constructing filters.
+class MatchFilter {
+public:

ilya-biryukov wrote:
> Intuitively, it feels that any filtering should be possible at the level of 
> the AST matchers. Is that not the case?
> Could you provide some motivating examples where AST matchers cannot be used 
> to nail down the matching nodes and we need `MatchFilter`? 
> 
> Please note I have limited experience with AST matchers, so there might be 
> some obvious things that I'm missing.
Good point. The examples I have would actually be perfectly suited to a 
matcher.  That said, there is not matcher support for a simple predicate of 
this form, along the lines of gtest's `Truly(predicate)`. I'll remove this and 
separately try to add something like `Truly` to the matchers.



Comment at: clang/include/clang/Tooling/Refactoring/Transformer.h:135
+// \endcode
+class RewriteRule {
+public:

ilya-biryukov wrote:
> Maybe consider separating the fluent API to build the rewrite rule from the 
> rewrite rule itself?
> 
> Not opposed to having the fluent builder API, this does look nice and seems 
> to nicely align with the matcher APIs.
> However, it is somewhat hard to figure out what can `RewriteRule` do 
> **after** it was built when looking at the code right now.
> ```
> class RewriteRule {
> public:
>   RewriteRule(DynTypedMatcher, TextGenerator Replacement, TextGenerator 
> Explanation);
> 
>   DynTypedMatcher matcher() const;
>   Expected replacement() const;
>   Expected explanation() const;
> };
> 
> struct RewriteRuleBuilder { // Having a better name than 'Builder' would be 
> nice.
>   RewriteRule finish() &&; // produce the final RewriteRule.
> 
>   template 
>   RewriteRuleBuilder (const TypedNodeId ,
>   NodePart Part = NodePart::Node) &;
>   RewriteRuleBuilder (TextGenerator Replacement) &;
>   RewriteRuleBuilder (TextGenerator Explanation) &;
> private:
>   RewriteRule RuleInProgress;
> };
> RewriteRuleBuilder makeRewriteRule();
> ```
I see your point, but do you think it might be enough to improve the comments 
on the class? My concern with a builder is the mental burden on the user of 
another concept (the builder) and the need for an extra `.build()` everywhere. 
To a lesser extent, I also don't love the cost of an extra copy, although I 
doubt it matters and I suppose we could support moves in the build method.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59376



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


Re: r356222 - [analyzer] Support C++17 aggregates with bases without constructors.

2019-03-19 Thread Alexander Kornienko via cfe-commits
On Tue, Mar 19, 2019 at 6:24 PM Artem Dergachev  wrote:

> Hi,
>
> I'll try to fix this ASAP!
>

Thanks!

> It sounds as if i don't have nearly enough C++17 codebases for testing,
> are there any obvious open-source projects that you could recommend?


No, but this particular example comes from C++11 code that just has subtly
different semantics in C++17. I guess, just adding -std=c++17 on existing
code (LLVM, for example ;) could help uncover some of the issues. I
believe, we can also continue providing reports in case CSA fails
assertions on our code.


> I'd
> love to try to reincarnate
>
> http://green.lab.llvm.org/green/view/Experimental/job/StaticAnalyzerBenchmarks/
> with those.
>
> On 3/19/19 9:37 AM, Alexander Kornienko wrote:
> > Filed this as https://bugs.llvm.org/show_bug.cgi?id=41142. Any hope
> > for a prompt fix here?
> >
> > On Tue, Mar 19, 2019 at 5:34 PM Alexander Kornienko  > > wrote:
> >
> > A reduced test case:
> > $ cat test-RegionStoreManager__bindStruct.cc
> > struct a {};
> > class b : a {};
> > b c() { b d{c()}; }
> > $ ./clang-tidy -checks="-*,clang-analyzer*"
> > test-RegionStoreManager__bindStruct.cc -- -std=c++17
> > assert.h assertion failed at
> > tools/clang/lib/StaticAnalyzer/Core/RegionStore.cpp:2362 in
> > (anonymous namespace)::RegionBindingsRef (anonym
> > ous
> > namespace)::RegionStoreManager::bindStruct(RegionBindingsConstRef,
> > const clang::ento::TypedValueRegion *, clang::ento::SVal):
> > CRD->isAggregate() && "Non-aggregates are constructed with a
> > constructor!"
> > @ 0x559908170326  __assert_fail
> > @ 0x5599068d4854  (anonymous
> > namespace)::RegionStoreManager::bindStruct()
> > @ 0x5599068c93c8  (anonymous
> > namespace)::RegionStoreManager::Bind()
> > @ 0x5599068b409f clang::ento::ProgramState::bindLoc()
> > @ 0x559906865935
> > clang::ento::ExprEngine::processPointerEscapedOnBind()
> > @ 0x55990685d4b3 clang::ento::ExprEngine::evalBind()
> > @ 0x559906872a43 clang::ento::ExprEngine::VisitDeclStmt()
> > @ 0x55990685c16f clang::ento::ExprEngine::Visit()
> > @ 0x559906858b1f clang::ento::ExprEngine::ProcessStmt()
> > @ 0x559906858808 clang::ento::ExprEngine::processCFGElement()
> > @ 0x55990684cb65 clang::ento::CoreEngine::HandlePostStmt()
> > @ 0x55990684bf5c clang::ento::CoreEngine::ExecuteWorkList()
> > @ 0x5599065b635b  (anonymous
> > namespace)::AnalysisConsumer::HandleCode()
> > @ 0x5599065a0135  (anonymous
> > namespace)::AnalysisConsumer::HandleTranslationUnit()
> > @ 0x559906bb7cbc
> > clang::MultiplexConsumer::HandleTranslationUnit()
> > @ 0x559906d226d4  clang::ParseAST()
> > @ 0x559906b98a83 clang::FrontendAction::Execute()
> > @ 0x559906b31cd1 clang::CompilerInstance::ExecuteAction()
> > @ 0x559906a9cf61
> > clang::tooling::FrontendActionFactory::runInvocation()
> > @ 0x55990620cc07
> > clang::tidy::runClangTidy()::ActionFactory::runInvocation()
> > @ 0x559906a9ccca
> > clang::tooling::ToolInvocation::runInvocation()
> > @ 0x559906a9c646 clang::tooling::ToolInvocation::run()
> > @ 0x559906a9ef22 clang::tooling::ClangTool::run()
> > @ 0x559906207ecf  clang::tidy::runClangTidy()
> > @ 0x559902d47c45  main
> >
> > On Tue, Mar 19, 2019 at 1:14 AM Alexander Kornienko
> > mailto:ale...@google.com>> wrote:
> >
> > On Fri, Mar 15, 2019 at 1:21 AM Artem Dergachev via
> > cfe-commits  > > wrote:
> >
> > Author: dergachev
> > Date: Thu Mar 14 17:22:59 2019
> > New Revision: 356222
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=356222=rev
> > Log:
> > [analyzer] Support C++17 aggregates with bases without
> > constructors.
> >
> > RegionStore now knows how to bind a nonloc::CompoundVal
> > that represents the
> > value of an aggregate initializer when it has its initial
> > segment of sub-values
> > correspond to base classes.
> >
> > Additionally, fixes the crash from pr40022.
> >
> > Differential Revision: https://reviews.llvm.org/D59054
> >
> > Modified:
> > cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
> > cfe/trunk/test/Analysis/array-struct-region.cpp
> >
> > Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
> > URL:
> >
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=356222=356221=356222=diff
> >
>  
> ==

[PATCH] D59302: [clangd] Surface diagnostics from headers inside main file

2019-03-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet planned changes to this revision.
kadircet added a comment.

- Limit per include directive
- Use hardcoded value for limit


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D59302



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


Re: r356222 - [analyzer] Support C++17 aggregates with bases without constructors.

2019-03-19 Thread Artem Dergachev via cfe-commits

Hi,

I'll try to fix this ASAP!

It sounds as if i don't have nearly enough C++17 codebases for testing, 
are there any obvious open-source projects that you could recommend? I'd 
love to try to reincarnate 
http://green.lab.llvm.org/green/view/Experimental/job/StaticAnalyzerBenchmarks/ 
with those.


On 3/19/19 9:37 AM, Alexander Kornienko wrote:
Filed this as https://bugs.llvm.org/show_bug.cgi?id=41142. Any hope 
for a prompt fix here?


On Tue, Mar 19, 2019 at 5:34 PM Alexander Kornienko > wrote:


A reduced test case:
$ cat test-RegionStoreManager__bindStruct.cc
struct a {};
class b : a {};
b c() { b d{c()}; }
$ ./clang-tidy -checks="-*,clang-analyzer*"
test-RegionStoreManager__bindStruct.cc -- -std=c++17
assert.h assertion failed at
tools/clang/lib/StaticAnalyzer/Core/RegionStore.cpp:2362 in
(anonymous namespace)::RegionBindingsRef (anonym
ous
namespace)::RegionStoreManager::bindStruct(RegionBindingsConstRef,
const clang::ento::TypedValueRegion *, clang::ento::SVal):
CRD->isAggregate() && "Non-aggregates are constructed with a
constructor!"
    @     0x559908170326  __assert_fail
    @     0x5599068d4854  (anonymous
namespace)::RegionStoreManager::bindStruct()
    @     0x5599068c93c8  (anonymous
namespace)::RegionStoreManager::Bind()
    @     0x5599068b409f clang::ento::ProgramState::bindLoc()
    @     0x559906865935
clang::ento::ExprEngine::processPointerEscapedOnBind()
    @     0x55990685d4b3 clang::ento::ExprEngine::evalBind()
    @     0x559906872a43 clang::ento::ExprEngine::VisitDeclStmt()
    @     0x55990685c16f clang::ento::ExprEngine::Visit()
    @     0x559906858b1f clang::ento::ExprEngine::ProcessStmt()
    @     0x559906858808 clang::ento::ExprEngine::processCFGElement()
    @     0x55990684cb65 clang::ento::CoreEngine::HandlePostStmt()
    @     0x55990684bf5c clang::ento::CoreEngine::ExecuteWorkList()
    @     0x5599065b635b  (anonymous
namespace)::AnalysisConsumer::HandleCode()
    @     0x5599065a0135  (anonymous
namespace)::AnalysisConsumer::HandleTranslationUnit()
    @     0x559906bb7cbc
clang::MultiplexConsumer::HandleTranslationUnit()
    @     0x559906d226d4  clang::ParseAST()
    @     0x559906b98a83 clang::FrontendAction::Execute()
    @     0x559906b31cd1 clang::CompilerInstance::ExecuteAction()
    @     0x559906a9cf61
clang::tooling::FrontendActionFactory::runInvocation()
    @     0x55990620cc07
clang::tidy::runClangTidy()::ActionFactory::runInvocation()
    @     0x559906a9ccca
clang::tooling::ToolInvocation::runInvocation()
    @     0x559906a9c646 clang::tooling::ToolInvocation::run()
    @     0x559906a9ef22 clang::tooling::ClangTool::run()
    @     0x559906207ecf  clang::tidy::runClangTidy()
    @     0x559902d47c45  main

On Tue, Mar 19, 2019 at 1:14 AM Alexander Kornienko
mailto:ale...@google.com>> wrote:

On Fri, Mar 15, 2019 at 1:21 AM Artem Dergachev via
cfe-commits mailto:cfe-commits@lists.llvm.org>> wrote:

Author: dergachev
Date: Thu Mar 14 17:22:59 2019
New Revision: 356222

URL: http://llvm.org/viewvc/llvm-project?rev=356222=rev
Log:
[analyzer] Support C++17 aggregates with bases without
constructors.

RegionStore now knows how to bind a nonloc::CompoundVal
that represents the
value of an aggregate initializer when it has its initial
segment of sub-values
correspond to base classes.

Additionally, fixes the crash from pr40022.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
cfe/trunk/test/Analysis/array-struct-region.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=356222=356221=356222=diff

==
--- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
(original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Thu
Mar 14 17:22:59 2019
@@ -2334,12 +2334,57 @@ RegionBindingsRef
RegionStoreManager::bi
   if (V.isUnknown() || !V.getAs())
     return bindAggregate(B, R, UnknownVal());

+  // The raw CompoundVal is essentially a symbolic
InitListExpr: an (immutable)
+  // list of other values. It appears pretty much only
when there's an actual
+  // initializer list expression in the program, and the
analyzer tries to
+  // unwrap it as 

[PATCH] D59544: [OpenCL] Minor improvements in default header testing

2019-03-19 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356479: [OpenCL] Minor improvements in default header 
testing (authored by stulova, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59544?vs=191289=191341#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59544

Files:
  cfe/trunk/test/Headers/opencl-c-header.cl


Index: cfe/trunk/test/Headers/opencl-c-header.cl
===
--- cfe/trunk/test/Headers/opencl-c-header.cl
+++ cfe/trunk/test/Headers/opencl-c-header.cl
@@ -53,15 +53,14 @@
 // CHECK: _Z16convert_char_rtec
 // CHECK-NOT: _Z3ctzc
 // CHECK20: _Z3ctzc
-// CHECK20-NOT: _Z16convert_char_rtec
+// CHECK20: _Z16convert_char_rtec
 char f(char x) {
-#if !defined(__OPENCL_CPP_VERSION__) && (__OPENCL_C_VERSION__ != 
CL_VERSION_2_0)
-  return convert_char_rte(x);
-
-#else //__OPENCL_C_VERSION__
+// Check functionality from OpenCL 2.0 onwards
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
   ndrange_t t;
-  return ctz(x);
+  x = ctz(x);
 #endif //__OPENCL_C_VERSION__
+  return convert_char_rte(x);
 }
 
 // Verify that a builtin using a write_only image3d_t type is available


Index: cfe/trunk/test/Headers/opencl-c-header.cl
===
--- cfe/trunk/test/Headers/opencl-c-header.cl
+++ cfe/trunk/test/Headers/opencl-c-header.cl
@@ -53,15 +53,14 @@
 // CHECK: _Z16convert_char_rtec
 // CHECK-NOT: _Z3ctzc
 // CHECK20: _Z3ctzc
-// CHECK20-NOT: _Z16convert_char_rtec
+// CHECK20: _Z16convert_char_rtec
 char f(char x) {
-#if !defined(__OPENCL_CPP_VERSION__) && (__OPENCL_C_VERSION__ != CL_VERSION_2_0)
-  return convert_char_rte(x);
-
-#else //__OPENCL_C_VERSION__
+// Check functionality from OpenCL 2.0 onwards
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
   ndrange_t t;
-  return ctz(x);
+  x = ctz(x);
 #endif //__OPENCL_C_VERSION__
+  return convert_char_rte(x);
 }
 
 // Verify that a builtin using a write_only image3d_t type is available
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r356480 - [OPENMP]Remove unused parameter, NFC.

2019-03-19 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Mar 19 10:09:52 2019
New Revision: 356480

URL: http://llvm.org/viewvc/llvm-project?rev=356480=rev
Log:
[OPENMP]Remove unused parameter, NFC.

Parameter CodeGenModule  is not required for CGOpenMPRuntime member
functions, since class holds the reference to the CGM.

Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=356480=356479=356480=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Tue Mar 19 10:09:52 2019
@@ -2574,5 +2574,5 @@ void CodeGenModule::EmitOMPDeclareMapper
 }
 
 void CodeGenModule::EmitOMPRequiresDecl(const OMPRequiresDecl *D) {
-  getOpenMPRuntime().checkArchForUnifiedAddressing(*this, D);
+  getOpenMPRuntime().checkArchForUnifiedAddressing(D);
 }

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=356480=356479=356480=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue Mar 19 10:09:52 2019
@@ -5499,9 +5499,9 @@ static void emitReductionCombiner(CodeGe
 }
 
 llvm::Function *CGOpenMPRuntime::emitReductionFunction(
-CodeGenModule , SourceLocation Loc, llvm::Type *ArgsType,
-ArrayRef Privates, ArrayRef LHSExprs,
-ArrayRef RHSExprs, ArrayRef ReductionOps) {
+SourceLocation Loc, llvm::Type *ArgsType, ArrayRef Privates,
+ArrayRef LHSExprs, ArrayRef RHSExprs,
+ArrayRef ReductionOps) {
   ASTContext  = CGM.getContext();
 
   // void reduction_func(void *LHSArg, void *RHSArg);
@@ -5712,8 +5712,8 @@ void CGOpenMPRuntime::emitReduction(Code
 
   // 2. Emit reduce_func().
   llvm::Function *ReductionFn = emitReductionFunction(
-  CGM, Loc, CGF.ConvertTypeForMem(ReductionArrayTy)->getPointerTo(),
-  Privates, LHSExprs, RHSExprs, ReductionOps);
+  Loc, CGF.ConvertTypeForMem(ReductionArrayTy)->getPointerTo(), Privates,
+  LHSExprs, RHSExprs, ReductionOps);
 
   // 3. Create static kmp_critical_name lock = { 0 };
   std::string Name = getName({"reduction"});

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=356480=356479=356480=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Tue Mar 19 10:09:52 2019
@@ -1229,7 +1229,7 @@ public:
   /// \param RHSExprs List of RHS in \a ReductionOps reduction operations.
   /// \param ReductionOps List of reduction operations in form 'LHS binop RHS'
   /// or 'operator binop(LHS, RHS)'.
-  llvm::Function *emitReductionFunction(CodeGenModule , SourceLocation Loc,
+  llvm::Function *emitReductionFunction(SourceLocation Loc,
 llvm::Type *ArgsType,
 ArrayRef Privates,
 ArrayRef LHSExprs,
@@ -1597,8 +1597,7 @@ public:
 
   /// Perform check on requires decl to ensure that target architecture
   /// supports unified addressing
-  virtual void checkArchForUnifiedAddressing(CodeGenModule ,
- const OMPRequiresDecl *D) const {}
+  virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) const {}
 };
 
 /// Class supports emissionof SIMD-only code.

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=356480=356479=356480=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Tue Mar 19 10:09:52 2019
@@ -4316,8 +4316,8 @@ void CGOpenMPRuntimeNVPTX::emitReduction
   llvm::Value *RL = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
   ReductionList.getPointer(), CGF.VoidPtrTy);
   llvm::Function *ReductionFn = emitReductionFunction(
-  CGM, Loc, CGF.ConvertTypeForMem(ReductionArrayTy)->getPointerTo(),
-  Privates, LHSExprs, RHSExprs, ReductionOps);
+  Loc, CGF.ConvertTypeForMem(ReductionArrayTy)->getPointerTo(), Privates,
+  LHSExprs, RHSExprs, ReductionOps);
   llvm::Value *ReductionArrayTySize = CGF.getTypeSize(ReductionArrayTy);
   llvm::Function *ShuffleAndReduceFn = emitShuffleAndReduceFunction(
   CGM, Privates, ReductionArrayTy, ReductionFn, Loc);
@@ -4861,7 +4861,7 @@ static CudaArch getCudaArch(CodeGenModul
 /// Check 

r356479 - [OpenCL] Minor improvements in default header testing

2019-03-19 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Tue Mar 19 10:09:06 2019
New Revision: 356479

URL: http://llvm.org/viewvc/llvm-project?rev=356479=rev
Log:
[OpenCL] Minor improvements in default header testing

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


Modified:
cfe/trunk/test/Headers/opencl-c-header.cl

Modified: cfe/trunk/test/Headers/opencl-c-header.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/opencl-c-header.cl?rev=356479=356478=356479=diff
==
--- cfe/trunk/test/Headers/opencl-c-header.cl (original)
+++ cfe/trunk/test/Headers/opencl-c-header.cl Tue Mar 19 10:09:06 2019
@@ -53,15 +53,14 @@
 // CHECK: _Z16convert_char_rtec
 // CHECK-NOT: _Z3ctzc
 // CHECK20: _Z3ctzc
-// CHECK20-NOT: _Z16convert_char_rtec
+// CHECK20: _Z16convert_char_rtec
 char f(char x) {
-#if !defined(__OPENCL_CPP_VERSION__) && (__OPENCL_C_VERSION__ != 
CL_VERSION_2_0)
-  return convert_char_rte(x);
-
-#else //__OPENCL_C_VERSION__
+// Check functionality from OpenCL 2.0 onwards
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
   ndrange_t t;
-  return ctz(x);
+  x = ctz(x);
 #endif //__OPENCL_C_VERSION__
+  return convert_char_rte(x);
 }
 
 // Verify that a builtin using a write_only image3d_t type is available


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


[PATCH] D59360: [clang-tidy] Fix more false positives for bugprone-string-integer-assignment

2019-03-19 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp:115
+Expr::EvalResult EvalResult;
+if (!E->EvaluateAsInt(EvalResult, Ctx, Expr::SE_AllowSideEffects))
+  return false;

courbet wrote:
> alexfh wrote:
> > I believe you should also check (or assert) that `E` is not 
> > instantiation-dependent before running the evaluator.
> Interesting. AFAICT if I don't check that , I end up warning in the cases 
> when the instantiation does result in a too large constant, which is what we 
> want (the user should add a cast if they want to silence this). 
IIUC, expression evaluation is just not supposed to be used on 
instantiation-dependent expressions. I've recently fixed a related crash 
(https://reviews.llvm.org/rL355401). I guess, there's a similar possibility 
here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59360



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


[PATCH] D59367: [Sema] Adjust address space of operands in remaining builtin operators

2019-03-19 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D59367#1434353 , @rjmccall wrote:

> This patch LGTM.
>
> You might consider adding tests for weird cases like class types with 
> conversion operators to reference types.  To a certain extent that sort of 
> thing is unimplementable because the space of address spaces is infinite, so 
> we can't fall back on adding a candidate for every possible address space; 
> but even if we don't plan on addressing it, we can test our current behavior 
> to check that we don't do something unexpected (like crash or give a 
> nonsensical diagnostic).


Thanks for the suggestion. I will look into this!


Repository:
  rC Clang

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

https://reviews.llvm.org/D59367



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


[PATCH] D59367: [Sema] Adjust address space of operands in remaining builtin operators

2019-03-19 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC356475: [Sema] Adjust addr space of reference operand in 
compound assignment (authored by stulova, committed by ).
Herald added a subscriber: kristina.
Herald added a project: clang.

Repository:
  rC Clang

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

https://reviews.llvm.org/D59367

Files:
  lib/Sema/SemaOverload.cpp
  test/CodeGenOpenCLCXX/addrspace-operators.cl


Index: test/CodeGenOpenCLCXX/addrspace-operators.cl
===
--- test/CodeGenOpenCLCXX/addrspace-operators.cl
+++ test/CodeGenOpenCLCXX/addrspace-operators.cl
@@ -14,6 +14,8 @@
 };
 
 __global E globE;
+volatile __global int globVI;
+__global int globI;
 //CHECK-LABEL: define spir_func void @_Z3barv()
 void bar() {
   C c;
@@ -25,13 +27,18 @@
   c.OrAssign(a);
 
   E e;
-  // CHECK: store i32 1, i32* %e
+  //CHECK: store i32 1, i32* %e
   e = b;
-  // CHECK: store i32 0, i32 addrspace(1)* @globE
+  //CHECK: store i32 0, i32 addrspace(1)* @globE
   globE = a;
-  // FIXME: Sema fails here because it thinks the types are incompatible.
-  //e = b;
-  //globE = a;
+  //CHECK: store i32 %or, i32 addrspace(1)* @globI
+  globI |= b;
+  //CHECK: store i32 %add, i32 addrspace(1)* @globI
+  globI += a;
+  //CHECK: store volatile i32 %and, i32 addrspace(1)* @globVI
+  globVI &= b;
+  //CHECK: store volatile i32 %sub, i32 addrspace(1)* @globVI
+  globVI -= a;
 }
 
 //CHECK: define linkonce_odr void @_ZNU3AS41C6AssignE1E(%class.C addrspace(4)* 
%this, i32 %e)
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -8513,17 +8513,16 @@
Right < LastPromotedArithmeticType; ++Right) {
 QualType ParamTypes[2];
 ParamTypes[1] = ArithmeticTypes[Right];
-
+auto LeftBaseTy = AdjustAddressSpaceForBuiltinOperandType(
+S, ArithmeticTypes[Left], Args[0]);
 // Add this built-in operator as a candidate (VQ is empty).
-ParamTypes[0] =
-  S.Context.getLValueReferenceType(ArithmeticTypes[Left]);
+ParamTypes[0] = S.Context.getLValueReferenceType(LeftBaseTy);
 S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet,
   /*IsAssigmentOperator=*/isEqualOp);
 
 // Add this built-in operator as a candidate (VQ is 'volatile').
 if (VisibleTypeConversionsQuals.hasVolatile()) {
-  ParamTypes[0] =
-S.Context.getVolatileType(ArithmeticTypes[Left]);
+  ParamTypes[0] = S.Context.getVolatileType(LeftBaseTy);
   ParamTypes[0] = S.Context.getLValueReferenceType(ParamTypes[0]);
   S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet,
 /*IsAssigmentOperator=*/isEqualOp);
@@ -8579,15 +8578,14 @@
Right < LastPromotedIntegralType; ++Right) {
 QualType ParamTypes[2];
 ParamTypes[1] = ArithmeticTypes[Right];
-
+auto LeftBaseTy = AdjustAddressSpaceForBuiltinOperandType(
+S, ArithmeticTypes[Left], Args[0]);
 // Add this built-in operator as a candidate (VQ is empty).
-ParamTypes[0] = S.Context.getLValueReferenceType(
-AdjustAddressSpaceForBuiltinOperandType(S, ArithmeticTypes[Left],
-Args[0]));
+ParamTypes[0] = S.Context.getLValueReferenceType(LeftBaseTy);
 S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);
 if (VisibleTypeConversionsQuals.hasVolatile()) {
   // Add this built-in operator as a candidate (VQ is 'volatile').
-  ParamTypes[0] = ArithmeticTypes[Left];
+  ParamTypes[0] = LeftBaseTy;
   ParamTypes[0] = S.Context.getVolatileType(ParamTypes[0]);
   ParamTypes[0] = S.Context.getLValueReferenceType(ParamTypes[0]);
   S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);


Index: test/CodeGenOpenCLCXX/addrspace-operators.cl
===
--- test/CodeGenOpenCLCXX/addrspace-operators.cl
+++ test/CodeGenOpenCLCXX/addrspace-operators.cl
@@ -14,6 +14,8 @@
 };
 
 __global E globE;
+volatile __global int globVI;
+__global int globI;
 //CHECK-LABEL: define spir_func void @_Z3barv()
 void bar() {
   C c;
@@ -25,13 +27,18 @@
   c.OrAssign(a);
 
   E e;
-  // CHECK: store i32 1, i32* %e
+  //CHECK: store i32 1, i32* %e
   e = b;
-  // CHECK: store i32 0, i32 addrspace(1)* @globE
+  //CHECK: store i32 0, i32 addrspace(1)* @globE
   globE = a;
-  // FIXME: Sema fails here because it thinks the types are incompatible.
-  //e = b;
-  //globE = a;
+  //CHECK: store i32 %or, i32 addrspace(1)* @globI
+  globI |= b;
+  //CHECK: store i32 %add, i32 addrspace(1)* @globI
+  globI += a;
+  //CHECK: store volatile i32 %and, i32 addrspace(1)* @globVI
+  globVI &= b;
+  //CHECK: store 

r356475 - [Sema] Adjust addr space of reference operand in compound assignment

2019-03-19 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Tue Mar 19 09:50:21 2019
New Revision: 356475

URL: http://llvm.org/viewvc/llvm-project?rev=356475=rev
Log:
[Sema] Adjust addr space of reference operand in compound assignment

When we create overloads for the builtin compound assignment operators
we need to preserve address space for the reference operand taking it
from the argument that is passed in.

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


Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/CodeGenOpenCLCXX/addrspace-operators.cl

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=356475=356474=356475=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Mar 19 09:50:21 2019
@@ -8513,17 +8513,16 @@ public:
Right < LastPromotedArithmeticType; ++Right) {
 QualType ParamTypes[2];
 ParamTypes[1] = ArithmeticTypes[Right];
-
+auto LeftBaseTy = AdjustAddressSpaceForBuiltinOperandType(
+S, ArithmeticTypes[Left], Args[0]);
 // Add this built-in operator as a candidate (VQ is empty).
-ParamTypes[0] =
-  S.Context.getLValueReferenceType(ArithmeticTypes[Left]);
+ParamTypes[0] = S.Context.getLValueReferenceType(LeftBaseTy);
 S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet,
   /*IsAssigmentOperator=*/isEqualOp);
 
 // Add this built-in operator as a candidate (VQ is 'volatile').
 if (VisibleTypeConversionsQuals.hasVolatile()) {
-  ParamTypes[0] =
-S.Context.getVolatileType(ArithmeticTypes[Left]);
+  ParamTypes[0] = S.Context.getVolatileType(LeftBaseTy);
   ParamTypes[0] = S.Context.getLValueReferenceType(ParamTypes[0]);
   S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet,
 /*IsAssigmentOperator=*/isEqualOp);
@@ -8579,15 +8578,14 @@ public:
Right < LastPromotedIntegralType; ++Right) {
 QualType ParamTypes[2];
 ParamTypes[1] = ArithmeticTypes[Right];
-
+auto LeftBaseTy = AdjustAddressSpaceForBuiltinOperandType(
+S, ArithmeticTypes[Left], Args[0]);
 // Add this built-in operator as a candidate (VQ is empty).
-ParamTypes[0] = S.Context.getLValueReferenceType(
-AdjustAddressSpaceForBuiltinOperandType(S, ArithmeticTypes[Left],
-Args[0]));
+ParamTypes[0] = S.Context.getLValueReferenceType(LeftBaseTy);
 S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);
 if (VisibleTypeConversionsQuals.hasVolatile()) {
   // Add this built-in operator as a candidate (VQ is 'volatile').
-  ParamTypes[0] = ArithmeticTypes[Left];
+  ParamTypes[0] = LeftBaseTy;
   ParamTypes[0] = S.Context.getVolatileType(ParamTypes[0]);
   ParamTypes[0] = S.Context.getLValueReferenceType(ParamTypes[0]);
   S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);

Modified: cfe/trunk/test/CodeGenOpenCLCXX/addrspace-operators.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCLCXX/addrspace-operators.cl?rev=356475=356474=356475=diff
==
--- cfe/trunk/test/CodeGenOpenCLCXX/addrspace-operators.cl (original)
+++ cfe/trunk/test/CodeGenOpenCLCXX/addrspace-operators.cl Tue Mar 19 09:50:21 
2019
@@ -14,6 +14,8 @@ public:
 };
 
 __global E globE;
+volatile __global int globVI;
+__global int globI;
 //CHECK-LABEL: define spir_func void @_Z3barv()
 void bar() {
   C c;
@@ -25,13 +27,18 @@ void bar() {
   c.OrAssign(a);
 
   E e;
-  // CHECK: store i32 1, i32* %e
+  //CHECK: store i32 1, i32* %e
   e = b;
-  // CHECK: store i32 0, i32 addrspace(1)* @globE
+  //CHECK: store i32 0, i32 addrspace(1)* @globE
   globE = a;
-  // FIXME: Sema fails here because it thinks the types are incompatible.
-  //e = b;
-  //globE = a;
+  //CHECK: store i32 %or, i32 addrspace(1)* @globI
+  globI |= b;
+  //CHECK: store i32 %add, i32 addrspace(1)* @globI
+  globI += a;
+  //CHECK: store volatile i32 %and, i32 addrspace(1)* @globVI
+  globVI &= b;
+  //CHECK: store volatile i32 %sub, i32 addrspace(1)* @globVI
+  globVI -= a;
 }
 
 //CHECK: define linkonce_odr void @_ZNU3AS41C6AssignE1E(%class.C addrspace(4)* 
%this, i32 %e)


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


[PATCH] D59540: [clang-tidy] [PR41119] readability-identifier-naming incorrectly fixes lambda capture

2019-03-19 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:790
   if (const auto *DeclRef = Result.Nodes.getNodeAs("declRef")) {
-SourceRange Range = DeclRef->getNameInfo().getSourceRange();
-addUsage(NamingCheckFailures, DeclRef->getDecl(), Range,
- Result.SourceManager);
-return;
+const auto  = Result.Context->getParents(*DeclRef);
+bool LambdaDeclRef = false;

Type is not obvious, so auto should not be used.



Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:797
+  if (ST && isa(ST)) {
+const auto  = Result.Context->getParents(*ST);
+if (!CastParents.empty())

Type is not obvious, so auto should not be used.


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

https://reviews.llvm.org/D59540



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


[PATCH] D59449: [clang-tidy] Integrate clang-tidy-diff.py machinery into run-clang-tidy.py

2019-03-19 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

How is this functionality different from the clang-tidy-diff.py script with the 
-j option being added in the other patch?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D59449



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


r356472 - [OPENMP] Codegen for local variables with the allocate pragma.

2019-03-19 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Mar 19 09:41:16 2019
New Revision: 356472

URL: http://llvm.org/viewvc/llvm-project?rev=356472=rev
Log:
[OPENMP] Codegen for local variables with the allocate pragma.

Added initial codegen for the local variables with the #pragma omp
allocate directive. Instead of allocating the variables on the stack,
__kmpc_alloc|__kmpc_free functions are used for memory (de-)allocation.

Added:
cfe/trunk/test/OpenMP/allocate_codegen.cpp
  - copied, changed from r356458, 
cfe/trunk/test/OpenMP/allocate_allocator_ast_print.cpp
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/test/OpenMP/allocate_allocator_ast_print.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=356472=356471=356472=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue Mar 19 09:41:16 2019
@@ -667,6 +667,10 @@ enum OpenMPRTLFunction {
   // Call to void *__kmpc_task_reduction_get_th_data(int gtid, void *tg, void
   // *d);
   OMPRTL__kmpc_task_reduction_get_th_data,
+  // Call to void *__kmpc_alloc(int gtid, size_t sz, const omp_allocator_t 
*al);
+  OMPRTL__kmpc_alloc,
+  // Call to void __kmpc_free(int gtid, void *ptr, const omp_allocator_t *al);
+  OMPRTL__kmpc_free,
 
   //
   // Offloading related calls
@@ -2195,6 +2199,26 @@ llvm::FunctionCallee CGOpenMPRuntime::cr
 FnTy, /*Name=*/"__kmpc_task_reduction_get_th_data");
 break;
   }
+  case OMPRTL__kmpc_alloc: {
+// Build to void *__kmpc_alloc(int gtid, size_t sz, const omp_allocator_t
+// *al);
+// omp_allocator_t type is void *.
+llvm::Type *TypeParams[] = {CGM.IntTy, CGM.SizeTy, CGM.VoidPtrPtrTy};
+auto *FnTy =
+llvm::FunctionType::get(CGM.VoidPtrTy, TypeParams, /*isVarArg=*/false);
+RTLFn = CGM.CreateRuntimeFunction(FnTy, /*Name=*/"__kmpc_alloc");
+break;
+  }
+  case OMPRTL__kmpc_free: {
+// Build to void __kmpc_free(int gtid, void *ptr, const omp_allocator_t
+// *al);
+// omp_allocator_t type is void *.
+llvm::Type *TypeParams[] = {CGM.IntTy, CGM.VoidPtrTy, CGM.VoidPtrPtrTy};
+auto *FnTy =
+llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg=*/false);
+RTLFn = CGM.CreateRuntimeFunction(FnTy, /*Name=*/"__kmpc_free");
+break;
+  }
   case OMPRTL__kmpc_push_target_tripcount: {
 // Build void __kmpc_push_target_tripcount(int64_t device_id, kmp_uint64
 // size);
@@ -9669,8 +9693,81 @@ Address CGOpenMPRuntime::getParameterAdd
   return CGF.GetAddrOfLocalVar(NativeParam);
 }
 
+namespace {
+/// Cleanup action for allocate support.
+class OMPAllocateCleanupTy final : public EHScopeStack::Cleanup {
+public:
+  static const int CleanupArgs = 3;
+
+private:
+  llvm::FunctionCallee RTLFn;
+  llvm::Value *Args[CleanupArgs];
+
+public:
+  OMPAllocateCleanupTy(llvm::FunctionCallee RTLFn,
+   ArrayRef CallArgs)
+  : RTLFn(RTLFn) {
+assert(CallArgs.size() == CleanupArgs &&
+   "Size of arguments does not match.");
+std::copy(CallArgs.begin(), CallArgs.end(), std::begin(Args));
+  }
+  void Emit(CodeGenFunction , Flags /*flags*/) override {
+if (!CGF.HaveInsertPoint())
+  return;
+CGF.EmitRuntimeCall(RTLFn, Args);
+  }
+};
+} // namespace
+
 Address CGOpenMPRuntime::getAddressOfLocalVariable(CodeGenFunction ,
const VarDecl *VD) {
+  const VarDecl *CVD = VD->getCanonicalDecl();
+  if (!CVD->hasAttr())
+return Address::invalid();
+  for (const Attr *A: CVD->getAttrs()) {
+if (const auto *AA = dyn_cast(A)) {
+  auto  = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn);
+  if (!Elem.second.ServiceInsertPt)
+setLocThreadIdInsertPt(CGF);
+  CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
+  CGF.Builder.SetInsertPoint(Elem.second.ServiceInsertPt);
+  llvm::Value *Size;
+  CharUnits Align = CGM.getContext().getDeclAlign(CVD);
+  if (CVD->getType()->isVariablyModifiedType()) {
+Size = CGF.getTypeSize(CVD->getType());
+Align = CGM.getContext().getTypeAlignInChars(CVD->getType());
+  } else {
+CharUnits Sz = CGM.getContext().getTypeSizeInChars(CVD->getType());
+Align = CGM.getContext().getDeclAlign(CVD);
+Size = CGM.getSize(Sz.alignTo(Align));
+  }
+  llvm::Value *ThreadID = getThreadID(CGF, CVD->getBeginLoc());
+  llvm::Value *Allocator;
+  if (const Expr *AllocExpr = AA->getAllocator()) {
+Allocator = CGF.EmitScalarExpr(AA->getAllocator());
+  } else {
+// Default allocator in libomp is nullptr.
+Allocator = llvm::ConstantPointerNull::get(CGM.VoidPtrPtrTy);
+  }
+  llvm::Value *Args[] = {ThreadID, Size, 

Re: r356222 - [analyzer] Support C++17 aggregates with bases without constructors.

2019-03-19 Thread Alexander Kornienko via cfe-commits
Filed this as https://bugs.llvm.org/show_bug.cgi?id=41142. Any hope for a
prompt fix here?

On Tue, Mar 19, 2019 at 5:34 PM Alexander Kornienko 
wrote:

> A reduced test case:
> $ cat test-RegionStoreManager__bindStruct.cc
> struct a {};
> class b : a {};
> b c() { b d{c()}; }
> $ ./clang-tidy -checks="-*,clang-analyzer*"
> test-RegionStoreManager__bindStruct.cc -- -std=c++17
> assert.h assertion failed at
> tools/clang/lib/StaticAnalyzer/Core/RegionStore.cpp:2362 in (anonymous
> namespace)::RegionBindingsRef (anonym
> ous namespace)::RegionStoreManager::bindStruct(RegionBindingsConstRef,
> const clang::ento::TypedValueRegion *, clang::ento::SVal):
> CRD->isAggregate() && "Non-aggregates are constructed with a constructor!"
> @ 0x559908170326  __assert_fail
> @ 0x5599068d4854  (anonymous
> namespace)::RegionStoreManager::bindStruct()
> @ 0x5599068c93c8  (anonymous namespace)::RegionStoreManager::Bind()
> @ 0x5599068b409f  clang::ento::ProgramState::bindLoc()
> @ 0x559906865935
> clang::ento::ExprEngine::processPointerEscapedOnBind()
> @ 0x55990685d4b3  clang::ento::ExprEngine::evalBind()
> @ 0x559906872a43  clang::ento::ExprEngine::VisitDeclStmt()
> @ 0x55990685c16f  clang::ento::ExprEngine::Visit()
> @ 0x559906858b1f  clang::ento::ExprEngine::ProcessStmt()
> @ 0x559906858808  clang::ento::ExprEngine::processCFGElement()
> @ 0x55990684cb65  clang::ento::CoreEngine::HandlePostStmt()
> @ 0x55990684bf5c  clang::ento::CoreEngine::ExecuteWorkList()
> @ 0x5599065b635b  (anonymous
> namespace)::AnalysisConsumer::HandleCode()
> @ 0x5599065a0135  (anonymous
> namespace)::AnalysisConsumer::HandleTranslationUnit()
> @ 0x559906bb7cbc  clang::MultiplexConsumer::HandleTranslationUnit()
> @ 0x559906d226d4  clang::ParseAST()
> @ 0x559906b98a83  clang::FrontendAction::Execute()
> @ 0x559906b31cd1  clang::CompilerInstance::ExecuteAction()
> @ 0x559906a9cf61
> clang::tooling::FrontendActionFactory::runInvocation()
> @ 0x55990620cc07
> clang::tidy::runClangTidy()::ActionFactory::runInvocation()
> @ 0x559906a9ccca  clang::tooling::ToolInvocation::runInvocation()
> @ 0x559906a9c646  clang::tooling::ToolInvocation::run()
> @ 0x559906a9ef22  clang::tooling::ClangTool::run()
> @ 0x559906207ecf  clang::tidy::runClangTidy()
> @ 0x559902d47c45  main
>
> On Tue, Mar 19, 2019 at 1:14 AM Alexander Kornienko 
> wrote:
>
>> On Fri, Mar 15, 2019 at 1:21 AM Artem Dergachev via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: dergachev
>>> Date: Thu Mar 14 17:22:59 2019
>>> New Revision: 356222
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=356222=rev
>>> Log:
>>> [analyzer] Support C++17 aggregates with bases without constructors.
>>>
>>> RegionStore now knows how to bind a nonloc::CompoundVal that represents
>>> the
>>> value of an aggregate initializer when it has its initial segment of
>>> sub-values
>>> correspond to base classes.
>>>
>>> Additionally, fixes the crash from pr40022.
>>>
>>> Differential Revision: https://reviews.llvm.org/D59054
>>>
>>> Modified:
>>> cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
>>> cfe/trunk/test/Analysis/array-struct-region.cpp
>>>
>>> Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=356222=356221=356222=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
>>> +++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Thu Mar 14
>>> 17:22:59 2019
>>> @@ -2334,12 +2334,57 @@ RegionBindingsRef RegionStoreManager::bi
>>>if (V.isUnknown() || !V.getAs())
>>>  return bindAggregate(B, R, UnknownVal());
>>>
>>> +  // The raw CompoundVal is essentially a symbolic InitListExpr: an
>>> (immutable)
>>> +  // list of other values. It appears pretty much only when there's an
>>> actual
>>> +  // initializer list expression in the program, and the analyzer tries
>>> to
>>> +  // unwrap it as soon as possible.
>>> +  // This code is where such unwrap happens: when the compound value is
>>> put into
>>> +  // the object that it was supposed to initialize (it's an
>>> *initializer* list,
>>> +  // after all), instead of binding the whole value to the whole
>>> object, we bind
>>> +  // sub-values to sub-objects. Sub-values may themselves be compound
>>> values,
>>> +  // and in this case the procedure becomes recursive.
>>> +  // FIXME: The annoying part about compound values is that they don't
>>> carry
>>> +  // any sort of information about which value corresponds to which
>>> sub-object.
>>> +  // It's simply a list of values in the middle of nowhere; we expect
>>> to match
>>> +  // them to sub-objects, essentially, "by index": first value binds to
>>> +  // the 

Re: r356222 - [analyzer] Support C++17 aggregates with bases without constructors.

2019-03-19 Thread Alexander Kornienko via cfe-commits
A reduced test case:
$ cat test-RegionStoreManager__bindStruct.cc
struct a {};
class b : a {};
b c() { b d{c()}; }
$ ./clang-tidy -checks="-*,clang-analyzer*"
test-RegionStoreManager__bindStruct.cc -- -std=c++17
assert.h assertion failed at
tools/clang/lib/StaticAnalyzer/Core/RegionStore.cpp:2362 in (anonymous
namespace)::RegionBindingsRef (anonym
ous namespace)::RegionStoreManager::bindStruct(RegionBindingsConstRef,
const clang::ento::TypedValueRegion *, clang::ento::SVal):
CRD->isAggregate() && "Non-aggregates are constructed with a constructor!"
@ 0x559908170326  __assert_fail
@ 0x5599068d4854  (anonymous
namespace)::RegionStoreManager::bindStruct()
@ 0x5599068c93c8  (anonymous namespace)::RegionStoreManager::Bind()
@ 0x5599068b409f  clang::ento::ProgramState::bindLoc()
@ 0x559906865935
clang::ento::ExprEngine::processPointerEscapedOnBind()
@ 0x55990685d4b3  clang::ento::ExprEngine::evalBind()
@ 0x559906872a43  clang::ento::ExprEngine::VisitDeclStmt()
@ 0x55990685c16f  clang::ento::ExprEngine::Visit()
@ 0x559906858b1f  clang::ento::ExprEngine::ProcessStmt()
@ 0x559906858808  clang::ento::ExprEngine::processCFGElement()
@ 0x55990684cb65  clang::ento::CoreEngine::HandlePostStmt()
@ 0x55990684bf5c  clang::ento::CoreEngine::ExecuteWorkList()
@ 0x5599065b635b  (anonymous
namespace)::AnalysisConsumer::HandleCode()
@ 0x5599065a0135  (anonymous
namespace)::AnalysisConsumer::HandleTranslationUnit()
@ 0x559906bb7cbc  clang::MultiplexConsumer::HandleTranslationUnit()
@ 0x559906d226d4  clang::ParseAST()
@ 0x559906b98a83  clang::FrontendAction::Execute()
@ 0x559906b31cd1  clang::CompilerInstance::ExecuteAction()
@ 0x559906a9cf61
clang::tooling::FrontendActionFactory::runInvocation()
@ 0x55990620cc07
clang::tidy::runClangTidy()::ActionFactory::runInvocation()
@ 0x559906a9ccca  clang::tooling::ToolInvocation::runInvocation()
@ 0x559906a9c646  clang::tooling::ToolInvocation::run()
@ 0x559906a9ef22  clang::tooling::ClangTool::run()
@ 0x559906207ecf  clang::tidy::runClangTidy()
@ 0x559902d47c45  main

On Tue, Mar 19, 2019 at 1:14 AM Alexander Kornienko 
wrote:

> On Fri, Mar 15, 2019 at 1:21 AM Artem Dergachev via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: dergachev
>> Date: Thu Mar 14 17:22:59 2019
>> New Revision: 356222
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=356222=rev
>> Log:
>> [analyzer] Support C++17 aggregates with bases without constructors.
>>
>> RegionStore now knows how to bind a nonloc::CompoundVal that represents
>> the
>> value of an aggregate initializer when it has its initial segment of
>> sub-values
>> correspond to base classes.
>>
>> Additionally, fixes the crash from pr40022.
>>
>> Differential Revision: https://reviews.llvm.org/D59054
>>
>> Modified:
>> cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
>> cfe/trunk/test/Analysis/array-struct-region.cpp
>>
>> Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=356222=356221=356222=diff
>>
>> ==
>> --- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
>> +++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Thu Mar 14 17:22:59
>> 2019
>> @@ -2334,12 +2334,57 @@ RegionBindingsRef RegionStoreManager::bi
>>if (V.isUnknown() || !V.getAs())
>>  return bindAggregate(B, R, UnknownVal());
>>
>> +  // The raw CompoundVal is essentially a symbolic InitListExpr: an
>> (immutable)
>> +  // list of other values. It appears pretty much only when there's an
>> actual
>> +  // initializer list expression in the program, and the analyzer tries
>> to
>> +  // unwrap it as soon as possible.
>> +  // This code is where such unwrap happens: when the compound value is
>> put into
>> +  // the object that it was supposed to initialize (it's an
>> *initializer* list,
>> +  // after all), instead of binding the whole value to the whole object,
>> we bind
>> +  // sub-values to sub-objects. Sub-values may themselves be compound
>> values,
>> +  // and in this case the procedure becomes recursive.
>> +  // FIXME: The annoying part about compound values is that they don't
>> carry
>> +  // any sort of information about which value corresponds to which
>> sub-object.
>> +  // It's simply a list of values in the middle of nowhere; we expect to
>> match
>> +  // them to sub-objects, essentially, "by index": first value binds to
>> +  // the first field, second value binds to the second field, etc.
>> +  // It would have been much safer to organize non-lazy compound values
>> as
>> +  // a mapping from fields/bases to values.
>>const nonloc::CompoundVal& CV = V.castAs();
>>nonloc::CompoundVal::iterator VI = CV.begin(), VE = CV.end();
>>

[PATCH] D57662: [clang-tidy] Parallelize clang-tidy-diff.py

2019-03-19 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG with a nit




Comment at: clang-tidy/tool/clang-tidy-diff.py:90
+  # the top level key 'Diagnostics' in the output yaml files
+  mergekey="Diagnostics"
+  merged=[]

nit: Spaces around operators, please


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

https://reviews.llvm.org/D57662



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


[PATCH] D59302: [clangd] Surface diagnostics from headers inside main file

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

- Show include stack in diagnostic message
- Point to exact include location


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D59302

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/Compiler.h
  clangd/Diagnostics.cpp
  clangd/Diagnostics.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/DiagnosticsTests.cpp

Index: unittests/clangd/DiagnosticsTests.cpp
===
--- unittests/clangd/DiagnosticsTests.cpp
+++ unittests/clangd/DiagnosticsTests.cpp
@@ -9,6 +9,7 @@
 #include "Annotations.h"
 #include "ClangdUnit.h"
 #include "SourceCode.h"
+#include "TestFS.h"
 #include "TestIndex.h"
 #include "TestTU.h"
 #include "index/MemIndex.h"
@@ -73,7 +74,6 @@
   return true;
 }
 
-
 // Helper function to make tests shorter.
 Position pos(int line, int character) {
   Position Res;
@@ -603,7 +603,174 @@
   "Add include \"x.h\" for symbol a::X");
 }
 
+ParsedAST
+build(const std::string , const llvm::StringMap ,
+  llvm::Optional LimitDiagsOutsideMainFile = llvm::None) {
+  std::vector Cmd = {"clang", MainFile.c_str()};
+  ParseInputs Inputs;
+  Inputs.CompileCommand.Filename = MainFile;
+  Inputs.CompileCommand.CommandLine = {Cmd.begin(), Cmd.end()};
+  Inputs.CompileCommand.Directory = testRoot();
+  Inputs.Contents = Files.lookup(MainFile);
+  Inputs.FS = buildTestFS(Files);
+  Inputs.Opts = ParseOptions();
+  Inputs.Opts.LimitDiagsOutsideMainFile = LimitDiagsOutsideMainFile;
+  auto PCHs = std::make_shared();
+  auto CI = buildCompilerInvocation(Inputs);
+  assert(CI && "Failed to build compilation invocation.");
+  auto Preamble =
+  buildPreamble(MainFile, *CI,
+/*OldPreamble=*/nullptr,
+/*OldCompileCommand=*/Inputs.CompileCommand, Inputs, PCHs,
+/*StoreInMemory=*/true, /*PreambleCallback=*/nullptr);
+  auto AST = buildAST(MainFile, createInvocationFromCommandLine(Cmd), Inputs,
+  Preamble, PCHs);
+  if (!AST.hasValue()) {
+ADD_FAILURE() << "Failed to build code:\n" << Files.lookup(MainFile);
+llvm_unreachable("Failed to build TestTU!");
+  }
+  return std::move(*AST);
+}
+
+TEST(DiagsInHeaders, DiagInsideHeader) {
+  Annotations Main(R"cpp(
+#include [["a.h"]]
+void foo() {})cpp");
+  std::string MainFile = testPath("main.cc");
+  llvm::StringMap Files = {{MainFile, Main.code()},
+{testPath("a.h"), "no_type_spec;"}};
+  auto FS = buildTestFS(Files);
+
+  EXPECT_THAT(build(MainFile, Files).getDiagnostics(),
+  UnorderedElementsAre(
+  Diag(Main.range(), "/clangd-test/a.h:1:1: C++ requires a "
+ "type specifier for all declarations")));
+}
+
+TEST(DiagsInHeaders, DiagInTransitiveInclude) {
+  Annotations Main(R"cpp(
+#include [["a.h"]]
+void foo() {})cpp");
+  std::string MainFile = testPath("main.cc");
+  llvm::StringMap Files = {{MainFile, Main.code()},
+{testPath("a.h"), "#include \"b.h\""},
+{testPath("b.h"), "no_type_spec;"}};
+  auto FS = buildTestFS(Files);
+
+  EXPECT_THAT(build(MainFile, Files).getDiagnostics(),
+  UnorderedElementsAre(
+  Diag(Main.range(),
+   "In file included from: "
+   "/clangd-test/a.h:1:10:\n/clangd-test/b.h:1:1: C++ "
+   "requires a type specifier for all declarations")));
+}
+
+TEST(DiagsInHeaders, DiagInMultipleHeaders) {
+  Annotations Main(R"cpp(
+#include $a[["a.h"]]
+#include $b[["b.h"]]
+void foo() {})cpp");
+  std::string MainFile = testPath("main.cc");
+  llvm::StringMap Files = {{MainFile, Main.code()},
+{testPath("a.h"), "no_type_spec;"},
+{testPath("b.h"), "no_type_spec;"}};
+  auto FS = buildTestFS(Files);
+
+  EXPECT_THAT(
+  build(MainFile, Files).getDiagnostics(),
+  UnorderedElementsAre(
+  Diag(Main.range("a"), "/clangd-test/a.h:1:1: C++ requires a type "
+"specifier for all declarations"),
+  Diag(Main.range("b"), "/clangd-test/b.h:1:1: C++ requires a type "
+"specifier for all declarations")));
+}
+
+TEST(DiagsInHeaders, PreferExpansionLocation) {
+  Annotations Main(R"cpp(
+#include [["a.h"]]
+#include "b.h"
+void foo() {})cpp");
+  std::string MainFile = testPath("main.cc");
+  llvm::StringMap Files = {
+  {MainFile, Main.code()},
+  {testPath("a.h"), "#include \"b.h\"\n"},
+  {testPath("b.h"), "#ifndef X\n#define X\nno_type_spec;\n#endif"}};
+  auto FS = 

[PATCH] D59540: [clang-tidy] [PR41119] readability-identifier-naming incorrectly fixes lambda capture

2019-03-19 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Thanks for fixing this! Could you expand the test a bit? See the inline comment.




Comment at: test/clang-tidy/readability-identifier-naming.cpp:506
+bool Foo() {
+  bool Columns=false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local 
variable 'Columns'

If the formatting is not critical for the logic of the test, please 
clang-format the new test code.



Comment at: test/clang-tidy/readability-identifier-naming.cpp:509
+// CHECK-FIXES: {{^}}  bool columns=false;
+  auto ptr=[&]{return Columns;}();
+// CHECK-FIXES: {{^}}  auto ptr=[&]{return columns;}();

Please add more tests with
  1) by value automatic captures
  2) manual captures by value
  3) manual captures by reference
  4) nested lambdas capturing the same variable

A bit more nested code inside the lambda would also be interesting (where the 
use of the variable would be wrapped in a couple of compound statements).


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

https://reviews.llvm.org/D59540



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


[PATCH] D59540: [clang-tidy] [PR41119] readability-identifier-naming incorrectly fixes lambda capture

2019-03-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 191311.
MyDeveloperDay added a comment.

Minor modification to improve the `[=]` case

`[]` and `[Columns]` are not yet fixed and will not be correctly 
renamed to `[]` and `[columns]`

But at least they are left unaltered


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

https://reviews.llvm.org/D59540

Files:
  clang-tidy/readability/IdentifierNamingCheck.cpp
  test/clang-tidy/readability-identifier-naming.cpp

Index: test/clang-tidy/readability-identifier-naming.cpp
===
--- test/clang-tidy/readability-identifier-naming.cpp
+++ test/clang-tidy/readability-identifier-naming.cpp
@@ -501,3 +501,43 @@
 // CHECK-FIXES: {{^}}int * const lc_PointerB = nullptr;{{$}}
 }
 
+
+bool Foo() {
+  bool Columns=false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns=false;
+  auto ptr=[&]{return Columns;}();
+// CHECK-FIXES: {{^}}  auto ptr=[&]{return columns;}();
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool Foo1() {
+  bool Columns=false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns=false;
+  auto ptr=[=]{return Columns;}();
+// CHECK-FIXES: {{^}}  auto ptr=[=]{return columns;}();
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool Foo2() {
+  bool Columns=false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns=false;
+  auto ptr=[]{return Columns;}();
+// XXX_CHECK-FIXES: {{^}}  auto ptr=[]{return columns;}();
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool Foo3() {
+  bool Columns=false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns=false;
+  auto ptr=[Columns]{return Columns;}();
+// XXX_CHECK-FIXES: {{^}}  auto ptr=[columns]{return columns;}();
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
Index: clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -396,7 +396,7 @@
 
   if (isa(D) && NamingStyles[SK_ObjcIvar])
 return SK_ObjcIvar;
-  
+
   if (isa(D) && NamingStyles[SK_Typedef])
 return SK_Typedef;
 
@@ -506,7 +506,7 @@
   return SK_ParameterPack;
 
 if (!Type.isNull() && Type.getTypePtr()->isAnyPointerType() && NamingStyles[SK_PointerParameter])
-return SK_PointerParameter;
+  return SK_PointerParameter;
 
 if (NamingStyles[SK_Parameter])
   return SK_Parameter;
@@ -557,7 +557,7 @@
 
 if (Decl->isStaticLocal() && NamingStyles[SK_StaticVariable])
   return SK_StaticVariable;
- 
+
 if (Decl->isLocalVarDecl() && Type.getTypePtr()->isAnyPointerType() && NamingStyles[SK_LocalPointer])
   return SK_LocalPointer;
 
@@ -787,10 +787,28 @@
   }
 
   if (const auto *DeclRef = Result.Nodes.getNodeAs("declRef")) {
-SourceRange Range = DeclRef->getNameInfo().getSourceRange();
-addUsage(NamingCheckFailures, DeclRef->getDecl(), Range,
- Result.SourceManager);
-return;
+const auto  = Result.Context->getParents(*DeclRef);
+bool LambdaDeclRef = false;
+
+if (!Parents.empty()) {
+  const Stmt *ST = Parents[0].get();
+  // Step over the ImplicitCastExpr
+  if (ST && isa(ST)) {
+const auto  = Result.Context->getParents(*ST);
+if (!CastParents.empty())
+  ST = CastParents[0].get();
+  }
+
+  if (ST && isa(ST))
+LambdaDeclRef = true;
+}
+
+if (!LambdaDeclRef) {
+  SourceRange Range = DeclRef->getNameInfo().getSourceRange();
+  addUsage(NamingCheckFailures, DeclRef->getDecl(), Range,
+   Result.SourceManager);
+  return;
+}
   }
 
   if (const auto *Decl = Result.Nodes.getNodeAs("decl")) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54978: Move the SMT API to LLVM

2019-03-19 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho marked an inline comment as done.
mikhail.ramalho added a comment.

Fixed.


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

https://reviews.llvm.org/D54978



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


[PATCH] D54978: Move the SMT API to LLVM

2019-03-19 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho updated this revision to Diff 191305.
mikhail.ramalho added a comment.

Fix copy-and-paste error.


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

https://reviews.llvm.org/D54978

Files:
  clang/CMakeLists.txt
  clang/cmake/modules/FindZ3.cmake
  clang/include/clang/Config/config.h.cmake
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTAPI.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/CMakeLists.txt
  clang/lib/StaticAnalyzer/Core/SMTConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  llvm/CMakeLists.txt
  llvm/cmake/modules/FindZ3.cmake
  llvm/cmake/modules/LLVMConfig.cmake.in
  llvm/include/llvm/Config/config.h.cmake
  llvm/include/llvm/Support/SMTAPI.h
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/Z3Solver.cpp

Index: llvm/lib/Support/Z3Solver.cpp
===
--- llvm/lib/Support/Z3Solver.cpp
+++ llvm/lib/Support/Z3Solver.cpp
@@ -1,4 +1,4 @@
-//== Z3ConstraintManager.cpp *- C++ -*--==//
+//== Z3Solver.cpp ---*- C++ -*--==//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,18 +6,14 @@
 //
 //===--===//
 
-#include "clang/Basic/TargetInfo.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Config/config.h"
+#include "llvm/Support/SMTAPI.h"
+#include 
 
-#include "clang/Config/config.h"
+using namespace llvm;
 
-using namespace clang;
-using namespace ento;
-
-#if CLANG_ANALYZER_WITH_Z3
+#if LLVM_WITH_Z3
 
 #include 
 
@@ -818,18 +814,13 @@
 
 #endif
 
-SMTSolverRef clang::ento::CreateZ3Solver() {
-#if CLANG_ANALYZER_WITH_Z3
+llvm::SMTSolverRef llvm::CreateZ3Solver() {
+#if LLVM_WITH_Z3
   return llvm::make_unique();
 #else
   llvm::report_fatal_error("Clang was not compiled with Z3 support, rebuild "
-   "with -DCLANG_ANALYZER_ENABLE_Z3_SOLVER=ON",
+   "with -DLLVM_ENABLE_Z3_SOLVER=ON",
false);
   return nullptr;
 #endif
 }
-
-std::unique_ptr
-ento::CreateZ3ConstraintManager(ProgramStateManager , SubEngine *Eng) {
-  return llvm::make_unique(Eng, StMgr.getSValBuilder());
-}
Index: llvm/lib/Support/CMakeLists.txt
===
--- llvm/lib/Support/CMakeLists.txt
+++ llvm/lib/Support/CMakeLists.txt
@@ -44,6 +44,13 @@
   set (delayload_flags delayimp -delayload:shell32.dll -delayload:ole32.dll)
 endif()
 
+# Link Z3 if the user wants to build it.
+if(LLVM_WITH_Z3)
+  set(Z3_LINK_FILES ${Z3_LIBRARIES})
+else()
+  set(Z3_LINK_FILES "")
+endif()
+
 add_llvm_library(LLVMSupport
   AArch64TargetParser.cpp
   ARMTargetParser.cpp
@@ -152,6 +159,7 @@
   regfree.c
   regstrlcpy.c
   xxhash.cpp
+  Z3Solver.cpp
 
 # System
   Atomic.cpp
@@ -177,7 +185,14 @@
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/ADT
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/Support
   ${Backtrace_INCLUDE_DIRS}
-  LINK_LIBS ${system_libs} ${delayload_flags}
+  LINK_LIBS ${system_libs} ${delayload_flags} ${Z3_LINK_FILES}
   )
 
 set_property(TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS "${system_libs}")
+
+if(LLVM_WITH_Z3)
+  target_include_directories(LLVMSupport SYSTEM
+PRIVATE
+${Z3_INCLUDE_DIR}
+)
+endif()
Index: llvm/include/llvm/Support/SMTAPI.h
===
--- llvm/include/llvm/Support/SMTAPI.h
+++ llvm/include/llvm/Support/SMTAPI.h
@@ -11,15 +11,16 @@
 //
 //===--===//
 
-#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SMTSOLVER_H
-#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SMTSOLVER_H
+#ifndef LLVM_SUPPORT_SMTAPI_H
+#define LLVM_SUPPORT_SMTAPI_H
 
-#include "clang/Basic/TargetInfo.h"
+#include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/FoldingSet.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
 
-namespace clang {
-namespace ento {
+namespace llvm {
 
 /// Generic base class for SMT sorts
 class SMTSort {
@@ -399,7 +400,6 @@
 /// Convenience method to create and Z3Solver object
 SMTSolverRef CreateZ3Solver();
 
-} // namespace ento
-} // namespace clang
+} // namespace llvm
 
 #endif
Index: llvm/include/llvm/Config/config.h.cmake

[PATCH] D59461: [analyzer] Fix an assertion failure if plugins added dependencies

2019-03-19 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware accepted this revision.
baloghadamsoftware added a comment.
This revision is now accepted and ready to land.

This one seems straightforward.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59461



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


[PATCH] D59540: [clang-tidy] [PR41119] readability-identifier-naming incorrectly fixes lambda capture

2019-03-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay planned changes to this revision.
MyDeveloperDay added a comment.

In D59540#1434837 , @JonasToth wrote:

> What happens on `[=]() ...`, direct capture `[]()...` and 
> `[Columns]()...`?


Thanks for the review... in answer to your question.. not great!


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

https://reviews.llvm.org/D59540



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


[PATCH] D45978: dllexport const variables must have external linkage.

2019-03-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

> Would you mind committing the changes please? Thanks.

Happy to do so! I've committed in r356458.


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

https://reviews.llvm.org/D45978



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


r356458 - Ensure that const variables declared at namespace scope correctly have external linkage when marked as dllexport and targeting the MSVC ABI.

2019-03-19 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Mar 19 07:53:52 2019
New Revision: 356458

URL: http://llvm.org/viewvc/llvm-project?rev=356458=rev
Log:
Ensure that const variables declared at namespace scope correctly have external 
linkage when marked as dllexport and targeting the MSVC ABI.

Patch thanks to Zahira Ammarguellat.

Added:
cfe/trunk/test/CodeGen/dllexport-1.c
cfe/trunk/test/Sema/dllexport-1.cpp
cfe/trunk/test/Sema/dllexport-2.cpp
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/dllexport.cpp
cfe/trunk/test/SemaCXX/dllimport.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=356458=356457=356458=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Mar 19 07:53:52 2019
@@ -5964,10 +5964,24 @@ static void checkAttributesAfterMerging(
   }
 
   if (const InheritableAttr *Attr = getDLLAttr()) {
+auto *VD = dyn_cast();
+bool IsAnonymousNS = false;
+bool IsMicrosoft = S.Context.getTargetInfo().getCXXABI().isMicrosoft();
+if (VD) {
+  const NamespaceDecl *NS = dyn_cast(VD->getDeclContext());
+  while (NS && !IsAnonymousNS) {
+IsAnonymousNS = NS->isAnonymousNamespace();
+NS = dyn_cast(NS->getParent());
+  }
+}
 // dll attributes require external linkage. Static locals may have external
 // linkage but still cannot be explicitly imported or exported.
-auto *VD = dyn_cast();
-if (!ND.isExternallyVisible() || (VD && VD->isStaticLocal())) {
+// In Microsoft mode, a variable defined in anonymous namespace must have
+// external linkage in order to be exported.
+bool AnonNSInMicrosoftMode = IsAnonymousNS && IsMicrosoft;
+if ((ND.isExternallyVisible() && AnonNSInMicrosoftMode) ||
+(!AnonNSInMicrosoftMode &&
+ (!ND.isExternallyVisible() || (VD && VD->isStaticLocal() {
   S.Diag(ND.getLocation(), diag::err_attribute_dll_not_extern)
 <<  << Attr;
   ND.setInvalidDecl();
@@ -11376,6 +11390,14 @@ void Sema::AddInitializerToDecl(Decl *Re
 !isTemplateInstantiation(VDecl->getTemplateSpecializationKind()))
   Diag(VDecl->getLocation(), diag::warn_extern_init);
 
+// In Microsoft C++ mode, a const variable defined in namespace scope has
+// external linkage by default if the variable is declared with
+// __declspec(dllexport).
+if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
+getLangOpts().CPlusPlus && VDecl->getType().isConstQualified() &&
+VDecl->hasAttr() && VDecl->getDefinition())
+  VDecl->setStorageClass(SC_Extern);
+
 // C99 6.7.8p4. All file scoped initializers need to be constant.
 if (!getLangOpts().CPlusPlus && !VDecl->isInvalidDecl())
   CheckForConstantInitializer(Init, DclT);

Added: cfe/trunk/test/CodeGen/dllexport-1.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/dllexport-1.c?rev=356458=auto
==
--- cfe/trunk/test/CodeGen/dllexport-1.c (added)
+++ cfe/trunk/test/CodeGen/dllexport-1.c Tue Mar 19 07:53:52 2019
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -fms-extensions 
-Wno-ignored-attributes -Wno-extern-initializer -o - %s | FileCheck %s 
-check-prefix CHECK-LNX
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -emit-llvm -fms-extensions 
-o - -DMSVC %s | FileCheck %s -check-prefix CHECK-MSVC
+
+// Export const variable.
+
+// CHECK-MSVC: @x = dso_local dllexport constant i32 3, align 4
+// CHECK-LNX: @x = constant i32 3, align 4
+
+// CHECK-MSVC: @z = dso_local constant i32 4, align 4
+// CHECK-LNX: @z = constant i32 4, align 4
+
+// CHECK-MSVC: @y = common dso_local dllexport global i32 0, align 4
+// CHECK-LNX: @y = common global i32 0, align 4
+
+__declspec(dllexport) int const x = 3;
+__declspec(dllexport) const int y;
+
+// expected-warning@+1 {{'extern' variable has an initializer}}
+extern int const z = 4;
+
+int main() {
+  int a = x + y + z;
+  return a;
+}

Added: cfe/trunk/test/Sema/dllexport-1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/dllexport-1.cpp?rev=356458=auto
==
--- cfe/trunk/test/Sema/dllexport-1.cpp (added)
+++ cfe/trunk/test/Sema/dllexport-1.cpp Tue Mar 19 07:53:52 2019
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -fms-extensions 
-verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fsyntax-only 
-fms-extensions -verify %s  -DMSVC
+
+// Export const variable initialization.
+
+#ifdef MSVC
+// expected-no-diagnostics
+#endif
+
+#ifndef MSVC
+// expected-warning@+2 {{__declspec attribute 'dllexport' is not supported}}
+#endif
+__declspec(dllexport) int const x = 3;
+
+namespace {
+namespace named {
+#ifndef MSVC
+// 

[PATCH] D57896: Variable names rule

2019-03-19 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added subscribers: chandlerc, Charusso.
Charusso added a comment.

In D57896#1406812 , @lattner wrote:

> I can understand Zach's position here, but LLDB has historically never 
> conformed to the general LLVM naming or other conventions due to its 
> heritage.  It should not be taken as precedent that the rest of the project 
> should follow.
>
> In any case, I think that it is best for this discussion to take place on the 
> llvm-dev list where it is likely to get the most visibility.  Would you mind 
> moving comments and discussions there?


Hey! Random Clang developer is here after this topic became a little-bit dead 
as not everyone subbed to LLVM dev-list. I think the best solution for every 
difficult question is to let the users decide their own future among all the 
projects. I would announce polls (https://reviews.llvm.org/vote/) and announce 
them on every dev-list.

I do not see any better solution to decide if we would code like `DRE`, `VD` 
versus `expr`, `decl` as @lattner would code. And I am not sure if everyone 
happy with `this_new_styling` as @chandlerc and @zturner would code. E.g. I am 
not happy because I know my if-statements would take two lines of code instead 
of one and it would be super-duper-mega ugly and difficult to read. Here is an 
example:

  static Optional
  getConcreteIntegerValue(const Expr *CondVarExpr, const ExplodedNode *N) {
  //...
if (const auto *DRE = dyn_cast_or_null(CondVarExpr)) {
  if (const auto *VD = dyn_cast_or_null(DRE->getDecl())) {
  //...
  }

would be:

  static Optional 
  |
  getConcreteIntegerValue(const Expr *cond_var_expr, const ExplodedNode *node) 
{  |
  //... 
  |
if (const auto *decl_ref_expr = 
dyn_cast_or_null(cond_var_expr)) {
  if (const auto *var_decl = 
dyn_cast_or_null(decl_ref_expr->getDecl())) {
  //... 
  |
  } whoops 
column-81 ~^

Hungarian notation on members and globals are cool idea. However, the notation 
is made without the `_` part, so I think `mMember` is better than `m_member` as 
we used to 80-column standard and it is waste of space and hurts your 
C-developer eyes. I would recommend `b` prefix to booleans as Unreal Engine 4 
styling is used to do that (`bIsCoolStyle`) and it is handy. It is useful 
because booleans usually has multiple prefixes: `has, have, is` and you would 
list all the booleans together in autocompletion. Yes, there is a problem: if 
the notation is not capital like the pure Hungarian notation then it is 
problematic to list and we are back to the `BIsCapitalLetter` and `MMember` 
CamelCase-world where we started (except one project). I think @lattner could 
say if it is useful as all the Apple projects based on those notations and 
could be annoying.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57896



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


[PATCH] D59546: [clang-format] structured binding in range for detected as Objective C

2019-03-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: djasper, klimek, JonasToth, reuk.
MyDeveloperDay added a project: clang-tools-extra.

Sometime after 6.0.0 and the current trunk 9.0.0 the following code would be 
considered as objective C and not C++

Reported by: https://twitter.com/mattgodbolt/status/1096188576503644160

$ clang-format.exe test.h
Configuration file(s) do(es) not support Objective-C: 
C:\clang\build\.clang-format

- test.h --

  #include 
  #include 
  
  std::vector> C;
  
  void foo()
  {
 for (auto && [A,B] : C)
 {
 std::string D = A + B;
 }
  }

The following code fixes this issue of incorrect detection


https://reviews.llvm.org/D59546

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12924,6 +12924,9 @@
 guessLanguage("foo.h", "[[abusing clang:fallthrough] bar];"));
   EXPECT_EQ(FormatStyle::LK_Cpp,
 guessLanguage("foo.h", "[[using gsl: suppress(\"type\")]];"));
+  EXPECT_EQ(
+  FormatStyle::LK_Cpp,
+  guessLanguage("foo.h", "for (auto &&[endpoint, stream] : streams_)"));
   EXPECT_EQ(
   FormatStyle::LK_Cpp,
   guessLanguage("foo.h",
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -410,7 +410,10 @@
  Parent->isUnaryOperator() ||
  // FIXME(bug 36976): ObjC return types shouldn't use TT_CastRParen.
  Parent->isOneOf(TT_ObjCForIn, TT_CastRParen) ||
- getBinOpPrecedence(Parent->Tok.getKind(), true, true) > 
prec::Unknown);
+ // for (auto && [A,B] : C)  && structure binding seen as 
ObjCMethodExpr
+ (Parent->isNot(tok::ampamp) &&
+  getBinOpPrecedence(Parent->Tok.getKind(), true, true) >
+  prec::Unknown));
 bool ColonFound = false;
 
 unsigned BindingIncrease = 1;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12924,6 +12924,9 @@
 guessLanguage("foo.h", "[[abusing clang:fallthrough] bar];"));
   EXPECT_EQ(FormatStyle::LK_Cpp,
 guessLanguage("foo.h", "[[using gsl: suppress(\"type\")]];"));
+  EXPECT_EQ(
+  FormatStyle::LK_Cpp,
+  guessLanguage("foo.h", "for (auto &&[endpoint, stream] : streams_)"));
   EXPECT_EQ(
   FormatStyle::LK_Cpp,
   guessLanguage("foo.h",
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -410,7 +410,10 @@
  Parent->isUnaryOperator() ||
  // FIXME(bug 36976): ObjC return types shouldn't use TT_CastRParen.
  Parent->isOneOf(TT_ObjCForIn, TT_CastRParen) ||
- getBinOpPrecedence(Parent->Tok.getKind(), true, true) > prec::Unknown);
+ // for (auto && [A,B] : C)  && structure binding seen as ObjCMethodExpr
+ (Parent->isNot(tok::ampamp) &&
+  getBinOpPrecedence(Parent->Tok.getKind(), true, true) >
+  prec::Unknown));
 bool ColonFound = false;
 
 unsigned BindingIncrease = 1;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59466: [clang-tidy] openmp-exception-escape - a new check

2019-03-19 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D59466#1434841 , 
@baloghadamsoftware wrote:

> Great work! Thank you! I only have minor comment: did you consider moving the 
> refactoring of `ExceptionAnalyzer` into a separate (prerequisite) patch?


Yes, absolutely, that will be separate patch.
I just wanted to finally post the check to show how it **finally** (*sigh*) 
comes together in the end.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D59466



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


Re: r352930 - [WebAssembly] Add an import_field function attribute

2019-03-19 Thread Aaron Ballman via cfe-commits
On Mon, Mar 18, 2019 at 7:08 PM Dan Gohman  wrote:
>
>
>
> On Fri, Mar 15, 2019 at 10:55 AM Aaron Ballman  wrote:
>>
>>
>> Ping.
>
>
> I apologize for the extraordinarily delays here. I've now posted a patch to 
> address the review comments here:
>
> https://reviews.llvm.org/D59520

Delays happen to all of us; thank you for addressing the comments -- I
appreciate it!

~Aaron

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


[PATCH] D59520: [WebAssembly] Address review comments on r352930

2019-03-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I love functional changes that remove code and add tests -- thank you for these!

> Removes errnoneous use of diag::err_alias_is_definition, which turned out to 
> be ineffective anyway since functions can be defined later in the translation 
> unit and avoid detection.

If you need to keep the prohibition that these attributes not be applied to 
functions with definitions, there are ways to accomplish that (we merge 
declarations and can decide what to do at that point if we see a declaration 
that is a definition). Given that, do you still want to lift this restriction?




Comment at: test/Sema/attr-wasm.c:3
+
+void name_a() {}
+

Was this intended to be used somewhere? Probably can just be removed if not.



Comment at: test/Sema/attr-wasm.c:15
+
+void module_a() {}
+

Same here.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59520



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


[PATCH] D59466: [clang-tidy] openmp-exception-escape - a new check

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

Great work! Thank you! I only have minor comment: did you consider moving the 
refactoring of `ExceptionAnalyzer` into a separate (prerequisite) patch?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D59466



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


[PATCH] D59540: [clang-tidy] [PR41119] readability-identifier-naming incorrectly fixes lambda capture

2019-03-19 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

What happens on `[=]() ...`, direct capture `[]()...` and 
`[Columns]()...`?


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

https://reviews.llvm.org/D59540



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


[PATCH] D59492: [OpenCL] Allow variadic macros as Clang feature

2019-03-19 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D59492#1434636 , @Anastasia wrote:

> In D59492#1433796 , @arsenm wrote:
>
> > Should it be downgraded to a warning about an extension instead of just 
> > removing it?
>
>
> What would you suggest to put in a warning message? Clang normally doesn't 
> warn about extensions...


Isn't that what -pedantic is for?


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

https://reviews.llvm.org/D59492



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


[PATCH] D59544: [OpenCL] Minor improvements in default header testing

2019-03-19 Thread Alexey Bader via Phabricator via cfe-commits
bader accepted this revision.
bader added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


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

https://reviews.llvm.org/D59544



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


  1   2   >