[PATCH] D55662: [Sema][ObjC] Do not warn about repeated uses of weak variables when the variables are accessed in an unevaluated context.

2018-12-21 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D55662#1338766 , @ahatanak wrote:

> In D55662#1337141 , @rjmccall wrote:
>
> > In D55662#1336835 , @ahatanak 
> > wrote:
> >
> > > In D55662#1335773 , @rjmccall 
> > > wrote:
> > >
> > > > Okay.  You may need to push an unevaluated context when doing that.
> > >
> > >
> > > Since I'm just moving the call to `CheckPlaceholderExpr` to the call 
> > > site, I don't think I have to push an unevaluated context there?
> >
> >
> > Hmm.  Right, for the `auto` inference specifically it's fine because the 
> > expression is in fact evaluated: we're not just eliminating placeholders in 
> > order to resolve `decltype`, we're eliminating placeholders to actually 
> > figure out what's going on with the initialization.
>
>
> clang currently diagnose the repeated use of weak in the following case (with 
> or without this patch):
>
>   auto __weak wp = b.weakProp; 
>
>
> I find this counterintuitive, but I guess this is the expected behavior?


No, that's not right. it's not a repeated use of the same weak entity.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55662



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


[PATCH] D55869: Convert some ObjC retain/release msgSends to runtime calls

2018-12-21 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

It sounds like it's fine.


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

https://reviews.llvm.org/D55869



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


[PATCH] D55933: [Sema] Do not print default template parameters.

2018-12-21 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: test/SemaCXX/static-assert-cxx17.cpp:109
+template 
+void foo7() {
+  static_assert(X());

courbet wrote:
> Quuxplusone wrote:
> > None of these new test cases actually involve the default template argument.
> > 
> > I'd like to see two test cases explicitly mimicking `vector`. (Warning: I 
> > didn't run this code!)
> > ```
> > template struct A {};
> > template> struct V {};
> > template void testx() {
> > static_assert(std::is_same::value, "");
> > // expected-error@-1{{due to requirement 'std::is_same*, 
> > void>::value'}}
> > }
> > template testx>();
> > template struct PMRA {};
> > template using PMRV = V>;
> > template void test() {
> > static_assert(std::is_same::value, "");
> > // expected-error@-1{{due to requirement 'std::is_same > PMRA>*, void>::value'}}
> > // expected-error@-2{{due to requirement 'std::is_same*, 
> > void>::value'}}
> > }
> > template testy>();
> > ```
> > The `expected-error@-2` above is my fantasy world. I don't think it's 
> > possible to achieve in real life. :)
> > None of these new test cases actually involve the default template argument.
> 
> This one is to check that we actually do print when specified explicitly. 
> foo6 above tests  the default template arguments (notice the change from 
> `template  struct X to `template  struct 
> X` above). I've renamed `foo6` and `foo7` to make that clear.
> 
> Before this change, static_asserts in `foo6` and `foo7` printed the same 
> thing. Now they don't.
> 
> > I'd like to see two test cases explicitly mimicking vector.
> 
> OK, I think I misunderstood what you wanted here. I don't think what you want 
> is actually doable, because by the time you're in `test()`, C is just a type 
> without any way of knowing whether the user explicitly provided the template 
> parameter or relied on the default.
> 
> What we could do though is **always** erase template parameters that are the 
> same as default ones. But that would mean printing `due to requirement 
> 'std::is_same*, void>::value'` even when the user wrote `template 
> testx>>();`.
> WDYT ?
> 
> 
Here's what I wrote over on D55270.

>>! In D55270#1327704, @Quuxplusone wrote:
> @courbet: On the cpplang Slack, Peter Feichtinger mentioned that defaulted 
> template arguments should perhaps be treated differently. Is there any way to 
> suppress the `, std::allocator` part of this diagnostic? 
> https://godbolt.org/z/TM0UHc
> 
> Before your patches:
> ```
> :11:5: error: static_assert failed due to requirement 
> 'std::is_integral_v'
> static_assert(std::is_integral_v);
> ^ ~
> ```
> After your patches:
> ```
> :11:5: error: static_assert failed due to requirement 
> 'std::is_integral_v > >'
> static_assert(std::is_integral_v);
> ^ ~ 
> ```
> I don't think the new behavior is //worse//; but I don't think it's optimal, 
> either.
> 
> I think Clang already has a feature to suppress printing these parameters; 
> you would just have to figure out where it is and try to hook it into your 
> thing. (And if you do, I'm going to ask for a test case where `T::t` is 
> `std::pmr::vector`!)

So does this patch (D55933) actually change the message printed by Peter's 
https://godbolt.org/z/TM0UHc ? (I think it does not.)
Does it change the message printed by https://godbolt.org/z/Q0AD70 ? (I think 
it does.)

I think most of your new test cases in `foo7` are redundant and don't really 
need to be there. Contrariwise, I would like to see one new test case 
isomorphic to https://godbolt.org/z/Q0AD70 , because that strikes me as a very 
realistic case that we want to protect against regressions.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55933



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


[PATCH] D56024: [clang] [Distro] Support detecting Gentoo

2018-12-21 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: include/clang/Driver/Distro.h:118
   }
 
   bool IsUbuntu() const {

Shall we also introduce the `IsGentoo()` predicate for convenience?


Repository:
  rC Clang

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

https://reviews.llvm.org/D56024



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


[PATCH] D55981: [gn build] Add build files for clang, clang-offload-bundler, and clang/lib/Headers

2018-12-21 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn:6
+
+files = [
+  "adxintrin.h",

Why not just inline this? This variable doesn't seem to be used from anywhere 
else?


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

https://reviews.llvm.org/D55981



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


[PATCH] D55984: [gn build] Embed __TEXT __info_plist section into clang binary on macOS

2018-12-21 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D55984



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


[PATCH] D56000: [compiler-rt] [xray] Disable alignas() for thread_local objects on NetBSD

2018-12-21 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris added inline comments.



Comment at: lib/xray/xray_defs.h:22
 
+#if !SANITIZER_NETBSD
+#define XRAY_TLS_ALIGNAS(x) alignas(x)

krytarowski wrote:
> I would switch the order, in order to remove unneeded negation.
> 
> ```
> #if SANITIZER_NETBSD
> ...
> #else
> ...
> #endif
> ```
> 
> `#define XRAY_HAS_TLS_ALIGNAS 0` is not needed as `#if XRAY_HAS_TLS_ALIGNAS` 
> will evaluate to false anyway and `#define XRAY_HAS_TLS_ALIGNAS 1` is 
> equivalent to `#define XRAY_HAS_TLS_ALIGNAS`. But it's just a matter of style.
FWIW, I agree to this suggestion. I also prefer:

```
#if SANITIZER_NETBSD
...
#else
...
```

But I do like the explicit definition of `XRAY_HAS_TLS_ALIGNAS`.


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

https://reviews.llvm.org/D56000



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


[PATCH] D55853: Ignore ConstantExpr in IgnoreParens

2018-12-21 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Want to stamp this? It's 4pm on the Friday before Christmas, what could go 
wrong? :)


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

https://reviews.llvm.org/D55853



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


[PATCH] D56033: [CUDA] Treat extern global variable shadows same as regular extern vars.

2018-12-21 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 179387.
tra added a comment.

Fixed a typo.


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

https://reviews.llvm.org/D56033

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCUDA/device-stub.cu


Index: clang/test/CodeGenCUDA/device-stub.cu
===
--- clang/test/CodeGenCUDA/device-stub.cu
+++ clang/test/CodeGenCUDA/device-stub.cu
@@ -42,13 +42,20 @@
 // ALL-DAG: @ext_host_var = external global i32
 extern int ext_host_var;
 
-// Shadows for external device-side variables are *definitions* of
-// those variables.
-// ALL-DAG: @ext_device_var = internal global i32
+// external device-side variables -> extern references to their shadows.
+// ALL-DAG: @ext_device_var = external global i32
 extern __device__ int ext_device_var;
-// ALL-DAG: @ext_device_var = internal global i32
+// ALL-DAG: @ext_device_var = external global i32
 extern __constant__ int ext_constant_var;
 
+// external device-side variables with definitions should generate
+// definitions for the shadows.
+// ALL-DAG: @ext_device_var_def = internal global i32 undef,
+extern __device__ int ext_device_var_def;
+__device__ int ext_device_var_def = 1;
+// ALL-DAG: @ext_device_var_def = internal global i32 undef,
+__constant__ int ext_constant_var_def = 2;
+
 void use_pointers() {
   int *p;
   p = _var;
@@ -114,8 +121,8 @@
 // ALL: call{{.*}}[[PREFIX]]RegisterFunction(i8** %0, {{.*}}kernelfunc
 // ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, {{.*}}device_var{{.*}}i32 
0, i32 4, i32 0, i32 0
 // ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}constant_var{{.*}}i32 0, i32 4, i32 1, i32 0
-// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_device_var{{.*}}i32 1, i32 4, i32 0, i32 0
-// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_constant_var{{.*}}i32 1, i32 4, i32 1, i32 0
+// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_device_var_def{{.*}}i32 0, i32 4, i32 0, i32 0
+// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_constant_var_def{{.*}}i32 0, i32 4, i32 1, i32 0
 // ALL: ret void
 
 // Test that we've built a constructor.
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2188,15 +2188,7 @@
   } else {
 const auto *VD = cast(Global);
 assert(VD->isFileVarDecl() && "Cannot emit local var decl as global.");
-// We need to emit device-side global CUDA variables even if a
-// variable does not have a definition -- we still need to define
-// host-side shadow for it.
-bool MustEmitForCuda = LangOpts.CUDA && !LangOpts.CUDAIsDevice &&
-   !VD->hasDefinition() &&
-   (VD->hasAttr() ||
-VD->hasAttr());
-if (!MustEmitForCuda &&
-VD->isThisDeclarationADefinition() != VarDecl::Definition &&
+if (VD->isThisDeclarationADefinition() != VarDecl::Definition &&
 !Context.isMSStaticDataMemberInlineDefinition(VD)) {
   if (LangOpts.OpenMP) {
 // Emit declaration of the must-be-emitted declare target variable.
@@ -3616,7 +3608,10 @@
   Flags |= CGCUDARuntime::ExternDeviceVar;
 if (D->hasAttr())
   Flags |= CGCUDARuntime::ConstantDeviceVar;
-getCUDARuntime().registerDeviceVar(*GV, Flags);
+// Extern global variables will be registered in the TU where they are
+// defined.
+if (!D->hasExternalStorage())
+  getCUDARuntime().registerDeviceVar(*GV, Flags);
   } else if (D->hasAttr())
 // __shared__ variables are odd. Shadows do get created, but
 // they are not registered with the CUDA runtime, so they


Index: clang/test/CodeGenCUDA/device-stub.cu
===
--- clang/test/CodeGenCUDA/device-stub.cu
+++ clang/test/CodeGenCUDA/device-stub.cu
@@ -42,13 +42,20 @@
 // ALL-DAG: @ext_host_var = external global i32
 extern int ext_host_var;
 
-// Shadows for external device-side variables are *definitions* of
-// those variables.
-// ALL-DAG: @ext_device_var = internal global i32
+// external device-side variables -> extern references to their shadows.
+// ALL-DAG: @ext_device_var = external global i32
 extern __device__ int ext_device_var;
-// ALL-DAG: @ext_device_var = internal global i32
+// ALL-DAG: @ext_device_var = external global i32
 extern __constant__ int ext_constant_var;
 
+// external device-side variables with definitions should generate
+// definitions for the shadows.
+// ALL-DAG: @ext_device_var_def = internal global i32 undef,
+extern __device__ int ext_device_var_def;
+__device__ int ext_device_var_def = 1;
+// ALL-DAG: @ext_device_var_def = internal global i32 undef,
+__constant__ int ext_constant_var_def = 2;
+
 void use_pointers() {
   int *p;
 

[PATCH] D56042: [analyzer] pr38838, pr39976: Fix a crash on emitting diagnostics before destructor.

2018-12-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, george.karpenkov, a_sidorin, 
rnkovacs, mikhail.ramalho, baloghadamsoftware.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, 
a.sidorin, szepet.

All right guys, now this one's weird.

This patch looks fairly reasonable at a glance. Like, we need to be able to 
emit the diagnostic at `PreImplicitCall`, and the patch implements this 
functionality.

The real question, as usual, is why didn't we need that before. If you look at 
the test, you'll see that i'm not testing for any diagnostics. Let me explain.

The test emits two bug reports for

  test/Analysis/diagnostics/dtors.cpp:23:3: note: Called C++ object pointer is 
null
p.get()->foo();
^~~

Both of them are suppressed because by default we have `-analyzer-config 
suppress-null-return-paths=true`. If you change it to false, you'll see a 
warning, but it won't have any diagnostics attached to line 22, where the 
destructor is called. That's because you see the first warning, and the second 
warning gets de-duplicated out. Now, if you suppress the first warning with an 
early exit like this:

 21 void bar(smart_ptr p) {
  +  22   if (p.x)
  +  23 return;
 24   delete p.get();
 25   p.get()->foo();
 26 }

...then you'll see the second report, which would include the piece we're 
looking for:

  test/Analysis/diagnostics/dtors.cpp:24:16: note: Assuming pointer value is 
null
delete p.get();
 ^

The piece says that `p.s` is assumed to be non-null by the null dereference 
checker: otherwise we wouldn't have been able to call the destructor. This is 
fine.

The bad thing here is that if `p.s` is non-null, then the warning about calling 
a method on a null pointer is false! Therefore i don't want to add tests for 
diagnostic messages: they're incorrect and would need to be removed anyway.

Now, why do we have the false positive? That's because we have a dead symbol 
collection problem :/ Namely, the symbol for `p.x` gets garbage-collected too 
early, even though `p` is still alive as an lvalue expression. Then the 
constraint range for `reg_$1` is lost, and when we're entering `get()` for 
the second time, it is re-assumed to be null. Ugh.

Finally, i've no idea how to come up with a true positive to test this note 
piece. The only thing i can come up with that can happen in pre-call to 
destructor is this null dereference assumption. But what warning would you emit 
over a pointer that's known to be non-null so that the pointer was an 
interesting symbol with respect to this warning? I just can't come up with 
anything. Which explains why don't we see that many crashes of that kind. It 
seems that they only occur on false positives of a certain kind, which of 
course need to be fixed.

Still, fixing a crash is better than nothing, so i propose to land this before 
i dive into this dead symbol problem.


Repository:
  rC Clang

https://reviews.llvm.org/D56042

Files:
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  test/Analysis/diagnostics/dtors.cpp


Index: test/Analysis/diagnostics/dtors.cpp
===
--- /dev/null
+++ test/Analysis/diagnostics/dtors.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core,cplusplus -verify %s
+
+// expected-no-diagnostics
+
+namespace no_crash_on_delete_dtor {
+// We were crashing when producing diagnostics for this code.
+struct S {
+  void foo();
+  ~S();
+};
+
+struct smart_ptr {
+  int x;
+  S *s;
+  smart_ptr(S *);
+  S *get() {
+return (x || 0) ? nullptr : s;
+  }
+};
+
+void bar(smart_ptr p) {
+  delete p.get();
+  p.get()->foo();
+}
+} // namespace no_crash_on_delete_dtor
Index: lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -723,6 +723,8 @@
   } else if (Optional PIP = P.getAs()) {
 return PathDiagnosticLocation(PIP->getInitializer()->getSourceLocation(),
   SMng);
+  } else if (Optional PIC = P.getAs()) {
+return PathDiagnosticLocation(PIC->getLocation(), SMng);
   } else if (Optional PIE = P.getAs()) {
 return PathDiagnosticLocation(PIE->getLocation(), SMng);
   } else if (Optional CE = P.getAs()) {


Index: test/Analysis/diagnostics/dtors.cpp
===
--- /dev/null
+++ test/Analysis/diagnostics/dtors.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core,cplusplus -verify %s
+
+// expected-no-diagnostics
+
+namespace no_crash_on_delete_dtor {
+// We were crashing when producing diagnostics for this code.
+struct S {
+  void foo();
+  ~S();
+};
+
+struct smart_ptr {
+  int x;
+  S *s;
+  smart_ptr(S *);
+  S *get() {
+return (x || 0) ? nullptr : s;
+  }
+};
+
+void bar(smart_ptr p) {
+  delete p.get();
+  

r349948 - [AST][NFC] Remove stale comment in CXXRecordDecl::is(Virtually)DerivedFrom.

2018-12-21 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Fri Dec 21 12:23:07 2018
New Revision: 349948

URL: http://llvm.org/viewvc/llvm-project?rev=349948=rev
Log:
[AST][NFC] Remove stale comment in CXXRecordDecl::is(Virtually)DerivedFrom.

The "this" capture was removed in r291939.


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

Modified: cfe/trunk/lib/AST/CXXInheritance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CXXInheritance.cpp?rev=349948=349947=349948=diff
==
--- cfe/trunk/lib/AST/CXXInheritance.cpp (original)
+++ cfe/trunk/lib/AST/CXXInheritance.cpp Fri Dec 21 12:23:07 2018
@@ -103,7 +103,6 @@ bool CXXRecordDecl::isDerivedFrom(const
   Paths.setOrigin(const_cast(this));
 
   const CXXRecordDecl *BaseDecl = Base->getCanonicalDecl();
-  // FIXME: Capturing 'this' is a workaround for name lookup bugs in GCC 4.7.
   return lookupInBases(
   [BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath ) {
 return FindBaseClass(Specifier, Path, BaseDecl);
@@ -124,7 +123,6 @@ bool CXXRecordDecl::isVirtuallyDerivedFr
   Paths.setOrigin(const_cast(this));
 
   const CXXRecordDecl *BaseDecl = Base->getCanonicalDecl();
-  // FIXME: Capturing 'this' is a workaround for name lookup bugs in GCC 4.7.
   return lookupInBases(
   [BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath ) {
 return FindVirtualBaseClass(Specifier, Path, BaseDecl);


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


[PATCH] D56012: [clang-tidy] Be more liberal about literal zeroes in abseil checks

2018-12-21 Thread Hyrum Wright via Phabricator via cfe-commits
hwright updated this revision to Diff 179335.
hwright marked 6 inline comments as done.
hwright added a comment.

Add documentation, adjust test.


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

https://reviews.llvm.org/D56012

Files:
  clang-tidy/abseil/DurationFactoryScaleCheck.cpp
  clang-tidy/abseil/DurationRewriter.cpp
  test/clang-tidy/abseil-duration-factory-scale.cpp

Index: test/clang-tidy/abseil-duration-factory-scale.cpp
===
--- test/clang-tidy/abseil-duration-factory-scale.cpp
+++ test/clang-tidy/abseil-duration-factory-scale.cpp
@@ -2,6 +2,9 @@
 
 #include "absl/time/time.h"
 
+namespace std { typedef long long int64_t; }
+using int64_t = std::int64_t;
+
 void ScaleTest() {
   absl::Duration d;
 
@@ -30,6 +33,15 @@
   d = absl::Seconds(0x0.01p-126f);
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale]
   // CHECK-FIXES: absl::ZeroDuration();
+  d = absl::Seconds(int{0});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::ZeroDuration();
+  d = absl::Seconds(int64_t{0});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::ZeroDuration();
+  d = absl::Seconds(float{0});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::ZeroDuration();
 
   // Fold seconds into minutes
   d = absl::Seconds(30 * 60);
@@ -83,6 +95,8 @@
 
   // None of these should trigger the check
   d = absl::Seconds(60);
+  d = absl::Seconds(int{60});
+  d = absl::Seconds(float{60});
   d = absl::Seconds(60 + 30);
   d = absl::Seconds(60 - 30);
   d = absl::Seconds(50 * 30);
Index: clang-tidy/abseil/DurationRewriter.cpp
===
--- clang-tidy/abseil/DurationRewriter.cpp
+++ clang-tidy/abseil/DurationRewriter.cpp
@@ -105,14 +105,44 @@
   llvm_unreachable("unknown scaling factor");
 }
 
+/// Matches the n'th item of an initializer list expression.
+///
+/// Example matches y.
+/// (matcher = initListExpr(hasInit(0, expr(
+/// \code
+///   int x{y}.
+/// \endcode
+AST_MATCHER_P2(InitListExpr, hasInit, unsigned, N,
+   ast_matchers::internal::Matcher, InnerMatcher) {
+  return N < Node.getNumInits() &&
+  InnerMatcher.matches(*Node.getInit(N)->IgnoreParenImpCasts(), Finder,
+   Builder);
+}
+
 /// Returns `true` if `Node` is a value which evaluates to a literal `0`.
 bool IsLiteralZero(const MatchFinder::MatchResult , const Expr ) {
-  return selectFirst(
- "val",
- match(expr(ignoringImpCasts(anyOf(integerLiteral(equals(0)),
-   floatLiteral(equals(0.0)
-   .bind("val"),
-   Node, *Result.Context)) != nullptr;
+  auto ZeroMatcher =
+  anyOf(integerLiteral(equals(0)), floatLiteral(equals(0.0)));
+
+  // Check to see if we're using a zero directly.
+  if (selectFirst(
+  "val", match(expr(ignoringImpCasts(ZeroMatcher)).bind("val"), Node,
+   *Result.Context)) != nullptr)
+return true;
+
+  // Now check to see if we're using a functional cast with a scalar
+  // initializer expression, e.g. `int{0}`.
+  if (selectFirst(
+  "val",
+  match(cxxFunctionalCastExpr(
+hasDestinationType(
+anyOf(isInteger(), realFloatingPointType())),
+hasSourceExpression(initListExpr(hasInit(0, ZeroMatcher
+.bind("val"),
+Node, *Result.Context)) != nullptr)
+return true;
+
+  return false;
 }
 
 llvm::Optional
Index: clang-tidy/abseil/DurationFactoryScaleCheck.cpp
===
--- clang-tidy/abseil/DurationFactoryScaleCheck.cpp
+++ clang-tidy/abseil/DurationFactoryScaleCheck.cpp
@@ -123,6 +123,10 @@
   hasArgument(
   0,
   ignoringImpCasts(anyOf(
+  cxxFunctionalCastExpr(
+  hasDestinationType(
+  anyOf(isInteger(), realFloatingPointType())),
+  hasSourceExpression(initListExpr())),
   integerLiteral(equals(0)), floatLiteral(equals(0.0)),
   binaryOperator(hasOperatorName("*"),
  hasEitherOperand(ignoringImpCasts(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56012: [clang-tidy] Be more liberal about literal zeroes in abseil checks

2018-12-21 Thread Hyrum Wright via Phabricator via cfe-commits
hwright added a comment.

btw, I think `hasInit` should probably be moved into the core set of matchers 
at some point.




Comment at: clang-tidy/abseil/DurationRewriter.cpp:110
+   ast_matchers::internal::Matcher, InnerMatcher) {
+  return (N < Node.getNumInits() &&
+  InnerMatcher.matches(*Node.getInit(N)->IgnoreParenImpCasts(), Finder,

aaron.ballman wrote:
> Spurious parens can be removed.
Done.  (Though there are similar parens in the implementation of `hasArgument`. 
:)



Comment at: test/clang-tidy/abseil-duration-factory-scale.cpp:34
   // CHECK-FIXES: absl::ZeroDuration();
+  d = absl::Seconds(int{0});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for 
zero-length time intervals [abseil-duration-factory-scale]

aaron.ballman wrote:
> Do you also have users doing something like: `absl::Seconds(int{});`?
I have not yet seen that.


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

https://reviews.llvm.org/D56012



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


[PATCH] D56012: [clang-tidy] Be more liberal about literal zeroes in abseil checks

2018-12-21 Thread Hyrum Wright via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349953: [clang-tidy] Be more liberal about literal zeroes in 
abseil checks (authored by hwright, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56012?vs=179335=179341#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56012

Files:
  clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
  clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp
  clang-tools-extra/trunk/test/clang-tidy/abseil-duration-factory-scale.cpp

Index: clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp
===
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp
@@ -105,14 +105,44 @@
   llvm_unreachable("unknown scaling factor");
 }
 
+/// Matches the n'th item of an initializer list expression.
+///
+/// Example matches y.
+/// (matcher = initListExpr(hasInit(0, expr(
+/// \code
+///   int x{y}.
+/// \endcode
+AST_MATCHER_P2(InitListExpr, hasInit, unsigned, N,
+   ast_matchers::internal::Matcher, InnerMatcher) {
+  return N < Node.getNumInits() &&
+  InnerMatcher.matches(*Node.getInit(N)->IgnoreParenImpCasts(), Finder,
+   Builder);
+}
+
 /// Returns `true` if `Node` is a value which evaluates to a literal `0`.
 bool IsLiteralZero(const MatchFinder::MatchResult , const Expr ) {
-  return selectFirst(
- "val",
- match(expr(ignoringImpCasts(anyOf(integerLiteral(equals(0)),
-   floatLiteral(equals(0.0)
-   .bind("val"),
-   Node, *Result.Context)) != nullptr;
+  auto ZeroMatcher =
+  anyOf(integerLiteral(equals(0)), floatLiteral(equals(0.0)));
+
+  // Check to see if we're using a zero directly.
+  if (selectFirst(
+  "val", match(expr(ignoringImpCasts(ZeroMatcher)).bind("val"), Node,
+   *Result.Context)) != nullptr)
+return true;
+
+  // Now check to see if we're using a functional cast with a scalar
+  // initializer expression, e.g. `int{0}`.
+  if (selectFirst(
+  "val",
+  match(cxxFunctionalCastExpr(
+hasDestinationType(
+anyOf(isInteger(), realFloatingPointType())),
+hasSourceExpression(initListExpr(hasInit(0, ZeroMatcher
+.bind("val"),
+Node, *Result.Context)) != nullptr)
+return true;
+
+  return false;
 }
 
 llvm::Optional
Index: clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
@@ -123,6 +123,10 @@
   hasArgument(
   0,
   ignoringImpCasts(anyOf(
+  cxxFunctionalCastExpr(
+  hasDestinationType(
+  anyOf(isInteger(), realFloatingPointType())),
+  hasSourceExpression(initListExpr())),
   integerLiteral(equals(0)), floatLiteral(equals(0.0)),
   binaryOperator(hasOperatorName("*"),
  hasEitherOperand(ignoringImpCasts(
Index: clang-tools-extra/trunk/test/clang-tidy/abseil-duration-factory-scale.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/abseil-duration-factory-scale.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/abseil-duration-factory-scale.cpp
@@ -2,6 +2,9 @@
 
 #include "absl/time/time.h"
 
+namespace std { typedef long long int64_t; }
+using int64_t = std::int64_t;
+
 void ScaleTest() {
   absl::Duration d;
 
@@ -30,6 +33,15 @@
   d = absl::Seconds(0x0.01p-126f);
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale]
   // CHECK-FIXES: absl::ZeroDuration();
+  d = absl::Seconds(int{0});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::ZeroDuration();
+  d = absl::Seconds(int64_t{0});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::ZeroDuration();
+  d = absl::Seconds(float{0});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::ZeroDuration();
 
   // Fold seconds into minutes
   d = absl::Seconds(30 * 60);
@@ -83,6 +95,8 @@
 
   // None of 

[clang-tools-extra] r349953 - [clang-tidy] Be more liberal about literal zeroes in abseil checks

2018-12-21 Thread Hyrum Wright via cfe-commits
Author: hwright
Date: Fri Dec 21 13:07:11 2018
New Revision: 349953

URL: http://llvm.org/viewvc/llvm-project?rev=349953=rev
Log:
[clang-tidy] Be more liberal about literal zeroes in abseil checks

Summary:
Previously, we'd only match on literal floating or integral zeroes, but I've 
now also learned that some users spell that value as int{0} or float{0}, which 
also need to be matched.

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

Modified:
clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp
clang-tools-extra/trunk/test/clang-tidy/abseil-duration-factory-scale.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryScaleCheck.cpp?rev=349953=349952=349953=diff
==
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryScaleCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationFactoryScaleCheck.cpp Fri 
Dec 21 13:07:11 2018
@@ -123,6 +123,10 @@ void DurationFactoryScaleCheck::register
   hasArgument(
   0,
   ignoringImpCasts(anyOf(
+  cxxFunctionalCastExpr(
+  hasDestinationType(
+  anyOf(isInteger(), realFloatingPointType())),
+  hasSourceExpression(initListExpr())),
   integerLiteral(equals(0)), floatLiteral(equals(0.0)),
   binaryOperator(hasOperatorName("*"),
  hasEitherOperand(ignoringImpCasts(

Modified: clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp?rev=349953=349952=349953=diff
==
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp Fri Dec 21 
13:07:11 2018
@@ -105,14 +105,44 @@ llvm::StringRef getFactoryForScale(Durat
   llvm_unreachable("unknown scaling factor");
 }
 
+/// Matches the n'th item of an initializer list expression.
+///
+/// Example matches y.
+/// (matcher = initListExpr(hasInit(0, expr(
+/// \code
+///   int x{y}.
+/// \endcode
+AST_MATCHER_P2(InitListExpr, hasInit, unsigned, N,
+   ast_matchers::internal::Matcher, InnerMatcher) {
+  return N < Node.getNumInits() &&
+  InnerMatcher.matches(*Node.getInit(N)->IgnoreParenImpCasts(), Finder,
+   Builder);
+}
+
 /// Returns `true` if `Node` is a value which evaluates to a literal `0`.
 bool IsLiteralZero(const MatchFinder::MatchResult , const Expr ) {
-  return selectFirst(
- "val",
- match(expr(ignoringImpCasts(anyOf(integerLiteral(equals(0)),
-   floatLiteral(equals(0.0)
-   .bind("val"),
-   Node, *Result.Context)) != nullptr;
+  auto ZeroMatcher =
+  anyOf(integerLiteral(equals(0)), floatLiteral(equals(0.0)));
+
+  // Check to see if we're using a zero directly.
+  if (selectFirst(
+  "val", match(expr(ignoringImpCasts(ZeroMatcher)).bind("val"), Node,
+   *Result.Context)) != nullptr)
+return true;
+
+  // Now check to see if we're using a functional cast with a scalar
+  // initializer expression, e.g. `int{0}`.
+  if (selectFirst(
+  "val",
+  match(cxxFunctionalCastExpr(
+hasDestinationType(
+anyOf(isInteger(), realFloatingPointType())),
+hasSourceExpression(initListExpr(hasInit(0, ZeroMatcher
+.bind("val"),
+Node, *Result.Context)) != nullptr)
+return true;
+
+  return false;
 }
 
 llvm::Optional

Modified: 
clang-tools-extra/trunk/test/clang-tidy/abseil-duration-factory-scale.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/abseil-duration-factory-scale.cpp?rev=349953=349952=349953=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/abseil-duration-factory-scale.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/abseil-duration-factory-scale.cpp 
Fri Dec 21 13:07:11 2018
@@ -2,6 +2,9 @@
 
 #include "absl/time/time.h"
 
+namespace std { typedef long long int64_t; }
+using int64_t = std::int64_t;
+
 void ScaleTest() {
   absl::Duration d;
 
@@ -30,6 +33,15 @@ void ScaleTest() {
   d = absl::Seconds(0x0.01p-126f);
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for 
zero-length time intervals [abseil-duration-factory-scale]
   // CHECK-FIXES: absl::ZeroDuration();
+  d = 

[PATCH] D55979: [gn build] Add build file for clang/lib/ARCMigrate

2018-12-21 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D55979



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


[PATCH] D55955: Properly diagnose [[nodiscard]] on the body of a range-based for loop

2018-12-21 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Sema/SemaStmt.cpp:2846
 diag::warn_empty_range_based_for_body);
+  DiagnoseUnusedExprResult(B);
 

aaron.ballman wrote:
> rsmith wrote:
> > rsmith wrote:
> > > While this looks correct per the current approach to this function, we 
> > > really shouldn't be duplicating calls to this everywhere. Can we move all 
> > > the calls to a single call in `ActOnFinishFullStmt`?
> > Looks like that's not actually called from almost anywhere, but checking 
> > from `ActOnFinishFullExpr` in the case where `DiscardedValue` is `true` 
> > seems appropriate.
> That seems sensible, but how will that work with GNU statement expressions? 
> If we check for unused expression results, then we will trigger on code like 
> this:
> ```
> int a = ({blah(); yada(); 0;});
> // or
> int b = ({blah(); yada(); some_no_discard_call();});
> ```
> I don't know of a way to handle that case -- we call `ActOnFinishFullExpr()` 
> while parsing the compound statement for the `StmtExpr`, so there's no way to 
> know whether there's another statement coming (without lookahead) to 
> determine whether to suppress the diagnostic for the last expression 
> statement. Do you have ideas on how to handle that?
If we're calling `ActOnFinishFullExpr` there with `DiscardedValue == true`, 
that would be a bug that we should be fixing regardless. I don't think the 
lookahead is so bad itself -- it should just be a one-token lookahead for a `}` 
after the `;` -- but it might be awkward to wire it into our compound-statement 
/ expression-statement parsing. Still, it seems necessary for correctness.


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

https://reviews.llvm.org/D55955



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


[PATCH] D55853: Ignore ConstantExpr in IgnoreParens

2018-12-21 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 with `s/ConstantExpr/FullExpr/`.




Comment at: clang/lib/AST/Expr.cpp:2550
 }
+if (ConstantExpr *CE = dyn_cast(E)) {
+  E = CE->getSubExpr();

Does this pass the tests if you use `FullExpr` here instead? I don't think we 
should be treating `ConstantExpr` and  other `FullExpr`s differently.


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

https://reviews.llvm.org/D55853



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


[PATCH] D54565: Introduce `-Wctad` as a subgroup of `-Wc++14-compat`

2018-12-21 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

In D54565#1339454 , @thakis wrote:

> Since I don't know what it means, I don't know if I want a diagnostic for it 
> :-)


Fair point. ;) But the full text of the diagnostic message does say "class 
template argument deduction is...," which does hint at the meaning of "CTAD."
I just checked and the text of the diagnostic for `-Wvla` is "variable length 
array used"; maybe I should follow its lead and just say "class template 
argument deduction used," thus even further divorcing this option from 
`-Wc++14-compat`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D54565



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


[PATCH] D56022: [AST] Store the arguments of CXXConstructExpr in a trailing array

2018-12-21 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: include/clang/AST/ExprCXX.h:1613
+
+  TypeSourceInfo *TSI = nullptr;
+

riccibruno wrote:
> Changed the name from `Type` since `Type` was imho an unfortunate choice.
Agreed.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56022



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


[PATCH] D55875: [analyzer] pr38668: RegionStore: Do not attempt to cast loaded values of non-scalar types.

2018-12-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 179352.
NoQ added a comment.

Add test case `bool_to_nullptr` in `casts.cpp` on which my second attempt 
 crashes but the current code 
 does not.


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

https://reviews.llvm.org/D55875

Files:
  lib/StaticAnalyzer/Core/Store.cpp
  test/Analysis/casts.c
  test/Analysis/casts.cpp


Index: test/Analysis/casts.cpp
===
--- test/Analysis/casts.cpp
+++ test/Analysis/casts.cpp
@@ -102,3 +102,15 @@
   castToDerived(reinterpret_cast(ORef))->getNotInt();
 }
 } // namespace base_to_derived_opaque_class
+
+namespace bool_to_nullptr {
+struct S {
+  int *a[1];
+  bool b;
+};
+void foo(S s) {
+  s.b = true;
+  for (int i = 0; i < 3; ++i)
+(void)(s.a[i] != nullptr);
+}
+} // namespace bool_to_nullptr
Index: test/Analysis/casts.c
===
--- test/Analysis/casts.c
+++ test/Analysis/casts.c
@@ -213,3 +213,35 @@
 }
 
 #endif
+
+char no_crash_SymbolCast_of_float_type_aux(int *p) {
+  *p += 1;
+  return *p;
+}
+
+void no_crash_SymbolCast_of_float_type() {
+  extern float x;
+  char (*f)() = no_crash_SymbolCast_of_float_type_aux;
+  f();
+}
+
+double no_crash_reinterpret_double_as_int(double a) {
+  *(int *) = 1;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_ptr(double a) {
+  *(void **) = 0;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_sym_int(double a, int b) {
+  *(int *) = b;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_sym_ptr(double a, void * b) {
+  *(void **) = b;
+  return a * a;
+}
+
Index: lib/StaticAnalyzer/Core/Store.cpp
===
--- lib/StaticAnalyzer/Core/Store.cpp
+++ lib/StaticAnalyzer/Core/Store.cpp
@@ -402,6 +402,12 @@
   if (castTy.isNull() || V.isUnknownOrUndef())
 return V;
 
+  if (castTy->isFloatingType()) {
+SymbolRef Sym = V.getAsSymbol();
+if (Sym && !Sym->getType()->isFloatingType())
+  return UnknownVal();
+  }
+
   // When retrieving symbolic pointer and expecting a non-void pointer,
   // wrap them into element regions of the expected type if necessary.
   // SValBuilder::dispatchCast() doesn't do that, but it is necessary to


Index: test/Analysis/casts.cpp
===
--- test/Analysis/casts.cpp
+++ test/Analysis/casts.cpp
@@ -102,3 +102,15 @@
   castToDerived(reinterpret_cast(ORef))->getNotInt();
 }
 } // namespace base_to_derived_opaque_class
+
+namespace bool_to_nullptr {
+struct S {
+  int *a[1];
+  bool b;
+};
+void foo(S s) {
+  s.b = true;
+  for (int i = 0; i < 3; ++i)
+(void)(s.a[i] != nullptr);
+}
+} // namespace bool_to_nullptr
Index: test/Analysis/casts.c
===
--- test/Analysis/casts.c
+++ test/Analysis/casts.c
@@ -213,3 +213,35 @@
 }
 
 #endif
+
+char no_crash_SymbolCast_of_float_type_aux(int *p) {
+  *p += 1;
+  return *p;
+}
+
+void no_crash_SymbolCast_of_float_type() {
+  extern float x;
+  char (*f)() = no_crash_SymbolCast_of_float_type_aux;
+  f();
+}
+
+double no_crash_reinterpret_double_as_int(double a) {
+  *(int *) = 1;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_ptr(double a) {
+  *(void **) = 0;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_sym_int(double a, int b) {
+  *(int *) = b;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_sym_ptr(double a, void * b) {
+  *(void **) = b;
+  return a * a;
+}
+
Index: lib/StaticAnalyzer/Core/Store.cpp
===
--- lib/StaticAnalyzer/Core/Store.cpp
+++ lib/StaticAnalyzer/Core/Store.cpp
@@ -402,6 +402,12 @@
   if (castTy.isNull() || V.isUnknownOrUndef())
 return V;
 
+  if (castTy->isFloatingType()) {
+SymbolRef Sym = V.getAsSymbol();
+if (Sym && !Sym->getType()->isFloatingType())
+  return UnknownVal();
+  }
+
   // When retrieving symbolic pointer and expecting a non-void pointer,
   // wrap them into element regions of the expected type if necessary.
   // SValBuilder::dispatchCast() doesn't do that, but it is necessary to
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56024: [clang] [Distro] Support detecting Gentoo

2018-12-21 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: sylvestre.ledru, bruno, bkramer, phosek.

Add support for distinguishing plain Gentoo distribution, and a unit
test for it.  This is going to be used to introduce distro-specific
customizations in the driver code; most notably, it is going to be used
to disable -faddrsig.


Repository:
  rC Clang

https://reviews.llvm.org/D56024

Files:
  include/clang/Driver/Distro.h
  lib/Driver/Distro.cpp
  unittests/Driver/DistroTest.cpp


Index: unittests/Driver/DistroTest.cpp
===
--- unittests/Driver/DistroTest.cpp
+++ unittests/Driver/DistroTest.cpp
@@ -302,4 +302,28 @@
   ASSERT_FALSE(ArchLinux.IsDebian());
 }
 
+TEST(DistroTest, DetectGentoo) {
+  llvm::vfs::InMemoryFileSystem GentooFileSystem;
+  GentooFileSystem.addFile(
+  "/etc/gentoo-release", 0,
+  llvm::MemoryBuffer::getMemBuffer("Gentoo Base System release 2.6"));
+  GentooFileSystem.addFile(
+  "/etc/os-release", 0,
+  llvm::MemoryBuffer::getMemBuffer(
+  "NAME=Gentoo\n"
+  "ID=gentoo\n"
+  "PRETTY_NAME=\"Gentoo/Linux\"\n"
+  "ANSI_COLOR=\"1;32\"\n"
+  "HOME_URL=\"https://www.gentoo.org/\"\n;
+  "SUPPORT_URL=\"https://www.gentoo.org/support/\"\n;
+  "BUG_REPORT_URL=\"https://bugs.gentoo.org/\"\n;));
+
+  Distro Gentoo{GentooFileSystem};
+  ASSERT_EQ(Distro(Distro::Gentoo), Gentoo);
+  ASSERT_FALSE(Gentoo.IsUbuntu());
+  ASSERT_FALSE(Gentoo.IsRedhat());
+  ASSERT_FALSE(Gentoo.IsOpenSUSE());
+  ASSERT_FALSE(Gentoo.IsDebian());
+}
+
 } // end anonymous namespace
Index: lib/Driver/Distro.cpp
===
--- lib/Driver/Distro.cpp
+++ lib/Driver/Distro.cpp
@@ -138,6 +138,9 @@
   if (VFS.exists("/etc/arch-release"))
 return Distro::ArchLinux;
 
+  if (VFS.exists("/etc/gentoo-release"))
+return Distro::Gentoo;
+
   return Distro::UnknownDistro;
 }
 
Index: include/clang/Driver/Distro.h
===
--- include/clang/Driver/Distro.h
+++ include/clang/Driver/Distro.h
@@ -39,6 +39,7 @@
 RHEL6,
 RHEL7,
 Fedora,
+Gentoo,
 OpenSUSE,
 UbuntuHardy,
 UbuntuIntrepid,


Index: unittests/Driver/DistroTest.cpp
===
--- unittests/Driver/DistroTest.cpp
+++ unittests/Driver/DistroTest.cpp
@@ -302,4 +302,28 @@
   ASSERT_FALSE(ArchLinux.IsDebian());
 }
 
+TEST(DistroTest, DetectGentoo) {
+  llvm::vfs::InMemoryFileSystem GentooFileSystem;
+  GentooFileSystem.addFile(
+  "/etc/gentoo-release", 0,
+  llvm::MemoryBuffer::getMemBuffer("Gentoo Base System release 2.6"));
+  GentooFileSystem.addFile(
+  "/etc/os-release", 0,
+  llvm::MemoryBuffer::getMemBuffer(
+  "NAME=Gentoo\n"
+  "ID=gentoo\n"
+  "PRETTY_NAME=\"Gentoo/Linux\"\n"
+  "ANSI_COLOR=\"1;32\"\n"
+  "HOME_URL=\"https://www.gentoo.org/\"\n;
+  "SUPPORT_URL=\"https://www.gentoo.org/support/\"\n;
+  "BUG_REPORT_URL=\"https://bugs.gentoo.org/\"\n;));
+
+  Distro Gentoo{GentooFileSystem};
+  ASSERT_EQ(Distro(Distro::Gentoo), Gentoo);
+  ASSERT_FALSE(Gentoo.IsUbuntu());
+  ASSERT_FALSE(Gentoo.IsRedhat());
+  ASSERT_FALSE(Gentoo.IsOpenSUSE());
+  ASSERT_FALSE(Gentoo.IsDebian());
+}
+
 } // end anonymous namespace
Index: lib/Driver/Distro.cpp
===
--- lib/Driver/Distro.cpp
+++ lib/Driver/Distro.cpp
@@ -138,6 +138,9 @@
   if (VFS.exists("/etc/arch-release"))
 return Distro::ArchLinux;
 
+  if (VFS.exists("/etc/gentoo-release"))
+return Distro::Gentoo;
+
   return Distro::UnknownDistro;
 }
 
Index: include/clang/Driver/Distro.h
===
--- include/clang/Driver/Distro.h
+++ include/clang/Driver/Distro.h
@@ -39,6 +39,7 @@
 RHEL6,
 RHEL7,
 Fedora,
+Gentoo,
 OpenSUSE,
 UbuntuHardy,
 UbuntuIntrepid,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55490: Add dumpMethodDeclOverrides to NodeDumper

2018-12-21 Thread Stephen Kelly via Phabricator via cfe-commits
steveire abandoned this revision.
steveire added a comment.

Abandoning this because it's not really the right approach as it appears in the 
interface between the generic traverser and the generic node dumper, which it 
really shouldn't.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55490



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


[PATCH] D55489: Implement dumpFunctionDeclParameters in NodeDumper

2018-12-21 Thread Stephen Kelly via Phabricator via cfe-commits
steveire abandoned this revision.
steveire added a comment.

Abandoning this because it's not really the right approach as it appears in the 
interface between the generic traverser and the generic node dumper, which it 
really shouldn't.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55489



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


[PATCH] D55875: [analyzer] pr38668: RegionStore: Do not attempt to cast loaded values of non-scalar types.

2018-12-21 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov accepted this revision.
george.karpenkov added a comment.

Seems good, but a comment explaining why this is necessary and why the crash 
follows otherwise would be great.


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

https://reviews.llvm.org/D55875



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


r349981 - [CUDA] Treat extern global variable shadows same as regular extern vars.

2018-12-21 Thread Artem Belevich via cfe-commits
Author: tra
Date: Fri Dec 21 17:11:09 2018
New Revision: 349981

URL: http://llvm.org/viewvc/llvm-project?rev=349981=rev
Log:
[CUDA] Treat extern global variable shadows same as regular extern vars.

This fixes compiler crash when we attempted to compile this code:

extern __device__ int data;
__device__ int data = 1;

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

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCUDA/device-stub.cu

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=349981=349980=349981=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Dec 21 17:11:09 2018
@@ -2188,15 +2188,7 @@ void CodeGenModule::EmitGlobal(GlobalDec
   } else {
 const auto *VD = cast(Global);
 assert(VD->isFileVarDecl() && "Cannot emit local var decl as global.");
-// We need to emit device-side global CUDA variables even if a
-// variable does not have a definition -- we still need to define
-// host-side shadow for it.
-bool MustEmitForCuda = LangOpts.CUDA && !LangOpts.CUDAIsDevice &&
-   !VD->hasDefinition() &&
-   (VD->hasAttr() ||
-VD->hasAttr());
-if (!MustEmitForCuda &&
-VD->isThisDeclarationADefinition() != VarDecl::Definition &&
+if (VD->isThisDeclarationADefinition() != VarDecl::Definition &&
 !Context.isMSStaticDataMemberInlineDefinition(VD)) {
   if (LangOpts.OpenMP) {
 // Emit declaration of the must-be-emitted declare target variable.
@@ -3616,7 +3608,10 @@ void CodeGenModule::EmitGlobalVarDefinit
   Flags |= CGCUDARuntime::ExternDeviceVar;
 if (D->hasAttr())
   Flags |= CGCUDARuntime::ConstantDeviceVar;
-getCUDARuntime().registerDeviceVar(*GV, Flags);
+// Extern global variables will be registered in the TU where they are
+// defined.
+if (!D->hasExternalStorage())
+  getCUDARuntime().registerDeviceVar(*GV, Flags);
   } else if (D->hasAttr())
 // __shared__ variables are odd. Shadows do get created, but
 // they are not registered with the CUDA runtime, so they

Modified: cfe/trunk/test/CodeGenCUDA/device-stub.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/device-stub.cu?rev=349981=349980=349981=diff
==
--- cfe/trunk/test/CodeGenCUDA/device-stub.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/device-stub.cu Fri Dec 21 17:11:09 2018
@@ -42,13 +42,20 @@ int host_var;
 // ALL-DAG: @ext_host_var = external global i32
 extern int ext_host_var;
 
-// Shadows for external device-side variables are *definitions* of
-// those variables.
-// ALL-DAG: @ext_device_var = internal global i32
+// external device-side variables -> extern references to their shadows.
+// ALL-DAG: @ext_device_var = external global i32
 extern __device__ int ext_device_var;
-// ALL-DAG: @ext_device_var = internal global i32
+// ALL-DAG: @ext_device_var = external global i32
 extern __constant__ int ext_constant_var;
 
+// external device-side variables with definitions should generate
+// definitions for the shadows.
+// ALL-DAG: @ext_device_var_def = internal global i32 undef,
+extern __device__ int ext_device_var_def;
+__device__ int ext_device_var_def = 1;
+// ALL-DAG: @ext_device_var_def = internal global i32 undef,
+__constant__ int ext_constant_var_def = 2;
+
 void use_pointers() {
   int *p;
   p = _var;
@@ -114,8 +121,8 @@ void hostfunc(void) { kernelfunc<<<1, 1>
 // ALL: call{{.*}}[[PREFIX]]RegisterFunction(i8** %0, {{.*}}kernelfunc
 // ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, {{.*}}device_var{{.*}}i32 
0, i32 4, i32 0, i32 0
 // ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}constant_var{{.*}}i32 0, i32 4, i32 1, i32 0
-// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_device_var{{.*}}i32 1, i32 4, i32 0, i32 0
-// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_constant_var{{.*}}i32 1, i32 4, i32 1, i32 0
+// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_device_var_def{{.*}}i32 0, i32 4, i32 0, i32 0
+// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_constant_var_def{{.*}}i32 0, i32 4, i32 1, i32 0
 // ALL: ret void
 
 // Test that we've built a constructor.


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


[PATCH] D56022: [AST] Store the arguments of CXXConstructExpr in a trailing array

2018-12-21 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno created this revision.
riccibruno added a reviewer: rjmccall.
riccibruno added a project: clang.
Herald added a reviewer: shafik.
Herald added a subscriber: cfe-commits.

Store the arguments of `CXXConstructExpr` in a trailing array. This is very 
similar to the
`CallExpr` case in D55771 , with the exception 
that there is only one derived class
(`CXXTemporaryObjectExpr`) and that we compute the offset to the trailing array 
instead
of storing it.

This saves one pointer per `CXXConstructExpr` and `CXXTemporaryObjectExpr`.

(with some comments inline)


Repository:
  rC Clang

https://reviews.llvm.org/D56022

Files:
  include/clang/AST/ExprCXX.h
  include/clang/AST/Stmt.h
  lib/AST/ASTImporter.cpp
  lib/AST/ExprCXX.cpp
  lib/Sema/SemaInit.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp

Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -1315,18 +1315,21 @@
 
 void ASTStmtWriter::VisitCXXConstructExpr(CXXConstructExpr *E) {
   VisitExpr(E);
+
   Record.push_back(E->getNumArgs());
-  for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
-Record.AddStmt(E->getArg(I));
-  Record.AddDeclRef(E->getConstructor());
-  Record.AddSourceLocation(E->getLocation());
   Record.push_back(E->isElidable());
   Record.push_back(E->hadMultipleCandidates());
   Record.push_back(E->isListInitialization());
   Record.push_back(E->isStdInitListInitialization());
   Record.push_back(E->requiresZeroInitialization());
   Record.push_back(E->getConstructionKind()); // FIXME: stable encoding
+  Record.AddSourceLocation(E->getLocation());
+  Record.AddDeclRef(E->getConstructor());
   Record.AddSourceRange(E->getParenOrBraceRange());
+
+  for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
+Record.AddStmt(E->getArg(I));
+
   Code = serialization::EXPR_CXX_CONSTRUCT;
 }
 
Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -1353,20 +1353,22 @@
 
 void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
   VisitExpr(E);
-  E->NumArgs = Record.readInt();
-  if (E->NumArgs)
-E->Args = new (Record.getContext()) Stmt*[E->NumArgs];
-  for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
-E->setArg(I, Record.readSubExpr());
-  E->setConstructor(ReadDeclAs());
-  E->setLocation(ReadSourceLocation());
-  E->setElidable(Record.readInt());
-  E->setHadMultipleCandidates(Record.readInt());
-  E->setListInitialization(Record.readInt());
-  E->setStdInitListInitialization(Record.readInt());
-  E->setRequiresZeroInitialization(Record.readInt());
-  E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record.readInt());
+
+  unsigned NumArgs = Record.readInt();
+  assert((NumArgs == E->getNumArgs()) && "Wrong NumArgs!");
+
+  E->CXXConstructExprBits.Elidable = Record.readInt();
+  E->CXXConstructExprBits.HadMultipleCandidates = Record.readInt();
+  E->CXXConstructExprBits.ListInitialization = Record.readInt();
+  E->CXXConstructExprBits.StdInitListInitialization = Record.readInt();
+  E->CXXConstructExprBits.ZeroInitialization = Record.readInt();
+  E->CXXConstructExprBits.ConstructionKind = Record.readInt();
+  E->CXXConstructExprBits.Loc = ReadSourceLocation();
+  E->Constructor = ReadDeclAs();
   E->ParenOrBraceRange = ReadSourceRange();
+
+  for (unsigned I = 0; I != NumArgs; ++I)
+E->setArg(I, Record.readSubExpr());
 }
 
 void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
@@ -1379,7 +1381,7 @@
 
 void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
   VisitCXXConstructExpr(E);
-  E->Type = GetTypeSourceInfo();
+  E->TSI = GetTypeSourceInfo();
 }
 
 void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
@@ -3082,7 +3084,9 @@
   break;
 
 case EXPR_CXX_CONSTRUCT:
-  S = new (Context) CXXConstructExpr(Empty);
+  S = CXXConstructExpr::CreateEmpty(
+  Context,
+  /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
   break;
 
 case EXPR_CXX_INHERITED_CTOR_INIT:
@@ -3090,7 +3094,9 @@
   break;
 
 case EXPR_CXX_TEMPORARY_OBJECT:
-  S = new (Context) CXXTemporaryObjectExpr(Empty);
+  S = CXXTemporaryObjectExpr::CreateEmpty(
+  Context,
+  /* NumArgs=*/Record[ASTStmtReader::NumExprFields]);
   break;
 
 case EXPR_CXX_STATIC_CAST:
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -6199,7 +6199,7 @@
 }
 S.MarkFunctionReferenced(Loc, Constructor);
 
-CurInit = new (S.Context) CXXTemporaryObjectExpr(
+CurInit = CXXTemporaryObjectExpr::Create(
 S.Context, Constructor,
 

[PATCH] D56025: [clang-tidy] add IgnoreMacros option to readability-uppercase-literal-suffix

2018-12-21 Thread Miklos Vajna via Phabricator via cfe-commits
vmiklos created this revision.
vmiklos added reviewers: JonasToth, alexfh, lebedev.ri.
Herald added subscribers: cfe-commits, xazax.hun.

And also enable it by default to be consistent with e.g. modernize-use-using.

This helps e.g. when running this check on client code where the macro is 
provided by the system, so there is no easy way to modify it.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D56025

Files:
  clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
  clang-tidy/readability/UppercaseLiteralSuffixCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst
  test/clang-tidy/readability-uppercase-literal-suffix-integer-macro.cpp


Index: test/clang-tidy/readability-uppercase-literal-suffix-integer-macro.cpp
===
--- test/clang-tidy/readability-uppercase-literal-suffix-integer-macro.cpp
+++ test/clang-tidy/readability-uppercase-literal-suffix-integer-macro.cpp
@@ -1,4 +1,6 @@
-// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- -I 
%S
+// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- \
+// RUN:   -config="{CheckOptions: [{key: 
readability-uppercase-literal-suffix.IgnoreMacros, value: 0}]}" \
+// RUN:   -- -I %S
 
 void macros() {
 #define INMACRO(X) 1.f
Index: docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst
===
--- docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst
+++ docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst
@@ -49,3 +49,8 @@
 * ``uL`` will be kept as is.
 * ``ull`` will be kept as is, since it is not in the list
 * and so on.
+
+.. option:: IgnoreMacros
+
+   If this option is set to non-zero (default is `1`), the check will not warn
+   about literal suffixes inside macros.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -236,6 +236,10 @@
   ` check does not warn
   about calls inside macros anymore by default.
 
+- The :doc:`readability-uppercase-literal-suffix
+  ` check does not warn
+  about literal suffixes inside macros anymore by default.
+
 - The :doc:`cppcoreguidelines-narrowing-conversions
   ` check now
   detects more narrowing conversions:
Index: clang-tidy/readability/UppercaseLiteralSuffixCheck.h
===
--- clang-tidy/readability/UppercaseLiteralSuffixCheck.h
+++ clang-tidy/readability/UppercaseLiteralSuffixCheck.h
@@ -35,6 +35,7 @@
   bool checkBoundMatch(const ast_matchers::MatchFinder::MatchResult );
 
   const std::vector NewSuffixes;
+  const bool IgnoreMacros;
 };
 
 } // namespace readability
Index: clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
===
--- clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
+++ clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
@@ -183,12 +183,14 @@
 StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   NewSuffixes(
-  utils::options::parseStringList(Options.get("NewSuffixes", ""))) {}
+  utils::options::parseStringList(Options.get("NewSuffixes", ""))),
+  IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", 1) != 0) {}
 
 void UppercaseLiteralSuffixCheck::storeOptions(
 ClangTidyOptions::OptionMap ) {
   Options.store(Opts, "NewSuffixes",
 utils::options::serializeStringList(NewSuffixes));
+  Options.store(Opts, "IgnoreMacros", IgnoreMacros);
 }
 
 void UppercaseLiteralSuffixCheck::registerMatchers(MatchFinder *Finder) {
@@ -216,6 +218,8 @@
   // We might have a suffix that is already uppercase.
   if (auto Details = shouldReplaceLiteralSuffix(
   *Literal, NewSuffixes, *Result.SourceManager, getLangOpts())) {
+if (Details->LiteralLocation.getBegin().isMacroID() && IgnoreMacros)
+  return true;
 auto Complaint = diag(Details->LiteralLocation.getBegin(),
   "%0 literal has suffix '%1', which is not uppercase")
  << LiteralType::Name << Details->OldSuffix;


Index: test/clang-tidy/readability-uppercase-literal-suffix-integer-macro.cpp
===
--- test/clang-tidy/readability-uppercase-literal-suffix-integer-macro.cpp
+++ test/clang-tidy/readability-uppercase-literal-suffix-integer-macro.cpp
@@ -1,4 +1,6 @@
-// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- -I %S
+// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- \
+// RUN:   -config="{CheckOptions: [{key: readability-uppercase-literal-suffix.IgnoreMacros, value: 0}]}" \
+// RUN:   -- -I %S
 
 void macros() {
 #define INMACRO(X) 1.f
Index: docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst

[PATCH] D55875: [analyzer] pr38668: RegionStore: Do not attempt to cast loaded values of non-scalar types.

2018-12-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 179355.
NoQ added a comment.

`// no-crash` and a slightly cleaner test.


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

https://reviews.llvm.org/D55875

Files:
  lib/StaticAnalyzer/Core/Store.cpp
  test/Analysis/casts.c
  test/Analysis/casts.cpp


Index: test/Analysis/casts.cpp
===
--- test/Analysis/casts.cpp
+++ test/Analysis/casts.cpp
@@ -102,3 +102,15 @@
   castToDerived(reinterpret_cast(ORef))->getNotInt();
 }
 } // namespace base_to_derived_opaque_class
+
+namespace bool_to_nullptr {
+struct S {
+  int *a[1];
+  bool b;
+};
+void foo(S s) {
+  s.b = true;
+  for (int i = 0; i < 2; ++i)
+(void)(s.a[i] != nullptr); // no-crash
+}
+} // namespace bool_to_nullptr
Index: test/Analysis/casts.c
===
--- test/Analysis/casts.c
+++ test/Analysis/casts.c
@@ -213,3 +213,35 @@
 }
 
 #endif
+
+char no_crash_SymbolCast_of_float_type_aux(int *p) {
+  *p += 1;
+  return *p;
+}
+
+void no_crash_SymbolCast_of_float_type() {
+  extern float x;
+  char (*f)() = no_crash_SymbolCast_of_float_type_aux;
+  f();
+}
+
+double no_crash_reinterpret_double_as_int(double a) {
+  *(int *) = 1;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_ptr(double a) {
+  *(void **) = 0;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_sym_int(double a, int b) {
+  *(int *) = b;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_sym_ptr(double a, void * b) {
+  *(void **) = b;
+  return a * a;
+}
+
Index: lib/StaticAnalyzer/Core/Store.cpp
===
--- lib/StaticAnalyzer/Core/Store.cpp
+++ lib/StaticAnalyzer/Core/Store.cpp
@@ -402,6 +402,12 @@
   if (castTy.isNull() || V.isUnknownOrUndef())
 return V;
 
+  if (castTy->isFloatingType()) {
+SymbolRef Sym = V.getAsSymbol();
+if (Sym && !Sym->getType()->isFloatingType())
+  return UnknownVal();
+  }
+
   // When retrieving symbolic pointer and expecting a non-void pointer,
   // wrap them into element regions of the expected type if necessary.
   // SValBuilder::dispatchCast() doesn't do that, but it is necessary to


Index: test/Analysis/casts.cpp
===
--- test/Analysis/casts.cpp
+++ test/Analysis/casts.cpp
@@ -102,3 +102,15 @@
   castToDerived(reinterpret_cast(ORef))->getNotInt();
 }
 } // namespace base_to_derived_opaque_class
+
+namespace bool_to_nullptr {
+struct S {
+  int *a[1];
+  bool b;
+};
+void foo(S s) {
+  s.b = true;
+  for (int i = 0; i < 2; ++i)
+(void)(s.a[i] != nullptr); // no-crash
+}
+} // namespace bool_to_nullptr
Index: test/Analysis/casts.c
===
--- test/Analysis/casts.c
+++ test/Analysis/casts.c
@@ -213,3 +213,35 @@
 }
 
 #endif
+
+char no_crash_SymbolCast_of_float_type_aux(int *p) {
+  *p += 1;
+  return *p;
+}
+
+void no_crash_SymbolCast_of_float_type() {
+  extern float x;
+  char (*f)() = no_crash_SymbolCast_of_float_type_aux;
+  f();
+}
+
+double no_crash_reinterpret_double_as_int(double a) {
+  *(int *) = 1;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_ptr(double a) {
+  *(void **) = 0;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_sym_int(double a, int b) {
+  *(int *) = b;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_sym_ptr(double a, void * b) {
+  *(void **) = b;
+  return a * a;
+}
+
Index: lib/StaticAnalyzer/Core/Store.cpp
===
--- lib/StaticAnalyzer/Core/Store.cpp
+++ lib/StaticAnalyzer/Core/Store.cpp
@@ -402,6 +402,12 @@
   if (castTy.isNull() || V.isUnknownOrUndef())
 return V;
 
+  if (castTy->isFloatingType()) {
+SymbolRef Sym = V.getAsSymbol();
+if (Sym && !Sym->getType()->isFloatingType())
+  return UnknownVal();
+  }
+
   // When retrieving symbolic pointer and expecting a non-void pointer,
   // wrap them into element regions of the expected type if necessary.
   // SValBuilder::dispatchCast() doesn't do that, but it is necessary to
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56025: [clang-tidy] add IgnoreMacros option to readability-uppercase-literal-suffix

2018-12-21 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: 
test/clang-tidy/readability-uppercase-literal-suffix-integer-macro.cpp:2-3
+// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- \
+// RUN:   -config="{CheckOptions: [{key: 
readability-uppercase-literal-suffix.IgnoreMacros, value: 0}]}" \
+// RUN:   -- -I %S
 

And the positive test?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56025



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


[PATCH] D55980: [gn build] Add build file for clang/lib/FrontendTool

2018-12-21 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D55980



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


[PATCH] D55978: [gn build] Add build files for clang/lib/{ASTMatchers, CrossTU}, clang/lib/StaticAnalyzer/{Checkers, Core, Frontend}

2018-12-21 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D55978



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


[PATCH] D55875: [analyzer] pr38668: RegionStore: Do not attempt to cast loaded values of non-scalar types.

2018-12-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349984: [analyzer] pr38668: Do not attempt to cast loaded 
integers to floats. (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55875?vs=179389=179398#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55875

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp
  cfe/trunk/test/Analysis/casts.c
  cfe/trunk/test/Analysis/casts.cpp
  cfe/trunk/test/Analysis/expr-inspection.cpp
  cfe/trunk/test/Analysis/svalbuilder-float-cast.c

Index: cfe/trunk/test/Analysis/casts.cpp
===
--- cfe/trunk/test/Analysis/casts.cpp
+++ cfe/trunk/test/Analysis/casts.cpp
@@ -102,3 +102,15 @@
   castToDerived(reinterpret_cast(ORef))->getNotInt();
 }
 } // namespace base_to_derived_opaque_class
+
+namespace bool_to_nullptr {
+struct S {
+  int *a[1];
+  bool b;
+};
+void foo(S s) {
+  s.b = true;
+  for (int i = 0; i < 2; ++i)
+(void)(s.a[i] != nullptr); // no-crash
+}
+} // namespace bool_to_nullptr
Index: cfe/trunk/test/Analysis/casts.c
===
--- cfe/trunk/test/Analysis/casts.c
+++ cfe/trunk/test/Analysis/casts.c
@@ -213,3 +213,35 @@
 }
 
 #endif
+
+char no_crash_SymbolCast_of_float_type_aux(int *p) {
+  *p += 1;
+  return *p;
+}
+
+void no_crash_SymbolCast_of_float_type() {
+  extern float x;
+  char (*f)() = no_crash_SymbolCast_of_float_type_aux;
+  f();
+}
+
+double no_crash_reinterpret_double_as_int(double a) {
+  *(int *) = 1;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_ptr(double a) {
+  *(void **) = 0;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_sym_int(double a, int b) {
+  *(int *) = b;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_sym_ptr(double a, void * b) {
+  *(void **) = b;
+  return a * a;
+}
+
Index: cfe/trunk/test/Analysis/svalbuilder-float-cast.c
===
--- cfe/trunk/test/Analysis/svalbuilder-float-cast.c
+++ cfe/trunk/test/Analysis/svalbuilder-float-cast.c
@@ -0,0 +1,20 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker debug.ExprInspection -verify %s
+void clang_analyzer_denote(int, const char *);
+void clang_analyzer_express(int);
+
+void SymbolCast_of_float_type_aux(int *p) {
+  *p += 0;
+  // FIXME: Ideally, all unknown values should be symbolicated.
+  clang_analyzer_denote(*p, "$x"); // expected-warning{{Not a symbol}}
+
+  *p += 1;
+  // This should NOT be (float)$x + 1. Symbol $x was never casted to float.
+  // FIXME: Ideally, this should be $x + 1.
+  clang_analyzer_express(*p); // expected-warning{{Not a symbol}}
+}
+
+void SymbolCast_of_float_type() {
+  extern float x;
+  void (*f)() = SymbolCast_of_float_type_aux;
+  f();
+}
Index: cfe/trunk/test/Analysis/expr-inspection.cpp
===
--- cfe/trunk/test/Analysis/expr-inspection.cpp
+++ cfe/trunk/test/Analysis/expr-inspection.cpp
@@ -24,7 +24,7 @@
   clang_analyzer_denote(1, "$z"); // expected-warning{{Not a symbol}}
   clang_analyzer_express(1); // expected-warning{{Not a symbol}}
 
-  clang_analyzer_denote(x + 1, "$w"); // expected-warning{{Not an atomic symbol}}
-  clang_analyzer_express(x + 1); // expected-warning{{$x + 1}}
+  clang_analyzer_denote(x + 1, "$w");
+  clang_analyzer_express(x + 1); // expected-warning{{$w}}
   clang_analyzer_express(y + 1); // expected-warning{{$y + 1U}}
 }
Index: cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp
@@ -402,6 +402,17 @@
   if (castTy.isNull() || V.isUnknownOrUndef())
 return V;
 
+  // The dispatchCast() call below would convert the int into a float.
+  // What we want, however, is a bit-by-bit reinterpretation of the int
+  // as a float, which usually yields nothing garbage. For now skip casts
+  // from ints to floats.
+  // TODO: What other combinations of types are affected?
+  if (castTy->isFloatingType()) {
+SymbolRef Sym = V.getAsSymbol();
+if (Sym && !Sym->getType()->isFloatingType())
+  return UnknownVal();
+  }
+
   // When retrieving symbolic pointer and expecting a non-void pointer,
   // wrap them into element regions of the expected type if necessary.
   // SValBuilder::dispatchCast() doesn't do that, but it is necessary to
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
@@ -321,11 

r349984 - [analyzer] pr38668: Do not attempt to cast loaded integers to floats.

2018-12-21 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Dec 21 18:06:51 2018
New Revision: 349984

URL: http://llvm.org/viewvc/llvm-project?rev=349984=rev
Log:
[analyzer] pr38668: Do not attempt to cast loaded integers to floats.

This patch is a different approach to landing the reverted r349701.

It is expected to have the same object (memory region) treated as if it has
different types in different program points. The correct behavior for
RegionStore when an object is stored as an object of type T1 but loaded as
an object of type T2 is to store the object as if it has type T1 but cast it
to T2 during load.

Note that the cast here is some sort of a "reinterpret_cast" (even in C). For
instance, if you store an integer and load a float, you won't get your integer
represented as a float; instead, you will get garbage.

Admit that we cannot perform the cast and return an unknown value.

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

rdar://problem/45062567

Added:
cfe/trunk/test/Analysis/svalbuilder-float-cast.c
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp
cfe/trunk/test/Analysis/casts.c
cfe/trunk/test/Analysis/casts.cpp
cfe/trunk/test/Analysis/expr-inspection.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp?rev=349984=349983=349984=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp Fri Dec 21 
18:06:51 2018
@@ -321,11 +321,6 @@ void ExprInspectionChecker::analyzerDeno
 return;
   }
 
-  if (!isa(Sym)) {
-reportBug("Not an atomic symbol", C);
-return;
-  }
-
   const auto *E = dyn_cast(CE->getArg(1)->IgnoreParenCasts());
   if (!E) {
 reportBug("Not a string literal", C);
@@ -345,7 +340,7 @@ class SymbolExpressor
 public:
   SymbolExpressor(ProgramStateRef State) : State(State) {}
 
-  Optional VisitSymExpr(const SymExpr *S) {
+  Optional lookup(const SymExpr *S) {
 if (const StringLiteral *const *SLPtr = State->get(S)) {
   const StringLiteral *SL = *SLPtr;
   return std::string(SL->getBytes());
@@ -353,8 +348,14 @@ public:
 return None;
   }
 
+  Optional VisitSymExpr(const SymExpr *S) {
+return lookup(S);
+  }
+
   Optional VisitSymIntExpr(const SymIntExpr *S) {
-if (auto Str = Visit(S->getLHS()))
+if (Optional Str = lookup(S))
+  return Str;
+if (Optional Str = Visit(S->getLHS()))
   return (*Str + " " + BinaryOperator::getOpcodeStr(S->getOpcode()) + " " +
   std::to_string(S->getRHS().getLimitedValue()) +
   (S->getRHS().isUnsigned() ? "U" : ""))
@@ -363,12 +364,22 @@ public:
   }
 
   Optional VisitSymSymExpr(const SymSymExpr *S) {
-if (auto Str1 = Visit(S->getLHS()))
-  if (auto Str2 = Visit(S->getRHS()))
+if (Optional Str = lookup(S))
+  return Str;
+if (Optional Str1 = Visit(S->getLHS()))
+  if (Optional Str2 = Visit(S->getRHS()))
 return (*Str1 + " " + BinaryOperator::getOpcodeStr(S->getOpcode()) +
 " " + *Str2).str();
 return None;
   }
+
+  Optional VisitSymbolCast(const SymbolCast *S) {
+if (Optional Str = lookup(S))
+  return Str;
+if (Optional Str = Visit(S->getOperand()))
+  return (Twine("(") + S->getType().getAsString() + ")" + *Str).str();
+return None;
+  }
 };
 } // namespace
 

Modified: cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp?rev=349984=349983=349984=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp Fri Dec 21 18:06:51 2018
@@ -402,6 +402,17 @@ SVal StoreManager::CastRetrievedVal(SVal
   if (castTy.isNull() || V.isUnknownOrUndef())
 return V;
 
+  // The dispatchCast() call below would convert the int into a float.
+  // What we want, however, is a bit-by-bit reinterpretation of the int
+  // as a float, which usually yields nothing garbage. For now skip casts
+  // from ints to floats.
+  // TODO: What other combinations of types are affected?
+  if (castTy->isFloatingType()) {
+SymbolRef Sym = V.getAsSymbol();
+if (Sym && !Sym->getType()->isFloatingType())
+  return UnknownVal();
+  }
+
   // When retrieving symbolic pointer and expecting a non-void pointer,
   // wrap them into element regions of the expected type if necessary.
   // SValBuilder::dispatchCast() doesn't do that, but it is necessary to

Modified: cfe/trunk/test/Analysis/casts.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/casts.c?rev=349984=349983=349984=diff

[PATCH] D55869: Convert some ObjC retain/release msgSends to runtime calls

2018-12-21 Thread Pete Cooper via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC349952: Convert some ObjC retain/release msgSends to runtime 
calls. (authored by pete, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D55869

Files:
  include/clang/Basic/ObjCRuntime.h
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.h
  test/CodeGenObjC/convert-messages-to-runtime-calls.m

Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -396,6 +396,29 @@
 }
 break;
 
+  case OMF_autorelease:
+if (ResultType->isObjCObjectPointerType() &&
+CGM.getLangOpts().getGC() == LangOptions::NonGC &&
+Runtime.shouldUseARCFunctionsForRetainRelease())
+  return CGF.EmitObjCAutorelease(Receiver, CGF.ConvertType(ResultType));
+break;
+
+  case OMF_retain:
+if (ResultType->isObjCObjectPointerType() &&
+CGM.getLangOpts().getGC() == LangOptions::NonGC &&
+Runtime.shouldUseARCFunctionsForRetainRelease())
+  return CGF.EmitObjCRetainNonBlock(Receiver, CGF.ConvertType(ResultType));
+break;
+
+  case OMF_release:
+if (ResultType->isVoidType() &&
+CGM.getLangOpts().getGC() == LangOptions::NonGC &&
+Runtime.shouldUseARCFunctionsForRetainRelease()) {
+  CGF.EmitObjCRelease(Receiver, ARCPreciseLifetime);
+  return nullptr;
+}
+break;
+
   default:
 break;
   }
@@ -2006,6 +2029,11 @@
 llvm::FunctionType *fnType =
   llvm::FunctionType::get(CGF.Int8PtrTy, CGF.Int8PtrTy, false);
 fn = CGF.CGM.CreateRuntimeFunction(fnType, fnName);
+
+// We have Native ARC, so set nonlazybind attribute for performance
+if (llvm::Function *f = dyn_cast(fn))
+  if (fnName == "objc_retain")
+f->addFnAttr(llvm::Attribute::NonLazyBind);
   }
 
   // Cast the argument to 'id'.
@@ -2510,6 +2538,55 @@
   CGF.EmitARCIntrinsicUse(value);
 }
 
+/// Autorelease the given object.
+///   call i8* \@objc_autorelease(i8* %value)
+llvm::Value *CodeGenFunction::EmitObjCAutorelease(llvm::Value *value,
+  llvm::Type *returnType) {
+  return emitObjCValueOperation(*this, value, returnType,
+  CGM.getObjCEntrypoints().objc_autoreleaseRuntimeFunction,
+"objc_autorelease");
+}
+
+/// Retain the given object, with normal retain semantics.
+///   call i8* \@objc_retain(i8* %value)
+llvm::Value *CodeGenFunction::EmitObjCRetainNonBlock(llvm::Value *value,
+ llvm::Type *returnType) {
+  return emitObjCValueOperation(*this, value, returnType,
+  CGM.getObjCEntrypoints().objc_retainRuntimeFunction,
+"objc_retain");
+}
+
+/// Release the given object.
+///   call void \@objc_release(i8* %value)
+void CodeGenFunction::EmitObjCRelease(llvm::Value *value,
+  ARCPreciseLifetime_t precise) {
+  if (isa(value)) return;
+
+  llvm::Constant * = CGM.getObjCEntrypoints().objc_release;
+  if (!fn) {
+if (!fn) {
+  llvm::FunctionType *fnType =
+llvm::FunctionType::get(Builder.getVoidTy(), Int8PtrTy, false);
+  fn = CGM.CreateRuntimeFunction(fnType, "objc_release");
+  setARCRuntimeFunctionLinkage(CGM, fn);
+  // We have Native ARC, so set nonlazybind attribute for performance
+  if (llvm::Function *f = dyn_cast(fn))
+f->addFnAttr(llvm::Attribute::NonLazyBind);
+}
+  }
+
+  // Cast the argument to 'id'.
+  value = Builder.CreateBitCast(value, Int8PtrTy);
+
+  // Call objc_release.
+  llvm::CallInst *call = EmitNounwindRuntimeCall(fn, value);
+
+  if (precise == ARCImpreciseLifetime) {
+call->setMetadata("clang.imprecise_release",
+  llvm::MDNode::get(Builder.getContext(), None));
+  }
+}
+
 namespace {
   struct CallObjCAutoreleasePoolObject final : EHScopeStack::Cleanup {
 llvm::Value *Token;
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -138,6 +138,10 @@
   /// id objc_autorelease(id);
   llvm::Constant *objc_autorelease;
 
+  /// id objc_autorelease(id);
+  /// Note this is the runtime method not the intrinsic.
+  llvm::Constant *objc_autoreleaseRuntimeFunction;
+
   /// id objc_autoreleaseReturnValue(id);
   llvm::Constant *objc_autoreleaseReturnValue;
 
@@ -162,6 +166,10 @@
   /// id objc_retain(id);
   llvm::Constant *objc_retain;
 
+  /// id objc_retain(id);
+  /// Note this is the runtime method not the intrinsic.
+  llvm::Constant *objc_retainRuntimeFunction;
+
   /// id objc_retainAutorelease(id);
   llvm::Constant *objc_retainAutorelease;
 
@@ -177,6 +185,10 @@
   /// void objc_release(id);
   

r349952 - Convert some ObjC retain/release msgSends to runtime calls.

2018-12-21 Thread Pete Cooper via cfe-commits
Author: pete
Date: Fri Dec 21 13:00:32 2018
New Revision: 349952

URL: http://llvm.org/viewvc/llvm-project?rev=349952=rev
Log:
Convert some ObjC retain/release msgSends to runtime calls.

It is faster to directly call the ObjC runtime for methods such as 
retain/release instead of sending a message to those functions.

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

Reviewed By: rjmccall

Modified:
cfe/trunk/include/clang/Basic/ObjCRuntime.h
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m

Modified: cfe/trunk/include/clang/Basic/ObjCRuntime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/ObjCRuntime.h?rev=349952=349951=349952=diff
==
--- cfe/trunk/include/clang/Basic/ObjCRuntime.h (original)
+++ cfe/trunk/include/clang/Basic/ObjCRuntime.h Fri Dec 21 13:00:32 2018
@@ -173,6 +173,43 @@ public:
 llvm_unreachable("bad kind");
   }
 
+  /// Does this runtime provide ARC entrypoints that are likely to be faster
+  /// than an ordinary message send of the appropriate selector?
+  ///
+  /// The ARC entrypoints are guaranteed to be equivalent to just sending the
+  /// corresponding message.  If the entrypoint is implemented naively as just 
a
+  /// message send, using it is a trade-off: it sacrifices a few cycles of
+  /// overhead to save a small amount of code.  However, it's possible for
+  /// runtimes to detect and special-case classes that use "standard"
+  /// retain/release behavior; if that's dynamically a large proportion of all
+  /// retained objects, using the entrypoint will also be faster than using a
+  /// message send.
+  ///
+  /// When this method returns true, Clang will turn non-super message sends of
+  /// certain selectors into calls to the correspond entrypoint:
+  ///   retain => objc_retain
+  ///   release => objc_release
+  ///   autorelease => objc_autorelease
+  bool shouldUseARCFunctionsForRetainRelease() const {
+switch (getKind()) {
+case FragileMacOSX:
+  return false;
+case MacOSX:
+  return getVersion() >= VersionTuple(10, 10);
+case iOS:
+  return getVersion() >= VersionTuple(8);
+case WatchOS:
+  return true;
+case GCC:
+  return false;
+case GNUstep:
+  return false;
+case ObjFW:
+  return false;
+}
+llvm_unreachable("bad kind");
+  }
+
   /// Does this runtime provide entrypoints that are likely to be faster
   /// than an ordinary message send of the "alloc" selector?
   ///

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=349952=349951=349952=diff
==
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Fri Dec 21 13:00:32 2018
@@ -396,6 +396,29 @@ tryGenerateSpecializedMessageSend(CodeGe
 }
 break;
 
+  case OMF_autorelease:
+if (ResultType->isObjCObjectPointerType() &&
+CGM.getLangOpts().getGC() == LangOptions::NonGC &&
+Runtime.shouldUseARCFunctionsForRetainRelease())
+  return CGF.EmitObjCAutorelease(Receiver, CGF.ConvertType(ResultType));
+break;
+
+  case OMF_retain:
+if (ResultType->isObjCObjectPointerType() &&
+CGM.getLangOpts().getGC() == LangOptions::NonGC &&
+Runtime.shouldUseARCFunctionsForRetainRelease())
+  return CGF.EmitObjCRetainNonBlock(Receiver, CGF.ConvertType(ResultType));
+break;
+
+  case OMF_release:
+if (ResultType->isVoidType() &&
+CGM.getLangOpts().getGC() == LangOptions::NonGC &&
+Runtime.shouldUseARCFunctionsForRetainRelease()) {
+  CGF.EmitObjCRelease(Receiver, ARCPreciseLifetime);
+  return nullptr;
+}
+break;
+
   default:
 break;
   }
@@ -2006,6 +2029,11 @@ static llvm::Value *emitObjCValueOperati
 llvm::FunctionType *fnType =
   llvm::FunctionType::get(CGF.Int8PtrTy, CGF.Int8PtrTy, false);
 fn = CGF.CGM.CreateRuntimeFunction(fnType, fnName);
+
+// We have Native ARC, so set nonlazybind attribute for performance
+if (llvm::Function *f = dyn_cast(fn))
+  if (fnName == "objc_retain")
+f->addFnAttr(llvm::Attribute::NonLazyBind);
   }
 
   // Cast the argument to 'id'.
@@ -2510,6 +2538,55 @@ void CodeGenFunction::emitARCIntrinsicUs
   CGF.EmitARCIntrinsicUse(value);
 }
 
+/// Autorelease the given object.
+///   call i8* \@objc_autorelease(i8* %value)
+llvm::Value *CodeGenFunction::EmitObjCAutorelease(llvm::Value *value,
+  llvm::Type *returnType) {
+  return emitObjCValueOperation(*this, value, returnType,
+  CGM.getObjCEntrypoints().objc_autoreleaseRuntimeFunction,
+"objc_autorelease");
+}
+
+/// Retain the 

[PATCH] D55869: Convert some ObjC retain/release msgSends to runtime calls

2018-12-21 Thread Pete Cooper via Phabricator via cfe-commits
pete added a comment.

In D55869#1339537 , @rjmccall wrote:

> It sounds like it's fine.


Thanks for the review!  Just pushed it as r349952.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55869



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


[PATCH] D56022: [AST] Store the arguments of CXXConstructExpr in a trailing array

2018-12-21 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno marked 2 inline comments as done.
riccibruno added inline comments.



Comment at: include/clang/AST/ExprCXX.h:1295
+  /// A pointer to the constructor which will be ultimately called.
+  CXXConstructorDecl *Constructor;
+

Removed the default member initializer as it is initialized unconditionally
in the constructor.



Comment at: include/clang/AST/ExprCXX.h:1613
+
+  TypeSourceInfo *TSI = nullptr;
+

Changed the name from `Type` since `Type` was imho an unfortunate choice.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56022



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


[PATCH] D55710: add pragmas to control Software Pipelining optimisation

2018-12-21 Thread Alexey Lapshin via Phabricator via cfe-commits
alexey.lapshin marked 2 inline comments as done.
alexey.lapshin added a comment.

will correct all mistakes. please check explanations for the questions.




Comment at: include/clang/Basic/AttrDocs.td:2655
+  dependence violated. This constant interval(in cycles) between the start
+  of iterations called initiation interval. Cycles number of one iteration
+  of newly generated loop matches with Initiation Interval. For further

aaron.ballman wrote:
> is called the initiation interval.
> 
> I can't quite parse the second sentence, though. Is it trying to say that the 
> initiation interval is the number of cycles for a single iteration of the 
> optimized loop?
Not quite right : initiation interval is not a number of cycles for a single 
iteration of the optimized loop. But initiation interval matches with number of 
cycles for a single iteration of the optimized loop. Initiation interval is the 
number of cycles between next and previous iteration of original loop. New loop 
created so that single iteration of the optimized loop has the same number 
cycles as initiation interval( thus every new iteration of original loop 
started each time when new iteration of optimized loop started - difference 
between iterations is initiation interval). 

trying to rephrase : number of cycles for a single iteration of the optimized 
loop matches with number of cycles of initiation interval.



Comment at: include/clang/Basic/AttrDocs.td:2676
+  the software pipeliner to try the specified initiation interval.
+  If schedule found the resulting loop iteration would have specified
+  cycle count. The positive number greater than zero can be specified:

aaron.ballman wrote:
> I'm can't quite parse this sentence either. Is it trying to say that the 
> scheduler will try to find a loop iteration cycle count that most-closely 
> matches the specified initiation interval?
I wanted to say that pipeliner will try to find a schedule that exactly matches 
the specified initiation interval. And if schedule would be found then single 
iteration of the optimized loop would have exactly the same amount of cycles as 
initiation interval. trying to rephrase :

If schedule would be found then single iteration of the optimized loop would 
have exactly the same amount of cycles as initiation interval has. 


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

https://reviews.llvm.org/D55710



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


[PATCH] D56025: [clang-tidy] add IgnoreMacros option to readability-uppercase-literal-suffix

2018-12-21 Thread Miklos Vajna via Phabricator via cfe-commits
vmiklos updated this revision to Diff 179371.

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

https://reviews.llvm.org/D56025

Files:
  clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
  clang-tidy/readability/UppercaseLiteralSuffixCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst
  test/clang-tidy/readability-uppercase-literal-suffix-integer-macro.cpp
  test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp


Index: test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp
===
--- test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp
+++ test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp
@@ -235,6 +235,10 @@
   // CHECK-FIXES: static constexpr auto m0 = PASSTHROUGH(1U);
   static_assert(is_same::value, "");
   static_assert(m0 == 1, "");
+
+  // This location is inside a macro, no warning on that by default.
+#define MACRO 1u
+  int foo = MACRO;
 }
 
 // Check that user-defined literals do not cause any diags.
Index: test/clang-tidy/readability-uppercase-literal-suffix-integer-macro.cpp
===
--- test/clang-tidy/readability-uppercase-literal-suffix-integer-macro.cpp
+++ test/clang-tidy/readability-uppercase-literal-suffix-integer-macro.cpp
@@ -1,4 +1,6 @@
-// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- -I 
%S
+// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- \
+// RUN:   -config="{CheckOptions: [{key: 
readability-uppercase-literal-suffix.IgnoreMacros, value: 0}]}" \
+// RUN:   -- -I %S
 
 void macros() {
 #define INMACRO(X) 1.f
Index: docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst
===
--- docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst
+++ docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst
@@ -49,3 +49,8 @@
 * ``uL`` will be kept as is.
 * ``ull`` will be kept as is, since it is not in the list
 * and so on.
+
+.. option:: IgnoreMacros
+
+   If this option is set to non-zero (default is `1`), the check will not warn
+   about literal suffixes inside macros.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -236,6 +236,10 @@
   ` check does not warn
   about calls inside macros anymore by default.
 
+- The :doc:`readability-uppercase-literal-suffix
+  ` check does not warn
+  about literal suffixes inside macros anymore by default.
+
 - The :doc:`cppcoreguidelines-narrowing-conversions
   ` check now
   detects more narrowing conversions:
Index: clang-tidy/readability/UppercaseLiteralSuffixCheck.h
===
--- clang-tidy/readability/UppercaseLiteralSuffixCheck.h
+++ clang-tidy/readability/UppercaseLiteralSuffixCheck.h
@@ -35,6 +35,7 @@
   bool checkBoundMatch(const ast_matchers::MatchFinder::MatchResult );
 
   const std::vector NewSuffixes;
+  const bool IgnoreMacros;
 };
 
 } // namespace readability
Index: clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
===
--- clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
+++ clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
@@ -183,12 +183,14 @@
 StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   NewSuffixes(
-  utils::options::parseStringList(Options.get("NewSuffixes", ""))) {}
+  utils::options::parseStringList(Options.get("NewSuffixes", ""))),
+  IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", 1) != 0) {}
 
 void UppercaseLiteralSuffixCheck::storeOptions(
 ClangTidyOptions::OptionMap ) {
   Options.store(Opts, "NewSuffixes",
 utils::options::serializeStringList(NewSuffixes));
+  Options.store(Opts, "IgnoreMacros", IgnoreMacros);
 }
 
 void UppercaseLiteralSuffixCheck::registerMatchers(MatchFinder *Finder) {
@@ -216,6 +218,8 @@
   // We might have a suffix that is already uppercase.
   if (auto Details = shouldReplaceLiteralSuffix(
   *Literal, NewSuffixes, *Result.SourceManager, getLangOpts())) {
+if (Details->LiteralLocation.getBegin().isMacroID() && IgnoreMacros)
+  return true;
 auto Complaint = diag(Details->LiteralLocation.getBegin(),
   "%0 literal has suffix '%1', which is not uppercase")
  << LiteralType::Name << Details->OldSuffix;


Index: test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp
===
--- test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp
+++ test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp
@@ -235,6 +235,10 @@
   // CHECK-FIXES: static constexpr auto m0 

[PATCH] D56025: [clang-tidy] add IgnoreMacros option to readability-uppercase-literal-suffix

2018-12-21 Thread Miklos Vajna via Phabricator via cfe-commits
vmiklos marked 2 inline comments as done.
vmiklos added inline comments.



Comment at: 
test/clang-tidy/readability-uppercase-literal-suffix-integer-macro.cpp:2-3
+// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- \
+// RUN:   -config="{CheckOptions: [{key: 
readability-uppercase-literal-suffix.IgnoreMacros, value: 0}]}" \
+// RUN:   -- -I %S
 

lebedev.ri wrote:
> And the positive test?
Added a positive test now. :-)


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

https://reviews.llvm.org/D56025



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


[PATCH] D54565: Introduce `-Wctad` as a subgroup of `-Wc++14-compat`

2018-12-21 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

>> I think there is a case to be made for warning on this specific language 
>> feature, because using CTAD on class templates that weren't designed for it 
>> is dangerous and creates source compatibility problems for future changes to 
>> that library.
> 
> Personally I would go stronger: using CTAD on class templates that were 
> designed for it (1) is dangerous and (2) may create source compatibility 
> problems for future changes to that library!

I've given this a lot of thought, and while I'm very sympathetic to your desire 
here, I do not think that we have sufficient justification to provide a warning 
to allow (effectively) disabling this language features. There's an important 
difference here:

- using CTAD on arbitrary class templates that weren't designed for it creates 
a source compatibility problem that the class template author has no control 
over nor say in
- using CTAD on class templates that were designed for it does not create a new 
source compatibility problem -- the class template author created the source 
compatibility problem themselves when they designed how their class templates 
would interact with CTAD

Either way there's a source compatibility problem, but in the second case, it's 
the class template author's choice to extend their source compatibility 
contract. So:

- I still think it's a good idea to have a warning to warn on use of CTAD on a 
class where there is no evidence the class was designed for CTAD (this warning 
would be suppressed by either an explicit deduction guide or by an attribute on 
the class template definition indicating that the constructors are designed to 
support CTAD)
- it would also seem like a good idea to have warnings for CTAD cases that we 
have strong evidence are dangerous (eg, for `T(x...)` where `x` expands to a 
pack containing a single `T`, we should warn if we use the copy-deduction 
candidate and there's another candidate that would have been selected if the 
copy-deduction candidate didn't get a priority boost)

... but I don't think we can justify warning on all CTAD.

Have you considered the `clang-tidy` route? Given that it seems like your goal 
is to avoid accidental use of CTAD, an out-of-band (not part of regular 
compilations) check that you satisfy that goal would seem like it could be part 
of a solution.


Repository:
  rC Clang

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

https://reviews.llvm.org/D54565



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


[PATCH] D56033: [CUDA] Treat extern global variable shadows same as regular extern vars.

2018-12-21 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349981: [CUDA] Treat extern global variable shadows same as 
regular extern vars. (authored by tra, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56033?vs=179387=179395#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56033

Files:
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/test/CodeGenCUDA/device-stub.cu


Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -2188,15 +2188,7 @@
   } else {
 const auto *VD = cast(Global);
 assert(VD->isFileVarDecl() && "Cannot emit local var decl as global.");
-// We need to emit device-side global CUDA variables even if a
-// variable does not have a definition -- we still need to define
-// host-side shadow for it.
-bool MustEmitForCuda = LangOpts.CUDA && !LangOpts.CUDAIsDevice &&
-   !VD->hasDefinition() &&
-   (VD->hasAttr() ||
-VD->hasAttr());
-if (!MustEmitForCuda &&
-VD->isThisDeclarationADefinition() != VarDecl::Definition &&
+if (VD->isThisDeclarationADefinition() != VarDecl::Definition &&
 !Context.isMSStaticDataMemberInlineDefinition(VD)) {
   if (LangOpts.OpenMP) {
 // Emit declaration of the must-be-emitted declare target variable.
@@ -3616,7 +3608,10 @@
   Flags |= CGCUDARuntime::ExternDeviceVar;
 if (D->hasAttr())
   Flags |= CGCUDARuntime::ConstantDeviceVar;
-getCUDARuntime().registerDeviceVar(*GV, Flags);
+// Extern global variables will be registered in the TU where they are
+// defined.
+if (!D->hasExternalStorage())
+  getCUDARuntime().registerDeviceVar(*GV, Flags);
   } else if (D->hasAttr())
 // __shared__ variables are odd. Shadows do get created, but
 // they are not registered with the CUDA runtime, so they
Index: cfe/trunk/test/CodeGenCUDA/device-stub.cu
===
--- cfe/trunk/test/CodeGenCUDA/device-stub.cu
+++ cfe/trunk/test/CodeGenCUDA/device-stub.cu
@@ -42,13 +42,20 @@
 // ALL-DAG: @ext_host_var = external global i32
 extern int ext_host_var;
 
-// Shadows for external device-side variables are *definitions* of
-// those variables.
-// ALL-DAG: @ext_device_var = internal global i32
+// external device-side variables -> extern references to their shadows.
+// ALL-DAG: @ext_device_var = external global i32
 extern __device__ int ext_device_var;
-// ALL-DAG: @ext_device_var = internal global i32
+// ALL-DAG: @ext_device_var = external global i32
 extern __constant__ int ext_constant_var;
 
+// external device-side variables with definitions should generate
+// definitions for the shadows.
+// ALL-DAG: @ext_device_var_def = internal global i32 undef,
+extern __device__ int ext_device_var_def;
+__device__ int ext_device_var_def = 1;
+// ALL-DAG: @ext_device_var_def = internal global i32 undef,
+__constant__ int ext_constant_var_def = 2;
+
 void use_pointers() {
   int *p;
   p = _var;
@@ -114,8 +121,8 @@
 // ALL: call{{.*}}[[PREFIX]]RegisterFunction(i8** %0, {{.*}}kernelfunc
 // ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, {{.*}}device_var{{.*}}i32 
0, i32 4, i32 0, i32 0
 // ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}constant_var{{.*}}i32 0, i32 4, i32 1, i32 0
-// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_device_var{{.*}}i32 1, i32 4, i32 0, i32 0
-// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_constant_var{{.*}}i32 1, i32 4, i32 1, i32 0
+// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_device_var_def{{.*}}i32 0, i32 4, i32 0, i32 0
+// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_constant_var_def{{.*}}i32 0, i32 4, i32 1, i32 0
 // ALL: ret void
 
 // Test that we've built a constructor.


Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -2188,15 +2188,7 @@
   } else {
 const auto *VD = cast(Global);
 assert(VD->isFileVarDecl() && "Cannot emit local var decl as global.");
-// We need to emit device-side global CUDA variables even if a
-// variable does not have a definition -- we still need to define
-// host-side shadow for it.
-bool MustEmitForCuda = LangOpts.CUDA && !LangOpts.CUDAIsDevice &&
-   !VD->hasDefinition() &&
-   (VD->hasAttr() ||
-VD->hasAttr());
-if (!MustEmitForCuda &&
-VD->isThisDeclarationADefinition() != 

r349949 - [Sema][NFC] Fix a Wimplicit-fallthrough warning in CheckSpecializationInstantiationRedecl

2018-12-21 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Fri Dec 21 12:38:06 2018
New Revision: 349949

URL: http://llvm.org/viewvc/llvm-project?rev=349949=rev
Log:
[Sema][NFC] Fix a Wimplicit-fallthrough warning in 
CheckSpecializationInstantiationRedecl

All cases are covered so add an llvm_unreachable. NFC.


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

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=349949=349948=349949=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Dec 21 12:38:06 2018
@@ -7966,6 +7966,7 @@ Sema::CheckSpecializationInstantiationRe
   HasNoEffect = true;
   return false;
 }
+llvm_unreachable("Unexpected TemplateSpecializationKind!");
 
   case TSK_ExplicitInstantiationDefinition:
 switch (PrevTSK) {


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


[PATCH] D55949: Correctly handle function pointers returning a type marked nodiscard

2018-12-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested review of this revision.
aaron.ballman added a comment.

There's enough churn based on the review feedback that this should probably 
have a second round of review just to be sure.




Comment at: lib/AST/Expr.cpp:2281-2286
+  // If there is no FunctionDecl for the call, check the return type of the
+  // callee to see if it was declared with the WarnUnusedResult attribute.
+  if (!Func && !HasWarnUnusedResultAttr) {
+if (const TagDecl *TD = CE->getCallReturnType(Ctx)->getAsTagDecl())
+  HasWarnUnusedResultAttr = TD->hasAttr();
+  }

erik.pilkington wrote:
> This duplicates some logic from FunctionDecl::hasUnusedResultAttr(), maybe we 
> should move that member function to the CallExpr?
Good suggestion -- I think that cleans up the interface nicely.



Comment at: test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp:51
+
+  one(); // expected-warning {{ignoring return value of function declared with 
'nodiscard' attribute}}
+  two(); // expected-warning {{ignoring return value of function declared with 
'nodiscard' attribute}}

erik.pilkington wrote:
> This diagnostic should also probably be improved at some point, the function 
> wasn't declared 'nodiscard', the type was.
Yeah, I noticed that as well.


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

https://reviews.llvm.org/D55949



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


[PATCH] D56012: [clang-tidy] Be more liberal about literal zeroes in abseil checks

2018-12-21 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/D56012/new/

https://reviews.llvm.org/D56012



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


r349955 - Switch from static_cast<> to cast<>, update identifier for coding conventions; NFC.

2018-12-21 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Dec 21 13:11:36 2018
New Revision: 349955

URL: http://llvm.org/viewvc/llvm-project?rev=349955=rev
Log:
Switch from static_cast<> to cast<>, update identifier for coding conventions; 
NFC.

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

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=349955=349954=349955=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Fri Dec 21 13:11:36 2018
@@ -469,11 +469,9 @@ Sema::ActOnCaseStmt(SourceLocation CaseL
 }
 
 /// ActOnCaseStmtBody - This installs a statement as the body of a case.
-void Sema::ActOnCaseStmtBody(Stmt *caseStmt, Stmt *SubStmt) {
+void Sema::ActOnCaseStmtBody(Stmt *S, Stmt *SubStmt) {
   DiagnoseUnusedExprResult(SubStmt);
-
-  auto *CS = static_cast(caseStmt);
-  CS->setSubStmt(SubStmt);
+  cast(S)->setSubStmt(SubStmt);
 }
 
 StmtResult


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


[PATCH] D55878: [Driver] Use --hash-style=gnu instead of both on FreeBSD

2018-12-21 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D55878#1339098 , @emaste wrote:

> I think the arch-change (switching from a whitelist to a MIPS blacklist) is 
> reasonable. What is the motivation for dropping `DT_HASH`, just binary size 
> reduction?


Yes. It saves a few hundreds bytes to a few kilobytes for each EXE/DSO.

See `Linux.cpp`, some Linux distributions default to `--hash-style=gnu` too:

  if (!IsMips && !IsHexagon) {
if (Distro.IsRedhat() || Distro.IsOpenSUSE() || Distro.IsAlpineLinux() ||
(Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick) ||
(IsAndroid && !Triple.isAndroidVersionLT(23)))
  ExtraOpts.push_back("--hash-style=gnu");

This section is only consumed by dynamic loader. It is unfortunate that OpenBSD 
only ported this a month ago and illumos does not support it at all. The GNU 
section is superior to the SYSV counterpart, even in term of section sizes 
(`.hash` does not skip local symbols).


Repository:
  rC Clang

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

https://reviews.llvm.org/D55878



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


[PATCH] D56033: [CUDA] Treat extern global variable shadows same as regular extern vars.

2018-12-21 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
tra added a reviewer: jlebar.
Herald added subscribers: bixia, sanjoy.

This fixes compiler crash when we attempted to compile this code:

  extern __device__ int data;
  __device__ int data = 1;


https://reviews.llvm.org/D56033

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCUDA/device-stub.cu


Index: clang/test/CodeGenCUDA/device-stub.cu
===
--- clang/test/CodeGenCUDA/device-stub.cu
+++ clang/test/CodeGenCUDA/device-stub.cu
@@ -42,13 +42,20 @@
 // ALL-DAG: @ext_host_var = external global i32
 extern int ext_host_var;
 
-// Shadows for external device-side variables are *definitions* of
-// those variables.
-// ALL-DAG: @ext_device_var = internal global i32
+// external device-side variables -> extern references to their shadows.
+// ALL-DAG: @ext_device_var = external global i32
 extern __device__ int ext_device_var;
-// ALL-DAG: @ext_device_var = internal global i32
+// ALL-DAG: @ext_device_var = external global i32
 extern __constant__ int ext_constant_var;
 
+// external device-side variables with definitiions should generate
+// definitions for the shadows.
+// ALL-DAG: @ext_device_var_def = internal global i32 undef,
+extern __device__ int ext_device_var_def;
+__device__ int ext_device_var_def = 1;
+// ALL-DAG: @ext_device_var_def = internal global i32 undef,
+__constant__ int ext_constant_var_def = 2;
+
 void use_pointers() {
   int *p;
   p = _var;
@@ -114,8 +121,8 @@
 // ALL: call{{.*}}[[PREFIX]]RegisterFunction(i8** %0, {{.*}}kernelfunc
 // ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, {{.*}}device_var{{.*}}i32 
0, i32 4, i32 0, i32 0
 // ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}constant_var{{.*}}i32 0, i32 4, i32 1, i32 0
-// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_device_var{{.*}}i32 1, i32 4, i32 0, i32 0
-// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_constant_var{{.*}}i32 1, i32 4, i32 1, i32 0
+// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_device_var_def{{.*}}i32 0, i32 4, i32 0, i32 0
+// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, 
{{.*}}ext_constant_var_def{{.*}}i32 0, i32 4, i32 1, i32 0
 // ALL: ret void
 
 // Test that we've built a constructor.
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2188,15 +2188,7 @@
   } else {
 const auto *VD = cast(Global);
 assert(VD->isFileVarDecl() && "Cannot emit local var decl as global.");
-// We need to emit device-side global CUDA variables even if a
-// variable does not have a definition -- we still need to define
-// host-side shadow for it.
-bool MustEmitForCuda = LangOpts.CUDA && !LangOpts.CUDAIsDevice &&
-   !VD->hasDefinition() &&
-   (VD->hasAttr() ||
-VD->hasAttr());
-if (!MustEmitForCuda &&
-VD->isThisDeclarationADefinition() != VarDecl::Definition &&
+if (VD->isThisDeclarationADefinition() != VarDecl::Definition &&
 !Context.isMSStaticDataMemberInlineDefinition(VD)) {
   if (LangOpts.OpenMP) {
 // Emit declaration of the must-be-emitted declare target variable.
@@ -3616,7 +3608,10 @@
   Flags |= CGCUDARuntime::ExternDeviceVar;
 if (D->hasAttr())
   Flags |= CGCUDARuntime::ConstantDeviceVar;
-getCUDARuntime().registerDeviceVar(*GV, Flags);
+// Extern global variables will be registered in the TU where they are
+// defined.
+if (!D->hasExternalStorage())
+  getCUDARuntime().registerDeviceVar(*GV, Flags);
   } else if (D->hasAttr())
 // __shared__ variables are odd. Shadows do get created, but
 // they are not registered with the CUDA runtime, so they


Index: clang/test/CodeGenCUDA/device-stub.cu
===
--- clang/test/CodeGenCUDA/device-stub.cu
+++ clang/test/CodeGenCUDA/device-stub.cu
@@ -42,13 +42,20 @@
 // ALL-DAG: @ext_host_var = external global i32
 extern int ext_host_var;
 
-// Shadows for external device-side variables are *definitions* of
-// those variables.
-// ALL-DAG: @ext_device_var = internal global i32
+// external device-side variables -> extern references to their shadows.
+// ALL-DAG: @ext_device_var = external global i32
 extern __device__ int ext_device_var;
-// ALL-DAG: @ext_device_var = internal global i32
+// ALL-DAG: @ext_device_var = external global i32
 extern __constant__ int ext_constant_var;
 
+// external device-side variables with definitiions should generate
+// definitions for the shadows.
+// ALL-DAG: @ext_device_var_def = internal global i32 undef,
+extern __device__ int ext_device_var_def;
+__device__ int ext_device_var_def = 1;
+// ALL-DAG: @ext_device_var_def = internal global i32 undef,

[PATCH] D55875: [analyzer] pr38668: RegionStore: Do not attempt to cast loaded values of non-scalar types.

2018-12-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 179379.
NoQ added a comment.

Add a comment.

I guess it doesn't really matter why does this lead to a crash. The symbol 
itself is well-formed, but we probably don't support it yet in some place, and 
hopefully (but not necessarily) `CastRetrievedVal` is the only place we produce 
it. The point here is that the old behavior is clearly incorrect (i.e., the 
code doesn't do the right thing, and due to that the well-formed symbol is in 
fact not the symbol that we're looking for) and the new behavior is clearly 
conservative (i.e., returning `UnknownVal` should be pretty safe).

What we really need is a more direct test. Probably unit tests for 
`SValBuilder`, or some of those "denote - express" tests.


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

https://reviews.llvm.org/D55875

Files:
  lib/StaticAnalyzer/Core/Store.cpp
  test/Analysis/casts.c
  test/Analysis/casts.cpp


Index: test/Analysis/casts.cpp
===
--- test/Analysis/casts.cpp
+++ test/Analysis/casts.cpp
@@ -102,3 +102,15 @@
   castToDerived(reinterpret_cast(ORef))->getNotInt();
 }
 } // namespace base_to_derived_opaque_class
+
+namespace bool_to_nullptr {
+struct S {
+  int *a[1];
+  bool b;
+};
+void foo(S s) {
+  s.b = true;
+  for (int i = 0; i < 2; ++i)
+(void)(s.a[i] != nullptr); // no-crash
+}
+} // namespace bool_to_nullptr
Index: test/Analysis/casts.c
===
--- test/Analysis/casts.c
+++ test/Analysis/casts.c
@@ -213,3 +213,35 @@
 }
 
 #endif
+
+char no_crash_SymbolCast_of_float_type_aux(int *p) {
+  *p += 1;
+  return *p;
+}
+
+void no_crash_SymbolCast_of_float_type() {
+  extern float x;
+  char (*f)() = no_crash_SymbolCast_of_float_type_aux;
+  f();
+}
+
+double no_crash_reinterpret_double_as_int(double a) {
+  *(int *) = 1;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_ptr(double a) {
+  *(void **) = 0;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_sym_int(double a, int b) {
+  *(int *) = b;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_sym_ptr(double a, void * b) {
+  *(void **) = b;
+  return a * a;
+}
+
Index: lib/StaticAnalyzer/Core/Store.cpp
===
--- lib/StaticAnalyzer/Core/Store.cpp
+++ lib/StaticAnalyzer/Core/Store.cpp
@@ -402,6 +402,16 @@
   if (castTy.isNull() || V.isUnknownOrUndef())
 return V;
 
+  // The dispatchCast() call below would round the int to a float. What we 
want,
+  // however, is a bit-by-bit reinterpretation of the int as a float, which
+  // usually yields nothing garbage. For now skip casts from ints to floats.
+  // TODO: What other combinations of types are affected?
+  if (castTy->isFloatingType()) {
+SymbolRef Sym = V.getAsSymbol();
+if (Sym && !Sym->getType()->isFloatingType())
+  return UnknownVal();
+  }
+
   // When retrieving symbolic pointer and expecting a non-void pointer,
   // wrap them into element regions of the expected type if necessary.
   // SValBuilder::dispatchCast() doesn't do that, but it is necessary to


Index: test/Analysis/casts.cpp
===
--- test/Analysis/casts.cpp
+++ test/Analysis/casts.cpp
@@ -102,3 +102,15 @@
   castToDerived(reinterpret_cast(ORef))->getNotInt();
 }
 } // namespace base_to_derived_opaque_class
+
+namespace bool_to_nullptr {
+struct S {
+  int *a[1];
+  bool b;
+};
+void foo(S s) {
+  s.b = true;
+  for (int i = 0; i < 2; ++i)
+(void)(s.a[i] != nullptr); // no-crash
+}
+} // namespace bool_to_nullptr
Index: test/Analysis/casts.c
===
--- test/Analysis/casts.c
+++ test/Analysis/casts.c
@@ -213,3 +213,35 @@
 }
 
 #endif
+
+char no_crash_SymbolCast_of_float_type_aux(int *p) {
+  *p += 1;
+  return *p;
+}
+
+void no_crash_SymbolCast_of_float_type() {
+  extern float x;
+  char (*f)() = no_crash_SymbolCast_of_float_type_aux;
+  f();
+}
+
+double no_crash_reinterpret_double_as_int(double a) {
+  *(int *) = 1;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_ptr(double a) {
+  *(void **) = 0;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_sym_int(double a, int b) {
+  *(int *) = b;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_sym_ptr(double a, void * b) {
+  *(void **) = b;
+  return a * a;
+}
+
Index: lib/StaticAnalyzer/Core/Store.cpp
===
--- lib/StaticAnalyzer/Core/Store.cpp
+++ lib/StaticAnalyzer/Core/Store.cpp
@@ -402,6 +402,16 @@
   if (castTy.isNull() || V.isUnknownOrUndef())
 return V;
 
+  // The dispatchCast() call below would round the int to a float. What we want,
+  // however, is a bit-by-bit reinterpretation of the int as a float, which
+  // usually yields nothing garbage. For now skip casts from ints to floats.
+  

[PATCH] D56033: [CUDA] Treat extern global variable shadows same as regular extern vars.

2018-12-21 Thread Justin Lebar via Phabricator via cfe-commits
jlebar accepted this revision.
jlebar added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/test/CodeGenCUDA/device-stub.cu:51
 
+// external device-side variables with definitiions should generate
+// definitions for the shadows.

definiitions


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

https://reviews.llvm.org/D56033



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


[PATCH] D55875: [analyzer] pr38668: RegionStore: Do not attempt to cast loaded values of non-scalar types.

2018-12-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 179389.
NoQ added a comment.
Herald added a subscriber: jfb.

Add a denote - express test.


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

https://reviews.llvm.org/D55875

Files:
  lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  lib/StaticAnalyzer/Core/Store.cpp
  test/Analysis/casts.c
  test/Analysis/casts.cpp
  test/Analysis/expr-inspection.cpp
  test/Analysis/svalbuilder-float-cast.c

Index: test/Analysis/svalbuilder-float-cast.c
===
--- /dev/null
+++ test/Analysis/svalbuilder-float-cast.c
@@ -0,0 +1,20 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker debug.ExprInspection -verify %s
+void clang_analyzer_denote(int, const char *);
+void clang_analyzer_express(int);
+
+void SymbolCast_of_float_type_aux(int *p) {
+  *p += 0;
+  // FIXME: Ideally, all unknown values should be symbolicated.
+  clang_analyzer_denote(*p, "$x"); // expected-warning{{Not a symbol}}
+
+  *p += 1;
+  // This should NOT be (float)$x + 1. Symbol $x was never casted to float.
+  // FIXME: Ideally, this should be $x + 1.
+  clang_analyzer_express(*p); // expected-warning{{Not a symbol}}
+}
+
+void SymbolCast_of_float_type() {
+  extern float x;
+  void (*f)() = SymbolCast_of_float_type_aux;
+  f();
+}
Index: test/Analysis/expr-inspection.cpp
===
--- test/Analysis/expr-inspection.cpp
+++ test/Analysis/expr-inspection.cpp
@@ -24,7 +24,7 @@
   clang_analyzer_denote(1, "$z"); // expected-warning{{Not a symbol}}
   clang_analyzer_express(1); // expected-warning{{Not a symbol}}
 
-  clang_analyzer_denote(x + 1, "$w"); // expected-warning{{Not an atomic symbol}}
-  clang_analyzer_express(x + 1); // expected-warning{{$x + 1}}
+  clang_analyzer_denote(x + 1, "$w");
+  clang_analyzer_express(x + 1); // expected-warning{{$w}}
   clang_analyzer_express(y + 1); // expected-warning{{$y + 1U}}
 }
Index: test/Analysis/casts.cpp
===
--- test/Analysis/casts.cpp
+++ test/Analysis/casts.cpp
@@ -102,3 +102,15 @@
   castToDerived(reinterpret_cast(ORef))->getNotInt();
 }
 } // namespace base_to_derived_opaque_class
+
+namespace bool_to_nullptr {
+struct S {
+  int *a[1];
+  bool b;
+};
+void foo(S s) {
+  s.b = true;
+  for (int i = 0; i < 2; ++i)
+(void)(s.a[i] != nullptr); // no-crash
+}
+} // namespace bool_to_nullptr
Index: test/Analysis/casts.c
===
--- test/Analysis/casts.c
+++ test/Analysis/casts.c
@@ -213,3 +213,35 @@
 }
 
 #endif
+
+char no_crash_SymbolCast_of_float_type_aux(int *p) {
+  *p += 1;
+  return *p;
+}
+
+void no_crash_SymbolCast_of_float_type() {
+  extern float x;
+  char (*f)() = no_crash_SymbolCast_of_float_type_aux;
+  f();
+}
+
+double no_crash_reinterpret_double_as_int(double a) {
+  *(int *) = 1;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_ptr(double a) {
+  *(void **) = 0;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_sym_int(double a, int b) {
+  *(int *) = b;
+  return a * a;
+}
+
+double no_crash_reinterpret_double_as_sym_ptr(double a, void * b) {
+  *(void **) = b;
+  return a * a;
+}
+
Index: lib/StaticAnalyzer/Core/Store.cpp
===
--- lib/StaticAnalyzer/Core/Store.cpp
+++ lib/StaticAnalyzer/Core/Store.cpp
@@ -402,6 +402,16 @@
   if (castTy.isNull() || V.isUnknownOrUndef())
 return V;
 
+  // The dispatchCast() call below would round the int to a float. What we want,
+  // however, is a bit-by-bit reinterpretation of the int as a float, which
+  // usually yields nothing garbage. For now skip casts from ints to floats.
+  // TODO: What other combinations of types are affected?
+  if (castTy->isFloatingType()) {
+SymbolRef Sym = V.getAsSymbol();
+if (Sym && !Sym->getType()->isFloatingType())
+  return UnknownVal();
+  }
+
   // When retrieving symbolic pointer and expecting a non-void pointer,
   // wrap them into element regions of the expected type if necessary.
   // SValBuilder::dispatchCast() doesn't do that, but it is necessary to
Index: lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
+++ lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
@@ -321,11 +321,6 @@
 return;
   }
 
-  if (!isa(Sym)) {
-reportBug("Not an atomic symbol", C);
-return;
-  }
-
   const auto *E = dyn_cast(CE->getArg(1)->IgnoreParenCasts());
   if (!E) {
 reportBug("Not a string literal", C);
@@ -345,7 +340,7 @@
 public:
   SymbolExpressor(ProgramStateRef State) : State(State) {}
 
-  Optional VisitSymExpr(const SymExpr *S) {
+  Optional lookup(const SymExpr *S) {
 if (const StringLiteral *const *SLPtr = State->get(S)) {
   const StringLiteral *SL = *SLPtr;
 

[PATCH] D55933: [Sema] Do not print default template parameters.

2018-12-21 Thread Clement Courbet via Phabricator via cfe-commits
courbet marked 6 inline comments as done.
courbet added inline comments.



Comment at: lib/AST/TypePrinter.cpp:173
+  // information about whether default template parameters were actually
+  // written.
+  switch (QT.getTypePtr()->getTypeClass()) {

Quuxplusone wrote:
> FWIW, I don't understand this comment's terminology. "Whether default 
> template parameters were actually written": should that say something like 
> "whether a template parameter came from a default argument"?
> And why are the `Pointer`, `VariableArray`, etc. cases here? What goes wrong 
> if you remove them?
I've expanded the comments.



Comment at: test/SemaCXX/static-assert-cxx17.cpp:99
   static_assert((const X[]){} == nullptr);
-  // expected-error@-1{{static_assert failed due to requirement '(X 
const[0]){} == nullptr'}}
+  // expected-error@-1{{static_assert failed due to requirement '(const X 
[0]){} == nullptr'}}
   static_assert(sizeof(X().X::~X())>) 
== 0);

Quuxplusone wrote:
> (1) This cosmetic change is produced by the `case IncompleteArray:` that I 
> questioned above, right? I'm surprised that the pretty-printed type changes 
> from "east const" to "west const." But that's fine.
> 
> (2) Sorry I didn't notice before: surely where the message currently says 
> `[0]` it should say `[]` instead! That's an existing bug in the 
> pretty-printer, going back super far: https://godbolt.org/z/y9KzEq  So I 
> guess it's not your responsibility to fix. But I hope there's a bug open 
> about it somewhere?
> (1) This cosmetic change is produced by the case IncompleteArray: that I 
> questioned above, right? I'm surprised that the pretty-printed type changes 
> from "east const" to "west const." But that's fine.

Indeed. There's some logic in the printer to see where the const should go. 

> (2) Sorry I didn't notice before: surely where the message currently says [0] 
> it should say [] instead! That's an existing bug in the pretty-printer, going 
> back super far: https://godbolt.org/z/y9KzEq So I guess it's not your 
> responsibility to fix. But I hope there's a bug open about it somewhere?

Is it actually a bug ? In the godbolt example I actually thing putting the zero 
there actually clarifies the semantics of the expression for the reader, so I 
would'nt say it hurts.




Comment at: test/SemaCXX/static-assert-cxx17.cpp:103
+  static_assert(constexpr_return_false());
+  // expected-error@-1{{static_assert failed due to requirement 
'constexpr_return_false()'}}
 }

Quuxplusone wrote:
> Please keep the old test case 
> 
> static_assert(constexpr_return_false());
> // expected-error@-1{{static_assert failed due to requirement 
> 'constexpr_return_false()'}}
> 
> and then //add// this new test case. My understanding is that the old test 
> case should still pass, even after your change.
The old one is in foo7().



Comment at: test/SemaCXX/static-assert-cxx17.cpp:109
+template 
+void foo7() {
+  static_assert(X());

Quuxplusone wrote:
> None of these new test cases actually involve the default template argument.
> 
> I'd like to see two test cases explicitly mimicking `vector`. (Warning: I 
> didn't run this code!)
> ```
> template struct A {};
> template> struct V {};
> template void testx() {
> static_assert(std::is_same::value, "");
> // expected-error@-1{{due to requirement 'std::is_same*, 
> void>::value'}}
> }
> template testx>();
> template struct PMRA {};
> template using PMRV = V>;
> template void test() {
> static_assert(std::is_same::value, "");
> // expected-error@-1{{due to requirement 'std::is_same PMRA>*, void>::value'}}
> // expected-error@-2{{due to requirement 'std::is_same*, 
> void>::value'}}
> }
> template testy>();
> ```
> The `expected-error@-2` above is my fantasy world. I don't think it's 
> possible to achieve in real life. :)
> None of these new test cases actually involve the default template argument.

This one is to check that we actually do print when specified explicitly. foo6 
above tests  the default template arguments (notice the change from `template 
 struct X to `template  struct X` above). 
I've renamed `foo6` and `foo7` to make that clear.

Before this change, static_asserts in `foo6` and `foo7` printed the same thing. 
Now they don't.

> I'd like to see two test cases explicitly mimicking vector.

OK, I think I misunderstood what you wanted here. I don't think what you want 
is actually doable, because by the time you're in `test()`, C is just a type 
without any way of knowing whether the user explicitly provided the template 
parameter or relied on the default.

What we could do though is **always** erase template parameters that are the 
same as default ones. But that would mean printing `due to requirement 
'std::is_same*, void>::value'` even when the user wrote `template 
testx>>();`.
WDYT ?





Comment at: 

r349894 - Revert rL349876 from cfe/trunk: [analyzer] Perform escaping in RetainCountChecker on type mismatch even for inlined functions

2018-12-21 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Fri Dec 21 02:11:23 2018
New Revision: 349894

URL: http://llvm.org/viewvc/llvm-project?rev=349894=rev
Log:
Revert rL349876 from cfe/trunk: [analyzer] Perform escaping in 
RetainCountChecker on type mismatch even for inlined functions

The fix done in D55465 did not previously apply when the function was inlined.

rdar://46889541

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

Fixes broken buildbot: 
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/14764

Modified:

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

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp?rev=349894=349893=349894=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
(original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
Fri Dec 21 02:11:23 2018
@@ -502,25 +502,6 @@ static Optional refValFromRetEff
   return None;
 }
 
-static bool isPointerToObject(QualType QT) {
-  QualType PT = QT->getPointeeType();
-  if (!PT.isNull())
-if (PT->getAsCXXRecordDecl())
-  return true;
-  return false;
-}
-
-/// Whether the tracked value should be escaped on a given call.
-/// OSObjects are escaped when passed to void * / etc.
-static bool shouldEscapeArgumentOnCall(const CallEvent , unsigned ArgIdx,
-   const RefVal *TrackedValue) {
-  if (TrackedValue->getObjKind() != RetEffect::OS)
-return false;
-  if (ArgIdx >= CE.parameters().size())
-return false;
-  return !isPointerToObject(CE.parameters()[ArgIdx]->getType());
-}
-
 // We don't always get the exact modeling of the function with regards to the
 // retain count checker even when the function is inlined. For example, we need
 // to stop tracking the symbols which were marked with StopTrackingHard.
@@ -531,16 +512,11 @@ void RetainCountChecker::processSummaryO
 
   // Evaluate the effect of the arguments.
   for (unsigned idx = 0, e = CallOrMsg.getNumArgs(); idx != e; ++idx) {
-SVal V = CallOrMsg.getArgSVal(idx);
-
-if (SymbolRef Sym = V.getAsLocSymbol()) {
-  bool ShouldRemoveBinding = Summ.getArg(idx) == StopTrackingHard;
-  if (const RefVal *T = getRefBinding(state, Sym))
-if (shouldEscapeArgumentOnCall(CallOrMsg, idx, T))
-  ShouldRemoveBinding = true;
-
-  if (ShouldRemoveBinding)
+if (Summ.getArg(idx) == StopTrackingHard) {
+  SVal V = CallOrMsg.getArgSVal(idx);
+  if (SymbolRef Sym = V.getAsLocSymbol()) {
 state = removeRefBinding(state, Sym);
+  }
 }
   }
 
@@ -598,6 +574,25 @@ static ProgramStateRef updateOutParamete
   return State;
 }
 
+static bool isPointerToObject(QualType QT) {
+  QualType PT = QT->getPointeeType();
+  if (!PT.isNull())
+if (PT->getAsCXXRecordDecl())
+  return true;
+  return false;
+}
+
+/// Whether the tracked value should be escaped on a given call.
+/// OSObjects are escaped when passed to void * / etc.
+static bool shouldEscapeArgumentOnCall(const CallEvent , unsigned ArgIdx,
+   const RefVal *TrackedValue) {
+  if (TrackedValue->getObjKind() != RetEffect::OS)
+return false;
+  if (ArgIdx >= CE.parameters().size())
+return false;
+  return !isPointerToObject(CE.parameters()[ArgIdx]->getType());
+}
+
 void RetainCountChecker::checkSummary(const RetainSummary ,
   const CallEvent ,
   CheckerContext ) const {

Modified: cfe/trunk/test/Analysis/osobject-retain-release.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/osobject-retain-release.cpp?rev=349894=349893=349894=diff
==
--- cfe/trunk/test/Analysis/osobject-retain-release.cpp (original)
+++ cfe/trunk/test/Analysis/osobject-retain-release.cpp Fri Dec 21 02:11:23 2018
@@ -90,10 +90,7 @@ struct OSMetaClassBase {
   static OSObject *safeMetaCast(const OSObject *inst, const OSMetaClass *meta);
 };
 
-typedef unsigned long MYTYPE;
-
 void escape(void *);
-void escape_with_source(MYTYPE p) {}
 bool coin();
 
 bool os_consume_violation_two_args(OS_CONSUME OSObject *obj, bool extra) {
@@ -142,13 +139,6 @@ void test_escaping_into_voidstar() {
   escape(obj);
 }
 
-void test_escape_has_source() {
-  OSObject *obj = new OSObject;
-  if (obj)
-escape_with_source((MYTYPE)obj);
-  return;
-}
-
 void test_no_infinite_check_recursion(MyArray *arr) {
   OSObject *input = new OSObject;
   OSObject *o = arr->generateObject(input);


___
cfe-commits mailing list

[PATCH] D55994: [clangd] Check preceding char when completion triggers on ':' or '>'

2018-12-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: hokein.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ioeric.

Only run completion when we were trigerred on '->' and '::', otherwise
send an error code in return.
To avoid automatically invoking completions in cases like 'a >^' or
'a ? b :^'.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D55994

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/Protocol.cpp
  clangd/Protocol.h

Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -775,6 +775,31 @@
 };
 bool fromJSON(const llvm::json::Value &, TextDocumentPositionParams &);
 
+enum class CompletionTriggerKind {
+  /// Completion was triggered by typing an identifier (24x7 code
+  /// complete), manual invocation (e.g Ctrl+Space) or via API.
+  Invoked = 1,
+  /// Completion was triggered by a trigger character specified by
+  /// the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
+  TriggerCharacter = 2,
+  /// Completion was re-triggered as the current completion list is incomplete.
+  TriggerTriggerForIncompleteCompletions = 3
+};
+
+struct CompletionContext {
+  /// How the completion was triggered.
+  CompletionTriggerKind triggerKind = CompletionTriggerKind::Invoked;
+  /// The trigger character (a single character) that has trigger code complete.
+  /// Is undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter`
+  std::string triggerCharacter;
+};
+bool fromJSON(const llvm::json::Value &, CompletionContext &);
+
+struct CompletionParams : TextDocumentPositionParams {
+  CompletionContext context;
+};
+bool fromJSON(const llvm::json::Value &, CompletionParams &);
+
 enum class MarkupKind {
   PlainText,
   Markdown,
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -550,6 +550,29 @@
  O.map("position", R.position);
 }
 
+bool fromJSON(const llvm::json::Value , CompletionContext ) {
+  json::ObjectMapper O(Params);
+  if (!O)
+return false;
+
+  int triggerKind;
+  if (!O.map("triggerKind", triggerKind))
+return false;
+  R.triggerKind = static_cast(triggerKind);
+
+  if (auto *TC = Params.getAsObject()->get("triggerCharacter"))
+return fromJSON(*TC, R.triggerCharacter);
+  return true;
+}
+
+bool fromJSON(const llvm::json::Value , CompletionParams ) {
+  if (!fromJSON(Params, static_cast(R)))
+return false;
+  if (auto *Context = Params.getAsObject()->get("context"))
+return fromJSON(*Context, R.context);
+  return true;
+}
+
 static StringRef toTextKind(MarkupKind Kind) {
   switch (Kind) {
   case MarkupKind::PlainText:
Index: clangd/ClangdLSPServer.h
===
--- clangd/ClangdLSPServer.h
+++ clangd/ClangdLSPServer.h
@@ -74,8 +74,7 @@
   void onDocumentSymbol(const DocumentSymbolParams &,
 Callback);
   void onCodeAction(const CodeActionParams &, Callback);
-  void onCompletion(const TextDocumentPositionParams &,
-Callback);
+  void onCompletion(const CompletionParams &, Callback);
   void onSignatureHelp(const TextDocumentPositionParams &,
Callback);
   void onGoToDefinition(const TextDocumentPositionParams &,
@@ -98,6 +97,12 @@
 
   std::vector getFixes(StringRef File, const clangd::Diagnostic );
 
+  /// Checks if completion request should be ignored. We need this due to the
+  /// limitation of the LSP. Per LSP, a client sends requests for all "trigger
+  /// character" we specify, but for '>' and ':' we need to check they actually
+  /// produce '->' and '::', respectively.
+  bool isSporadicCompletion(const CompletionParams ) const;
+
   /// Forces a reparse of all currently opened files.  As a result, this method
   /// may be very expensive.  This method is normally called when the
   /// compilation database is changed.
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -22,6 +22,15 @@
 namespace clang {
 namespace clangd {
 namespace {
+class CompletionSporadicError : public llvm::ErrorInfo {
+public:
+  void log(llvm::raw_ostream ) const override {
+OS << "ignored triggered completion, preceding char did not match";
+  }
+  std::error_code convertToErrorCode() const override {
+return std::make_error_code(std::errc::operation_canceled);
+  }
+};
 
 void adjustSymbolKinds(llvm::MutableArrayRef Syms,
SymbolKindBitset Kinds) {
@@ -310,6 +319,8 @@
 {"completionProvider",
  json::Object{
  {"resolveProvider", false},
+ // We do extra checks for '>' and ':' in completion to only
+ // trigger on '->' and '::'.
  

[PATCH] D55710: add pragmas to control Software Pipelining optimisation

2018-12-21 Thread Alexey Lapshin via Phabricator via cfe-commits
alexey.lapshin updated this revision to Diff 179248.
alexey.lapshin added a comment.

put a better link to doc


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

https://reviews.llvm.org/D55710

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticParseKinds.td
  lib/CodeGen/CGLoopInfo.cpp
  lib/CodeGen/CGLoopInfo.h
  lib/Parse/ParsePragma.cpp
  lib/Sema/SemaStmtAttr.cpp
  test/CodeGenCXX/pragma-pipeline.cpp
  test/Parser/pragma-loop.cpp
  test/Parser/pragma-pipeline.cpp
  test/Parser/pragma-unroll-and-jam.cpp

Index: test/Parser/pragma-unroll-and-jam.cpp
===
--- test/Parser/pragma-unroll-and-jam.cpp
+++ test/Parser/pragma-unroll-and-jam.cpp
@@ -67,7 +67,7 @@
   }
 
 // pragma clang unroll_and_jam is disabled for the moment
-/* expected-error {{invalid option 'unroll_and_jam'; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, or distribute}} */ #pragma clang loop unroll_and_jam(4)
+/* expected-error {{invalid option 'unroll_and_jam'; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval or distribute}} */ #pragma clang loop unroll_and_jam(4)
   for (int i = 0; i < Length; i++) {
 for (int j = 0; j < Length; j++) {
   List[i * Length + j] = Value;
Index: test/Parser/pragma-pipeline.cpp
===
--- /dev/null
+++ test/Parser/pragma-pipeline.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+// Note that this puts the expected lines before the directives to work around
+// limitations in the -verify mode.
+
+void test(int *List, int Length, int Value) {
+  int i = 0;
+
+#pragma clang loop pipeline(disable)
+  for (int i = 0; i < Length; i++) {
+List[i] = Value;
+  }
+
+#pragma clang loop pipeline_initiation_interval(10)
+  for (int i = 0; i < Length; i++) {
+List[i] = Value;
+  }
+
+/* expected-error {{expected ')'}} */ #pragma clang loop pipeline(disable
+/* expected-error {{invalid argument; expected 'disable'}} */ #pragma clang loop pipeline(enable)
+/* expected-error {{invalid argument; expected 'disable'}} */ #pragma clang loop pipeline(error)
+/* expected-error {{expected '('}} */ #pragma clang loop pipeline disable
+/* expected-error {{missing argument; expected an integer value}} */ #pragma clang loop pipeline_initiation_interval()
+/* expected-error {{use of undeclared identifier 'error'}} */ #pragma clang loop pipeline_initiation_interval(error)
+/* expected-error {{expected '('}} */ #pragma clang loop pipeline_initiation_interval 1 2
+/* expected-error {{expected ')'}} */ #pragma clang loop pipeline_initiation_interval(1
+/* expected-error {{invalid argument of type 'double'; expected an integer type}} */ #pragma clang loop pipeline_initiation_interval(1.0)
+/* expected-error {{invalid value '0'; must be positive}} */ #pragma clang loop pipeline_initiation_interval(0)
+  for (int i = 0; i < Length; i++) {
+for (int j = 0; j < Length; j++) {
+  List[i * Length + j] = Value;
+}
+  }
+
+#pragma clang loop pipeline(disable) 
+/* expected-error {{expected a for, while, or do-while loop to follow '#pragma clang loop'}} */ int j = Length;
+#pragma clang loop pipeline_initiation_interval(4)
+/* expected-error {{expected a for, while, or do-while loop to follow '#pragma clang loop'}} */ int k = Length;
+
+#pragma clang loop pipeline(disable)
+#pragma clang loop pipeline_initiation_interval(4) /* expected-error {{incompatible directives 'pipeline(disable)' and 'pipeline_initiation_interval(4)'}} */
+  for (int i = 0; i < Length; i++) {
+List[i] = Value;
+  }
+
+#pragma clang loop pipeline(disable)
+/* expected-error {{expected statement}} */ }
Index: test/Parser/pragma-loop.cpp
===
--- test/Parser/pragma-loop.cpp
+++ test/Parser/pragma-loop.cpp
@@ -147,7 +147,7 @@
 /* expected-error {{missing argument; expected 'enable', 'full' or 'disable'}} */ #pragma clang loop unroll()
 /* expected-error {{missing argument; expected 'enable' or 'disable'}} */ #pragma clang loop distribute()
 
-/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, or distribute}} */ #pragma clang loop
+/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval or distribute}} */ #pragma clang loop
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword(enable)
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop vectorize(enable) badkeyword(4)
Index: test/CodeGenCXX/pragma-pipeline.cpp

[PATCH] D55865: [ObjC] Add a new attribute to opt-out of implicit callee retain/release in ARC

2018-12-21 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:3783
+parameters or local variables in ARC mode. When applied to parameters, it 
causes
+clang to omit the implicit calls to objc_retain and objc_release on function
+entry and exit respectivly. When applied to local variables, it causes clang to

These function names should be `typeset in mono`.



Comment at: clang/include/clang/Basic/AttrDocs.td:3784
+clang to omit the implicit calls to objc_retain and objc_release on function
+entry and exit respectivly. When applied to local variables, it causes clang to
+omit the call to retain on variable initialization, and release when the

Typo



Comment at: clang/include/clang/Basic/AttrDocs.td:3787
+variable goes out of scope. Parameters and variables annotated with this
+attribute are implicitly ``const``.
+

You should add a paragraph contrasting this with ``__unsafe_unretained``.  For 
example:

  Unlike an `__unsafe_unretained` variable, an externally-retained variable 
remains
  semantically `__strong`.  This affects features like block capture which copy 
the
  current value of the variable into a capture field of the same type: the 
block's
  capture field will still be `__strong`, and so the value will be retained as 
part of
  capturing it and released when the block is destroyed.  It also affects C++ 
features
  such as lambda capture, `decltype`, and template argument deduction.

You should also describe this attribute in AutomaticReferenceCounting.rst.
You can add it in a new `arc.misc.externally_retained` section immediately above
`arc.misc.self`.  You can borrow some of the existing wording from the two
following sections, `arc.misc.self` and `arc.misc.enumeration`, and then make
those sections refer back to the new concept.



Comment at: clang/include/clang/Basic/AttrDocs.td:3789
+
+This attribute is meant to be used to opt-out of the additional safety that ARC
+provides when the programmer knows that the safety isn't necessary. You can 
read

The hyphen is unneeded here.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3492
+def warn_ignored_objc_externally_retained : Warning<
+  "'objc_externally_retained' can only be applied to strong retainable "
+  "object pointer types with automatic storage">, InGroup;

erik.pilkington wrote:
> rjmccall wrote:
> > erik.pilkington wrote:
> > > aaron.ballman wrote:
> > > > This wording isn't quite right -- it doesn't apply to types, it applies 
> > > > to variables of those types. How about: `... to local variables or 
> > > > parameters of strong, retainable object pointer type`? or something 
> > > > along those lines?
> > > Sure, that is a bit more clear.
> > I'd split this into two diagnostics:
> > - "...can only be applied to local variables and parameters of retainable 
> > type" (if the type or decl kind is wrong)
> > - "...can only be applied to variables with strong ownership" (if the 
> > qualifier is wrong)
> Sure, I guess a lot of information is crammed into this one. I coalesced the 
> two you suggested into one with a %select.
WFM



Comment at: clang/lib/CodeGen/CGDecl.cpp:807
+// that we omit the retain, and causes non-autoreleased return values to be
+// immediatly released.
+LLVM_FALLTHROUGH;

typo



Comment at: clang/lib/CodeGen/CGDecl.cpp:2334
+  // If a parameter is pseudo-strong, either because of the attribute
+  // objc_externally_retained or because its 'self' in an non-init method,
+  // then we can omit the implicit retain.

I wouldn't enumerate the cases in this comment.  You might want to enumerate 
them in a comment on `isARCPseudoStrong()`, though.


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

https://reviews.llvm.org/D55865



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


[clang-tools-extra] r349891 - Fix warning about unused variable [NFC]

2018-12-21 Thread Bjorn Pettersson via cfe-commits
Author: bjope
Date: Fri Dec 21 00:51:04 2018
New Revision: 349891

URL: http://llvm.org/viewvc/llvm-project?rev=349891=rev
Log:
Fix warning about unused variable [NFC]

Modified:
clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp?rev=349891=349890=349891=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp 
Fri Dec 21 00:51:04 2018
@@ -525,7 +525,7 @@ void SimplifyBooleanExprCheck::registerM
 }
 
 void SimplifyBooleanExprCheck::check(const MatchFinder::MatchResult ) {
-  if (const auto *TU = Result.Nodes.getNodeAs("top"))
+  if (Result.Nodes.getNodeAs("top"))
 Visitor(this, Result).TraverseAST(*Result.Context);
   else if (const CXXBoolLiteralExpr *TrueConditionRemoved =
getBoolLiteral(Result, ConditionThenStmtId))


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


[PATCH] D53818: [ASTImporter] Changed use of Import to Import_New in ASTImporter.

2018-12-21 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 179249.
balazske added a comment.

Rebase.


Repository:
  rC Clang

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

https://reviews.llvm.org/D53818

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

Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -135,25 +135,6 @@
   To->setIsUsed();
   }
 
-  // FIXME: Temporary until every import returns Expected.
-  template <>
-  LLVM_NODISCARD Error
-  ASTImporter::importInto(SourceLocation , const SourceLocation ) {
-To = Import(From);
-if (From.isValid() && To.isInvalid())
-return llvm::make_error();
-return Error::success();
-  }
-  // FIXME: Temporary until every import returns Expected.
-  template <>
-  LLVM_NODISCARD Error
-  ASTImporter::importInto(QualType , const QualType ) {
-To = Import(From);
-if (!From.isNull() && To.isNull())
-return llvm::make_error();
-return Error::success();
-  }
-
   class ASTNodeImporter : public TypeVisitor,
   public DeclVisitor,
   public StmtVisitor {
@@ -7625,13 +7606,6 @@
 
 ASTImporter::~ASTImporter() = default;
 
-Expected ASTImporter::Import_New(QualType FromT) {
-  QualType ToT = Import(FromT);
-  if (ToT.isNull() && !FromT.isNull())
-return make_error();
-  return ToT;
-}
-
 Optional ASTImporter::getFieldIndex(Decl *F) {
   assert(F && (isa(*F) || isa(*F)) &&
   "Try to get field index for non-field.");
@@ -7683,9 +7657,9 @@
   LookupTable->add(ToND);
 }
 
-QualType ASTImporter::Import(QualType FromT) {
+Expected ASTImporter::Import_New(QualType FromT) {
   if (FromT.isNull())
-return {};
+return QualType{};
 
   const Type *FromTy = FromT.getTypePtr();
 
@@ -7698,46 +7672,64 @@
   // Import the type
   ASTNodeImporter Importer(*this);
   ExpectedType ToTOrErr = Importer.Visit(FromTy);
-  if (!ToTOrErr) {
-llvm::consumeError(ToTOrErr.takeError());
-return {};
-  }
+  if (!ToTOrErr)
+return ToTOrErr.takeError();
 
   // Record the imported type.
   ImportedTypes[FromTy] = (*ToTOrErr).getTypePtr();
 
   return ToContext.getQualifiedType(*ToTOrErr, FromT.getLocalQualifiers());
 }
+QualType ASTImporter::Import(QualType From) {
+  llvm::Expected To = Import_New(From);
+  if (To)
+return *To;
+  else
+llvm::consumeError(To.takeError());
+  return {};
+}
 
 Expected ASTImporter::Import_New(TypeSourceInfo *FromTSI) {
-  TypeSourceInfo *ToTSI = Import(FromTSI);
-  if (!ToTSI && FromTSI)
-return llvm::make_error();
-  return ToTSI;
-}
-TypeSourceInfo *ASTImporter::Import(TypeSourceInfo *FromTSI) {
   if (!FromTSI)
 return FromTSI;
 
   // FIXME: For now we just create a "trivial" type source info based
   // on the type and a single location. Implement a real version of this.
-  QualType T = Import(FromTSI->getType());
-  if (T.isNull())
-return nullptr;
+  ExpectedType TOrErr = Import_New(FromTSI->getType());
+  if (!TOrErr)
+return TOrErr.takeError();
+  ExpectedSLoc BeginLocOrErr = Import_New(FromTSI->getTypeLoc().getBeginLoc());
+  if (!BeginLocOrErr)
+return BeginLocOrErr.takeError();
 
-  return ToContext.getTrivialTypeSourceInfo(
-  T, Import(FromTSI->getTypeLoc().getBeginLoc()));
+  return ToContext.getTrivialTypeSourceInfo(*TOrErr, *BeginLocOrErr);
+}
+TypeSourceInfo *ASTImporter::Import(TypeSourceInfo *From) {
+  llvm::Expected To = Import_New(From);
+  if (To)
+return *To;
+  else
+llvm::consumeError(To.takeError());
+  return nullptr;
 }
 
 Expected ASTImporter::Import_New(const Attr *FromAttr) {
-  return Import(FromAttr);
-}
-Attr *ASTImporter::Import(const Attr *FromAttr) {
   Attr *ToAttr = FromAttr->clone(ToContext);
-  // NOTE: Import of SourceRange may fail.
-  ToAttr->setRange(Import(FromAttr->getRange()));
+  if (auto ToRangeOrErr = Import_New(FromAttr->getRange()))
+ToAttr->setRange(*ToRangeOrErr);
+  else
+return ToRangeOrErr.takeError();
+
   return ToAttr;
 }
+Attr *ASTImporter::Import(const Attr *From) {
+  llvm::Expected To = Import_New(From);
+  if (To)
+return *To;
+  else
+llvm::consumeError(To.takeError());
+  return nullptr;
+}
 
 Decl *ASTImporter::GetAlreadyImportedOrNull(const Decl *FromD) const {
   auto Pos = ImportedDecls.find(FromD);
@@ -7748,12 +7740,6 @@
 }
 
 Expected ASTImporter::Import_New(Decl *FromD) {
-  Decl *ToD = Import(FromD);
-  if (!ToD && FromD)
-return llvm::make_error();
-  return ToD;
-}
-Decl *ASTImporter::Import(Decl *FromD) {
   if (!FromD)
 return nullptr;
 
@@ -7767,12 +7753,10 @@
 return ToD;
   }
 
-  // Import the type.
+  // Import the declaration.
   ExpectedDecl ToDOrErr = Importer.Visit(FromD);
-  if (!ToDOrErr) {
-llvm::consumeError(ToDOrErr.takeError());
-return nullptr;
-  }
+  if (!ToDOrErr)
+return ToDOrErr;
   ToD = *ToDOrErr;
 
   // Once the decl is connected to the 

[clang-tools-extra] r349893 - [clangd] Cleanup syntax errors in the test, NFC.

2018-12-21 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Dec 21 01:32:49 2018
New Revision: 349893

URL: http://llvm.org/viewvc/llvm-project?rev=349893=rev
Log:
[clangd] Cleanup syntax errors in the test, NFC.

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

Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=349893=349892=349893=diff
==
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Fri Dec 21 
01:32:49 2018
@@ -195,7 +195,7 @@ struct ClassWithMembers {
   int AAA();
   int BBB();
   int CCC();
-}
+};
 int main() { ClassWithMembers().^ }
   )cpp",
  /*IndexSymbols=*/{}, Opts);
@@ -628,7 +628,7 @@ TEST(CompletionTest, NoIncludeInsertionW
  R"cpp(
   namespace ns {
 class X;
-class Y {}
+class Y {};
   }
   int main() { ns::^ }
   )cpp",
@@ -651,7 +651,7 @@ TEST(CompletionTest, IndexSuppressesPrea
   #include "bar.h"
   namespace ns { int local; }
   void f() { ns::^; }
-  void f() { ns::preamble().$2^; }
+  void f2() { ns::preamble().$2^; }
   )cpp");
   runAddDocument(Server, File, Test.code());
   clangd::CodeCompleteOptions Opts = {};
@@ -1927,7 +1927,7 @@ TEST(CompletionTest, EnableSpeculativeIn
   namespace ns1 { int abc; }
   namespace ns2 { int abc; }
   void f() { ns1::ab$1^; ns1::ab$2^; }
-  void f() { ns2::ab$3^; }
+  void f2() { ns2::ab$3^; }
   )cpp");
   runAddDocument(Server, File, Test.code());
   clangd::CodeCompleteOptions Opts = {};

Modified: clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp?rev=349893=349892=349893=diff
==
--- clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp Fri Dec 21 
01:32:49 2018
@@ -439,7 +439,7 @@ TEST_F(DocumentSymbolsTest, DeclarationD
 TEST_F(DocumentSymbolsTest, ExternSymbol) {
   std::string FilePath = testPath("foo.cpp");
   addFile(testPath("foo.h"), R"cpp(
-  extern int var = 2;
+  extern int var;
   )cpp");
   addFile(FilePath, R"cpp(
   #include "foo.h"

Modified: clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp?rev=349893=349892=349893=diff
==
--- clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp Fri Dec 21 
01:32:49 2018
@@ -429,7 +429,7 @@ TEST(QualityTests, Operator) {
   auto Header = TestTU::withHeaderCode(R"cpp(
 class Foo {
 public:
-  bool operator<(const Foo& f1, const Foo& f2);
+  bool operator<(const Foo& f1);
 };
   )cpp");
   auto AST = Header.build();

Modified: clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp?rev=349893=349892=349893=diff
==
--- clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp Fri Dec 
21 01:32:49 2018
@@ -131,7 +131,7 @@ TEST_F(ShouldCollectSymbolTest, ShouldCo
 namespace nx {
 class X{};
 auto f() { int Local; } // auto ensures function body is parsed.
-struct { int x } var;
+struct { int x; } var;
 namespace { class InAnonymous {}; }
 }
   )",


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


[PATCH] D55994: [clangd] Check preceding char when completion triggers on ':' or '>'

2018-12-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

This still needs tests, will add them before committing the change. However, 
the implementation should be good for review.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55994



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


[PATCH] D54589: [clang][UBSan] Sanitization for alignment assumptions.

2018-12-21 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 179272.
lebedev.ri added a comment.

Rebased, NFC.


Repository:
  rC Clang

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

https://reviews.llvm.org/D54589

Files:
  docs/ReleaseNotes.rst
  docs/UndefinedBehaviorSanitizer.rst
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/catch-alignment-assumption-attribute-align_value-on-lvalue.cpp
  test/CodeGen/catch-alignment-assumption-attribute-align_value-on-paramvar.cpp
  
test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
  test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
  
test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function-two-params.cpp
  
test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function.cpp
  test/CodeGen/catch-alignment-assumption-blacklist.c
  
test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp
  
test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp
  test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
  test/CodeGen/catch-alignment-assumption-openmp.cpp

Index: test/CodeGen/catch-alignment-assumption-openmp.cpp
===
--- /dev/null
+++ test/CodeGen/catch-alignment-assumption-openmp.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fopenmp-simd -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-NOSANITIZE
+// RUN: %clang_cc1 -fopenmp-simd -fsanitize=alignment -fno-sanitize-recover=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-NORECOVER,CHECK-SANITIZE-UNREACHABLE
+// RUN: %clang_cc1 -fopenmp-simd -fsanitize=alignment -fsanitize-recover=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-RECOVER
+// RUN: %clang_cc1 -fopenmp-simd -fsanitize=alignment -fsanitize-trap=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-TRAP,CHECK-SANITIZE-UNREACHABLE
+
+// CHECK-SANITIZE-ANYRECOVER: @[[CHAR:.*]] = {{.*}} c"'char *'\00" }
+// CHECK-SANITIZE-ANYRECOVER: @[[LINE_100_ALIGNMENT_ASSUMPTION:.*]] = {{.*}}, i32 100, i32 30 }, {{.*}}* @[[CHAR]] }
+
+void func(char *data) {
+  // CHECK: define void @{{.*}}(i8* %[[DATA:.*]])
+  // CHECK-NEXT: [[ENTRY:.*]]:
+  // CHECK-NEXT:   %[[DATA_ADDR:.*]] = alloca i8*, align 8
+  // CHECK:   store i8* %[[DATA]], i8** %[[DATA_ADDR]], align 8
+  // CHECK:   %[[DATA_RELOADED:.*]] = load i8*, i8** %[[DATA_ADDR]], align 8
+  // CHECK-NEXT:   %[[PTRINT:.*]] = ptrtoint i8* %[[DATA_RELOADED]] to i64
+  // CHECK-NEXT:   %[[MASKEDPTR:.*]] = and i64 %[[PTRINT]], 1073741823
+  // CHECK-NEXT:   %[[MASKCOND:.*]] = icmp eq i64 %[[MASKEDPTR]], 0
+  // CHECK-SANITIZE-NEXT:   %[[PTRINT_DUP:.*]] = ptrtoint i8* %[[DATA_RELOADED]] to i64, !nosanitize
+  // CHECK-SANITIZE-NEXT:   br i1 %[[MASKCOND]], label %[[CONT:.*]], label %[[HANDLER_ALIGNMENT_ASSUMPTION:[^,]+]],{{.*}} !nosanitize
+  // CHECK-SANITIZE:  [[HANDLER_ALIGNMENT_ASSUMPTION]]:
+  // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_alignment_assumption_abort(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[LINE_100_ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 1073741824, i64 0){{.*}}, !nosanitize
+  // CHECK-SANITIZE-RECOVER-NEXT:   call void @__ubsan_handle_alignment_assumption(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[LINE_100_ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 1073741824, i64 0){{.*}}, !nosanitize
+  // CHECK-SANITIZE-TRAP-NEXT:  call void @llvm.trap(){{.*}}, !nosanitize
+  // CHECK-SANITIZE-UNREACHABLE-NEXT:   unreachable, !nosanitize
+  // CHECK-SANITIZE:  [[CONT]]:
+  // CHECK-NEXT:call void @llvm.assume(i1 %[[MASKCOND]])
+
+#line 100
+#pragma omp for simd aligned(data : 0x4000)
+  for (int x = 0; x < 1; x++)
+data[x] = data[x];
+}
Index: test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
===
--- /dev/null
+++ test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-NOSANITIZE
+// RUN: %clang_cc1 -fsanitize=alignment 

[PATCH] D55916: [clang] Replace getOS() == llvm::Triple::*BSD with isOS*BSD() [NFCI]

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

No problem. I'm sorry about my initial mistake. Apparently it slipped me even 
though I've double checked it originally.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55916



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


[PATCH] D55125: [clang-tidy] Fix a false positive in misc-redundant-expression check

2018-12-21 Thread Daniel Krupp via Phabricator via cfe-commits
dkrupp updated this revision to Diff 179277.
dkrupp marked an inline comment as done.
dkrupp added a comment.

All comments fixed.

I also added the handling of redundancy comparison of sizeof(..), alignof() 
operators.


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

https://reviews.llvm.org/D55125

Files:
  clang-tidy/misc/RedundantExpressionCheck.cpp
  test/clang-tidy/misc-redundant-expression.cpp

Index: test/clang-tidy/misc-redundant-expression.cpp
===
--- test/clang-tidy/misc-redundant-expression.cpp
+++ test/clang-tidy/misc-redundant-expression.cpp
@@ -106,6 +106,7 @@
 
 #define COND_OP_MACRO 9
 #define COND_OP_OTHER_MACRO 9
+#define COND_OP_THIRD_MACRO COND_OP_MACRO
 int TestConditional(int x, int y) {
   int k = 0;
   k += (y < 0) ? x : x;
@@ -114,16 +115,33 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: 'true' and 'false' expressions are equivalent
   k += (y < 0) ? COND_OP_MACRO : COND_OP_MACRO;
   // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: 'true' and 'false' expressions are equivalent
+  k += (y < 0) ? COND_OP_MACRO + COND_OP_OTHER_MACRO : COND_OP_MACRO + COND_OP_OTHER_MACRO;
+  // CHECK-MESSAGES: :[[@LINE-1]]:54: warning: 'true' and 'false' expressions are equivalent
 
   // Do not match for conditional operators with a macro and a const.
   k += (y < 0) ? COND_OP_MACRO : 9;
   // Do not match for conditional operators with expressions from different macros.
   k += (y < 0) ? COND_OP_MACRO : COND_OP_OTHER_MACRO;
+  // Do not match for conditional operators when a macro is defined to another macro
+  k += (y < 0) ? COND_OP_MACRO : COND_OP_THIRD_MACRO;
+#undef COND_OP_THIRD_MACRO
+#define   COND_OP_THIRD_MACRO 8
+  k += (y < 0) ? COND_OP_MACRO : COND_OP_THIRD_MACRO;
+#undef COND_OP_THIRD_MACRO
+
+  k += (y < 0) ? sizeof(I64) : sizeof(I64);
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: 'true' and 'false' expressions are equivalent
+  k += (y < 0) ? sizeof(TestConditional(k,y)) : sizeof(TestConditional(k,y));
+  // CHECK-MESSAGES: :[[@LINE-1]]:47: warning: 'true' and 'false' expressions are equivalent
+  // No warning if the expression arguments are different.
+  k += (y < 0) ? sizeof(TestConditional(k,y)) : sizeof(Valid(k,y));
+
   return k;
 }
 #undef COND_OP_MACRO
 #undef COND_OP_OTHER_MACRO
 
+
 // Overloaded operators that compare two instances of a struct.
 struct MyStruct {
   int x;  
Index: clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -132,6 +132,18 @@
   case Stmt::BinaryOperatorClass:
 return cast(Left)->getOpcode() ==
cast(Right)->getOpcode();
+  case Stmt::UnaryExprOrTypeTraitExprClass:
+if (cast(Left)->isArgumentType() &&
+cast(Right)->isArgumentType())
+  return cast(Left)->getArgumentType() ==
+ cast(Right)->getArgumentType();
+else if (!cast(Left)->isArgumentType() &&
+ !cast(Right)->isArgumentType())
+  return areEquivalentExpr(
+  cast(Left)->getArgumentExpr(),
+  cast(Right)->getArgumentExpr());
+
+return false;
   }
 }
 
@@ -598,23 +610,66 @@
   return true;
 }
 
+static bool isSameToken(Token , Token , const SourceManager ) {
+  if (T1.getKind()!=T2.getKind())
+return false;
+  else if (T1.isNot(tok::raw_identifier))
+return true;
+  if (T1.getLength() != T2.getLength())
+return false;
+  return strncmp(SM.getCharacterData(T1.getLocation()),
+ SM.getCharacterData(T2.getLocation()), T1.getLength()) == 0;
+}
+
+unsigned getCharCountUntilEndOfExpr(SourceRange ExprSR, Token T,
+const SourceManager ) {
+  assert((T.getLocation() < ExprSR.getBegin()  ||
+  ExprSR.getEnd() < T.getLocation()) &&
+ "Token is not within the expression range!");
+
+  return SM.getCharacterData(SM.getExpansionLoc(ExprSR.getEnd())) -
+ SM.getCharacterData(T.getLocation());
+}
+
+/// Returns true if both LhsEpxr and RhsExpr are
+/// macro expressions and they are expanded
+/// from different macros.
 static bool areExprsFromDifferentMacros(const Expr *LhsExpr,
 const Expr *RhsExpr,
 const ASTContext *AstCtx) {
   if (!LhsExpr || !RhsExpr)
 return false;
-
-  SourceLocation LhsLoc = LhsExpr->getExprLoc();
-  SourceLocation RhsLoc = RhsExpr->getExprLoc();
-
-  if (!LhsLoc.isMacroID() || !RhsLoc.isMacroID())
+  SourceRange Lsr = LhsExpr->getSourceRange();
+  SourceRange Rsr = RhsExpr->getSourceRange();
+  if (!Lsr.getBegin().isMacroID() || !Rsr.getBegin().isMacroID())
 return false;
-
   const SourceManager  = AstCtx->getSourceManager();
   const LangOptions  = AstCtx->getLangOpts();
 
-  return !(Lexer::getImmediateMacroName(LhsLoc, SM, LO) ==
-  Lexer::getImmediateMacroName(RhsLoc, SM, 

[PATCH] D55982: [OPENMP] Add support for explicit mapping of classes using 'this' pointer

2018-12-21 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rC Clang

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

https://reviews.llvm.org/D55982



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


r349904 - [Sema][NFC] Remove some unnecessary calls to getASTContext.

2018-12-21 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Fri Dec 21 06:35:24 2018
New Revision: 349904

URL: http://llvm.org/viewvc/llvm-project?rev=349904=rev
Log:
[Sema][NFC] Remove some unnecessary calls to getASTContext.

The AST context is already easily available. NFC.


Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=349904=349903=349904=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Dec 21 06:35:24 2018
@@ -5148,8 +5148,6 @@ Sema::SemaBuiltinAtomicOverloaded(ExprRe
 TheCall->setArg(i+1, Arg.get());
   }
 
-  ASTContext& Context = this->getASTContext();
-
   // Create a new DeclRefExpr to refer to the new decl.
   DeclRefExpr* NewDRE = DeclRefExpr::Create(
   Context,

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=349904=349903=349904=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Dec 21 06:35:24 2018
@@ -5875,10 +5875,10 @@ isOutOfScopePreviousDeclaration(NamedDec
   return true;
 }
 
-static void SetNestedNameSpecifier(DeclaratorDecl *DD, Declarator ) {
+static void SetNestedNameSpecifier(Sema , DeclaratorDecl *DD, Declarator ) 
{
   CXXScopeSpec  = D.getCXXScopeSpec();
   if (!SS.isSet()) return;
-  DD->setQualifierInfo(SS.getWithLocInContext(DD->getASTContext()));
+  DD->setQualifierInfo(SS.getWithLocInContext(S.Context));
 }
 
 bool Sema::inferObjCARCLifetime(ValueDecl *decl) {
@@ -6583,7 +6583,7 @@ NamedDecl *Sema::ActOnVariableDeclarator
 NewTemplate->setInvalidDecl();
 }
 
-SetNestedNameSpecifier(NewVD, D);
+SetNestedNameSpecifier(*this, NewVD, D);
 
 // If we have any template parameter lists that don't directly belong to
 // the variable (matching the scope specifier), store them.
@@ -8384,7 +8384,7 @@ Sema::ActOnFunctionDeclarator(Scope *S,
 Diag(D.getDeclSpec().getVirtualSpecLoc(), diag::err_virtual_in_union);
 }
 
-SetNestedNameSpecifier(NewFD, D);
+SetNestedNameSpecifier(*this, NewFD, D);
 isMemberSpecialization = false;
 isFunctionTemplateSpecialization = false;
 if (D.isInvalidType())

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=349904=349903=349904=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Dec 21 06:35:24 2018
@@ -16547,7 +16547,7 @@ ExprResult RebuildUnknownAnyExpr::resolv
   DeclRefExpr *DRE = dyn_cast(E);
   if (DRE && Proto && Proto->getParamTypes().empty() && 
Proto->isVariadic()) {
 SourceLocation Loc = FD->getLocation();
-FunctionDecl *NewFD = FunctionDecl::Create(FD->getASTContext(),
+FunctionDecl *NewFD = FunctionDecl::Create(S.Context,
   FD->getDeclContext(),
   Loc, Loc, FD->getNameInfo().getName(),
   DestType, FD->getTypeSourceInfo(),

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=349904=349903=349904=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Dec 21 06:35:24 2018
@@ -1255,9 +1255,10 @@ Sema::ActOnTemplateParameterList(unsigne
   RAngleLoc, RequiresClause);
 }
 
-static void SetNestedNameSpecifier(TagDecl *T, const CXXScopeSpec ) {
+static void SetNestedNameSpecifier(Sema , TagDecl *T,
+   const CXXScopeSpec ) {
   if (SS.isSet())
-T->setQualifierInfo(SS.getWithLocInContext(T->getASTContext()));
+T->setQualifierInfo(SS.getWithLocInContext(S.Context));
 }
 
 DeclResult Sema::CheckClassTemplate(
@@ -1554,7 +1555,7 @@ DeclResult Sema::CheckClassTemplate(
   PrevClassTemplate && ShouldAddRedecl ?
 PrevClassTemplate->getTemplatedDecl() : nullptr,
   /*DelayTypeCreation=*/true);
-  SetNestedNameSpecifier(NewClass, SS);
+  SetNestedNameSpecifier(*this, NewClass, SS);
   if (NumOuterTemplateParamLists > 0)
 NewClass->setTemplateParameterListsInfo(
 Context, llvm::makeArrayRef(OuterTemplateParamLists,
@@ -7650,7 +7651,7 @@ DeclResult Sema::ActOnClassTemplateSpeci
TemplateArgs,
CanonType,
 

[PATCH] D55891: [compiler-rt] [xray] [tests] Detect and handle missing LLVMTestingSupport gracefully

2018-12-21 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349899: [xray] [tests] Detect and handle missing 
LLVMTestingSupport gracefully (authored by mgorny, committed by ).
Herald added a subscriber: delcypher.

Changed prior to commit:
  https://reviews.llvm.org/D55891?vs=178896=179275#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55891

Files:
  compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
  compiler-rt/trunk/lib/xray/tests/CMakeLists.txt
  compiler-rt/trunk/lib/xray/tests/unit/CMakeLists.txt


Index: compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
===
--- compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
+++ compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
@@ -239,7 +239,7 @@
 # Detect if we have the LLVMXRay and TestingSupport library installed and
 # available from llvm-config.
 execute_process(
-  COMMAND ${LLVM_CONFIG_PATH} "--ldflags" "--libs" "xray" "testingsupport"
+  COMMAND ${LLVM_CONFIG_PATH} "--ldflags" "--libs" "xray"
   RESULT_VARIABLE HAD_ERROR
   OUTPUT_VARIABLE CONFIG_OUTPUT)
 if (HAD_ERROR)
@@ -254,6 +254,26 @@
   set(COMPILER_RT_HAS_LLVMXRAY TRUE)
 endif()
 
+set(COMPILER_RT_HAS_LLVMTESTINGSUPPORT FALSE)
+execute_process(
+  COMMAND ${LLVM_CONFIG_PATH} "--ldflags" "--libs" "testingsupport"
+  RESULT_VARIABLE HAD_ERROR
+  OUTPUT_VARIABLE CONFIG_OUTPUT)
+if (HAD_ERROR)
+  message(WARNING "llvm-config finding testingsupport failed with status 
${HAD_ERROR}")
+else()
+  string(REGEX REPLACE "[ \t]*[\r\n]+[ \t]*" ";" CONFIG_OUTPUT 
${CONFIG_OUTPUT})
+  list(GET CONFIG_OUTPUT 0 LDFLAGS)
+  list(GET CONFIG_OUTPUT 1 LIBLIST)
+  if (LIBLIST STREQUAL "")
+message(WARNING "testingsupport library not installed, some tests will 
be skipped")
+  else()
+set(LLVM_TESTINGSUPPORT_LDFLAGS ${LDFLAGS} CACHE STRING "Linker flags 
for LLVMTestingSupport library")
+set(LLVM_TESTINGSUPPORT_LIBLIST ${LIBLIST} CACHE STRING "Library list 
for LLVMTestingSupport")
+set(COMPILER_RT_HAS_LLVMTESTINGSUPPORT TRUE)
+  endif()
+endif()
+
 # Make use of LLVM CMake modules.
 # --cmakedir is supported since llvm r291218 (4.0 release)
 execute_process(
Index: compiler-rt/trunk/lib/xray/tests/unit/CMakeLists.txt
===
--- compiler-rt/trunk/lib/xray/tests/unit/CMakeLists.txt
+++ compiler-rt/trunk/lib/xray/tests/unit/CMakeLists.txt
@@ -1,10 +1,16 @@
-add_xray_unittest(XRayTest SOURCES
+set(TEST_SOURCES
   allocator_test.cc
   buffer_queue_test.cc
-  fdr_controller_test.cc
-  fdr_log_writer_test.cc
   function_call_trie_test.cc
   profile_collector_test.cc
   segmented_array_test.cc
   test_helpers.cc
   xray_unit_test_main.cc)
+
+if (NOT COMPILER_RT_STANDALONE_BUILD OR COMPILER_RT_HAS_LLVMTESTINGSUPPORT)
+  list(APPEND TEST_SOURCES
+fdr_controller_test.cc
+fdr_log_writer_test.cc)
+endif()
+
+add_xray_unittest(XRayTest SOURCES ${TEST_SOURCES})
Index: compiler-rt/trunk/lib/xray/tests/CMakeLists.txt
===
--- compiler-rt/trunk/lib/xray/tests/CMakeLists.txt
+++ compiler-rt/trunk/lib/xray/tests/CMakeLists.txt
@@ -60,6 +60,10 @@
   if (COMPILER_RT_STANDALONE_BUILD)
 append_list_if(COMPILER_RT_HAS_LLVMXRAY ${LLVM_XRAY_LDFLAGS} 
XRAY_UNITTEST_LINK_FLAGS)
 append_list_if(COMPILER_RT_HAS_LLVMXRAY ${LLVM_XRAY_LIBLIST} 
XRAY_UNITTEST_LINK_FLAGS)
+append_list_if(COMPILER_RT_HAS_LLVMTESTINGSUPPORT
+  ${LLVM_TESTINGSUPPORT_LDFLAGS} XRAY_UNITTEST_LINK_FLAGS)
+append_list_if(COMPILER_RT_HAS_LLVMTESTINGSUPPORT
+  ${LLVM_TESTINGSUPPORT_LIBLIST} XRAY_UNITTEST_LINK_FLAGS)
   else()
 # We add the library directories one at a time in our CFLAGS.
 foreach (DIR ${LLVM_LIBRARY_DIR})


Index: compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
===
--- compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
+++ compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
@@ -239,7 +239,7 @@
 # Detect if we have the LLVMXRay and TestingSupport library installed and
 # available from llvm-config.
 execute_process(
-  COMMAND ${LLVM_CONFIG_PATH} "--ldflags" "--libs" "xray" "testingsupport"
+  COMMAND ${LLVM_CONFIG_PATH} "--ldflags" "--libs" "xray"
   RESULT_VARIABLE HAD_ERROR
   OUTPUT_VARIABLE CONFIG_OUTPUT)
 if (HAD_ERROR)
@@ -254,6 +254,26 @@
   set(COMPILER_RT_HAS_LLVMXRAY TRUE)
 endif()
 
+set(COMPILER_RT_HAS_LLVMTESTINGSUPPORT FALSE)
+execute_process(
+  COMMAND ${LLVM_CONFIG_PATH} "--ldflags" "--libs" "testingsupport"
+  RESULT_VARIABLE HAD_ERROR
+  OUTPUT_VARIABLE CONFIG_OUTPUT)
+if (HAD_ERROR)
+  message(WARNING "llvm-config 

r349901 - [AST][NFC] Pass the AST context to one of the ctor of DeclRefExpr.

2018-12-21 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Fri Dec 21 06:10:18 2018
New Revision: 349901

URL: http://llvm.org/viewvc/llvm-project?rev=349901=rev
Log:
[AST][NFC] Pass the AST context to one of the ctor of DeclRefExpr.

All of the other constructors already take a reference to the AST context.
This avoids calling Decl::getASTContext in most cases. Additionally move
the definition of the constructor from Expr.h to Expr.cpp since it is calling
DeclRefExpr::computeDependence. NFC.


Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/Analysis/ThreadSafety.cpp
cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaCUDA.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=349901=349900=349901=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Fri Dec 21 06:10:18 2018
@@ -1086,20 +1086,10 @@ class DeclRefExpr final
   void computeDependence(const ASTContext );
 
 public:
-  DeclRefExpr(ValueDecl *D, bool RefersToEnclosingVariableOrCapture, QualType 
T,
+  DeclRefExpr(const ASTContext , ValueDecl *D,
+  bool RefersToEnclosingVariableOrCapture, QualType T,
   ExprValueKind VK, SourceLocation L,
-  const DeclarationNameLoc  = DeclarationNameLoc())
-  : Expr(DeclRefExprClass, T, VK, OK_Ordinary, false, false, false, false),
-D(D), DNLoc(LocInfo) {
-DeclRefExprBits.HasQualifier = false;
-DeclRefExprBits.HasTemplateKWAndArgsInfo = false;
-DeclRefExprBits.HasFoundDecl = false;
-DeclRefExprBits.HadMultipleCandidates = false;
-DeclRefExprBits.RefersToEnclosingVariableOrCapture =
-RefersToEnclosingVariableOrCapture;
-DeclRefExprBits.Loc = L;
-computeDependence(D->getASTContext());
-  }
+  const DeclarationNameLoc  = DeclarationNameLoc());
 
   static DeclRefExpr *
   Create(const ASTContext , NestedNameSpecifierLoc QualifierLoc,

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=349901=349900=349901=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri Dec 21 06:10:18 2018
@@ -4320,7 +4320,7 @@ TemplateArgument ASTContext::getInjected
 Arg = TemplateArgument(ArgType);
   } else if (auto *NTTP = dyn_cast(Param)) {
 Expr *E = new (*this) DeclRefExpr(
-NTTP, /*enclosing*/false,
+*this, NTTP, /*enclosing*/ false,
 NTTP->getType().getNonLValueExprType(*this),
 Expr::getValueKindForType(NTTP->getType()), NTTP->getLocation());
 

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=349901=349900=349901=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Fri Dec 21 06:10:18 2018
@@ -341,16 +341,31 @@ void DeclRefExpr::computeDependence(cons
 ExprBits.ContainsUnexpandedParameterPack = true;
 }
 
+DeclRefExpr::DeclRefExpr(const ASTContext , ValueDecl *D,
+ bool RefersToEnclosingVariableOrCapture, QualType T,
+ ExprValueKind VK, SourceLocation L,
+ const DeclarationNameLoc )
+: Expr(DeclRefExprClass, T, VK, OK_Ordinary, false, false, false, false),
+  D(D), DNLoc(LocInfo) {
+  DeclRefExprBits.HasQualifier = false;
+  DeclRefExprBits.HasTemplateKWAndArgsInfo = false;
+  DeclRefExprBits.HasFoundDecl = false;
+  DeclRefExprBits.HadMultipleCandidates = false;
+  DeclRefExprBits.RefersToEnclosingVariableOrCapture =
+  RefersToEnclosingVariableOrCapture;
+  DeclRefExprBits.Loc = L;
+  computeDependence(Ctx);
+}
+
 DeclRefExpr::DeclRefExpr(const ASTContext ,
  NestedNameSpecifierLoc QualifierLoc,
- SourceLocation TemplateKWLoc,
- ValueDecl *D, bool RefersToEnclosingVariableOrCapture,
- const DeclarationNameInfo ,
- NamedDecl *FoundD,
+ SourceLocation TemplateKWLoc, ValueDecl *D,
+ bool RefersToEnclosingVariableOrCapture,
+   

[PATCH] D55125: [clang-tidy] Fix a false positive in misc-redundant-expression check

2018-12-21 Thread Daniel Krupp via Phabricator via cfe-commits
dkrupp marked 13 inline comments as done.
dkrupp added a comment.

Thanks for your comments. I fixed them all. I also added the handling of 
redundant sizeof() and alignof() operators on the way. Please check if OK now...




Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:602
+static bool compareToks(Token , Token , const SourceManager ) {
+  if (T1.getLength() != T2.getLength())
+return false;

Szelethus wrote:
> alexfh wrote:
> > `Token::getLength()` will assert-fail for annotation tokens.
> I guess if `T1.isNot(tok::raw_identifier)` (or `T2`) we could get away with 
> simply comparing token kinds. If they are, it wouldn't assert. :)
I changed to code as per the suggestion from Szelethus.
So we will compare only raw_identifiers char-by-char, the rest by kind only. 
According to my tests, macros and types, typedefs for example are such 
raw_identifiers. 




Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:605
+  return strncmp(SM.getCharacterData(T1.getLocation()),
+ SM.getCharacterData(T2.getLocation()), T1.getLength()) == 0;
+}

alexfh wrote:
> JonasToth wrote:
> > This operation could overflow if `len(T1) > len(T2)` and `T2` is the last 
> > token of the file. I think `std::min(T1.getLength(), T2.getLength())` would 
> > be better.
> This code is only executed when they have the same length.
exactly, overflow should not happen.



Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:638
+  SourceLocation LLoc, RLoc;
+  int LRem, RRem;
+  do {//we compare the expressions token-by-token

Szelethus wrote:
> It seems like we're only checking whether these values are `0` or not, maybe 
> make them `bool`? Also, I find `Rem` a little cryptic, what is it referring 
> to? Maybe `RemainingCharCount`?
> 
> Maybe we should just make a simple function, so we could both boost 
> readability, and get rid of some these variables (`LLoc`, `RLoc`) entirely:
> 
> ```
> unsinged getCharCountUntilEndOfExpr(SourceRange ExprSR, Token T,
> const SourceManager ) {
> 
>   assert((ExprSR.getBegin() > T.getLocation() ||
>   ExprSR.getEnd() < T.getLocation()) &&
>  "Token is not within the expression range!");
> 
>   return SM.getCharacterData(SM.getExpansionLoc(ExprSR.getEnd())) -
>  SM.getCharacterData(T.getLocation());
> }
> ```
> 
> 
good point. Refactored ass suggested.


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

https://reviews.llvm.org/D55125



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


[PATCH] D56000: [compiler-rt] [xray] Disable alignas() for thread_local objects on NetBSD

2018-12-21 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: krytarowski, dberris, vitalybuka.
Herald added subscribers: Sanitizers, llvm-commits.

Disable enforcing alignas() for structs that are used as thread_local
data on NetBSD.  The NetBSD ld.so implementation is buggy and does
not enforce correct alignment; however, clang seems to take it for
granted and generates instructions that segv on wrongly aligned objects.
Therefore, disable those alignas() statements on NetBSD until we can
establish a better fix.

Apparently, std::aligned_storage<> does not have any real effect
at the moment, so we can leave it as-is.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D56000

Files:
  lib/xray/xray_basic_logging.cc
  lib/xray/xray_fdr_logging.cc


Index: lib/xray/xray_fdr_logging.cc
===
--- lib/xray/xray_fdr_logging.cc
+++ lib/xray/xray_fdr_logging.cc
@@ -51,7 +51,12 @@
 // call so that it can be initialized on first use instead of as a global. We
 // force the alignment to 64-bytes for x86 cache line alignment, as this
 // structure is used in the hot path of implementation.
-struct alignas(64) ThreadLocalData {
+struct
+/* TLD is not aligned properly on NetBSD, resulting in segfault */
+#if !SANITIZER_NETBSD
+alignas(64)
+#endif
+ThreadLocalData {
   BufferQueue::Buffer Buffer{};
   BufferQueue *BQ = nullptr;
 
@@ -124,8 +129,10 @@
 // critical section, calling a function that might be XRay instrumented (and
 // thus in turn calling into malloc by virtue of registration of the
 // thread_local's destructor).
+#if !SANITIZER_NETBSD
 static_assert(alignof(ThreadLocalData) >= 64,
   "ThreadLocalData must be cache line aligned.");
+#endif
 static ThreadLocalData () {
   thread_local typename std::aligned_storage<
   sizeof(ThreadLocalData), alignof(ThreadLocalData)>::type TLDStorage{};
Index: lib/xray/xray_basic_logging.cc
===
--- lib/xray/xray_basic_logging.cc
+++ lib/xray/xray_basic_logging.cc
@@ -55,7 +55,12 @@
 
 static_assert(sizeof(StackEntry) == 16, "Wrong size for StackEntry");
 
-struct alignas(64) ThreadLocalData {
+struct
+/* TLD is not aligned properly on NetBSD, resulting in segfault */
+#if !SANITIZER_NETBSD
+alignas(64)
+#endif
+ThreadLocalData {
   void *InMemoryBuffer = nullptr;
   size_t BufferSize = 0;
   size_t BufferOffset = 0;


Index: lib/xray/xray_fdr_logging.cc
===
--- lib/xray/xray_fdr_logging.cc
+++ lib/xray/xray_fdr_logging.cc
@@ -51,7 +51,12 @@
 // call so that it can be initialized on first use instead of as a global. We
 // force the alignment to 64-bytes for x86 cache line alignment, as this
 // structure is used in the hot path of implementation.
-struct alignas(64) ThreadLocalData {
+struct
+/* TLD is not aligned properly on NetBSD, resulting in segfault */
+#if !SANITIZER_NETBSD
+alignas(64)
+#endif
+ThreadLocalData {
   BufferQueue::Buffer Buffer{};
   BufferQueue *BQ = nullptr;
 
@@ -124,8 +129,10 @@
 // critical section, calling a function that might be XRay instrumented (and
 // thus in turn calling into malloc by virtue of registration of the
 // thread_local's destructor).
+#if !SANITIZER_NETBSD
 static_assert(alignof(ThreadLocalData) >= 64,
   "ThreadLocalData must be cache line aligned.");
+#endif
 static ThreadLocalData () {
   thread_local typename std::aligned_storage<
   sizeof(ThreadLocalData), alignof(ThreadLocalData)>::type TLDStorage{};
Index: lib/xray/xray_basic_logging.cc
===
--- lib/xray/xray_basic_logging.cc
+++ lib/xray/xray_basic_logging.cc
@@ -55,7 +55,12 @@
 
 static_assert(sizeof(StackEntry) == 16, "Wrong size for StackEntry");
 
-struct alignas(64) ThreadLocalData {
+struct
+/* TLD is not aligned properly on NetBSD, resulting in segfault */
+#if !SANITIZER_NETBSD
+alignas(64)
+#endif
+ThreadLocalData {
   void *InMemoryBuffer = nullptr;
   size_t BufferSize = 0;
   size_t BufferOffset = 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55981: [gn build] Add build files for clang, clang-offload-bundler, and clang/lib/Headers

2018-12-21 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 179404.
thakis marked an inline comment as done.

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

https://reviews.llvm.org/D55981

Files:
  llvm/utils/gn/secondary/BUILD.gn
  llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
  llvm/utils/gn/secondary/clang/tools/clang-offload-bundler/BUILD.gn
  llvm/utils/gn/secondary/clang/tools/driver/BUILD.gn

Index: llvm/utils/gn/secondary/clang/tools/driver/BUILD.gn
===
--- /dev/null
+++ llvm/utils/gn/secondary/clang/tools/driver/BUILD.gn
@@ -0,0 +1,72 @@
+import("//llvm/utils/gn/build/symlink_or_copy.gni")
+
+symlinks = [
+  # target_name, symlink_target pairs: GN doesn't support '+' in rule names.
+  [
+"clangxx",
+"clang++",
+  ],
+  [
+"clang-cl",
+"clang-cl",
+  ],
+  [
+"clang-cpp",
+"clang-cpp",
+  ],
+]
+foreach(target, symlinks) {
+  symlink_or_copy(target[0]) {
+deps = [
+  ":clang",
+]
+source = "clang"
+output = "$root_out_dir/bin/${target[1]}"
+  }
+}
+
+# //:clang depends on this symlink target, see comment in //BUILD.gn.
+group("symlinks") {
+  deps = []
+  foreach(target, symlinks) {
+deps += [ ":${target[0]}" ]
+  }
+}
+
+executable("clang") {
+  configs += [ "//llvm/utils/gn/build:clang_code" ]
+  deps = [
+"//clang/include/clang/Config",
+"//clang/lib/Basic",
+"//clang/lib/CodeGen",
+"//clang/lib/Driver",
+"//clang/lib/Frontend",
+"//clang/lib/FrontendTool",
+"//clang/lib/Headers",
+"//clang/tools/clang-offload-bundler",
+"//llvm/include/llvm/Config:llvm-config",
+"//llvm/lib/Analysis",
+"//llvm/lib/CodeGen",
+"//llvm/lib/IR",
+"//llvm/lib/MC",
+"//llvm/lib/MC/MCParser",
+"//llvm/lib/Option",
+"//llvm/lib/Support",
+"//llvm/lib/Target:TargetsToBuild",
+"//llvm/lib/Transforms/IPO",
+"//llvm/lib/Transforms/InstCombine",
+"//llvm/lib/Transforms/Instrumentation",
+"//llvm/lib/Transforms/ObjCARC",
+"//llvm/lib/Transforms/Scalar",
+"//llvm/lib/Transforms/Utils",
+"//llvm/lib/Transforms/Vectorize",
+  ]
+  sources = [
+"cc1_main.cpp",
+"cc1as_main.cpp",
+"cc1gen_reproducer_main.cpp",
+"driver.cpp",
+  ]
+
+  # FIXME: Info.plist embedding for mac builds.
+}
Index: llvm/utils/gn/secondary/clang/tools/clang-offload-bundler/BUILD.gn
===
--- /dev/null
+++ llvm/utils/gn/secondary/clang/tools/clang-offload-bundler/BUILD.gn
@@ -0,0 +1,13 @@
+executable("clang-offload-bundler") {
+  configs += [ "//llvm/utils/gn/build:clang_code" ]
+  deps = [
+"//clang/lib/Basic",
+"//llvm/lib/Bitcode/Writer",
+"//llvm/lib/IR",
+"//llvm/lib/Object",
+"//llvm/lib/Support",
+  ]
+  sources = [
+"ClangOffloadBundler.cpp",
+  ]
+}
Index: llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
===
--- /dev/null
+++ llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
@@ -0,0 +1,163 @@
+import("//clang/utils/TableGen/clang_tablegen.gni")
+import("//llvm/version.gni")
+
+# Generate arm_neon.h
+clang_tablegen("arm_neon") {
+  args = [ "-gen-arm-neon" ]
+  td_file = "//clang/include/clang/Basic/arm_neon.td"
+  output_name = "arm_neon.h"
+}
+
+# Generate arm_fp16.h
+clang_tablegen("arm_fp16") {
+  args = [ "-gen-arm-fp16" ]
+  td_file = "//clang/include/clang/Basic/arm_fp16.td"
+  output_name = "arm_fp16.h"
+}
+
+output_dir = "$root_out_dir/lib/clang/$llvm_version/include"
+
+copy("arm_headers") {
+  visibility = [ ":Headers" ]
+  deps = [
+":arm_fp16",
+":arm_neon",
+  ]
+  sources = get_target_outputs(":arm_neon") + get_target_outputs(":arm_fp16")
+  outputs = [
+"$output_dir/{{source_file_part}}",
+  ]
+}
+
+copy("Headers") {
+  deps = [
+":arm_headers",
+  ]
+
+  # Tell `gn format` to not reorder the sources list: Its order matches CMake,
+  # and the ordering is alphabetical but ignores leading underscores.
+  # NOSORT
+  sources = [
+"adxintrin.h",
+"altivec.h",
+"ammintrin.h",
+"arm_acle.h",
+"armintr.h",
+"arm64intr.h",
+"avx2intrin.h",
+"avx512bwintrin.h",
+"avx512bitalgintrin.h",
+"avx512vlbitalgintrin.h",
+"avx512cdintrin.h",
+"avx512vpopcntdqintrin.h",
+"avx512dqintrin.h",
+"avx512erintrin.h",
+"avx512fintrin.h",
+"avx512ifmaintrin.h",
+"avx512ifmavlintrin.h",
+"avx512pfintrin.h",
+"avx512vbmiintrin.h",
+"avx512vbmivlintrin.h",
+"avx512vbmi2intrin.h",
+"avx512vlvbmi2intrin.h",
+"avx512vlbwintrin.h",
+"avx512vlcdintrin.h",
+"avx512vldqintrin.h",
+"avx512vlintrin.h",
+"avx512vpopcntdqvlintrin.h",
+"avx512vnniintrin.h",
+"avx512vlvnniintrin.h",
+"avxintrin.h",
+"bmi2intrin.h",
+"bmiintrin.h",
+"__clang_cuda_builtin_vars.h",
+"__clang_cuda_cmath.h",
+"__clang_cuda_complex_builtins.h",
+

[PATCH] D55981: [gn build] Add build files for clang, clang-offload-bundler, and clang/lib/Headers

2018-12-21 Thread Nico Weber via Phabricator via cfe-commits
thakis marked 2 inline comments as done.
thakis added inline comments.



Comment at: llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn:6
+
+files = [
+  "adxintrin.h",

phosek wrote:
> Why not just inline this? This variable doesn't seem to be used from anywhere 
> else?
Good question. No good reason, done.


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

https://reviews.llvm.org/D55981



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


[PATCH] D56044: [Driver] Support object files in addition to static and shared libraries in compiler-rt

2018-12-21 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: echristo.
Herald added subscribers: cfe-commits, atanasyan, jrtc27, dberris, sdardis.

This change introduces support for object files in addition to static
and shared libraries which were already supported which requires
changing the type of the argument from boolean to an enum.


Repository:
  rC Clang

https://reviews.llvm.org/D56044

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/lib/Driver/ToolChains/MipsLinux.cpp
  clang/lib/Driver/ToolChains/MipsLinux.h

Index: clang/lib/Driver/ToolChains/MipsLinux.h
===
--- clang/lib/Driver/ToolChains/MipsLinux.h
+++ clang/lib/Driver/ToolChains/MipsLinux.h
@@ -38,8 +38,9 @@
   void AddCXXStdlibLibArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
 
-  std::string getCompilerRT(const llvm::opt::ArgList , StringRef Component,
-bool Shared = false) const override;
+  std::string
+  getCompilerRT(const llvm::opt::ArgList , StringRef Component,
+FileType Type = ToolChain::FT_Static) const override;
 
   std::string computeSysRoot() const override;
 
Index: clang/lib/Driver/ToolChains/MipsLinux.cpp
===
--- clang/lib/Driver/ToolChains/MipsLinux.cpp
+++ clang/lib/Driver/ToolChains/MipsLinux.cpp
@@ -119,11 +119,23 @@
 
 std::string MipsLLVMToolChain::getCompilerRT(const ArgList ,
  StringRef Component,
- bool Shared) const {
+ FileType Type) const {
   SmallString<128> Path(getDriver().ResourceDir);
   llvm::sys::path::append(Path, SelectedMultilib.osSuffix(), "lib" + LibSuffix,
   getOS());
-  llvm::sys::path::append(Path, Twine("libclang_rt." + Component + "-" +
-  "mips" + (Shared ? ".so" : ".a")));
+  const char *Suffix;
+  switch (Type) {
+  case ToolChain::FT_Object:
+Suffix = ".o";
+break;
+  case ToolChain::FT_Static:
+Suffix = ".a";
+break;
+  case ToolChain::FT_Shared:
+Suffix = ".so";
+break;
+  }
+  llvm::sys::path::append(
+  Path, Twine("libclang_rt." + Component + "-" + "mips" + Suffix));
   return Path.str();
 }
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -249,8 +249,8 @@
 
   if (Sanitize.needsAsanRt()) {
 // MinGW always links against a shared MSVCRT.
-CmdArgs.push_back(
-TC.getCompilerRTArgString(Args, "asan_dynamic", true));
+CmdArgs.push_back(TC.getCompilerRTArgString(Args, "asan_dynamic",
+ToolChain::FT_Shared));
 CmdArgs.push_back(
 TC.getCompilerRTArgString(Args, "asan_dynamic_runtime_thunk"));
 CmdArgs.push_back(Args.MakeArgString("--require-defined"));
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -530,7 +530,8 @@
   // Wrap any static runtimes that must be forced into executable in
   // whole-archive.
   if (IsWhole) CmdArgs.push_back("--whole-archive");
-  CmdArgs.push_back(TC.getCompilerRTArgString(Args, Sanitizer, IsShared));
+  CmdArgs.push_back(TC.getCompilerRTArgString(
+  Args, Sanitizer, IsShared ? ToolChain::FT_Shared : ToolChain::FT_Static));
   if (IsWhole) CmdArgs.push_back("--no-whole-archive");
 
   if (IsShared) {
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -363,16 +363,27 @@
 }
 
 std::string ToolChain::getCompilerRT(const ArgList , StringRef Component,
- bool Shared) const {
+ FileType Type) const {
   const llvm::Triple  = getTriple();
   bool IsITANMSVCWindows =
   TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment();
 
-  const char *Prefix = IsITANMSVCWindows ? "" : "lib";
-  const char *Suffix = Shared ? (Triple.isOSWindows() ? ".lib" : ".so")
-  : (IsITANMSVCWindows ? ".lib" : ".a");
-  if (Shared && Triple.isWindowsGNUEnvironment())
-Suffix = ".dll.a";
+  const char *Prefix =
+  IsITANMSVCWindows || Type == ToolChain::FT_Object ? "" : "lib";
+  const char *Suffix;
+  switch (Type) {
+  case ToolChain::FT_Object:
+Suffix = Triple.isOSWindows() ? ".obj" : ".o";
+break;
+  case ToolChain::FT_Static:
+

[PATCH] D55981: [gn build] Add build files for clang, clang-offload-bundler, and clang/lib/Headers

2018-12-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349991: [gn build] Add build files for clang, 
clang-offload-bundler, and… (authored by nico, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55981?vs=179404=179407#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55981

Files:
  llvm/trunk/utils/gn/secondary/BUILD.gn
  llvm/trunk/utils/gn/secondary/clang/lib/Headers/BUILD.gn
  llvm/trunk/utils/gn/secondary/clang/tools/clang-offload-bundler/BUILD.gn
  llvm/trunk/utils/gn/secondary/clang/tools/driver/BUILD.gn

Index: llvm/trunk/utils/gn/secondary/clang/lib/Headers/BUILD.gn
===
--- llvm/trunk/utils/gn/secondary/clang/lib/Headers/BUILD.gn
+++ llvm/trunk/utils/gn/secondary/clang/lib/Headers/BUILD.gn
@@ -0,0 +1,163 @@
+import("//clang/utils/TableGen/clang_tablegen.gni")
+import("//llvm/version.gni")
+
+# Generate arm_neon.h
+clang_tablegen("arm_neon") {
+  args = [ "-gen-arm-neon" ]
+  td_file = "//clang/include/clang/Basic/arm_neon.td"
+  output_name = "arm_neon.h"
+}
+
+# Generate arm_fp16.h
+clang_tablegen("arm_fp16") {
+  args = [ "-gen-arm-fp16" ]
+  td_file = "//clang/include/clang/Basic/arm_fp16.td"
+  output_name = "arm_fp16.h"
+}
+
+output_dir = "$root_out_dir/lib/clang/$llvm_version/include"
+
+copy("arm_headers") {
+  visibility = [ ":Headers" ]
+  deps = [
+":arm_fp16",
+":arm_neon",
+  ]
+  sources = get_target_outputs(":arm_neon") + get_target_outputs(":arm_fp16")
+  outputs = [
+"$output_dir/{{source_file_part}}",
+  ]
+}
+
+copy("Headers") {
+  deps = [
+":arm_headers",
+  ]
+
+  # Tell `gn format` to not reorder the sources list: Its order matches CMake,
+  # and the ordering is alphabetical but ignores leading underscores.
+  # NOSORT
+  sources = [
+"adxintrin.h",
+"altivec.h",
+"ammintrin.h",
+"arm_acle.h",
+"armintr.h",
+"arm64intr.h",
+"avx2intrin.h",
+"avx512bwintrin.h",
+"avx512bitalgintrin.h",
+"avx512vlbitalgintrin.h",
+"avx512cdintrin.h",
+"avx512vpopcntdqintrin.h",
+"avx512dqintrin.h",
+"avx512erintrin.h",
+"avx512fintrin.h",
+"avx512ifmaintrin.h",
+"avx512ifmavlintrin.h",
+"avx512pfintrin.h",
+"avx512vbmiintrin.h",
+"avx512vbmivlintrin.h",
+"avx512vbmi2intrin.h",
+"avx512vlvbmi2intrin.h",
+"avx512vlbwintrin.h",
+"avx512vlcdintrin.h",
+"avx512vldqintrin.h",
+"avx512vlintrin.h",
+"avx512vpopcntdqvlintrin.h",
+"avx512vnniintrin.h",
+"avx512vlvnniintrin.h",
+"avxintrin.h",
+"bmi2intrin.h",
+"bmiintrin.h",
+"__clang_cuda_builtin_vars.h",
+"__clang_cuda_cmath.h",
+"__clang_cuda_complex_builtins.h",
+"__clang_cuda_device_functions.h",
+"__clang_cuda_intrinsics.h",
+"__clang_cuda_libdevice_declares.h",
+"__clang_cuda_math_forward_declares.h",
+"__clang_cuda_runtime_wrapper.h",
+"cetintrin.h",
+"cldemoteintrin.h",
+"clzerointrin.h",
+"cpuid.h",
+"clflushoptintrin.h",
+"clwbintrin.h",
+"emmintrin.h",
+"f16cintrin.h",
+"float.h",
+"fma4intrin.h",
+"fmaintrin.h",
+"fxsrintrin.h",
+"gfniintrin.h",
+"htmintrin.h",
+"htmxlintrin.h",
+"ia32intrin.h",
+"immintrin.h",
+"intrin.h",
+"inttypes.h",
+"invpcidintrin.h",
+"iso646.h",
+"limits.h",
+"lwpintrin.h",
+"lzcntintrin.h",
+"mm3dnow.h",
+"mmintrin.h",
+"mm_malloc.h",
+"module.modulemap",
+"movdirintrin.h",
+"msa.h",
+"mwaitxintrin.h",
+"nmmintrin.h",
+"opencl-c.h",
+"pconfigintrin.h",
+"pkuintrin.h",
+"pmmintrin.h",
+"popcntintrin.h",
+"prfchwintrin.h",
+"ptwriteintrin.h",
+"rdseedintrin.h",
+"rtmintrin.h",
+"s390intrin.h",
+"sgxintrin.h",
+"shaintrin.h",
+"smmintrin.h",
+"stdalign.h",
+"stdarg.h",
+"stdatomic.h",
+"stdbool.h",
+"stddef.h",
+"__stddef_max_align_t.h",
+"stdint.h",
+"stdnoreturn.h",
+"tbmintrin.h",
+"tgmath.h",
+"tmmintrin.h",
+"unwind.h",
+"vadefs.h",
+"vaesintrin.h",
+"varargs.h",
+"vecintrin.h",
+"vpclmulqdqintrin.h",
+"waitpkgintrin.h",
+"wbnoinvdintrin.h",
+"wmmintrin.h",
+"__wmmintrin_aes.h",
+"__wmmintrin_pclmul.h",
+"x86intrin.h",
+"xmmintrin.h",
+"xopintrin.h",
+"xsavecintrin.h",
+"xsaveintrin.h",
+"xsaveoptintrin.h",
+"xsavesintrin.h",
+"xtestintrin.h",
+"cuda_wrappers/algorithm",
+"cuda_wrappers/complex",
+"cuda_wrappers/new",
+  ]
+  outputs = [
+"$output_dir/{{source_target_relative}}",
+  ]
+}
Index: llvm/trunk/utils/gn/secondary/clang/tools/clang-offload-bundler/BUILD.gn
===
--- 

[PATCH] D55984: [gn build] Embed __TEXT __info_plist section into clang binary on macOS

2018-12-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349992: [gn build] Embed __TEXT __info_plist section into 
clang binary on macOS (authored by nico, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55984?vs=179237=179408#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55984

Files:
  llvm/trunk/utils/gn/secondary/clang/tools/driver/BUILD.gn


Index: llvm/trunk/utils/gn/secondary/clang/tools/driver/BUILD.gn
===
--- llvm/trunk/utils/gn/secondary/clang/tools/driver/BUILD.gn
+++ llvm/trunk/utils/gn/secondary/clang/tools/driver/BUILD.gn
@@ -1,4 +1,5 @@
 import("//llvm/utils/gn/build/symlink_or_copy.gni")
+import("//llvm/version.gni")
 
 symlinks = [
   # target_name, symlink_target pairs: GN doesn't support '+' in rule names.
@@ -33,6 +34,29 @@
   }
 }
 
+if (host_os == "mac") {
+  action("write_info_plist") {
+script = "//llvm/utils/gn/build/write_cmake_config.py"
+sources = [
+  "Info.plist.in",
+]
+outputs = [
+  "$target_gen_dir/Info.plist",
+]
+
+args = [
+  "-o",
+  rebase_path(outputs[0], root_out_dir),
+  rebase_path(sources[0], root_out_dir),
+
+  "TOOL_INFO_BUILD_VERSION=$llvm_version_major.$llvm_version_minor",
+  "TOOL_INFO_NAME=clang",
+  "TOOL_INFO_UTI=org.llvm.clang",
+  "TOOL_INFO_VERSION=$llvm_version",
+]
+  }
+}
+
 executable("clang") {
   configs += [ "//llvm/utils/gn/build:clang_code" ]
   deps = [
@@ -61,12 +85,16 @@
 "//llvm/lib/Transforms/Utils",
 "//llvm/lib/Transforms/Vectorize",
   ]
+  if (host_os == "mac") {
+deps += [ ":write_info_plist" ]
+plist = get_target_outputs(":write_info_plist")
+ldflags = [ "-Wl,-sectcreate,__TEXT,__info_plist," +
+rebase_path(plist[0], root_out_dir) ]
+  }
   sources = [
 "cc1_main.cpp",
 "cc1as_main.cpp",
 "cc1gen_reproducer_main.cpp",
 "driver.cpp",
   ]
-
-  # FIXME: Info.plist embedding for mac builds.
 }


Index: llvm/trunk/utils/gn/secondary/clang/tools/driver/BUILD.gn
===
--- llvm/trunk/utils/gn/secondary/clang/tools/driver/BUILD.gn
+++ llvm/trunk/utils/gn/secondary/clang/tools/driver/BUILD.gn
@@ -1,4 +1,5 @@
 import("//llvm/utils/gn/build/symlink_or_copy.gni")
+import("//llvm/version.gni")
 
 symlinks = [
   # target_name, symlink_target pairs: GN doesn't support '+' in rule names.
@@ -33,6 +34,29 @@
   }
 }
 
+if (host_os == "mac") {
+  action("write_info_plist") {
+script = "//llvm/utils/gn/build/write_cmake_config.py"
+sources = [
+  "Info.plist.in",
+]
+outputs = [
+  "$target_gen_dir/Info.plist",
+]
+
+args = [
+  "-o",
+  rebase_path(outputs[0], root_out_dir),
+  rebase_path(sources[0], root_out_dir),
+
+  "TOOL_INFO_BUILD_VERSION=$llvm_version_major.$llvm_version_minor",
+  "TOOL_INFO_NAME=clang",
+  "TOOL_INFO_UTI=org.llvm.clang",
+  "TOOL_INFO_VERSION=$llvm_version",
+]
+  }
+}
+
 executable("clang") {
   configs += [ "//llvm/utils/gn/build:clang_code" ]
   deps = [
@@ -61,12 +85,16 @@
 "//llvm/lib/Transforms/Utils",
 "//llvm/lib/Transforms/Vectorize",
   ]
+  if (host_os == "mac") {
+deps += [ ":write_info_plist" ]
+plist = get_target_outputs(":write_info_plist")
+ldflags = [ "-Wl,-sectcreate,__TEXT,__info_plist," +
+rebase_path(plist[0], root_out_dir) ]
+  }
   sources = [
 "cc1_main.cpp",
 "cc1as_main.cpp",
 "cc1gen_reproducer_main.cpp",
 "driver.cpp",
   ]
-
-  # FIXME: Info.plist embedding for mac builds.
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56043: [Driver] Don't pass default value to getCompilerRTArgString

2018-12-21 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: echristo.
Herald added a subscriber: cfe-commits.

Using static library is already a default. This makes it easier to change the 
parameter type in the future.


Repository:
  rC Clang

https://reviews.llvm.org/D56043

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/OpenBSD.cpp
  clang/lib/Driver/ToolChains/Solaris.cpp


Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -101,7 +101,7 @@
   // __start_SECNAME labels.
   CmdArgs.push_back("--whole-archive");
   CmdArgs.push_back(
-  getToolChain().getCompilerRTArgString(Args, "sancov_begin", false));
+  getToolChain().getCompilerRTArgString(Args, "sancov_begin"));
   CmdArgs.push_back("--no-whole-archive");
 
   getToolChain().AddFilePathLibArgs(Args, CmdArgs);
@@ -136,7 +136,7 @@
   // __stop_SECNAME labels.
   CmdArgs.push_back("--whole-archive");
   CmdArgs.push_back(
-  getToolChain().getCompilerRTArgString(Args, "sancov_end", false));
+  getToolChain().getCompilerRTArgString(Args, "sancov_end"));
   CmdArgs.push_back("--no-whole-archive");
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
Index: clang/lib/Driver/ToolChains/OpenBSD.cpp
===
--- clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -189,11 +189,11 @@
 CmdArgs.push_back("-lm");
 }
 if (NeedsSanitizerDeps) {
-  CmdArgs.push_back(ToolChain.getCompilerRTArgString(Args, "builtins", 
false));
+  CmdArgs.push_back(ToolChain.getCompilerRTArgString(Args, "builtins"));
   linkSanitizerRuntimeDeps(ToolChain, CmdArgs);
 }
 if (NeedsXRayDeps) {
-  CmdArgs.push_back(ToolChain.getCompilerRTArgString(Args, "builtins", 
false));
+  CmdArgs.push_back(ToolChain.getCompilerRTArgString(Args, "builtins"));
   linkXRayRuntimeDeps(ToolChain, CmdArgs);
 }
 // FIXME: For some reason GCC passes -lgcc before adding
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -378,7 +378,7 @@
 if (!Args.hasArg(options::OPT_shared))
   CmdArgs.push_back(
   Args.MakeArgString(std::string("-wholearchive:") +
- TC.getCompilerRTArgString(Args, "fuzzer", 
false)));
+ TC.getCompilerRTArgString(Args, "fuzzer")));
 CmdArgs.push_back(Args.MakeArgString("-debug"));
 // Prevent the linker from padding sections we use for instrumentation
 // arrays.
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -777,9 +777,9 @@
 
   if (TC.getXRayArgs().needsXRayRt()) {
 CmdArgs.push_back("-whole-archive");
-CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
+CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray"));
 for (const auto  : TC.getXRayArgs().modeList())
-  CmdArgs.push_back(TC.getCompilerRTArgString(Args, Mode, false));
+  CmdArgs.push_back(TC.getCompilerRTArgString(Args, Mode));
 CmdArgs.push_back("-no-whole-archive");
 return true;
   }


Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -101,7 +101,7 @@
   // __start_SECNAME labels.
   CmdArgs.push_back("--whole-archive");
   CmdArgs.push_back(
-  getToolChain().getCompilerRTArgString(Args, "sancov_begin", false));
+  getToolChain().getCompilerRTArgString(Args, "sancov_begin"));
   CmdArgs.push_back("--no-whole-archive");
 
   getToolChain().AddFilePathLibArgs(Args, CmdArgs);
@@ -136,7 +136,7 @@
   // __stop_SECNAME labels.
   CmdArgs.push_back("--whole-archive");
   CmdArgs.push_back(
-  getToolChain().getCompilerRTArgString(Args, "sancov_end", false));
+  getToolChain().getCompilerRTArgString(Args, "sancov_end"));
   CmdArgs.push_back("--no-whole-archive");
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
Index: clang/lib/Driver/ToolChains/OpenBSD.cpp
===
--- clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -189,11 +189,11 @@
 CmdArgs.push_back("-lm");
 }
 if (NeedsSanitizerDeps) {
-  CmdArgs.push_back(ToolChain.getCompilerRTArgString(Args, "builtins", false));
+  CmdArgs.push_back(ToolChain.getCompilerRTArgString(Args, "builtins"));
   

[PATCH] D55980: [gn build] Add build file for clang/lib/FrontendTool

2018-12-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349988: [gn build] Add build file for clang/lib/FrontendTool 
(authored by nico, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55980?vs=179233=179402#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55980

Files:
  llvm/trunk/utils/gn/secondary/BUILD.gn
  llvm/trunk/utils/gn/secondary/clang/lib/FrontendTool/BUILD.gn


Index: llvm/trunk/utils/gn/secondary/clang/lib/FrontendTool/BUILD.gn
===
--- llvm/trunk/utils/gn/secondary/clang/lib/FrontendTool/BUILD.gn
+++ llvm/trunk/utils/gn/secondary/clang/lib/FrontendTool/BUILD.gn
@@ -0,0 +1,29 @@
+import("//clang/lib/ARCMigrate/enable.gni")
+import("//clang/lib/StaticAnalyzer/Frontend/enable.gni")
+
+assert(clang_enable_static_analyzer || !clang_enable_arcmt,
+   "Cannot disable static analyzer while enabling ARCMT")
+
+static_library("FrontendTool") {
+  output_name = "clangFrontendTool"
+  configs += [ "//llvm/utils/gn/build:clang_code" ]
+  deps = [
+"//clang/include/clang/Config",
+"//clang/lib/Basic",
+"//clang/lib/CodeGen",
+"//clang/lib/Driver",
+"//clang/lib/Frontend",
+"//clang/lib/Frontend/Rewrite",
+"//llvm/lib/Option",
+"//llvm/lib/Support",
+  ]
+  if (clang_enable_arcmt) {
+deps += [ "//clang/lib/ARCMigrate" ]
+  }
+  if (clang_enable_static_analyzer) {
+deps += [ "//clang/lib/StaticAnalyzer/Frontend" ]
+  }
+  sources = [
+"ExecuteCompilerInvocation.cpp",
+  ]
+}
Index: llvm/trunk/utils/gn/secondary/BUILD.gn
===
--- llvm/trunk/utils/gn/secondary/BUILD.gn
+++ llvm/trunk/utils/gn/secondary/BUILD.gn
@@ -8,6 +8,7 @@
 "//clang/lib/Driver",
 "//clang/lib/Frontend",
 "//clang/lib/Frontend/Rewrite",
+"//clang/lib/FrontendTool",
 "//clang/lib/Index",
 "//clang/lib/Parse",
 "//clang/lib/Serialization",


Index: llvm/trunk/utils/gn/secondary/clang/lib/FrontendTool/BUILD.gn
===
--- llvm/trunk/utils/gn/secondary/clang/lib/FrontendTool/BUILD.gn
+++ llvm/trunk/utils/gn/secondary/clang/lib/FrontendTool/BUILD.gn
@@ -0,0 +1,29 @@
+import("//clang/lib/ARCMigrate/enable.gni")
+import("//clang/lib/StaticAnalyzer/Frontend/enable.gni")
+
+assert(clang_enable_static_analyzer || !clang_enable_arcmt,
+   "Cannot disable static analyzer while enabling ARCMT")
+
+static_library("FrontendTool") {
+  output_name = "clangFrontendTool"
+  configs += [ "//llvm/utils/gn/build:clang_code" ]
+  deps = [
+"//clang/include/clang/Config",
+"//clang/lib/Basic",
+"//clang/lib/CodeGen",
+"//clang/lib/Driver",
+"//clang/lib/Frontend",
+"//clang/lib/Frontend/Rewrite",
+"//llvm/lib/Option",
+"//llvm/lib/Support",
+  ]
+  if (clang_enable_arcmt) {
+deps += [ "//clang/lib/ARCMigrate" ]
+  }
+  if (clang_enable_static_analyzer) {
+deps += [ "//clang/lib/StaticAnalyzer/Frontend" ]
+  }
+  sources = [
+"ExecuteCompilerInvocation.cpp",
+  ]
+}
Index: llvm/trunk/utils/gn/secondary/BUILD.gn
===
--- llvm/trunk/utils/gn/secondary/BUILD.gn
+++ llvm/trunk/utils/gn/secondary/BUILD.gn
@@ -8,6 +8,7 @@
 "//clang/lib/Driver",
 "//clang/lib/Frontend",
 "//clang/lib/Frontend/Rewrite",
+"//clang/lib/FrontendTool",
 "//clang/lib/Index",
 "//clang/lib/Parse",
 "//clang/lib/Serialization",
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55981: [gn build] Add build files for clang, clang-offload-bundler, and clang/lib/Headers

2018-12-21 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D55981



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


[PATCH] D55979: [gn build] Add build file for clang/lib/ARCMigrate

2018-12-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349987: [gn build] Add build file for clang/lib/ARCMigrate 
(authored by nico, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55979?vs=179231=179401#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55979

Files:
  llvm/trunk/utils/gn/secondary/BUILD.gn
  llvm/trunk/utils/gn/secondary/clang/lib/ARCMigrate/BUILD.gn


Index: llvm/trunk/utils/gn/secondary/clang/lib/ARCMigrate/BUILD.gn
===
--- llvm/trunk/utils/gn/secondary/clang/lib/ARCMigrate/BUILD.gn
+++ llvm/trunk/utils/gn/secondary/clang/lib/ARCMigrate/BUILD.gn
@@ -0,0 +1,39 @@
+static_library("ARCMigrate") {
+  output_name = "clangARCMigrate"
+  configs += [ "//llvm/utils/gn/build:clang_code" ]
+  deps = [
+"//clang/lib/AST",
+"//clang/lib/Analysis",
+"//clang/lib/Basic",
+"//clang/lib/Edit",
+"//clang/lib/Frontend",
+"//clang/lib/Lex",
+"//clang/lib/Rewrite",
+"//clang/lib/Sema",
+"//clang/lib/Serialization",
+"//clang/lib/StaticAnalyzer/Checkers",
+"//llvm/lib/Support",
+  ]
+  sources = [
+"ARCMT.cpp",
+"ARCMTActions.cpp",
+"FileRemapper.cpp",
+"ObjCMT.cpp",
+"PlistReporter.cpp",
+"TransAPIUses.cpp",
+"TransARCAssign.cpp",
+"TransAutoreleasePool.cpp",
+"TransBlockObjCVariable.cpp",
+"TransEmptyStatementsAndDealloc.cpp",
+"TransGCAttrs.cpp",
+"TransGCCalls.cpp",
+"TransProperties.cpp",
+"TransProtectedScope.cpp",
+"TransRetainReleaseDealloc.cpp",
+"TransUnbridgedCasts.cpp",
+"TransUnusedInitDelegate.cpp",
+"TransZeroOutPropsInDealloc.cpp",
+"TransformActions.cpp",
+"Transforms.cpp",
+  ]
+}
Index: llvm/trunk/utils/gn/secondary/BUILD.gn
===
--- llvm/trunk/utils/gn/secondary/BUILD.gn
+++ llvm/trunk/utils/gn/secondary/BUILD.gn
@@ -1,5 +1,6 @@
 group("default") {
   deps = [
+"//clang/lib/ARCMigrate",
 "//clang/lib/AST",
 "//clang/lib/ASTMatchers",
 "//clang/lib/CodeGen",


Index: llvm/trunk/utils/gn/secondary/clang/lib/ARCMigrate/BUILD.gn
===
--- llvm/trunk/utils/gn/secondary/clang/lib/ARCMigrate/BUILD.gn
+++ llvm/trunk/utils/gn/secondary/clang/lib/ARCMigrate/BUILD.gn
@@ -0,0 +1,39 @@
+static_library("ARCMigrate") {
+  output_name = "clangARCMigrate"
+  configs += [ "//llvm/utils/gn/build:clang_code" ]
+  deps = [
+"//clang/lib/AST",
+"//clang/lib/Analysis",
+"//clang/lib/Basic",
+"//clang/lib/Edit",
+"//clang/lib/Frontend",
+"//clang/lib/Lex",
+"//clang/lib/Rewrite",
+"//clang/lib/Sema",
+"//clang/lib/Serialization",
+"//clang/lib/StaticAnalyzer/Checkers",
+"//llvm/lib/Support",
+  ]
+  sources = [
+"ARCMT.cpp",
+"ARCMTActions.cpp",
+"FileRemapper.cpp",
+"ObjCMT.cpp",
+"PlistReporter.cpp",
+"TransAPIUses.cpp",
+"TransARCAssign.cpp",
+"TransAutoreleasePool.cpp",
+"TransBlockObjCVariable.cpp",
+"TransEmptyStatementsAndDealloc.cpp",
+"TransGCAttrs.cpp",
+"TransGCCalls.cpp",
+"TransProperties.cpp",
+"TransProtectedScope.cpp",
+"TransRetainReleaseDealloc.cpp",
+"TransUnbridgedCasts.cpp",
+"TransUnusedInitDelegate.cpp",
+"TransZeroOutPropsInDealloc.cpp",
+"TransformActions.cpp",
+"Transforms.cpp",
+  ]
+}
Index: llvm/trunk/utils/gn/secondary/BUILD.gn
===
--- llvm/trunk/utils/gn/secondary/BUILD.gn
+++ llvm/trunk/utils/gn/secondary/BUILD.gn
@@ -1,5 +1,6 @@
 group("default") {
   deps = [
+"//clang/lib/ARCMigrate",
 "//clang/lib/AST",
 "//clang/lib/ASTMatchers",
 "//clang/lib/CodeGen",
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55978: [gn build] Add build files for clang/lib/{ASTMatchers, CrossTU}, clang/lib/StaticAnalyzer/{Checkers, Core, Frontend}

2018-12-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349986: [gn build] Add build files for 
clang/lib/{ASTMatchers,CrossTU}… (authored by nico, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55978?vs=179224=179400#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55978

Files:
  llvm/trunk/utils/gn/secondary/BUILD.gn
  llvm/trunk/utils/gn/secondary/clang/lib/ASTMatchers/BUILD.gn
  llvm/trunk/utils/gn/secondary/clang/lib/CrossTU/BUILD.gn
  llvm/trunk/utils/gn/secondary/clang/lib/Index/BUILD.gn
  llvm/trunk/utils/gn/secondary/clang/lib/StaticAnalyzer/Checkers/BUILD.gn
  llvm/trunk/utils/gn/secondary/clang/lib/StaticAnalyzer/Core/BUILD.gn
  llvm/trunk/utils/gn/secondary/clang/lib/StaticAnalyzer/Frontend/BUILD.gn

Index: llvm/trunk/utils/gn/secondary/clang/lib/StaticAnalyzer/Frontend/BUILD.gn
===
--- llvm/trunk/utils/gn/secondary/clang/lib/StaticAnalyzer/Frontend/BUILD.gn
+++ llvm/trunk/utils/gn/secondary/clang/lib/StaticAnalyzer/Frontend/BUILD.gn
@@ -0,0 +1,23 @@
+static_library("Frontend") {
+  output_name = "clangStaticAnalyzerFrontend"
+  configs += [ "//llvm/utils/gn/build:clang_code" ]
+  deps = [
+"//clang/lib/AST",
+"//clang/lib/Analysis",
+"//clang/lib/Basic",
+"//clang/lib/CrossTU",
+"//clang/lib/Frontend",
+"//clang/lib/Lex",
+"//clang/lib/StaticAnalyzer/Checkers",
+"//clang/lib/StaticAnalyzer/Core",
+"//llvm/lib/Support",
+  ]
+  sources = [
+"AnalysisConsumer.cpp",
+"CheckerRegistration.cpp",
+"CheckerRegistry.cpp",
+"FrontendActions.cpp",
+"ModelConsumer.cpp",
+"ModelInjector.cpp",
+  ]
+}
Index: llvm/trunk/utils/gn/secondary/clang/lib/StaticAnalyzer/Core/BUILD.gn
===
--- llvm/trunk/utils/gn/secondary/clang/lib/StaticAnalyzer/Core/BUILD.gn
+++ llvm/trunk/utils/gn/secondary/clang/lib/StaticAnalyzer/Core/BUILD.gn
@@ -0,0 +1,67 @@
+static_library("Core") {
+  output_name = "clangStaticAnalyzerCore"
+  configs += [ "//llvm/utils/gn/build:clang_code" ]
+  deps = [
+"//clang/include/clang/Config",
+"//clang/lib/AST",
+"//clang/lib/ASTMatchers",
+"//clang/lib/Analysis",
+"//clang/lib/Basic",
+"//clang/lib/CrossTU",
+"//clang/lib/Lex",
+"//clang/lib/Rewrite",
+"//llvm/lib/Support",
+  ]
+  sources = [
+"APSIntType.cpp",
+"AnalysisManager.cpp",
+"AnalyzerOptions.cpp",
+"BasicValueFactory.cpp",
+"BlockCounter.cpp",
+"BugReporter.cpp",
+"BugReporterVisitors.cpp",
+"CallEvent.cpp",
+"Checker.cpp",
+"CheckerContext.cpp",
+"CheckerHelpers.cpp",
+"CheckerManager.cpp",
+"CommonBugCategories.cpp",
+"ConstraintManager.cpp",
+"CoreEngine.cpp",
+"DynamicTypeMap.cpp",
+"Environment.cpp",
+"ExplodedGraph.cpp",
+"ExprEngine.cpp",
+"ExprEngineC.cpp",
+"ExprEngineCXX.cpp",
+"ExprEngineCallAndReturn.cpp",
+"ExprEngineObjC.cpp",
+"FunctionSummary.cpp",
+"HTMLDiagnostics.cpp",
+"IssueHash.cpp",
+"LoopUnrolling.cpp",
+"LoopWidening.cpp",
+"MemRegion.cpp",
+"PathDiagnostic.cpp",
+"PlistDiagnostics.cpp",
+"ProgramState.cpp",
+"RangeConstraintManager.cpp",
+"RangedConstraintManager.cpp",
+"RegionStore.cpp",
+"RetainSummaryManager.cpp",
+"SValBuilder.cpp",
+"SVals.cpp",
+"SarifDiagnostics.cpp",
+"SimpleConstraintManager.cpp",
+"SimpleSValBuilder.cpp",
+"Store.cpp",
+"SubEngine.cpp",
+"SymbolManager.cpp",
+"TaintManager.cpp",
+"WorkList.cpp",
+"Z3ConstraintManager.cpp",
+  ]
+
+  # FIXME: clang/Config/BUILD.gn currently always sets CLANG_ANALYZER_WITH_Z3
+  # to false. If that changes we need to link to Z3 libs here.
+}
Index: llvm/trunk/utils/gn/secondary/clang/lib/StaticAnalyzer/Checkers/BUILD.gn
===
--- llvm/trunk/utils/gn/secondary/clang/lib/StaticAnalyzer/Checkers/BUILD.gn
+++ llvm/trunk/utils/gn/secondary/clang/lib/StaticAnalyzer/Checkers/BUILD.gn
@@ -0,0 +1,114 @@
+static_library("Checkers") {
+  output_name = "clangStaticAnalyzerCheckers"
+  configs += [ "//llvm/utils/gn/build:clang_code" ]
+  deps = [
+"//clang/include/clang/StaticAnalyzer/Checkers",
+"//clang/lib/AST",
+"//clang/lib/ASTMatchers",
+"//clang/lib/Analysis",
+"//clang/lib/Basic",
+"//clang/lib/Lex",
+"//clang/lib/StaticAnalyzer/Core",
+"//llvm/lib/Support",
+  ]
+  sources = [
+"AnalysisOrderChecker.cpp",
+"AnalyzerStatsChecker.cpp",
+"ArrayBoundChecker.cpp",
+"ArrayBoundCheckerV2.cpp",
+"BasicObjCFoundationChecks.cpp",
+"BlockInCriticalSectionChecker.cpp",
+"BoolAssignmentChecker.cpp",
+"BuiltinFunctionChecker.cpp",
+"CStringChecker.cpp",
+

[PATCH] D56012: Be more liberal about literal zeroes in abseil checks

2018-12-21 Thread Hyrum Wright via Phabricator via cfe-commits
hwright created this revision.
hwright added reviewers: aaron.ballman, JonasToth, alexfh, hokein.
hwright added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Previously, we'd only match on literal floating or integral zeroes, but I've 
now also learned that some users spell that value as `int{0}` or `float{0}`, 
which also need to be matched.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D56012

Files:
  clang-tidy/abseil/DurationFactoryScaleCheck.cpp
  clang-tidy/abseil/DurationRewriter.cpp
  test/clang-tidy/abseil-duration-factory-scale.cpp


Index: test/clang-tidy/abseil-duration-factory-scale.cpp
===
--- test/clang-tidy/abseil-duration-factory-scale.cpp
+++ test/clang-tidy/abseil-duration-factory-scale.cpp
@@ -1,5 +1,6 @@
 // RUN: %check_clang_tidy %s abseil-duration-factory-scale %t -- -- -I%S/Inputs
 
+#include 
 #include "absl/time/time.h"
 
 void ScaleTest() {
@@ -30,6 +31,15 @@
   d = absl::Seconds(0x0.01p-126f);
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for 
zero-length time intervals [abseil-duration-factory-scale]
   // CHECK-FIXES: absl::ZeroDuration();
+  d = absl::Seconds(int{0});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for 
zero-length time intervals [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::ZeroDuration();
+  d = absl::Seconds(int64_t{0});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for 
zero-length time intervals [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::ZeroDuration();
+  d = absl::Seconds(float{0});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for 
zero-length time intervals [abseil-duration-factory-scale]
+  // CHECK-FIXES: absl::ZeroDuration();
 
   // Fold seconds into minutes
   d = absl::Seconds(30 * 60);
@@ -83,6 +93,8 @@
 
   // None of these should trigger the check
   d = absl::Seconds(60);
+  d = absl::Seconds(int{60});
+  d = absl::Seconds(float{60});
   d = absl::Seconds(60 + 30);
   d = absl::Seconds(60 - 30);
   d = absl::Seconds(50 * 30);
Index: clang-tidy/abseil/DurationRewriter.cpp
===
--- clang-tidy/abseil/DurationRewriter.cpp
+++ clang-tidy/abseil/DurationRewriter.cpp
@@ -105,14 +105,37 @@
   llvm_unreachable("unknown scaling factor");
 }
 
+AST_MATCHER_P2(InitListExpr, hasInit, unsigned, N,
+   ast_matchers::internal::Matcher, InnerMatcher) {
+  return (N < Node.getNumInits() &&
+  InnerMatcher.matches(*Node.getInit(N)->IgnoreParenImpCasts(), Finder,
+   Builder));
+}
+
 /// Returns `true` if `Node` is a value which evaluates to a literal `0`.
 bool IsLiteralZero(const MatchFinder::MatchResult , const Expr ) {
-  return selectFirst(
- "val",
- match(expr(ignoringImpCasts(anyOf(integerLiteral(equals(0)),
-   floatLiteral(equals(0.0)
-   .bind("val"),
-   Node, *Result.Context)) != nullptr;
+  auto ZeroMatcher =
+  anyOf(integerLiteral(equals(0)), floatLiteral(equals(0.0)));
+
+  // Check to see if we're using a zero directly.
+  if (selectFirst(
+  "val", match(expr(ignoringImpCasts(ZeroMatcher)).bind("val"), Node,
+   *Result.Context)) != nullptr)
+return true;
+
+  // Now check to see if we're using a functional cast with a scalar
+  // initializer expression, e.g. `int{0}`.
+  if (selectFirst(
+  "val",
+  match(cxxFunctionalCastExpr(
+hasDestinationType(
+anyOf(isInteger(), realFloatingPointType())),
+hasSourceExpression(initListExpr(hasInit(0, ZeroMatcher
+.bind("val"),
+Node, *Result.Context)) != nullptr)
+return true;
+
+  return false;
 }
 
 llvm::Optional
Index: clang-tidy/abseil/DurationFactoryScaleCheck.cpp
===
--- clang-tidy/abseil/DurationFactoryScaleCheck.cpp
+++ clang-tidy/abseil/DurationFactoryScaleCheck.cpp
@@ -123,6 +123,10 @@
   hasArgument(
   0,
   ignoringImpCasts(anyOf(
+  cxxFunctionalCastExpr(
+  hasDestinationType(
+  anyOf(isInteger(), realFloatingPointType())),
+  hasSourceExpression(initListExpr())),
   integerLiteral(equals(0)), floatLiteral(equals(0.0)),
   binaryOperator(hasOperatorName("*"),
  hasEitherOperand(ignoringImpCasts(


Index: test/clang-tidy/abseil-duration-factory-scale.cpp
===
--- test/clang-tidy/abseil-duration-factory-scale.cpp
+++ test/clang-tidy/abseil-duration-factory-scale.cpp
@@ -1,5 +1,6 @@
 // RUN: 

[PATCH] D56012: [clang-tidy] Be more liberal about literal zeroes in abseil checks

2018-12-21 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: test/clang-tidy/abseil-duration-factory-scale.cpp:3
 
+#include 
 #include "absl/time/time.h"

cstdint, please.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56012



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


[PATCH] D55949: Correctly handle function pointers returning a type marked nodiscard

2018-12-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 179318.
aaron.ballman marked 3 inline comments as done.
aaron.ballman added a comment.

Updated based on review feedback.

Moved `FunctionDecl::hasUnusedResultAttr()` and 
`FunctionDecl::getUnusedResultAttr()` to `CallExpr` to reduce logic duplication 
on checking.


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

https://reviews.llvm.org/D55949

Files:
  include/clang/AST/Decl.h
  include/clang/AST/Expr.h
  lib/AST/Decl.cpp
  lib/AST/Expr.cpp
  lib/Sema/SemaStmt.cpp
  test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp

Index: test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp
===
--- test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp
+++ test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp
@@ -32,6 +32,35 @@
   // OK, warning suppressed.
   (void)fp();
 }
+
+namespace PR31526 {
+typedef E (*fp1)();
+typedef S (*fp2)();
+
+typedef S S_alias;
+typedef S_alias (*fp3)();
+
+typedef fp2 fp2_alias;
+
+void f() {
+  fp1 one;
+  fp2 two;
+  fp3 three;
+  fp2_alias four;
+
+  one(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  two(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  three(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  four(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+  // These are all okay because of the explicit cast to void.
+  (void)one();
+  (void)two();
+  (void)three();
+  (void)four();
+}
+} // namespace PR31526
+
 #ifdef EXT
 // expected-warning@4 {{use of the 'nodiscard' attribute is a C++17 extension}}
 // expected-warning@8 {{use of the 'nodiscard' attribute is a C++17 extension}}
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -259,17 +259,16 @@
 if (E->getType()->isVoidType())
   return;
 
+if (const Attr *A = CE->getUnusedResultAttr(Context)) {
+  Diag(Loc, diag::warn_unused_result) << A << R1 << R2;
+  return;
+}
+
 // If the callee has attribute pure, const, or warn_unused_result, warn with
 // a more specific message to make it clear what is happening. If the call
 // is written in a macro body, only warn if it has the warn_unused_result
 // attribute.
 if (const Decl *FD = CE->getCalleeDecl()) {
-  if (const Attr *A = isa(FD)
-  ? cast(FD)->getUnusedResultAttr()
-  : FD->getAttr()) {
-Diag(Loc, diag::warn_unused_result) << A << R1 << R2;
-return;
-  }
   if (ShouldSuppress)
 return;
   if (FD->hasAttr()) {
Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -1363,6 +1363,19 @@
   return FnType->getReturnType();
 }
 
+const Attr *CallExpr::getUnusedResultAttr(const ASTContext ) const {
+  // If the return type is a struct, union, or enum that is marked nodiscard,
+  // then return the return type attribute.
+  if (const TagDecl *TD = getCallReturnType(Ctx)->getAsTagDecl())
+if (const auto *A = TD->getAttr())
+  return A;
+
+  // Otherwise, see if the callee is marked nodiscard and return that attribute
+  // instead.
+  const Decl *D = getCalleeDecl();
+  return D ? D->getAttr() : nullptr;
+}
+
 SourceLocation CallExpr::getBeginLoc() const {
   if (isa(this))
 return cast(this)->getBeginLoc();
@@ -2274,16 +2287,12 @@
 // If this is a direct call, get the callee.
 const CallExpr *CE = cast(this);
 if (const Decl *FD = CE->getCalleeDecl()) {
-  const FunctionDecl *Func = dyn_cast(FD);
-  bool HasWarnUnusedResultAttr = Func ? Func->hasUnusedResultAttr()
-  : FD->hasAttr();
-
   // If the callee has attribute pure, const, or warn_unused_result, warn
   // about it. void foo() { strlen("bar"); } should warn.
   //
   // Note: If new cases are added here, DiagnoseUnusedExprResult should be
   // updated to match for QoI.
-  if (HasWarnUnusedResultAttr ||
+  if (CE->hasUnusedResultAttr(Ctx) ||
   FD->hasAttr() || FD->hasAttr()) {
 WarnE = this;
 Loc = CE->getCallee()->getBeginLoc();
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -3231,20 +3231,6 @@
   return FTL.getExceptionSpecRange();
 }
 
-const Attr *FunctionDecl::getUnusedResultAttr() const {
-  QualType RetType = getReturnType();
-  if (const auto *Ret = RetType->getAsRecordDecl()) {
-if (const auto *R = Ret->getAttr())
-  return R;
-  } else if (const auto *ET = RetType->getAs()) {
-if (const EnumDecl *ED = ET->getDecl()) {
-  if (const auto *R = 

[PATCH] D55955: Properly diagnose [[nodiscard]] on the body of a range-based for loop

2018-12-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked 3 inline comments as done.
aaron.ballman added inline comments.



Comment at: lib/Sema/SemaStmt.cpp:2846
 diag::warn_empty_range_based_for_body);
+  DiagnoseUnusedExprResult(B);
 

rsmith wrote:
> rsmith wrote:
> > While this looks correct per the current approach to this function, we 
> > really shouldn't be duplicating calls to this everywhere. Can we move all 
> > the calls to a single call in `ActOnFinishFullStmt`?
> Looks like that's not actually called from almost anywhere, but checking from 
> `ActOnFinishFullExpr` in the case where `DiscardedValue` is `true` seems 
> appropriate.
That seems sensible, but how will that work with GNU statement expressions? If 
we check for unused expression results, then we will trigger on code like this:
```
int a = ({blah(); yada(); 0;});
// or
int b = ({blah(); yada(); some_no_discard_call();});
```
I don't know of a way to handle that case -- we call `ActOnFinishFullExpr()` 
while parsing the compound statement for the `StmtExpr`, so there's no way to 
know whether there's another statement coming (without lookahead) to determine 
whether to suppress the diagnostic for the last expression statement. Do you 
have ideas on how to handle that?


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

https://reviews.llvm.org/D55955



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


[PATCH] D55878: [Driver] Use --hash-style=gnu instead of both on FreeBSD

2018-12-21 Thread Ed Maste via Phabricator via cfe-commits
emaste added a comment.

I think the arch-change (switching from a whitelist to a MIPS blacklist) is 
reasonable. What is the motivation for dropping `DT_HASH`, just binary size 
reduction?


Repository:
  rC Clang

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

https://reviews.llvm.org/D55878



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


r349910 - [AST] Store the callee and argument expressions of CallExpr in a trailing array.

2018-12-21 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Fri Dec 21 07:20:32 2018
New Revision: 349910

URL: http://llvm.org/viewvc/llvm-project?rev=349910=rev
Log:
[AST] Store the callee and argument expressions of CallExpr in a trailing array.

Since CallExpr::setNumArgs has been removed, it is now possible to store the
callee expression and the argument expressions of CallExpr in a trailing array.
This saves one pointer per CallExpr, CXXOperatorCallExpr, CXXMemberCallExpr,
CUDAKernelCallExpr and UserDefinedLiteral.

Given that CallExpr is used as a base of the above classes we cannot use
llvm::TrailingObjects. Instead we store the offset in bytes from the this 
pointer
to the start of the trailing objects and manually do the casts + arithmetic.

Some notes:

1.) I did not try to fit the number of arguments in the bit-fields of Stmt.
This leaves some space for future additions and avoid the discussion about
whether x bits are sufficient to hold the number of arguments.

2.) It would be perfectly possible to recompute the offset to the trailing
objects before accessing the trailing objects. However the trailing objects
are frequently accessed and benchmarks show that it is slightly faster to
just load the offset from the bit-fields. Additionally, because of 1),
we have plenty of space in the bit-fields of Stmt.

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

Reviewed By: rjmccall


Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/Analysis/BodyFarm.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=349910=349909=349910=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Fri Dec 21 07:20:32 2018
@@ -2395,59 +2395,126 @@ public:
 /// a subclass for overloaded operator calls that use operator syntax, e.g.,
 /// "str1 + str2" to resolve to a function call.
 class CallExpr : public Expr {
-  enum { FN=0, PREARGS_START=1 };
-  Stmt **SubExprs;
+  enum { FN = 0, PREARGS_START = 1 };
+
+  /// The number of arguments in the call expression.
   unsigned NumArgs;
+
+  /// The location of the right parenthese. This has a different meaning for
+  /// the derived classes of CallExpr.
   SourceLocation RParenLoc;
 
   void updateDependenciesFromArg(Expr *Arg);
 
+  // CallExpr store some data in trailing objects. However since CallExpr
+  // is used a base of other expression classes we cannot use
+  // llvm::TrailingObjects. Instead we manually perform the pointer arithmetic
+  // and casts.
+  //
+  // The trailing objects are in order:
+  //
+  // * A single "Stmt *" for the callee expression.
+  //
+  // * An array of getNumPreArgs() "Stmt *" for the pre-argument expressions.
+  //
+  // * An array of getNumArgs() "Stmt *" for the argument expressions.
+  //
+  // Note that we store the offset in bytes from the this pointer to the start
+  // of the trailing objects. It would be perfectly possible to compute it
+  // based on the dynamic kind of the CallExpr. However 1.) we have plenty of
+  // space in the bit-fields of Stmt. 2.) It was benchmarked to be faster to
+  // compute this once and then load the offset from the bit-fields of Stmt,
+  // instead of re-computing the offset each time the trailing objects are
+  // accessed.
+
+  /// Return a pointer to the start of the trailing array of "Stmt *".
+  Stmt **getTrailingStmts() {
+return reinterpret_cast(reinterpret_cast(this) +
+ CallExprBits.OffsetToTrailingObjects);
+  }
+  Stmt *const *getTrailingStmts() const {
+return const_cast(this)->getTrailingStmts();
+  }
+
+  /// Map a statement class to the appropriate offset in bytes from the
+  /// this pointer to the trailing objects.
+  static unsigned offsetToTrailingObjects(StmtClass SC);
+
 public:
   enum class ADLCallKind : bool { NotADL, UsesADL };
   static constexpr ADLCallKind NotADL = ADLCallKind::NotADL;
   static constexpr ADLCallKind UsesADL = ADLCallKind::UsesADL;
 
 protected:
-  // These versions of the constructor are for derived classes.
-  CallExpr(const ASTContext , StmtClass SC, Expr *fn,
-   ArrayRef preargs, ArrayRef args, QualType t,
-   ExprValueKind VK, SourceLocation rparenloc, unsigned MinNumArgs = 0,
-   ADLCallKind UsesADL = NotADL);
-  

[PATCH] D56000: [compiler-rt] [xray] Disable alignas() for thread_local objects on NetBSD

2018-12-21 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added inline comments.



Comment at: lib/xray/xray_basic_logging.cc:58
 
-struct alignas(64) ThreadLocalData {
+struct
+/* TLD is not aligned properly on NetBSD, resulting in segfault */

Can we introduce a macro like:

```
#if SANITIZER_NETBSD
#define XRAY_TLS_ALIGNAS64 /* Nor supported */
#else
#define XRAY_TLS_ALIGNED_SUPPORTED
#define XRAY_TLS_ALIGNAS64 alignas(64)
#endif
```

And later:

```
struct XRAY_TLS_ALIGNAS64 ThreadLocalData {
```

and

```
#ifdef XRAY_TLS_ALIGNED_SUPPORTED
static_assert(alignof(ThreadLocalData) >= 64,
  "ThreadLocalData must be cache line aligned.");
#endif
```


Repository:
  rCRT Compiler Runtime

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

https://reviews.llvm.org/D56000



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


[PATCH] D56006: [AST] Fix a -Wimplicit-fallthrough warning in ScanfFormatString.cpp

2018-12-21 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno created this revision.
riccibruno added a reviewer: hans.
riccibruno added a project: clang.
Herald added a subscriber: cfe-commits.

This is showing up with some bots
(eg 
http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/19061/steps/build%20stage%201/logs/warnings%20%284%29)

I am putting this for review since I am not familiar with this code and am not
sure whether adding `llvm_unreachable` is better than adding a default case
covering the invalid cases, as is done a few lines below.


Repository:
  rC Clang

https://reviews.llvm.org/D56006

Files:
  lib/AST/ScanfFormatString.cpp


Index: lib/AST/ScanfFormatString.cpp
===
--- lib/AST/ScanfFormatString.cpp
+++ lib/AST/ScanfFormatString.cpp
@@ -264,6 +264,7 @@
 case LengthModifier::AsWide:
   return ArgType::Invalid();
   }
+  llvm_unreachable("Unexpected length modifier!");
 
 // Unsigned int.
 case ConversionSpecifier::oArg:
@@ -303,6 +304,7 @@
 case LengthModifier::AsWide:
   return ArgType::Invalid();
   }
+  llvm_unreachable("Unexpected length modifier!");
 
 // Float.
 case ConversionSpecifier::aArg:


Index: lib/AST/ScanfFormatString.cpp
===
--- lib/AST/ScanfFormatString.cpp
+++ lib/AST/ScanfFormatString.cpp
@@ -264,6 +264,7 @@
 case LengthModifier::AsWide:
   return ArgType::Invalid();
   }
+  llvm_unreachable("Unexpected length modifier!");
 
 // Unsigned int.
 case ConversionSpecifier::oArg:
@@ -303,6 +304,7 @@
 case LengthModifier::AsWide:
   return ArgType::Invalid();
   }
+  llvm_unreachable("Unexpected length modifier!");
 
 // Float.
 case ConversionSpecifier::aArg:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2018-12-21 Thread vit9696 via Phabricator via cfe-commits
vit9696 added a comment.

Ok, I found the fix for the first crash that landed in 8.0 trunk. It works fine 
for me if backported to 7.0.1:
https://reviews.llvm.org/D50461


Repository:
  rC Clang

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

https://reviews.llvm.org/D49754



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


[PATCH] D56000: [compiler-rt] [xray] Disable alignas() for thread_local objects on NetBSD

2018-12-21 Thread Michał Górny via Phabricator via cfe-commits
mgorny marked an inline comment as done.
mgorny added inline comments.



Comment at: lib/xray/xray_basic_logging.cc:58
 
-struct alignas(64) ThreadLocalData {
+struct
+/* TLD is not aligned properly on NetBSD, resulting in segfault */

krytarowski wrote:
> Can we introduce a macro like:
> 
> ```
> #if SANITIZER_NETBSD
> #define XRAY_TLS_ALIGNAS64 /* Nor supported */
> #else
> #define XRAY_TLS_ALIGNED_SUPPORTED
> #define XRAY_TLS_ALIGNAS64 alignas(64)
> #endif
> ```
> 
> And later:
> 
> ```
> struct XRAY_TLS_ALIGNAS64 ThreadLocalData {
> ```
> 
> and
> 
> ```
> #ifdef XRAY_TLS_ALIGNED_SUPPORTED
> static_assert(alignof(ThreadLocalData) >= 64,
>   "ThreadLocalData must be cache line aligned.");
> #endif
> ```
Maybe. Though i suppose it'd make more sense to make `64` an argument to the 
macro.


Repository:
  rCRT Compiler Runtime

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

https://reviews.llvm.org/D56000



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


[PATCH] D56000: [compiler-rt] [xray] Disable alignas() for thread_local objects on NetBSD

2018-12-21 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added inline comments.



Comment at: lib/xray/xray_basic_logging.cc:58
 
-struct alignas(64) ThreadLocalData {
+struct
+/* TLD is not aligned properly on NetBSD, resulting in segfault */

krytarowski wrote:
> mgorny wrote:
> > krytarowski wrote:
> > > Can we introduce a macro like:
> > > 
> > > ```
> > > #if SANITIZER_NETBSD
> > > #define XRAY_TLS_ALIGNAS64 /* Nor supported */
> > > #else
> > > #define XRAY_TLS_ALIGNED_SUPPORTED
> > > #define XRAY_TLS_ALIGNAS64 alignas(64)
> > > #endif
> > > ```
> > > 
> > > And later:
> > > 
> > > ```
> > > struct XRAY_TLS_ALIGNAS64 ThreadLocalData {
> > > ```
> > > 
> > > and
> > > 
> > > ```
> > > #ifdef XRAY_TLS_ALIGNED_SUPPORTED
> > > static_assert(alignof(ThreadLocalData) >= 64,
> > >   "ThreadLocalData must be cache line aligned.");
> > > #endif
> > > ```
> > Maybe. Though i suppose it'd make more sense to make `64` an argument to 
> > the macro.
> ```
> #if !SANITIZER_NETBSD
> #define XRAY_TLS_ALIGNAS(x) alignas(x)
> #endif
> ```
> 
> ```
> struct XRAY_TLS_ALIGNAS(64) ThreadLocalData {
> ```
> 
> and
> 
> ```
> #ifdef XRAY_TLS_ALIGNAS
> static_assert(alignof(ThreadLocalData) >= 64,
>   "ThreadLocalData must be cache line aligned.");
> #endif
> ```
Oops, actually not fully correct, but some variation of the above.


Repository:
  rCRT Compiler Runtime

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

https://reviews.llvm.org/D56000



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


[PATCH] D55771: [AST] Store the callee and argument expressions of CallExpr in a trailing array.

2018-12-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349910: [AST] Store the callee and argument expressions of 
CallExpr in a trailing array. (authored by brunoricci, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55771?vs=178641=179286#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55771

Files:
  cfe/trunk/include/clang/AST/Expr.h
  cfe/trunk/include/clang/AST/ExprCXX.h
  cfe/trunk/include/clang/AST/Stmt.h
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/lib/AST/Expr.cpp
  cfe/trunk/lib/AST/ExprCXX.cpp
  cfe/trunk/lib/Analysis/BodyFarm.cpp
  cfe/trunk/lib/CodeGen/CGObjC.cpp
  cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/lib/Sema/TreeTransform.h
  cfe/trunk/lib/Serialization/ASTReaderStmt.cpp

Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -6990,9 +6990,8 @@
   if (Error Err = ImportContainerChecked(E->arguments(), ToArgs))
 return std::move(Err);
 
-  return new (Importer.getToContext()) CXXMemberCallExpr(
-  Importer.getToContext(), ToCallee, ToArgs, ToType, E->getValueKind(),
-  ToRParenLoc);
+  return CXXMemberCallExpr::Create(Importer.getToContext(), ToCallee, ToArgs,
+   ToType, E->getValueKind(), ToRParenLoc);
 }
 
 ExpectedStmt ASTNodeImporter::VisitCXXThisExpr(CXXThisExpr *E) {
@@ -7317,15 +7316,15 @@
  return std::move(Err);
 
   if (const auto *OCE = dyn_cast(E)) {
-return new (Importer.getToContext()) CXXOperatorCallExpr(
+return CXXOperatorCallExpr::Create(
 Importer.getToContext(), OCE->getOperator(), ToCallee, ToArgs, ToType,
 OCE->getValueKind(), ToRParenLoc, OCE->getFPFeatures(),
 OCE->getADLCallKind());
   }
 
-  return new (Importer.getToContext()) CallExpr(
-  Importer.getToContext(), ToCallee, ToArgs, ToType, E->getValueKind(),
-  ToRParenLoc, /*MinNumArgs=*/0, E->getADLCallKind());
+  return CallExpr::Create(Importer.getToContext(), ToCallee, ToArgs, ToType,
+  E->getValueKind(), ToRParenLoc, /*MinNumArgs=*/0,
+  E->getADLCallKind());
 }
 
 ExpectedStmt ASTNodeImporter::VisitLambdaExpr(LambdaExpr *E) {
Index: cfe/trunk/lib/AST/ExprCXX.cpp
===
--- cfe/trunk/lib/AST/ExprCXX.cpp
+++ cfe/trunk/lib/AST/ExprCXX.cpp
@@ -478,6 +478,46 @@
   return End;
 }
 
+CXXOperatorCallExpr::CXXOperatorCallExpr(OverloadedOperatorKind OpKind,
+ Expr *Fn, ArrayRef Args,
+ QualType Ty, ExprValueKind VK,
+ SourceLocation OperatorLoc,
+ FPOptions FPFeatures,
+ ADLCallKind UsesADL)
+: CallExpr(CXXOperatorCallExprClass, Fn, /*PreArgs=*/{}, Args, Ty, VK,
+   OperatorLoc, /*MinNumArgs=*/0, UsesADL),
+  Operator(OpKind), FPFeatures(FPFeatures) {
+  Range = getSourceRangeImpl();
+}
+
+CXXOperatorCallExpr::CXXOperatorCallExpr(unsigned NumArgs, EmptyShell Empty)
+: CallExpr(CXXOperatorCallExprClass, /*NumPreArgs=*/0, NumArgs, Empty) {}
+
+CXXOperatorCallExpr *CXXOperatorCallExpr::Create(
+const ASTContext , OverloadedOperatorKind OpKind, Expr *Fn,
+ArrayRef Args, QualType Ty, ExprValueKind VK,
+SourceLocation OperatorLoc, FPOptions FPFeatures, ADLCallKind UsesADL) {
+  // Allocate storage for the trailing objects of CallExpr.
+  unsigned NumArgs = Args.size();
+  unsigned SizeOfTrailingObjects =
+  CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/0, NumArgs);
+  void *Mem = Ctx.Allocate(sizeof(CXXOperatorCallExpr) + SizeOfTrailingObjects,
+   alignof(CXXOperatorCallExpr));
+  return new (Mem) CXXOperatorCallExpr(OpKind, Fn, Args, Ty, VK, OperatorLoc,
+   FPFeatures, UsesADL);
+}
+
+CXXOperatorCallExpr *CXXOperatorCallExpr::CreateEmpty(const ASTContext ,
+  unsigned NumArgs,
+  EmptyShell Empty) {
+  // Allocate storage for the trailing objects of CallExpr.
+  unsigned SizeOfTrailingObjects =
+  CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/0, NumArgs);
+  void *Mem = Ctx.Allocate(sizeof(CXXOperatorCallExpr) + SizeOfTrailingObjects,
+   alignof(CXXOperatorCallExpr));
+  return new (Mem) CXXOperatorCallExpr(NumArgs, Empty);
+}
+
 SourceRange 

[PATCH] D56000: [compiler-rt] [xray] Disable alignas() for thread_local objects on NetBSD

2018-12-21 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added inline comments.



Comment at: lib/xray/xray_basic_logging.cc:58
 
-struct alignas(64) ThreadLocalData {
+struct
+/* TLD is not aligned properly on NetBSD, resulting in segfault */

mgorny wrote:
> krytarowski wrote:
> > Can we introduce a macro like:
> > 
> > ```
> > #if SANITIZER_NETBSD
> > #define XRAY_TLS_ALIGNAS64 /* Nor supported */
> > #else
> > #define XRAY_TLS_ALIGNED_SUPPORTED
> > #define XRAY_TLS_ALIGNAS64 alignas(64)
> > #endif
> > ```
> > 
> > And later:
> > 
> > ```
> > struct XRAY_TLS_ALIGNAS64 ThreadLocalData {
> > ```
> > 
> > and
> > 
> > ```
> > #ifdef XRAY_TLS_ALIGNED_SUPPORTED
> > static_assert(alignof(ThreadLocalData) >= 64,
> >   "ThreadLocalData must be cache line aligned.");
> > #endif
> > ```
> Maybe. Though i suppose it'd make more sense to make `64` an argument to the 
> macro.
```
#if !SANITIZER_NETBSD
#define XRAY_TLS_ALIGNAS(x) alignas(x)
#endif
```

```
struct XRAY_TLS_ALIGNAS(64) ThreadLocalData {
```

and

```
#ifdef XRAY_TLS_ALIGNAS
static_assert(alignof(ThreadLocalData) >= 64,
  "ThreadLocalData must be cache line aligned.");
#endif
```


Repository:
  rCRT Compiler Runtime

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

https://reviews.llvm.org/D56000



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


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

2018-12-21 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz added a comment.

In D49754#1339161 , @vit9696 wrote:

> Ok, I found the fix for the first crash that landed in 8.0 trunk. It works 
> fine for me if backported to 7.0.1:
>  https://reviews.llvm.org/D50461


That's awesome, thanks so much for fixing that issue!


Repository:
  rC Clang

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

https://reviews.llvm.org/D49754



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


[PATCH] D56000: [compiler-rt] [xray] Disable alignas() for thread_local objects on NetBSD

2018-12-21 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 179297.

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

https://reviews.llvm.org/D56000

Files:
  lib/xray/xray_basic_logging.cc
  lib/xray/xray_defs.h
  lib/xray/xray_fdr_logging.cc


Index: lib/xray/xray_fdr_logging.cc
===
--- lib/xray/xray_fdr_logging.cc
+++ lib/xray/xray_fdr_logging.cc
@@ -51,7 +51,7 @@
 // call so that it can be initialized on first use instead of as a global. We
 // force the alignment to 64-bytes for x86 cache line alignment, as this
 // structure is used in the hot path of implementation.
-struct alignas(64) ThreadLocalData {
+struct XRAY_TLS_ALIGNAS(64) ThreadLocalData {
   BufferQueue::Buffer Buffer{};
   BufferQueue *BQ = nullptr;
 
@@ -124,8 +124,10 @@
 // critical section, calling a function that might be XRay instrumented (and
 // thus in turn calling into malloc by virtue of registration of the
 // thread_local's destructor).
+#if XRAY_HAS_TLS_ALIGNAS
 static_assert(alignof(ThreadLocalData) >= 64,
   "ThreadLocalData must be cache line aligned.");
+#endif
 static ThreadLocalData () {
   thread_local typename std::aligned_storage<
   sizeof(ThreadLocalData), alignof(ThreadLocalData)>::type TLDStorage{};
Index: lib/xray/xray_defs.h
===
--- lib/xray/xray_defs.h
+++ lib/xray/xray_defs.h
@@ -19,4 +19,14 @@
 #define XRAY_NEVER_INSTRUMENT
 #endif
 
+#if !SANITIZER_NETBSD
+#define XRAY_TLS_ALIGNAS(x) alignas(x)
+#define XRAY_HAS_TLS_ALIGNAS 1
+#else
+// NetBSD: thread_local is not aligned properly, and the code relying
+// on it segfaults
+#define XRAY_TLS_ALIGNAS(x)
+#define XRAY_HAS_TLS_ALIGNAS 0
+#endif
+
 #endif  // XRAY_XRAY_DEFS_H
Index: lib/xray/xray_basic_logging.cc
===
--- lib/xray/xray_basic_logging.cc
+++ lib/xray/xray_basic_logging.cc
@@ -55,7 +55,7 @@
 
 static_assert(sizeof(StackEntry) == 16, "Wrong size for StackEntry");
 
-struct alignas(64) ThreadLocalData {
+struct XRAY_TLS_ALIGNAS(64) ThreadLocalData {
   void *InMemoryBuffer = nullptr;
   size_t BufferSize = 0;
   size_t BufferOffset = 0;


Index: lib/xray/xray_fdr_logging.cc
===
--- lib/xray/xray_fdr_logging.cc
+++ lib/xray/xray_fdr_logging.cc
@@ -51,7 +51,7 @@
 // call so that it can be initialized on first use instead of as a global. We
 // force the alignment to 64-bytes for x86 cache line alignment, as this
 // structure is used in the hot path of implementation.
-struct alignas(64) ThreadLocalData {
+struct XRAY_TLS_ALIGNAS(64) ThreadLocalData {
   BufferQueue::Buffer Buffer{};
   BufferQueue *BQ = nullptr;
 
@@ -124,8 +124,10 @@
 // critical section, calling a function that might be XRay instrumented (and
 // thus in turn calling into malloc by virtue of registration of the
 // thread_local's destructor).
+#if XRAY_HAS_TLS_ALIGNAS
 static_assert(alignof(ThreadLocalData) >= 64,
   "ThreadLocalData must be cache line aligned.");
+#endif
 static ThreadLocalData () {
   thread_local typename std::aligned_storage<
   sizeof(ThreadLocalData), alignof(ThreadLocalData)>::type TLDStorage{};
Index: lib/xray/xray_defs.h
===
--- lib/xray/xray_defs.h
+++ lib/xray/xray_defs.h
@@ -19,4 +19,14 @@
 #define XRAY_NEVER_INSTRUMENT
 #endif
 
+#if !SANITIZER_NETBSD
+#define XRAY_TLS_ALIGNAS(x) alignas(x)
+#define XRAY_HAS_TLS_ALIGNAS 1
+#else
+// NetBSD: thread_local is not aligned properly, and the code relying
+// on it segfaults
+#define XRAY_TLS_ALIGNAS(x)
+#define XRAY_HAS_TLS_ALIGNAS 0
+#endif
+
 #endif  // XRAY_XRAY_DEFS_H
Index: lib/xray/xray_basic_logging.cc
===
--- lib/xray/xray_basic_logging.cc
+++ lib/xray/xray_basic_logging.cc
@@ -55,7 +55,7 @@
 
 static_assert(sizeof(StackEntry) == 16, "Wrong size for StackEntry");
 
-struct alignas(64) ThreadLocalData {
+struct XRAY_TLS_ALIGNAS(64) ThreadLocalData {
   void *InMemoryBuffer = nullptr;
   size_t BufferSize = 0;
   size_t BufferOffset = 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56000: [compiler-rt] [xray] Disable alignas() for thread_local objects on NetBSD

2018-12-21 Thread Michał Górny via Phabricator via cfe-commits
mgorny marked 3 inline comments as done.
mgorny added a comment.

Updated as requested.


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

https://reviews.llvm.org/D56000



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


[clang-tools-extra] r349930 - [clang-tidy] Add export-fixes flag to clang-tidy-diff

2018-12-21 Thread Julie Hockett via cfe-commits
Author: juliehockett
Date: Fri Dec 21 09:25:27 2018
New Revision: 349930

URL: http://llvm.org/viewvc/llvm-project?rev=349930=rev
Log:
[clang-tidy] Add export-fixes flag to clang-tidy-diff

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

Modified:
clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py

Modified: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py?rev=349930=349929=349930=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py Fri Dec 21 
09:25:27 2018
@@ -57,6 +57,9 @@ def main():
   default='')
   parser.add_argument('-path', dest='build_path',
   help='Path used to read a compile command database.')
+  parser.add_argument('-export-fixes', metavar='FILE', dest='export_fixes',
+  help='Create a yaml file to store suggested fixes in, '
+  'which can be applied with clang-apply-replacements.')
   parser.add_argument('-extra-arg', dest='extra_arg',
   action='append', default=[],
   help='Additional argument to append to the compiler '
@@ -122,6 +125,8 @@ def main():
   command.append('-line-filter=' + quote + line_filter_json + quote)
   if args.fix:
 command.append('-fix')
+  if args.export_fixes:
+command.append('-export-fixes=' + args.export_fixes)
   if args.checks != '':
 command.append('-checks=' + quote + args.checks + quote)
   if args.quiet:


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


[PATCH] D55848: [clang-tidy] Add export-fixes flag to clang-tidy-diff

2018-12-21 Thread Julie Hockett via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349930: [clang-tidy] Add export-fixes flag to 
clang-tidy-diff (authored by juliehockett, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55848?vs=178757=179301#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55848

Files:
  clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py


Index: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
===
--- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
+++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
@@ -57,6 +57,9 @@
   default='')
   parser.add_argument('-path', dest='build_path',
   help='Path used to read a compile command database.')
+  parser.add_argument('-export-fixes', metavar='FILE', dest='export_fixes',
+  help='Create a yaml file to store suggested fixes in, '
+  'which can be applied with clang-apply-replacements.')
   parser.add_argument('-extra-arg', dest='extra_arg',
   action='append', default=[],
   help='Additional argument to append to the compiler '
@@ -122,6 +125,8 @@
   command.append('-line-filter=' + quote + line_filter_json + quote)
   if args.fix:
 command.append('-fix')
+  if args.export_fixes:
+command.append('-export-fixes=' + args.export_fixes)
   if args.checks != '':
 command.append('-checks=' + quote + args.checks + quote)
   if args.quiet:


Index: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
===
--- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
+++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
@@ -57,6 +57,9 @@
   default='')
   parser.add_argument('-path', dest='build_path',
   help='Path used to read a compile command database.')
+  parser.add_argument('-export-fixes', metavar='FILE', dest='export_fixes',
+  help='Create a yaml file to store suggested fixes in, '
+  'which can be applied with clang-apply-replacements.')
   parser.add_argument('-extra-arg', dest='extra_arg',
   action='append', default=[],
   help='Additional argument to append to the compiler '
@@ -122,6 +125,8 @@
   command.append('-line-filter=' + quote + line_filter_json + quote)
   if args.fix:
 command.append('-fix')
+  if args.export_fixes:
+command.append('-export-fixes=' + args.export_fixes)
   if args.checks != '':
 command.append('-checks=' + quote + args.checks + quote)
   if args.quiet:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55792: Allow direct navigation to static analysis checker documentation through SARIF exports

2018-12-21 Thread Phil Camp via Phabricator via cfe-commits
FlameTop added a comment.

I'm afraid we are seeing a build failure here on our local Windows checking 
MSVC build. Unfortunately I cannot find a public buildbot that uses the exact 
configuration that causes the assertion. The assertion we are seeing is

Assertion failed: isa(Val) && "cast() argument of incompatible type!", 
file F:\merge3\o\llvm\include\llvm/Support/Casting.h, line 255

It would appear it will not allow a cast from 'Init' to 'BitInit'. There is a 
very similar routine in the file X86EX2VEXTTablesEmitter.cpp as follows

static inline uint64_t getValueFromBitsInit(const BitsInit *B) {
uint64_t Value = 0;
for (unsigned i = 0, e = B->getNumBits(); i != e; ++i) {

  if (BitInit *Bit = dyn_cast(B->getBit(i)))
Value |= uint64_t(Bit->getValue()) << i;
  else
PrintFatalError("Invalid VectSize bit");

}
return Value;
}

Which appears to serve the same purpose but uses a dynamic cast. If I replace 
your routine with this technique our build succeeds.

regards

Phil Camp, SIE


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

https://reviews.llvm.org/D55792



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


r349933 - [Sema][NFC] Fix Wimplicit-fallthrough warning in getCursorKindForDecl

2018-12-21 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Fri Dec 21 09:52:13 2018
New Revision: 349933

URL: http://llvm.org/viewvc/llvm-project?rev=349933=rev
Log:
[Sema][NFC] Fix Wimplicit-fallthrough warning in getCursorKindForDecl

All cases are covered so add an llvm_unreachable. NFC.


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

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=349933=349932=349933=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Fri Dec 21 09:52:13 2018
@@ -3447,6 +3447,7 @@ CXCursorKind clang::getCursorKindForDecl
 case ObjCPropertyImplDecl::Synthesize:
   return CXCursor_ObjCSynthesizeDecl;
 }
+llvm_unreachable("Unexpected Kind!");
 
   case Decl::Import:
 return CXCursor_ModuleImportDecl;


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


  1   2   >