[PATCH] D25475: [analyzer] Add a new SVal to support pointer-to-member operations.

2016-10-18 Thread Devin Coughlin via cfe-commits
dcoughlin added inline comments.



Comment at: lib/StaticAnalyzer/Core/ExprEngineC.cpp:462
+  case CK_ReinterpretMemberPointer: {
+const Expr *UOExpr = CastE->getSubExpr()->IgnoreParenCasts();
+assert(isa(UOExpr) &&

dcoughlin wrote:
> dcoughlin wrote:
> > I don't think pattern matching on the sub expression to find the 
> > referred-to declaration is the right thing to do here. It isn't always the 
> > case that the casted expression will be a unary pointer to member 
> > operation. For example, this is perfectly fine and triggers an assertion 
> > failure on your patch:
> > 
> > ```
> > struct B {
> >   int f;
> > };
> > 
> > struct D : public B {
> >   int g;
> > };
> > 
> > void foo() {
> >   D d;
> >   d.f = 7;
> > 
> >   int B::* pfb = &B::f;
> >   int D::* pfd = pfb;
> >   int v = d.*pfd;
> > }
> > ```
> > Note that you can't just propagate the value already computed for the 
> > subexpression. Here is a particularly annoying example from the C++ spec:
> > 
> > ```
> > struct B {
> >   int f;
> > };
> > struct L : public B { };
> > struct R : public B { };
> > struct D : public L, R { };
> > 
> > void foo() {
> >   D d;
> > 
> >   int B::* pb = &B::f;
> >   int L::* pl = pb;
> >   int R::* pr = pb;
> > 
> >   int D::* pdl = pl;
> >   int D::* pdr = pr;
> > 
> >   clang_analyzer_eval(pdl == pdr); // FALSE
> >   clang_analyzer_eval(pb == pl); // TRUE
> > }
> > ```
> > My guess is this will require accumulating CXXBasePath s or something 
> > similar for each cast. I don't know how to do this efficiently. 
> > I don't know how to do this efficiently.
> 
> Jordan suggested storing this in a bump-pointer allocated object with a 
> lifetime of the AnalysisDeclContext. The common case is no multiple 
> inheritance, so that should be the fast case.
> 
> Maybe the Data could be a pointer union between a DeclaratorDecl and an 
> immutable linked list (with sharing) of CXXBaseSpecifiers from the CastExprs 
> in the AST. The storage for this could be managed with a new manager in 
> SValBuilder.
(The bump pointer-allocated thing would have to have the Decl as well.)

This could also probably live in BasicValueFactory. The extra data would be 
similar to LazyCompoundValData.


https://reviews.llvm.org/D25475



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


[PATCH] D25475: [analyzer] Add a new SVal to support pointer-to-member operations.

2016-10-18 Thread Devin Coughlin via cfe-commits
dcoughlin added inline comments.



Comment at: lib/StaticAnalyzer/Core/ExprEngineC.cpp:462
+  case CK_ReinterpretMemberPointer: {
+const Expr *UOExpr = CastE->getSubExpr()->IgnoreParenCasts();
+assert(isa(UOExpr) &&

dcoughlin wrote:
> I don't think pattern matching on the sub expression to find the referred-to 
> declaration is the right thing to do here. It isn't always the case that the 
> casted expression will be a unary pointer to member operation. For example, 
> this is perfectly fine and triggers an assertion failure on your patch:
> 
> ```
> struct B {
>   int f;
> };
> 
> struct D : public B {
>   int g;
> };
> 
> void foo() {
>   D d;
>   d.f = 7;
> 
>   int B::* pfb = &B::f;
>   int D::* pfd = pfb;
>   int v = d.*pfd;
> }
> ```
> Note that you can't just propagate the value already computed for the 
> subexpression. Here is a particularly annoying example from the C++ spec:
> 
> ```
> struct B {
>   int f;
> };
> struct L : public B { };
> struct R : public B { };
> struct D : public L, R { };
> 
> void foo() {
>   D d;
> 
>   int B::* pb = &B::f;
>   int L::* pl = pb;
>   int R::* pr = pb;
> 
>   int D::* pdl = pl;
>   int D::* pdr = pr;
> 
>   clang_analyzer_eval(pdl == pdr); // FALSE
>   clang_analyzer_eval(pb == pl); // TRUE
> }
> ```
> My guess is this will require accumulating CXXBasePath s or something similar 
> for each cast. I don't know how to do this efficiently. 
> I don't know how to do this efficiently.

Jordan suggested storing this in a bump-pointer allocated object with a 
lifetime of the AnalysisDeclContext. The common case is no multiple 
inheritance, so that should be the fast case.

Maybe the Data could be a pointer union between a DeclaratorDecl and an 
immutable linked list (with sharing) of CXXBaseSpecifiers from the CastExprs in 
the AST. The storage for this could be managed with a new manager in 
SValBuilder.


https://reviews.llvm.org/D25475



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


Re: [libcxx] r284214 - XFAIL aligned allocation tests for older Clang versions

2016-10-18 Thread Tim Northover via cfe-commits
On 15 October 2016 at 13:08, Eric Fiselier via cfe-commits
 wrote:
> Are these tests still broken for you?

They're still breaking multiple Green Dragon bots (e.g. the basic
"make check" at
http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA/)[1].
What do you need to help fix the issue?

Cheers.

Tim.

[1] Becoming more important now that we think we've fixed the hardware
problem in their lab and want to re-enable notifications.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r284256 - Link static PIE programs against rcrt0.o on OpenBSD

2016-10-18 Thread Brad Smith via cfe-commits
On Fri, Oct 14, 2016 at 09:47:17PM -0400, Brad Smith via cfe-commits wrote:
> On Fri, Oct 14, 2016 at 05:59:54PM -, Ed Maste via cfe-commits wrote:
> > Author: emaste
> > Date: Fri Oct 14 12:59:53 2016
> > New Revision: 284256
> > 
> > URL: http://llvm.org/viewvc/llvm-project?rev=284256&view=rev
> > Log:
> > Link static PIE programs against rcrt0.o on OpenBSD
> > 
> > Patch by Stefan Kempf.
> > 
> > Differential Revision:  https://reviews.llvm.org/D22130
> > 
> > Modified:
> > cfe/trunk/lib/Driver/Tools.cpp
> > cfe/trunk/test/Driver/openbsd.c
> > 
> > Modified: cfe/trunk/lib/Driver/Tools.cpp
> > URL: 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=284256&r1=284255&r2=284256&view=diff
> > ==
> > --- cfe/trunk/lib/Driver/Tools.cpp (original)
> > +++ cfe/trunk/lib/Driver/Tools.cpp Fri Oct 14 12:59:53 2016
> > @@ -8519,6 +8519,10 @@ void openbsd::Linker::ConstructJob(Compi
> >if (Args.hasArg(options::OPT_pg))
> >  CmdArgs.push_back(
> >  Args.MakeArgString(getToolChain().GetFilePath("gcrt0.o")));
> > +  else if (Args.hasArg(options::OPT_static) &&
> > +   !Args.hasArg(options::OPT_nopie))
> > +CmdArgs.push_back(
> > +Args.MakeArgString(getToolChain().GetFilePath("rcrt0.o")));
> >else
> >  CmdArgs.push_back(
> >  Args.MakeArgString(getToolChain().GetFilePath("crt0.o")));
> > 
> > Modified: cfe/trunk/test/Driver/openbsd.c
> > URL: 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openbsd.c?rev=284256&r1=284255&r2=284256&view=diff
> > ==
> > --- cfe/trunk/test/Driver/openbsd.c (original)
> > +++ cfe/trunk/test/Driver/openbsd.c Fri Oct 14 12:59:53 2016
> > @@ -67,3 +67,26 @@
> >  // CHECK-MIPS64-PIC: as{{.*}}" "-mabi" "64" "-EB" "-KPIC"
> >  // CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL"
> >  // CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC"
> > +
> > +// Check linking against correct startup code when (not) using PIE
> > +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -### 2>&1 
> > \
> > +// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
> > +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -fno-pie 
> > %s -### 2>&1 \
> > +// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
> > +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static %s 
> > -### 2>&1 \
> > +// RUN:   | FileCheck -check-prefix=CHECK-STATIC-PIE %s
> > +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static 
> > -fno-pie %s -### 2>&1 \
> > +// RUN:   | FileCheck -check-prefix=CHECK-STATIC-PIE %s
> > +// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -nopie %s -### 
> > 2>&1 \
> > +// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
> > +// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -fno-pie 
> > -nopie %s -### 2>&1 \
> > +// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
> > +// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -static -nopie 
> > %s -### 2>&1 \
> > +// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
> > +// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -fno-pie 
> > -static -nopie %s -### 2>&1 \
> > +// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
> > +// CHECK-PIE: "/usr/lib/crt0.o"
> > +// CHECK-PIE-NOT: "-nopie"
> > +// CHECK-STATIC-PIE: "/usr/lib/rcrt0.o"
> > +// CHECK-STATIC-PIE-NOT: "-nopie"
> > +// CHECK-NOPIE: "-nopie" {{.*}}"/usr/lib/crt0.o"
> 
> Ok, I see the obvious issue with -no-canonical-prefix vs 
> -no-canonical-prefixes
> and fix the typo with the target triples.
 
After seeing what the test failure was I have adjusted the tests as appropriate.


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp(revision 283697)
+++ lib/Driver/Tools.cpp(working copy)
@@ -8469,6 +8469,10 @@
   if (Args.hasArg(options::OPT_pg))
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("gcrt0.o")));
+  else if (Args.hasArg(options::OPT_static) &&
+   !Args.hasArg(options::OPT_nopie))
+CmdArgs.push_back(
+Args.MakeArgString(getToolChain().GetFilePath("rcrt0.o")));
   else
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crt0.o")));
Index: test/Driver/openbsd.c
===
--- test/Driver/openbsd.c   (revision 283697)
+++ test/Driver/openbsd.c   (working copy)
@@ -67,3 +67,26 @@
 // CHECK-MIPS64-PIC: as{{.*}}" "-mabi" "64" "-EB" "-KPIC"
 // CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL"
 // CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC"
+
+// Check linking against correct startup code when (not) using PIE
+// RUN: %clang -no-canonical-prefixes -target i686-pc-

[PATCH] D25475: [analyzer] Add a new SVal to support pointer-to-member operations.

2016-10-18 Thread Devin Coughlin via cfe-commits
dcoughlin added inline comments.



Comment at: lib/StaticAnalyzer/Core/ExprEngineC.cpp:462
+  case CK_ReinterpretMemberPointer: {
+const Expr *UOExpr = CastE->getSubExpr()->IgnoreParenCasts();
+assert(isa(UOExpr) &&

I don't think pattern matching on the sub expression to find the referred-to 
declaration is the right thing to do here. It isn't always the case that the 
casted expression will be a unary pointer to member operation. For example, 
this is perfectly fine and triggers an assertion failure on your patch:

```
struct B {
  int f;
};

struct D : public B {
  int g;
};

void foo() {
  D d;
  d.f = 7;

  int B::* pfb = &B::f;
  int D::* pfd = pfb;
  int v = d.*pfd;
}
```
Note that you can't just propagate the value already computed for the 
subexpression. Here is a particularly annoying example from the C++ spec:

```
struct B {
  int f;
};
struct L : public B { };
struct R : public B { };
struct D : public L, R { };

void foo() {
  D d;

  int B::* pb = &B::f;
  int L::* pl = pb;
  int R::* pr = pb;

  int D::* pdl = pl;
  int D::* pdr = pr;

  clang_analyzer_eval(pdl == pdr); // FALSE
  clang_analyzer_eval(pb == pl); // TRUE
}
```
My guess is this will require accumulating CXXBasePath s or something similar 
for each cast. I don't know how to do this efficiently. 


https://reviews.llvm.org/D25475



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


r284556 - Resolve exception specifications when selecting an overloaded operator.

2016-10-18 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Oct 18 19:14:23 2016
New Revision: 284556

URL: http://llvm.org/viewvc/llvm-project?rev=284556&view=rev
Log:
Resolve exception specifications when selecting an overloaded operator.

Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx1z.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=284556&r1=284555&r2=284556&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Oct 18 19:14:23 2016
@@ -60,6 +60,8 @@ CreateFunctionRefExpr(Sema &S, FunctionD
   // being used.
   if (FoundDecl != Fn && S.DiagnoseUseOfDecl(Fn, Loc))
 return ExprError();
+  if (auto *FPT = Fn->getType()->getAs())
+S.ResolveExceptionSpec(Loc, FPT);
   DeclRefExpr *DRE = new (S.Context) DeclRefExpr(Fn, false, Fn->getType(),
  VK_LValue, Loc, LocInfo);
   if (HadMultipleCandidates)

Modified: cfe/trunk/test/SemaCXX/constant-expression-cxx1z.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression-cxx1z.cpp?rev=284556&r1=284555&r2=284556&view=diff
==
--- cfe/trunk/test/SemaCXX/constant-expression-cxx1z.cpp (original)
+++ cfe/trunk/test/SemaCXX/constant-expression-cxx1z.cpp Tue Oct 18 19:14:23 
2016
@@ -33,7 +33,9 @@ namespace NoexceptFunctionTypes {
   template struct A {
 constexpr bool f() noexcept(true) { return true; }
 constexpr bool g() { return f(); }
+constexpr bool operator()() const noexcept(true) { return true; }
   };
   static_assert(A().f());
   static_assert(A().g());
+  static_assert(A()());
 }


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


r284553 - [CUDA] Rework tests now that we emit deferred diagnostics during sema. Test-only change.

2016-10-18 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Tue Oct 18 19:06:49 2016
New Revision: 284553

URL: http://llvm.org/viewvc/llvm-project?rev=284553&view=rev
Log:
[CUDA] Rework tests now that we emit deferred diagnostics during sema.  
Test-only change.

Summary:
Previously we had to split out a lot of our tests into a test that
checked only immediate errors and a test that checked only deferred
errors.  This was because, if you emitted any immediate errors, we
wouldn't run codegen, where the deferred errors were emitted.

We've fixed this, and now emit deferred errors during sema.  This lets
us merge a bunch of tests, and lets us convert some other tests to
-fsyntax-only.

Reviewers: tra

Subscribers: cfe-commits

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

Removed:
cfe/trunk/test/SemaCUDA/exceptions-host-device.cu
cfe/trunk/test/SemaCUDA/function-overload-hd.cu
cfe/trunk/test/SemaCUDA/implicit-device-lambda-hd.cu
cfe/trunk/test/SemaCUDA/static-vars-hd.cu
cfe/trunk/test/SemaCUDA/vla-host-device.cu
Modified:
cfe/trunk/test/PCH/pragma-cuda-force-host-device.cu
cfe/trunk/test/Parser/cuda-force-host-device-templates.cu
cfe/trunk/test/SemaCUDA/device-var-init.cu
cfe/trunk/test/SemaCUDA/exceptions.cu
cfe/trunk/test/SemaCUDA/function-overload.cu
cfe/trunk/test/SemaCUDA/implicit-device-lambda.cu
cfe/trunk/test/SemaCUDA/vla.cu

Modified: cfe/trunk/test/PCH/pragma-cuda-force-host-device.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/pragma-cuda-force-host-device.cu?rev=284553&r1=284552&r2=284553&view=diff
==
--- cfe/trunk/test/PCH/pragma-cuda-force-host-device.cu (original)
+++ cfe/trunk/test/PCH/pragma-cuda-force-host-device.cu Tue Oct 18 19:06:49 2016
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -emit-pch %s -o %t
-// RUN: %clang_cc1 -verify -verify-ignore-unexpected=note -include-pch %t -S 
-o /dev/null %s
+// RUN: %clang_cc1 -verify -verify-ignore-unexpected=note -include-pch %t 
-fsyntax-only %s
 
 #ifndef HEADER
 #define HEADER

Modified: cfe/trunk/test/Parser/cuda-force-host-device-templates.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cuda-force-host-device-templates.cu?rev=284553&r1=284552&r2=284553&view=diff
==
--- cfe/trunk/test/Parser/cuda-force-host-device-templates.cu (original)
+++ cfe/trunk/test/Parser/cuda-force-host-device-templates.cu Tue Oct 18 
19:06:49 2016
@@ -1,8 +1,7 @@
-// RUN: %clang_cc1 -std=c++14 -S -verify -fcuda-is-device %s -o /dev/null
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify -fcuda-is-device %s
 
 // Check how the force_cuda_host_device pragma interacts with template
-// instantiations.  The errors here are emitted at codegen, so we can't do
-// -fsyntax-only.
+// instantiations.
 
 template 
 auto foo() {  // expected-note {{declared here}}

Modified: cfe/trunk/test/SemaCUDA/device-var-init.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/device-var-init.cu?rev=284553&r1=284552&r2=284553&view=diff
==
--- cfe/trunk/test/SemaCUDA/device-var-init.cu (original)
+++ cfe/trunk/test/SemaCUDA/device-var-init.cu Tue Oct 18 19:06:49 2016
@@ -213,3 +213,15 @@ __device__ void df_sema() {
   static int v;
   // expected-error@-1 {{within a __device__ function, only __shared__ 
variables may be marked 'static'}}
 }
+
+__host__ __device__ void hd_sema() {
+  static int x = 42;
+#ifdef __CUDA_ARCH__
+  // expected-error@-2 {{within a __host__ __device__ function, only 
__shared__ variables may be marked 'static'}}
+#endif
+}
+
+inline __host__ __device__ void hd_emitted_host_only() {
+  static int x = 42; // no error on device because this is never codegen'ed 
there.
+}
+void call_hd_emitted_host_only() { hd_emitted_host_only(); }

Removed: cfe/trunk/test/SemaCUDA/exceptions-host-device.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/exceptions-host-device.cu?rev=284552&view=auto
==
--- cfe/trunk/test/SemaCUDA/exceptions-host-device.cu (original)
+++ cfe/trunk/test/SemaCUDA/exceptions-host-device.cu (removed)
@@ -1,38 +0,0 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fcuda-is-device -verify %s -S -o /dev/null
-// RUN: %clang_cc1 -fcxx-exceptions -verify -DHOST %s -S -o /dev/null
-
-#include "Inputs/cuda.h"
-
-// Check that it's an error to use 'try' and 'throw' from a __host__ __device__
-// function if and only if it's codegen'ed for device.
-
-#ifdef HOST
-// expected-no-diagnostics
-#endif
-
-__host__ __device__ void hd1() {
-  throw NULL;
-  try {} catch(void*) {}
-#ifndef HOST
-  // expected-error@-3 {{cannot use 'throw' in __host__ __device__ function}}
-  // expected-error@-3 {{cannot use 'try' in __host__ __device__ function}}
-#endif
-}
-
-// No error, never instantiated on device.

[PATCH] D25755: [CUDA] Rework tests now that we emit deferred diagnostics during sema. Test-only change.

2016-10-18 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284553: [CUDA] Rework tests now that we emit deferred 
diagnostics during sema.  Test… (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D25755?vs=75085&id=75099#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25755

Files:
  cfe/trunk/test/PCH/pragma-cuda-force-host-device.cu
  cfe/trunk/test/Parser/cuda-force-host-device-templates.cu
  cfe/trunk/test/SemaCUDA/device-var-init.cu
  cfe/trunk/test/SemaCUDA/exceptions-host-device.cu
  cfe/trunk/test/SemaCUDA/exceptions.cu
  cfe/trunk/test/SemaCUDA/function-overload-hd.cu
  cfe/trunk/test/SemaCUDA/function-overload.cu
  cfe/trunk/test/SemaCUDA/implicit-device-lambda-hd.cu
  cfe/trunk/test/SemaCUDA/implicit-device-lambda.cu
  cfe/trunk/test/SemaCUDA/static-vars-hd.cu
  cfe/trunk/test/SemaCUDA/vla-host-device.cu
  cfe/trunk/test/SemaCUDA/vla.cu

Index: cfe/trunk/test/PCH/pragma-cuda-force-host-device.cu
===
--- cfe/trunk/test/PCH/pragma-cuda-force-host-device.cu
+++ cfe/trunk/test/PCH/pragma-cuda-force-host-device.cu
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -emit-pch %s -o %t
-// RUN: %clang_cc1 -verify -verify-ignore-unexpected=note -include-pch %t -S -o /dev/null %s
+// RUN: %clang_cc1 -verify -verify-ignore-unexpected=note -include-pch %t -fsyntax-only %s
 
 #ifndef HEADER
 #define HEADER
Index: cfe/trunk/test/Parser/cuda-force-host-device-templates.cu
===
--- cfe/trunk/test/Parser/cuda-force-host-device-templates.cu
+++ cfe/trunk/test/Parser/cuda-force-host-device-templates.cu
@@ -1,8 +1,7 @@
-// RUN: %clang_cc1 -std=c++14 -S -verify -fcuda-is-device %s -o /dev/null
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify -fcuda-is-device %s
 
 // Check how the force_cuda_host_device pragma interacts with template
-// instantiations.  The errors here are emitted at codegen, so we can't do
-// -fsyntax-only.
+// instantiations.
 
 template 
 auto foo() {  // expected-note {{declared here}}
Index: cfe/trunk/test/SemaCUDA/implicit-device-lambda.cu
===
--- cfe/trunk/test/SemaCUDA/implicit-device-lambda.cu
+++ cfe/trunk/test/SemaCUDA/implicit-device-lambda.cu
@@ -76,6 +76,26 @@
   f4();
 }
 
+__host__ __device__ void hd_fn() {
+  auto f1 = [&] {};
+  f1(); // implicitly __host__ __device__
+
+  auto f2 = [&] __device__ {};
+  f2();
+#ifndef __CUDA_ARCH__
+  // expected-error@-2 {{reference to __device__ function}}
+#endif
+
+  auto f3 = [&] __host__ {};
+  f3();
+#ifdef __CUDA_ARCH__
+  // expected-error@-2 {{reference to __host__ function}}
+#endif
+
+  auto f4 = [&] __host__ __device__ {};
+  f4();
+}
+
 // The special treatment above only applies to lambdas.
 __device__ void foo() {
   struct X {
Index: cfe/trunk/test/SemaCUDA/vla.cu
===
--- cfe/trunk/test/SemaCUDA/vla.cu
+++ cfe/trunk/test/SemaCUDA/vla.cu
@@ -10,3 +10,16 @@
 __device__ void device(int n) {
   int x[n];  // expected-error {{cannot use variable-length arrays in __device__ functions}}
 }
+
+__host__ __device__ void hd(int n) {
+  int x[n];
+#ifdef __CUDA_ARCH__
+  // expected-error@-2 {{cannot use variable-length arrays in __host__ __device__ functions}}
+#endif
+}
+
+// No error because never codegen'ed for device.
+__host__ __device__ inline void hd_inline(int n) {
+  int x[n];
+}
+void call_hd_inline() { hd_inline(42); }
Index: cfe/trunk/test/SemaCUDA/function-overload.cu
===
--- cfe/trunk/test/SemaCUDA/function-overload.cu
+++ cfe/trunk/test/SemaCUDA/function-overload.cu
@@ -193,12 +193,22 @@
   CurrentFnPtr fp_cdh = cdh;
   CurrentReturnTy ret_cdh = cdh();
 
+  GlobalFnPtr fp_g = g;
+#if defined(__CUDA_ARCH__)
+  // expected-error@-2 {{reference to __global__ function 'g' in __host__ __device__ function}}
+#endif
+
   g();
 #if defined (__CUDA_ARCH__)
   // expected-error@-2 {{reference to __global__ function 'g' in __host__ __device__ function}}
 #else
   // expected-error@-4 {{call to global function g not configured}}
 #endif
+
+  g<<<0,0>>>();
+#if defined(__CUDA_ARCH__)
+  // expected-error@-2 {{reference to __global__ function 'g' in __host__ __device__ function}}
+#endif
 }
 
 // Test for address of overloaded function resolution in the global context.
Index: cfe/trunk/test/SemaCUDA/device-var-init.cu
===
--- cfe/trunk/test/SemaCUDA/device-var-init.cu
+++ cfe/trunk/test/SemaCUDA/device-var-init.cu
@@ -213,3 +213,15 @@
   static int v;
   // expected-error@-1 {{within a __device__ function, only __shared__ variables may be marked 'static'}}
 }
+
+__host__ __device__ void hd_sema() {
+  static int x = 42;
+#ifdef __CUDA_ARCH__
+  // expected-error@-2 {{within a __host__ __device__ function, only

[PATCH] D25755: [CUDA] Rework tests now that we emit deferred diagnostics during sema. Test-only change.

2016-10-18 Thread Artem Belevich via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D25755



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


Re: [libcxx] r249738 - Split out of .

2016-10-18 Thread Richard Smith via cfe-commits
On Mon, Oct 17, 2016 at 3:31 PM, Manman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:
>
> > On Oct 17, 2016, at 2:11 PM, Bruno Cardoso Lopes via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >
> > Hi,
> >
> > On Fri, Oct 14, 2016 at 3:09 PM, Richard Smith 
> wrote:
> >> On Fri, Oct 14, 2016 at 11:44 AM, Bruno Cardoso Lopes
> >>  wrote:
> >>>
> >>> Hi Richard,
> >>>
> >>> I have a patch on top of your suggested patch from a year ago, that
> >>> break the cyclic dependency we're seeing, with this (and a few changes
> >>> to the SDK) we can bootstrap clang with submodule local visibility on
> >>> darwin. I've attached the patch with a reduced, standalone testcase
> >>> that doesn't depend on the SDK. The issues that are not covered by
> >>> your patch, that I cover in mine, are related to built-in and textual
> >>> headers: they can be found in paths where they don't map to any
> >>> modules, triggering other cycles. I fix that by looking further to
> >>> find a matching module for the header in question, instead the first
> >>> found header in header search.
> >>
> >>
> >> It looks like the 0002 patch is working around a bug in the 0001 patch:
> with
> >> 0001 applied, a module with [no_undeclared_includes] can still include a
> >> textual header from another module on which it doesn't declare a
> dependency
> >> (in the testcase, the libc module is incorrectly permitted to include
> the
> >> textual header  from libc++). Rather than preferring
> non-modular
> >> headers over modular headers as the 0002 patch does, I wonder if the
> issue
> >> could instead be resolved by fixing that apparent bug.
> >
> > Thanks for the fast answer and for the new patch :-)
> > My intend with 0002 was actually to prefer modular headers instead of
> > non-modular, but fallback to the later in case none is found.
> >
> >> I gave that a go; the result is attached. I also had to change the way
> we
> >> handle builtin headers -- instead of implicitly including (for
> instance) the
> >> builtin  as a modular header in any module that provides its
> own
> >> , I now only include it as a textual header (this also lets
> us use
> >> the same approach for this case whether or not we're using local
> submodule
> >> visibility).
>
> @Richard,
>
> I wonder why (prior to your patch) we need to use a different approach for
> builtin headers with local submodule visibility.
>

I don't think we did (see the FIXME I deleted suggesting to use the local
submodule visibiltiy logic in all cases).

Thanks,
>
> >> That exposed a couple of testcases that were (unreasonably, in
> >> my opinion) failing to include_next the real builtin header from their
> >> wrapper header.
> >
> > I'm curious about these, are they from clang tests?
> >
> >> The attached patch causes your testcase to pass; I'd be interested to
> know
> >> if it works in practice on Darwin.
> >
> > It works for building the Darwin module, but failed for "#include
> > " on darwin (which was working under 0001+0002 patch):
> >
> > While building module 'std' imported from all-headers.cpp:1:
> > While building module 'Darwin' imported from
> > /clang-install/include/c++/v1/string.h:61:
> > In file included from :422:
> > In file included from /SDK/MacOSX10.12.sdk/usr/include/mach/mach.h:67:
> > In file included from /SDK/MacOSX10.12.sdk/usr/
> include/mach/mach_interface.h:42:
> > In file included from /SDK/MacOSX10.12.sdk/usr/
> include/mach/clock_priv.h:6:
> > /clang-install/include/c++/v1/string.h:74:7: error: redefinition of
> > '__libcpp_strchr'
> > char* __libcpp_strchr(const char* __s, int __c) {return
> > (char*)strchr(__s, __c);}
> >  ^
> > /clang-install/include/c++/v1/string.h:74:7: note: previous definition
> is here
>
> @Bruno,
>
> Can you try "-fdiagnostics-show-note-include-stack” so we know the other
> path that leads to string.h?
>
> Manman
>
> > char* __libcpp_strchr(const char* __s, int __c) {return
> > (char*)strchr(__s, __c);}
> >  ^
> > While building module 'std' imported from all-headers.cpp:1:
> > While building module 'Darwin' imported from
> > /clang-install/include/c++/v1/string.h:61:
> > In file included from :422:
> > In file included from /SDK/MacOSX10.12.sdk/usr/include/mach/mach.h:67:
> > In file included from /SDK/MacOSX10.12.sdk/usr/
> include/mach/mach_interface.h:42:
> > In file included from /SDK/MacOSX10.12.sdk/usr/
> include/mach/clock_priv.h:6:
> > /clang-install/include/c++/v1/string.h:76:13: error: redefinition of
> 'strchr'
> > const char* strchr(const char* __s, int __c) {return
> __libcpp_strchr(__s, __c);}
> >^
> > /clang-install/include/c++/v1/string.h:76:13: note: previous definition
> is here
> > const char* strchr(const char* __s, int __c) {return
> __libcpp_strchr(__s, __c);}
> >^
> > <...>
> > While building module 'std' imported from all-headers.cpp:1:
> > In file included from :1:
> > In file included from /clang-install/include/c++/v1/algorithm:638:
> > In file included from /clang-insta

Re: [libcxx] r249738 - Split out of .

2016-10-18 Thread Richard Smith via cfe-commits
On Tue, Oct 18, 2016 at 4:30 PM, Bruno Cardoso Lopes <
bruno.card...@gmail.com> wrote:

> Hi Richard,
>
> Turns out that the redefinition error was caused because libc++
> modulemap lacked a module for its "string.h", and therefore it would
> be textually included in more than one module, yielding the error.
>
> With the attached patch for libc++ modulemap (extracted from parts of
> a modulemap you previously attached to the thread) + your patch, I can
> successfully compile Darwin and selfhost clang with submodule local
> visibility.


Awesome.


> I can also upstream the patches for you in case your too
> busy, let me know.
>

Sure, go ahead.


> One minor note: the keyword name 'no_undeclared_includes' sounds a bit
> confusing, how about 'direct_uses_only', or something along these
> lines?
>

Hmm. Ideally, we should try to pick something that captures the spirit of
"only non-modular headers and headers from used modules". Something like
"ignore_modules_not_declared_used", but less wordy?


> Thanks,
>
> On Mon, Oct 17, 2016 at 3:59 PM, Bruno Cardoso Lopes
>  wrote:
> >> @Bruno,
> >>
> >> Can you try "-fdiagnostics-show-note-include-stack” so we know the
> other path that leads to string.h?
> >
> > Attached the complete error log (this snippet won't help without full
> > context anyway)
>
> --
> Bruno Cardoso Lopes
> http://www.brunocardoso.cc
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r284549 - DR1330: instantiate exception-specifications when "needed". We previously did

2016-10-18 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Oct 18 18:39:12 2016
New Revision: 284549

URL: http://llvm.org/viewvc/llvm-project?rev=284549&view=rev
Log:
DR1330: instantiate exception-specifications when "needed". We previously did
not instantiate exception specifications of functions if they were only used in
unevaluated contexts (other than 'noexcept' expressions).

In C++17 onwards, this becomes essential since the exception specification is
now part of the function's type.

Note that this means that constructs like the following no longer work:

  struct A {
static T f() noexcept(...);
decltype(f()) *p;
  };

... because the decltype expression now needs the exception specification of
'f', which has not yet been parsed.

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/CXX/drs/dr13xx.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx1z.cpp
cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
cfe/trunk/test/SemaCXX/libstdcxx_pair_swap_hack.cpp
cfe/trunk/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=284549&r1=284548&r2=284549&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Oct 18 18:39:12 2016
@@ -2889,6 +2889,14 @@ ExprResult Sema::BuildDeclarationNameExp
 
   {
 QualType type = VD->getType();
+if (auto *FPT = type->getAs()) {
+  // C++ [except.spec]p17:
+  //   An exception-specification is considered to be needed when:
+  //   - in an expression, the function is the unique lookup result or
+  // the selected member of a set of overloaded functions.
+  ResolveExceptionSpec(Loc, FPT);
+  type = VD->getType();
+}
 ExprValueKind valueKind = VK_RValue;
 
 switch (D->getKind()) {
@@ -13138,6 +13146,19 @@ void Sema::MarkFunctionReferenced(Source
Func->getMemberSpecializationInfo()))
 checkSpecializationVisibility(Loc, Func);
 
+  // C++14 [except.spec]p17:
+  //   An exception-specification is considered to be needed when:
+  //   - the function is odr-used or, if it appears in an unevaluated operand,
+  // would be odr-used if the expression were potentially-evaluated;
+  //
+  // Note, we do this even if MightBeOdrUse is false. That indicates that the
+  // function is a pure virtual function we're calling, and in that case the
+  // function was selected by overload resolution and we need to resolve its
+  // exception specification for a different reason.
+  const FunctionProtoType *FPT = Func->getType()->getAs();
+  if (FPT && isUnresolvedExceptionSpec(FPT->getExceptionSpecType()))
+ResolveExceptionSpec(Loc, FPT);
+
   // If we don't need to mark the function as used, and we don't need to
   // try to provide a definition, there's nothing more to do.
   if ((Func->isUsed(/*CheckUsedAttr=*/false) || !OdrUse) &&
@@ -13196,12 +13217,6 @@ void Sema::MarkFunctionReferenced(Source
   // FIXME: Is this really right?
   if (CurContext == Func) return;
 
-  // Resolve the exception specification for any function which is
-  // used: CodeGen will need it.
-  const FunctionProtoType *FPT = Func->getType()->getAs();
-  if (FPT && isUnresolvedExceptionSpec(FPT->getExceptionSpecType()))
-ResolveExceptionSpec(Loc, FPT);
-
   // Implicit instantiation of function templates and member functions of
   // class templates.
   if (Func->isImplicitlyInstantiable()) {

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=284549&r1=284548&r2=284549&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Oct 18 18:39:12 2016
@@ -13166,6 +13166,13 @@ Expr *Sema::FixOverloadedFunctionReferen
UnOp->getOperatorLoc());
   }
 
+  // C++ [except.spec]p17:
+  //   An exception-specification is considered to be needed when:
+  //   - in an expression the function is the unique lookup result or the
+  // selected member of a set of overloaded functions
+  if (auto *FPT = Fn->getType()->getAs())
+ResolveExceptionSpec(E->getExprLoc(), FPT);
+
   if (UnresolvedLookupExpr *ULE = dyn_cast(E)) {
 // FIXME: avoid copy.
 TemplateArgumentListInfo TemplateArgsBuffer, *TemplateArgs = nullptr;

Modified: cfe/trunk/test/CXX/drs/dr13xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr13xx.cpp?rev=284549&r1=284548&r2=284549&view=diff
==
--- cfe/trunk/test/CXX/drs/dr13xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr13xx.cpp Tue Oct 18 18:39:12 2016
@@ -3,6 +3,91 @@
 // RUN: %clang_cc1 

[PATCH] D25596: alpha.core.Conversion - Fix false positive for 'U32 += S16; ' expression, that is not unsafe

2016-10-18 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Looks like you've also added handling of Xor, Or , Div, and Rem. Should there 
be tests for those?


Repository:
  rL LLVM

https://reviews.llvm.org/D25596



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


Re: [libcxx] r249738 - Split out of .

2016-10-18 Thread Bruno Cardoso Lopes via cfe-commits
Hi Richard,

Turns out that the redefinition error was caused because libc++
modulemap lacked a module for its "string.h", and therefore it would
be textually included in more than one module, yielding the error.

With the attached patch for libc++ modulemap (extracted from parts of
a modulemap you previously attached to the thread) + your patch, I can
successfully compile Darwin and selfhost clang with submodule local
visibility. I can also upstream the patches for you in case your too
busy, let me know.

One minor note: the keyword name 'no_undeclared_includes' sounds a bit
confusing, how about 'direct_uses_only', or something along these
lines?

Thanks,

On Mon, Oct 17, 2016 at 3:59 PM, Bruno Cardoso Lopes
 wrote:
>> @Bruno,
>>
>> Can you try "-fdiagnostics-show-note-include-stack” so we know the other 
>> path that leads to string.h?
>
> Attached the complete error log (this snippet won't help without full
> context anyway)

-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc


0001-ModuleMap-Add-module-entries-for-non-modular-headers.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25755: [CUDA] Rework tests now that we emit deferred diagnostics during sema. Test-only change.

2016-10-18 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 75085.
jlebar added a comment.

Remove line that should be added in a different patch.


https://reviews.llvm.org/D25755

Files:
  clang/test/PCH/pragma-cuda-force-host-device.cu
  clang/test/Parser/cuda-force-host-device-templates.cu
  clang/test/SemaCUDA/device-var-init.cu
  clang/test/SemaCUDA/exceptions-host-device.cu
  clang/test/SemaCUDA/exceptions.cu
  clang/test/SemaCUDA/function-overload-hd.cu
  clang/test/SemaCUDA/function-overload.cu
  clang/test/SemaCUDA/implicit-device-lambda-hd.cu
  clang/test/SemaCUDA/implicit-device-lambda.cu
  clang/test/SemaCUDA/static-vars-hd.cu
  clang/test/SemaCUDA/vla-host-device.cu
  clang/test/SemaCUDA/vla.cu

Index: clang/test/SemaCUDA/vla.cu
===
--- clang/test/SemaCUDA/vla.cu
+++ clang/test/SemaCUDA/vla.cu
@@ -10,3 +10,16 @@
 __device__ void device(int n) {
   int x[n];  // expected-error {{cannot use variable-length arrays in __device__ functions}}
 }
+
+__host__ __device__ void hd(int n) {
+  int x[n];
+#ifdef __CUDA_ARCH__
+  // expected-error@-2 {{cannot use variable-length arrays in __host__ __device__ functions}}
+#endif
+}
+
+// No error because never codegen'ed for device.
+__host__ __device__ inline void hd_inline(int n) {
+  int x[n];
+}
+void call_hd_inline() { hd_inline(42); }
Index: clang/test/SemaCUDA/vla-host-device.cu
===
--- clang/test/SemaCUDA/vla-host-device.cu
+++ /dev/null
@@ -1,21 +0,0 @@
-// RUN: %clang_cc1 -fcuda-is-device -verify -S %s -o /dev/null
-// RUN: %clang_cc1 -verify -DHOST %s -S -o /dev/null
-
-#include "Inputs/cuda.h"
-
-#ifdef HOST
-// expected-no-diagnostics
-#endif
-
-__host__ __device__ void hd(int n) {
-  int x[n];
-#ifndef HOST
-  // expected-error@-2 {{cannot use variable-length arrays in __host__ __device__ functions}}
-#endif
-}
-
-// No error because never codegen'ed for device.
-__host__ __device__ inline void hd_inline(int n) {
-  int x[n];
-}
-void call_hd_inline() { hd_inline(42); }
Index: clang/test/SemaCUDA/static-vars-hd.cu
===
--- clang/test/SemaCUDA/static-vars-hd.cu
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fcuda-is-device -S -o /dev/null -verify %s
-// RUN: %clang_cc1 -fcxx-exceptions -S -o /dev/null -D HOST -verify %s
-
-#include "Inputs/cuda.h"
-
-#ifdef HOST
-// expected-no-diagnostics
-#endif
-
-__host__ __device__ void f() {
-  static int x = 42;
-#ifndef HOST
-  // expected-error@-2 {{within a __host__ __device__ function, only __shared__ variables may be marked 'static'}}
-#endif
-}
-
-inline __host__ __device__ void g() {
-  static int x = 42; // no error on device because this is never codegen'ed there.
-}
-void call_g() { g(); }
Index: clang/test/SemaCUDA/implicit-device-lambda.cu
===
--- clang/test/SemaCUDA/implicit-device-lambda.cu
+++ clang/test/SemaCUDA/implicit-device-lambda.cu
@@ -76,6 +76,26 @@
   f4();
 }
 
+__host__ __device__ void hd_fn() {
+  auto f1 = [&] {};
+  f1(); // implicitly __host__ __device__
+
+  auto f2 = [&] __device__ {};
+  f2();
+#ifndef __CUDA_ARCH__
+  // expected-error@-2 {{reference to __device__ function}}
+#endif
+
+  auto f3 = [&] __host__ {};
+  f3();
+#ifdef __CUDA_ARCH__
+  // expected-error@-2 {{reference to __host__ function}}
+#endif
+
+  auto f4 = [&] __host__ __device__ {};
+  f4();
+}
+
 // The special treatment above only applies to lambdas.
 __device__ void foo() {
   struct X {
Index: clang/test/SemaCUDA/implicit-device-lambda-hd.cu
===
--- clang/test/SemaCUDA/implicit-device-lambda-hd.cu
+++ /dev/null
@@ -1,27 +0,0 @@
-// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -verify -verify-ignore-unexpected=note \
-// RUN:   -S -o /dev/null %s
-// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only -verify-ignore-unexpected=note \
-// RUN:   -DHOST -S -o /dev/null %s
-#include "Inputs/cuda.h"
-
-__host__ __device__ void hd_fn() {
-  auto f1 = [&] {};
-  f1(); // implicitly __host__ __device__
-
-  auto f2 = [&] __device__ {};
-  f2();
-#ifdef HOST
-  // expected-error@-2 {{reference to __device__ function}}
-#endif
-
-  auto f3 = [&] __host__ {};
-  f3();
-#ifndef HOST
-  // expected-error@-2 {{reference to __host__ function}}
-#endif
-
-  auto f4 = [&] __host__ __device__ {};
-  f4();
-}
-
-
Index: clang/test/SemaCUDA/function-overload.cu
===
--- clang/test/SemaCUDA/function-overload.cu
+++ clang/test/SemaCUDA/function-overload.cu
@@ -193,12 +193,22 @@
   CurrentFnPtr fp_cdh = cdh;
   CurrentReturnTy ret_cdh = cdh();
 
+  GlobalFnPtr fp_g = g;
+#if defined(__CUDA_ARCH__)
+  // expected-error@-2 {{reference to __global__ function 'g' in __host__ __device__ function}}
+#endif
+
   g();
 #if defined (__CUDA_ARCH__)
   // expec

[PATCH] D25755: [CUDA] Rework tests now that we emit deferred diagnostics during sema. Test-only change.

2016-10-18 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added a subscriber: cfe-commits.

Previously we had to split out a lot of our tests into a test that
checked only immediate errors and a test that checked only deferred
errors.  This was because, if you emitted any immediate errors, we
wouldn't run codegen, where the deferred errors were emitted.

We've fixed this, and now emit deferred errors during sema.  This lets
us merge a bunch of tests, and lets us convert some other tests to
-fsyntax-only.


https://reviews.llvm.org/D25755

Files:
  clang/test/PCH/pragma-cuda-force-host-device.cu
  clang/test/Parser/cuda-force-host-device-templates.cu
  clang/test/SemaCUDA/device-var-init.cu
  clang/test/SemaCUDA/exceptions-host-device.cu
  clang/test/SemaCUDA/exceptions.cu
  clang/test/SemaCUDA/function-overload-hd.cu
  clang/test/SemaCUDA/function-overload.cu
  clang/test/SemaCUDA/implicit-device-lambda-hd.cu
  clang/test/SemaCUDA/implicit-device-lambda.cu
  clang/test/SemaCUDA/static-vars-hd.cu
  clang/test/SemaCUDA/vla-host-device.cu
  clang/test/SemaCUDA/vla.cu

Index: clang/test/SemaCUDA/vla.cu
===
--- clang/test/SemaCUDA/vla.cu
+++ clang/test/SemaCUDA/vla.cu
@@ -10,3 +10,16 @@
 __device__ void device(int n) {
   int x[n];  // expected-error {{cannot use variable-length arrays in __device__ functions}}
 }
+
+__host__ __device__ void hd(int n) {
+  int x[n];
+#ifdef __CUDA_ARCH__
+  // expected-error@-2 {{cannot use variable-length arrays in __host__ __device__ functions}}
+#endif
+}
+
+// No error because never codegen'ed for device.
+__host__ __device__ inline void hd_inline(int n) {
+  int x[n];
+}
+void call_hd_inline() { hd_inline(42); }
Index: clang/test/SemaCUDA/vla-host-device.cu
===
--- clang/test/SemaCUDA/vla-host-device.cu
+++ /dev/null
@@ -1,21 +0,0 @@
-// RUN: %clang_cc1 -fcuda-is-device -verify -S %s -o /dev/null
-// RUN: %clang_cc1 -verify -DHOST %s -S -o /dev/null
-
-#include "Inputs/cuda.h"
-
-#ifdef HOST
-// expected-no-diagnostics
-#endif
-
-__host__ __device__ void hd(int n) {
-  int x[n];
-#ifndef HOST
-  // expected-error@-2 {{cannot use variable-length arrays in __host__ __device__ functions}}
-#endif
-}
-
-// No error because never codegen'ed for device.
-__host__ __device__ inline void hd_inline(int n) {
-  int x[n];
-}
-void call_hd_inline() { hd_inline(42); }
Index: clang/test/SemaCUDA/static-vars-hd.cu
===
--- clang/test/SemaCUDA/static-vars-hd.cu
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fcuda-is-device -S -o /dev/null -verify %s
-// RUN: %clang_cc1 -fcxx-exceptions -S -o /dev/null -D HOST -verify %s
-
-#include "Inputs/cuda.h"
-
-#ifdef HOST
-// expected-no-diagnostics
-#endif
-
-__host__ __device__ void f() {
-  static int x = 42;
-#ifndef HOST
-  // expected-error@-2 {{within a __host__ __device__ function, only __shared__ variables may be marked 'static'}}
-#endif
-}
-
-inline __host__ __device__ void g() {
-  static int x = 42; // no error on device because this is never codegen'ed there.
-}
-void call_g() { g(); }
Index: clang/test/SemaCUDA/implicit-device-lambda.cu
===
--- clang/test/SemaCUDA/implicit-device-lambda.cu
+++ clang/test/SemaCUDA/implicit-device-lambda.cu
@@ -76,6 +76,26 @@
   f4();
 }
 
+__host__ __device__ void hd_fn() {
+  auto f1 = [&] {};
+  f1(); // implicitly __host__ __device__
+
+  auto f2 = [&] __device__ {};
+  f2();
+#ifndef __CUDA_ARCH__
+  // expected-error@-2 {{reference to __device__ function}}
+#endif
+
+  auto f3 = [&] __host__ {};
+  f3();
+#ifdef __CUDA_ARCH__
+  // expected-error@-2 {{reference to __host__ function}}
+#endif
+
+  auto f4 = [&] __host__ __device__ {};
+  f4();
+}
+
 // The special treatment above only applies to lambdas.
 __device__ void foo() {
   struct X {
Index: clang/test/SemaCUDA/implicit-device-lambda-hd.cu
===
--- clang/test/SemaCUDA/implicit-device-lambda-hd.cu
+++ /dev/null
@@ -1,27 +0,0 @@
-// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -verify -verify-ignore-unexpected=note \
-// RUN:   -S -o /dev/null %s
-// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only -verify-ignore-unexpected=note \
-// RUN:   -DHOST -S -o /dev/null %s
-#include "Inputs/cuda.h"
-
-__host__ __device__ void hd_fn() {
-  auto f1 = [&] {};
-  f1(); // implicitly __host__ __device__
-
-  auto f2 = [&] __device__ {};
-  f2();
-#ifdef HOST
-  // expected-error@-2 {{reference to __device__ function}}
-#endif
-
-  auto f3 = [&] __host__ {};
-  f3();
-#ifndef HOST
-  // expected-error@-2 {{reference to __host__ function}}
-#endif
-
-  auto f4 = [&] __host__ __device__ {};
-  f4();
-}
-
-
Index: clang/test/SemaCUDA/function-overload.cu
=

[PATCH] D25621: DebugInfo: use uin32_t for alignment

2016-10-18 Thread Adrian Prantl via cfe-commits
aprantl added a comment.

This patch is conflating two set of changes:
(1) NFC: rename all occurrences of unsigned for alignment purposes in the 
frontend with uint32_t
(2) shrink all debug-info-related alignment variables from uint64_t -> 
unint32_t.

I think this patch should only be doing the changes in (2).


https://reviews.llvm.org/D25621



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


[PATCH] D25403: [CUDA] Mark __libcpp_{isnan, isinf, isfinite} as constexpr.

2016-10-18 Thread Justin Lebar via cfe-commits
jlebar added a comment.

In https://reviews.llvm.org/D25403#573666, @mclow.lists wrote:

> Yesterday and today is the first time in a while that clang has been 
> seriously broken for more than an hour or so.
>  I'm not inclined to worry about it yet.


Oh, awesome.  That sounds good to me.

The question about build configurations still stands, though -- should that be 
documented somewhere?  In particular I could not successfully run check-cxx by 
following the directions I found by googling.  I am volunteering to write the 
patch if we can agree on what the workflow should be.

>>> I don't see how this can possibly be constexpr.
>>>  it calls isfinite(), which is hoisted from ::isfinite(), which comes from 
>>> the C library.
>>>  Since C knows nothing about constexpr, we're stuck.
>> 
>> Functions that call non-constexpr things can be marked constexpr; you just 
>> can't evaluate them in a constexpr context (as you demonstrated).
>> 
>> All I need is for the function to be marked as constexpr; I do not need the 
>> function be constexpr-evaluatable.
> 
> Then what's the point? How can you test if it is correct?

https://reviews.llvm.org/D24971 tests this.  I suppose we could write a test 
inside libcxx, but it would be kind of ugly.

> I guess I don't understand the motivation for this change.

To make  work in CUDA, we do the following terrible, awful, horrible, 
no good thing: ...well, I can just show you the code.  
https://github.com/llvm-project/llvm-project/blob/master/clang/lib/Headers/cuda_wrappers/complex

The significant part here is

  #pragma clang force_cuda_host_device begin
  #include_next 
  #pragma clang force_cuda_host_device end

This tells clang, everything between the two pragmas is something that we can 
run on the host (CPU) and device (GPU).  And that works fine for libstdc++.  
But for libc++, marking everything inside  as host+device is not 
enough -- we also need to mark these four functions, which are called from 
.

We could mark them as __host__ __device__ explicitly, but then we'd need checks 
for CUDA compilation inside of libc++, and I've been avoiding asking for that.  
Instead, marking these functions as constexpr works, because constexpr 
functions are implicitly host+device in our CUDA implementation.


https://reviews.llvm.org/D25403



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


[PATCH] D25403: [CUDA] Mark __libcpp_{isnan, isinf, isfinite} as constexpr.

2016-10-18 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

In https://reviews.llvm.org/D25403#573104, @jlebar wrote:

> Likewise, should I update the documentation to indicate that check-cxx may 
> fail with a clang built from tip of tree, due to c++17 support being 
> experimental?  Or do you all want to change the target so that it doesn't run 
> the c++17 tests by default?  This burned about an hour of developer time 
> yesterday, I guess because we couldn't believe that check-cxx would be 
> intentionally broken like that, so it would be nice to have some sort of fix.


Yesterday and today is the first time in a while that clang has been seriously 
broken for more than an hour or so.
I'm not inclined to worry about it yet.

>> I don't see how this can possibly be constexpr.
>>  it calls isfinite(), which is hoisted from ::isfinite(), which comes from 
>> the C library.
>>  Since C knows nothing about constexpr, we're stuck.
> 
> Functions that call non-constexpr things can be marked constexpr; you just 
> can't evaluate them in a constexpr context (as you demonstrated).
> 
> All I need is for the function to be marked as constexpr; I do not need the 
> function be constexpr-evaluatable.

Then what's the point? How can you test if it is correct?

> I think the implications of this change would be that, if you evaluated this 
> function in a constexpr context, before the change would be a compile error 
> when calling __libcpp_isnan, and after this change it would be a compile 
> error at calling ::isnan.  Since the function should not be called outside of 
> libc++ anyway, I was hoping that wouldn't make a difference to anyone.

I guess I don't understand the motivation for this change.


https://reviews.llvm.org/D25403



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


[PATCH] D25621: DebugInfo: use uin32_t for alignment

2016-10-18 Thread Victor Leschuk via cfe-commits
vleschuk added a comment.

Can anyone take a look at this please? =)


https://reviews.llvm.org/D25621



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


[PATCH] D25741: [libc++] Add configuration define for off_t functions

2016-10-18 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

I like this; I would like to see no mentions of `_WIN32` outside of 
`<__config>`.
That being said, we usually write things in the negative in libc++.

So the flag would be `_LIBCPP_HAS_NO_OFF_T_FUNCTIONS`, and the tests would be 
`#ifdef _LIBCPP_HAS_NO_OFF_T_FUNCTIONS`


https://reviews.llvm.org/D25741



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


[PATCH] D25093: [libcxx] [cmake] Allow testing against installed LLVM with no sources

2016-10-18 Thread Chris Bieneman via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D25093



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


[PATCH] D22638: Module: add debug_type to dump debugging messages related to modules being out of date

2016-10-18 Thread Manman Ren via cfe-commits
manmanren added a comment.

Thanks a lot for the pointers!

I will definitely try them. What I proposed here is something similar to what 
llvm does that dumps logging messages, it should be complementary to your 
debugging aids.

Manman

In https://reviews.llvm.org/D22638#572753, @v.g.vassilev wrote:

> I am not sure whether that's useful for debugging out-of-date issues but this 
> is what I use and it is helpful.
>
> Some debugging aids (suggested by Richard Smith):
>
>   -fdiagnostics-show-note-include-stack will tell you which module a note 
> comes from
>   #pragma clang __debug dump X allows you to produce an AST dump from within 
> a source file, so you can see which modules declare a given name
>   #pragma clang __debug macro M allows you to dump a macro, which can be 
> useful to see which module(s) export visible include guards for a header
>   
>
> If a name is not visible in a modules build but is visible in a non-modules 
> build, i usually find that's due to one of two things
>
>   some part of the machinery that provides it depends on macro definitions 
> leaking into a modular header from outside, or
>   there is an include cycle involving a modular header and a non-modular 
> header



https://reviews.llvm.org/D22638



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


r284530 - Add missing warning for use of C++1z init-statements in C++14 and before.

2016-10-18 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Oct 18 15:27:16 2016
New Revision: 284530

URL: http://llvm.org/viewvc/llvm-project?rev=284530&view=rev
Log:
Add missing warning for use of C++1z init-statements in C++14 and before.

Added:
cfe/trunk/test/SemaCXX/warn-c++1z-extensions.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/ParseExprCXX.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=284530&r1=284529&r2=284530&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Tue Oct 18 15:27:16 
2016
@@ -521,6 +521,12 @@ def ext_constexpr_if : ExtWarn<
 def warn_cxx14_compat_constexpr_if : Warning<
   "constexpr if is incompatible with C++ standards before C++1z">,
   DefaultIgnore, InGroup;
+def ext_init_statement : ExtWarn<
+  "'%select{if|switch}0' initialization statements are a C++1z extension">,
+  InGroup;
+def warn_cxx14_compat_init_statement : Warning<
+  "%select{if|switch}0 initialization statements are incompatible with "
+  "C++ standards before C++1z">, DefaultIgnore, InGroup;
 
 // C++ derived classes
 def err_dup_virtual : Error<"duplicate 'virtual' in base specifier">;

Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=284530&r1=284529&r2=284530&view=diff
==
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Tue Oct 18 15:27:16 2016
@@ -1787,6 +1787,10 @@ Sema::ConditionResult Parser::ParseCXXCo
   }
 
   case ConditionOrInitStatement::InitStmtDecl: {
+Diag(Tok.getLocation(), getLangOpts().CPlusPlus1z
+? diag::warn_cxx14_compat_init_statement
+: diag::ext_init_statement)
+<< (CK == Sema::ConditionKind::Switch);
 SourceLocation DeclStart = Tok.getLocation(), DeclEnd;
 DeclGroupPtrTy DG = ParseSimpleDeclaration(
 Declarator::InitStmtContext, DeclEnd, attrs, /*RequireSemi=*/true);

Added: cfe/trunk/test/SemaCXX/warn-c++1z-extensions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-c%2B%2B1z-extensions.cpp?rev=284530&view=auto
==
--- cfe/trunk/test/SemaCXX/warn-c++1z-extensions.cpp (added)
+++ cfe/trunk/test/SemaCXX/warn-c++1z-extensions.cpp Tue Oct 18 15:27:16 2016
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
+
+void f() {
+  if (bool b = true; b) {} // expected-warning {{'if' initialization 
statements are a C++1z extension}}
+  switch (int n = 5; n) { // expected-warning {{'switch' initialization 
statements are a C++1z extension}}
+  case 5: break;
+  }
+}


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


[PATCH] D25747: [clang-tidy] Fix an assertion failure in cppcoreguidelines-pro-type-member-init.

2016-10-18 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: aaron.ballman.
hokein added a subscriber: cfe-commits.
Herald added a subscriber: nemanjai.

The matcher for matching "class with default constructor" still match
some classes without default constructor, which trigger an assert at
Line 307. This patch makes the matcher more strict.


https://reviews.llvm.org/D25747

Files:
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp


Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -450,3 +450,9 @@
   NegativeIncompleteArrayMember() {}
   char e[];
 };
+
+template  class NoCrash {
+  class B : public NoCrash {
+template  B(U u) {}
+  };
+};
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -27,6 +27,10 @@
 
 namespace {
 
+AST_MATCHER(CXXRecordDecl, hasDefaultConstructor) {
+  return Node.hasDefaultConstructor();
+}
+
 // Iterate over all the fields in a record type, both direct and indirect (e.g.
 // if the record contains an anonmyous struct). If OneFieldPerUnion is true and
 // the record type (or indirect field) is a union, forEachField will stop after
@@ -275,6 +279,7 @@
   Finder->addMatcher(
   cxxRecordDecl(
   isDefinition(), unless(isInstantiated()),
+  hasDefaultConstructor(),
   anyOf(has(cxxConstructorDecl(isDefaultConstructor(), isDefaulted(),
unless(isImplicit(,
 unless(has(cxxConstructorDecl(,


Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -450,3 +450,9 @@
   NegativeIncompleteArrayMember() {}
   char e[];
 };
+
+template  class NoCrash {
+  class B : public NoCrash {
+template  B(U u) {}
+  };
+};
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -27,6 +27,10 @@
 
 namespace {
 
+AST_MATCHER(CXXRecordDecl, hasDefaultConstructor) {
+  return Node.hasDefaultConstructor();
+}
+
 // Iterate over all the fields in a record type, both direct and indirect (e.g.
 // if the record contains an anonmyous struct). If OneFieldPerUnion is true and
 // the record type (or indirect field) is a union, forEachField will stop after
@@ -275,6 +279,7 @@
   Finder->addMatcher(
   cxxRecordDecl(
   isDefinition(), unless(isInstantiated()),
+  hasDefaultConstructor(),
   anyOf(has(cxxConstructorDecl(isDefaultConstructor(), isDefaulted(),
unless(isImplicit(,
 unless(has(cxxConstructorDecl(,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r284528 - [c++1z] Fix corner case where we could create a function type whose canonical type is not actually canonical.

2016-10-18 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Oct 18 15:13:25 2016
New Revision: 284528

URL: http://llvm.org/viewvc/llvm-project?rev=284528&view=rev
Log:
[c++1z] Fix corner case where we could create a function type whose canonical 
type is not actually canonical.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=284528&r1=284527&r2=284528&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Oct 18 15:13:25 2016
@@ -1224,8 +1224,17 @@ public:
 
   /// \brief Return a normal function type with a typed argument list.
   QualType getFunctionType(QualType ResultTy, ArrayRef Args,
-   const FunctionProtoType::ExtProtoInfo &EPI) const;
+   const FunctionProtoType::ExtProtoInfo &EPI) const {
+return getFunctionTypeInternal(ResultTy, Args, EPI, false);
+  }
 
+private:
+  /// \brief Return a normal function type with a typed argument list.
+  QualType getFunctionTypeInternal(QualType ResultTy, ArrayRef Args,
+   const FunctionProtoType::ExtProtoInfo &EPI,
+   bool OnlyWantCanonical) const;
+
+public:
   /// \brief Return the unique reference to the type for the specified type
   /// declaration.
   QualType getTypeDeclType(const TypeDecl *Decl,

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=284528&r1=284527&r2=284528&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Oct 18 15:13:25 2016
@@ -3167,9 +3167,9 @@ static bool isCanonicalExceptionSpecific
   return false;
 }
 
-QualType
-ASTContext::getFunctionType(QualType ResultTy, ArrayRef ArgArray,
-const FunctionProtoType::ExtProtoInfo &EPI) const {
+QualType ASTContext::getFunctionTypeInternal(
+QualType ResultTy, ArrayRef ArgArray,
+const FunctionProtoType::ExtProtoInfo &EPI, bool OnlyWantCanonical) const {
   size_t NumArgs = ArgArray.size();
 
   // Unique functions, to guarantee there is only one function of a particular
@@ -3188,9 +3188,10 @@ ASTContext::getFunctionType(QualType Res
 
 // If we find a pre-existing equivalent FunctionProtoType, we can just 
reuse
 // it so long as our exception specification doesn't contain a dependent
-// noexcept expression. If it /does/, we're going to need to create a type
+// noexcept expression, or we're just looking for a canonical type.
+// Otherwise, we're going to need to create a type
 // sugar node to hold the concrete expression.
-if (EPI.ExceptionSpec.Type != EST_ComputedNoexcept ||
+if (OnlyWantCanonical || EPI.ExceptionSpec.Type != EST_ComputedNoexcept ||
 EPI.ExceptionSpec.NoexceptExpr == FPT->getNoexceptExpr())
   return Existing;
 
@@ -3212,6 +3213,10 @@ ASTContext::getFunctionType(QualType Res
 if (!ArgArray[i].isCanonicalAsParam())
   isCanonical = false;
 
+  if (OnlyWantCanonical)
+assert(isCanonical &&
+   "given non-canonical parameters constructing canonical type");
+
   // If this type isn't canonical, get the canonical version of it if we don't
   // already have it. The exception spec is only partially part of the
   // canonical type, and only in C++17 onwards.
@@ -3274,15 +3279,14 @@ ASTContext::getFunctionType(QualType Res
 Value.getBoolValue() ? EST_BasicNoexcept : EST_None;
 break;
   }
-  assert(isCanonicalExceptionSpecification(CanonicalEPI.ExceptionSpec,
-   NoexceptInType));
 } else {
   CanonicalEPI.ExceptionSpec = FunctionProtoType::ExceptionSpecInfo();
 }
 
 // Adjust the canonical function result type.
 CanQualType CanResultTy = getCanonicalFunctionResultType(ResultTy);
-Canonical = getFunctionType(CanResultTy, CanonicalArgs, CanonicalEPI);
+Canonical =
+getFunctionTypeInternal(CanResultTy, CanonicalArgs, CanonicalEPI, 
true);
 
 // Get the new insert position for the node we care about.
 FunctionProtoType *NewIP =

Modified: cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp?rev=284528&r1=284527&r2=284528&view=diff
==
--- cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp Tue Oct 18 15:13:25 
2016
@@ -12,6 +12,10 @@ template void redecl2()
 template void

r284519 - When two function types have equivalent (but distinct) noexcept specifications, create separate type sugar nodes. This is necessary so that substitution into the exception specification will

2016-10-18 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Oct 18 14:29:18 2016
New Revision: 284519

URL: http://llvm.org/viewvc/llvm-project?rev=284519&view=rev
Log:
When two function types have equivalent (but distinct) noexcept specifications, 
create separate type sugar nodes. This is necessary so that substitution into 
the exception specification will substitute into the correct expression.

Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp
cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=284519&r1=284518&r2=284519&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Oct 18 14:29:18 2016
@@ -3150,15 +3150,17 @@ static bool isCanonicalExceptionSpecific
 return true;
 
   // A dynamic exception specification is canonical if it only contains pack
-  // expansions (so we can't tell whether it's non-throwing).
+  // expansions (so we can't tell whether it's non-throwing) and all its
+  // contained types are canonical.
   if (ESI.Type == EST_Dynamic) {
 for (QualType ET : ESI.Exceptions)
-  if (!ET->getAs())
+  if (!ET.isCanonical() || !ET->getAs())
 return false;
 return true;
   }
 
-  // A noexcept(expr) specification is canonical if expr is value-dependent.
+  // A noexcept(expr) specification is (possibly) canonical if expr is
+  // value-dependent.
   if (ESI.Type == EST_ComputedNoexcept)
 return ESI.NoexceptExpr && ESI.NoexceptExpr->isValueDependent();
 
@@ -3170,33 +3172,50 @@ ASTContext::getFunctionType(QualType Res
 const FunctionProtoType::ExtProtoInfo &EPI) const {
   size_t NumArgs = ArgArray.size();
 
-  bool NoexceptInType = getLangOpts().CPlusPlus1z;
+  // Unique functions, to guarantee there is only one function of a particular
+  // structure.
+  llvm::FoldingSetNodeID ID;
+  FunctionProtoType::Profile(ID, ResultTy, ArgArray.begin(), NumArgs, EPI,
+ *this, true);
+
+  QualType Canonical;
+  bool Unique = false;
 
+  void *InsertPos = nullptr;
+  if (FunctionProtoType *FPT =
+FunctionProtoTypes.FindNodeOrInsertPos(ID, InsertPos)) {
+QualType Existing = QualType(FPT, 0);
+
+// If we find a pre-existing equivalent FunctionProtoType, we can just 
reuse
+// it so long as our exception specification doesn't contain a dependent
+// noexcept expression. If it /does/, we're going to need to create a type
+// sugar node to hold the concrete expression.
+if (EPI.ExceptionSpec.Type != EST_ComputedNoexcept ||
+EPI.ExceptionSpec.NoexceptExpr == FPT->getNoexceptExpr())
+  return Existing;
+
+// We need a new type sugar node for this one, to hold the new noexcept
+// expression. We do no canonicalization here, but that's OK since we don't
+// expect to see the same noexcept expression much more than once.
+Canonical = getCanonicalType(Existing);
+Unique = true;
+  }
+
+  bool NoexceptInType = getLangOpts().CPlusPlus1z;
   bool IsCanonicalExceptionSpec =
   isCanonicalExceptionSpecification(EPI.ExceptionSpec, NoexceptInType);
 
   // Determine whether the type being created is already canonical or not.
-  bool isCanonical = IsCanonicalExceptionSpec &&
+  bool isCanonical = !Unique && IsCanonicalExceptionSpec &&
  isCanonicalResultType(ResultTy) && !EPI.HasTrailingReturn;
   for (unsigned i = 0; i != NumArgs && isCanonical; ++i)
 if (!ArgArray[i].isCanonicalAsParam())
   isCanonical = false;
 
-  // Unique functions, to guarantee there is only one function of a particular
-  // structure.
-  llvm::FoldingSetNodeID ID;
-  FunctionProtoType::Profile(ID, ResultTy, ArgArray.begin(), NumArgs, EPI,
- *this, isCanonical);
-
-  void *InsertPos = nullptr;
-  if (FunctionProtoType *FTP =
-FunctionProtoTypes.FindNodeOrInsertPos(ID, InsertPos))
-return QualType(FTP, 0);
-
-  // If this type isn't canonical, get the canonical version of it.
-  // The exception spec is not part of the canonical type.
-  QualType Canonical;
-  if (!isCanonical) {
+  // If this type isn't canonical, get the canonical version of it if we don't
+  // already have it. The exception spec is only partially part of the
+  // canonical type, and only in C++17 onwards.
+  if (!isCanonical && Canonical.isNull()) {
 SmallVector CanonicalArgs;
 CanonicalArgs.reserve(NumArgs);
 for (unsigned i = 0; i != NumArgs; ++i)
@@ -3208,17 +3227,34 @@ ASTContext::getFunctionType(QualType Res
 if (IsCanonicalExceptionSpec) {
   // Exception spec is already OK.
 } else if (NoexceptInType) {
+  llvm::SmallVector ExceptionTypeStorage;
   switch (EPI.ExceptionSpec.Type) {
   case EST_Unparsed: case EST_Unevaluated: case EST_Uninstantia

r284517 - Fix clang tests

2016-10-18 Thread Mandeep Singh Grang via cfe-commits
Author: mgrang
Date: Tue Oct 18 14:22:20 2016
New Revision: 284517

URL: http://llvm.org/viewvc/llvm-project?rev=284517&view=rev
Log:
Fix clang tests

Summary:
Add REQUIRES for target specific tests.

Patch by Azharuddin Mohammed.

Reviewers: apazos, weimingz, rsmith, ddunbar, spop, mgrang

Subscribers: sebpop, llvm-commits

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

Modified:
cfe/trunk/test/Driver/mips-cs.cpp
cfe/trunk/test/Driver/mips-fsf.cpp
cfe/trunk/test/Driver/mips-img-v2.cpp
cfe/trunk/test/Driver/mips-img.cpp
cfe/trunk/test/Driver/sysroot.c

Modified: cfe/trunk/test/Driver/mips-cs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-cs.cpp?rev=284517&r1=284516&r2=284517&view=diff
==
--- cfe/trunk/test/Driver/mips-cs.cpp (original)
+++ cfe/trunk/test/Driver/mips-cs.cpp Tue Oct 18 14:22:20 2016
@@ -1,3 +1,5 @@
+// REQUIRES: mips-registered-target
+//
 // Check frontend and linker invocations on Mentor Graphics MIPS toolchain.
 //
 // = Big-endian, hard float

Modified: cfe/trunk/test/Driver/mips-fsf.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-fsf.cpp?rev=284517&r1=284516&r2=284517&view=diff
==
--- cfe/trunk/test/Driver/mips-fsf.cpp (original)
+++ cfe/trunk/test/Driver/mips-fsf.cpp Tue Oct 18 14:22:20 2016
@@ -1,3 +1,5 @@
+// REQUIRES: mips-registered-target
+
 // Check frontend and linker invocations on FSF MIPS toolchain.
 //
 // = Big-endian, mips32, hard float

Modified: cfe/trunk/test/Driver/mips-img-v2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-img-v2.cpp?rev=284517&r1=284516&r2=284517&view=diff
==
--- cfe/trunk/test/Driver/mips-img-v2.cpp (original)
+++ cfe/trunk/test/Driver/mips-img-v2.cpp Tue Oct 18 14:22:20 2016
@@ -1,3 +1,5 @@
+// REQUIRES: mips-registered-target
+
 // Check frontend and linker invocations on the IMG v2 MIPS toolchain.
 
 // -EB -mips32r6 -mhard-float -mabi=32

Modified: cfe/trunk/test/Driver/mips-img.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-img.cpp?rev=284517&r1=284516&r2=284517&view=diff
==
--- cfe/trunk/test/Driver/mips-img.cpp (original)
+++ cfe/trunk/test/Driver/mips-img.cpp Tue Oct 18 14:22:20 2016
@@ -1,3 +1,5 @@
+// REQUIRES: mips-registered-target
+
 // Check frontend and linker invocations on the IMG MIPS toolchain.
 //
 // = Big-endian, mips32r6

Modified: cfe/trunk/test/Driver/sysroot.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/sysroot.c?rev=284517&r1=284516&r2=284517&view=diff
==
--- cfe/trunk/test/Driver/sysroot.c (original)
+++ cfe/trunk/test/Driver/sysroot.c Tue Oct 18 14:22:20 2016
@@ -1,3 +1,5 @@
+// REQUIRES: x86-registered-target
+//
 // Check that --sysroot= also applies to header search paths.
 // RUN: %clang -target i386-unk-unk --sysroot=/FOO -### -E %s 2> %t1
 // RUN: FileCheck --check-prefix=CHECK-SYSROOTEQ < %t1 %s


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


[PATCH] D25547: [CodeGen][ObjC] Do not emit objc_storeStrong to initialize a constexpr variable

2016-10-18 Thread Akira Hatanaka via cfe-commits
This revision was automatically updated to reflect the committed changes.
ahatanak marked 2 inline comments as done.
Closed by commit rL284516: [CodeGen][ObjC] Do not call objc_storeStrong when 
initializing a (authored by ahatanak).

Changed prior to commit:
  https://reviews.llvm.org/D25547?vs=74944&id=75053#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25547

Files:
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CGObjC.cpp
  cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/test/CodeGenObjCXX/arc-constexpr.mm

Index: cfe/trunk/test/CodeGenObjCXX/arc-constexpr.mm
===
--- cfe/trunk/test/CodeGenObjCXX/arc-constexpr.mm
+++ cfe/trunk/test/CodeGenObjCXX/arc-constexpr.mm
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -o - -std=c++11 %s | FileCheck %s
+
+// CHECK: %[[TYPE:[a-z0-9]+]] = type opaque
+// CHECK: @[[CFSTRING:[a-z0-9_]+]] = private global %struct.__NSConstantString_tag
+
+// CHECK: define void @_Z5test1v
+// CHECK:   %[[ALLOCA:[A-Z]+]] = alloca %[[TYPE]]*
+// CHECK:   %[[V0:[0-9]+]] = call i8* @objc_retain(i8* bitcast (%struct.__NSConstantString_tag* @[[CFSTRING]]
+// CHECK:   %[[V1:[0-9]+]] = bitcast i8* %[[V0]] to %[[TYPE]]*
+// CHECK:   store %[[TYPE]]* %[[V1]], %[[TYPE]]** %[[ALLOCA]]
+// CHECK:   %[[V2:[0-9]+]] = bitcast %[[TYPE]]** %[[ALLOCA]]
+// CHECK:   call void @objc_storeStrong(i8** %[[V2]], i8* null)
+
+@class NSString;
+
+void test1() {
+  constexpr NSString *S = @"abc";
+}
Index: cfe/trunk/lib/CodeGen/CGDecl.cpp
===
--- cfe/trunk/lib/CodeGen/CGDecl.cpp
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp
@@ -774,37 +774,6 @@
   EmitStoreOfScalar(value, lvalue, /* isInitialization */ true);
 }
 
-/// EmitScalarInit - Initialize the given lvalue with the given object.
-void CodeGenFunction::EmitScalarInit(llvm::Value *init, LValue lvalue) {
-  Qualifiers::ObjCLifetime lifetime = lvalue.getObjCLifetime();
-  if (!lifetime)
-return EmitStoreThroughLValue(RValue::get(init), lvalue, true);
-
-  switch (lifetime) {
-  case Qualifiers::OCL_None:
-llvm_unreachable("present but none");
-
-  case Qualifiers::OCL_ExplicitNone:
-// nothing to do
-break;
-
-  case Qualifiers::OCL_Strong:
-init = EmitARCRetain(lvalue.getType(), init);
-break;
-
-  case Qualifiers::OCL_Weak:
-// Initialize and then skip the primitive store.
-EmitARCInitWeak(lvalue.getAddress(), init);
-return;
-
-  case Qualifiers::OCL_Autoreleasing:
-init = EmitARCRetainAutorelease(lvalue.getType(), init);
-break;
-  }
-
-  EmitStoreOfScalar(init, lvalue, /* isInitialization */ true);
-}
-
 /// canEmitInitWithFewStoresAfterMemset - Decide whether we can emit the
 /// non-zero parts of the specified initializer with equal or fewer than
 /// NumStores scalar stores.
Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -1629,11 +1629,19 @@
   break;
 
 case Qualifiers::OCL_Strong:
+  if (isInit) {
+Src = RValue::get(EmitARCRetain(Dst.getType(), Src.getScalarVal()));
+break;
+  }
   EmitARCStoreStrong(Dst, Src.getScalarVal(), /*ignore*/ true);
   return;
 
 case Qualifiers::OCL_Weak:
-  EmitARCStoreWeak(Dst.getAddress(), Src.getScalarVal(), /*ignore*/ true);
+  if (isInit)
+// Initialize and then skip the primitive store.
+EmitARCInitWeak(Dst.getAddress(), Src.getScalarVal());
+  else
+EmitARCStoreWeak(Dst.getAddress(), Src.getScalarVal(), /*ignore*/ true);
   return;
 
 case Qualifiers::OCL_Autoreleasing:
Index: cfe/trunk/lib/CodeGen/CGObjC.cpp
===
--- cfe/trunk/lib/CodeGen/CGObjC.cpp
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp
@@ -1662,7 +1662,8 @@
 elementLValue = EmitLValue(cast(S.getElement()));
 EmitStoreThroughLValue(RValue::get(CurrentItem), elementLValue);
   } else {
-EmitScalarInit(CurrentItem, elementLValue);
+EmitStoreThroughLValue(RValue::get(CurrentItem), elementLValue,
+   /*isInit*/ true);
   }
 
   // If we do have an element variable, this assignment is the end of
Index: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
===
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
@@ -188,7 +188,7 @@
 auto *RefVal = TmpAddr.getPointer();
 TmpAddr = CGF.CreateMemTemp(RefType, Twine(Name) + ".ref");
 auto TmpLVal = CGF.MakeAddrLValue(TmpAddr, RefType);
-CGF.EmitScalarInit(RefVal, TmpLVal);
+CGF.EmitStoreThroughLValue(RValue::get(RefVal), TmpLVal, /*isInit*/ true);
   }
 
   return TmpAddr;
@@ -2192,7 +2192,7 @@
 

r284516 - [CodeGen][ObjC] Do not call objc_storeStrong when initializing a

2016-10-18 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Tue Oct 18 14:05:41 2016
New Revision: 284516

URL: http://llvm.org/viewvc/llvm-project?rev=284516&view=rev
Log:
[CodeGen][ObjC] Do not call objc_storeStrong when initializing a
constexpr variable.

When compiling a constexpr NSString initialized with an objective-c
string literal, CodeGen emits objc_storeStrong on an uninitialized
alloca, which causes a crash.

This patch folds the code in EmitScalarInit into EmitStoreThroughLValue
and fixes the crash by calling objc_retain on the string instead of
using objc_storeStrong.

rdar://problem/28562009

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

Added:
cfe/trunk/test/CodeGenObjCXX/arc-constexpr.mm
Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=284516&r1=284515&r2=284516&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Tue Oct 18 14:05:41 2016
@@ -774,37 +774,6 @@ void CodeGenFunction::EmitScalarInit(con
   EmitStoreOfScalar(value, lvalue, /* isInitialization */ true);
 }
 
-/// EmitScalarInit - Initialize the given lvalue with the given object.
-void CodeGenFunction::EmitScalarInit(llvm::Value *init, LValue lvalue) {
-  Qualifiers::ObjCLifetime lifetime = lvalue.getObjCLifetime();
-  if (!lifetime)
-return EmitStoreThroughLValue(RValue::get(init), lvalue, true);
-
-  switch (lifetime) {
-  case Qualifiers::OCL_None:
-llvm_unreachable("present but none");
-
-  case Qualifiers::OCL_ExplicitNone:
-// nothing to do
-break;
-
-  case Qualifiers::OCL_Strong:
-init = EmitARCRetain(lvalue.getType(), init);
-break;
-
-  case Qualifiers::OCL_Weak:
-// Initialize and then skip the primitive store.
-EmitARCInitWeak(lvalue.getAddress(), init);
-return;
-
-  case Qualifiers::OCL_Autoreleasing:
-init = EmitARCRetainAutorelease(lvalue.getType(), init);
-break;
-  }
-
-  EmitStoreOfScalar(init, lvalue, /* isInitialization */ true);
-}
-
 /// canEmitInitWithFewStoresAfterMemset - Decide whether we can emit the
 /// non-zero parts of the specified initializer with equal or fewer than
 /// NumStores scalar stores.

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=284516&r1=284515&r2=284516&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Oct 18 14:05:41 2016
@@ -1629,11 +1629,19 @@ void CodeGenFunction::EmitStoreThroughLV
   break;
 
 case Qualifiers::OCL_Strong:
+  if (isInit) {
+Src = RValue::get(EmitARCRetain(Dst.getType(), Src.getScalarVal()));
+break;
+  }
   EmitARCStoreStrong(Dst, Src.getScalarVal(), /*ignore*/ true);
   return;
 
 case Qualifiers::OCL_Weak:
-  EmitARCStoreWeak(Dst.getAddress(), Src.getScalarVal(), /*ignore*/ true);
+  if (isInit)
+// Initialize and then skip the primitive store.
+EmitARCInitWeak(Dst.getAddress(), Src.getScalarVal());
+  else
+EmitARCStoreWeak(Dst.getAddress(), Src.getScalarVal(), /*ignore*/ 
true);
   return;
 
 case Qualifiers::OCL_Autoreleasing:

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=284516&r1=284515&r2=284516&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Tue Oct 18 14:05:41 2016
@@ -1662,7 +1662,8 @@ void CodeGenFunction::EmitObjCForCollect
 elementLValue = EmitLValue(cast(S.getElement()));
 EmitStoreThroughLValue(RValue::get(CurrentItem), elementLValue);
   } else {
-EmitScalarInit(CurrentItem, elementLValue);
+EmitStoreThroughLValue(RValue::get(CurrentItem), elementLValue,
+   /*isInit*/ true);
   }
 
   // If we do have an element variable, this assignment is the end of

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=284516&r1=284515&r2=284516&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Tue Oct 18 14:05:41 2016
@@ -188,7 +188,7 @@ static Address castValueFromUintptr(Code
 auto *RefVal = TmpAddr.getPointer();
 TmpAddr = CGF.CreateMemTemp(RefType, Twine(Name) + ".ref");
 auto TmpLVal = CGF.MakeAddrLValue(TmpAddr, RefType);
-CGF.EmitScalarInit(RefVal, TmpLVal);
+CGF.EmitStoreTh

[PATCH] D25731: [analyzer] NumberObjectConversion: Support CFNumberRef.

2016-10-18 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp:72
   assert(Conv);
-  const Expr *Osboolean = Result.Nodes.getNodeAs("osboolean");
-  const Expr *Nsnumber = Result.Nodes.getNodeAs("nsnumber");
-  bool IsObjC = (bool)Nsnumber;
-  const Expr *Obj = IsObjC ? Nsnumber : Osboolean;
+  const Expr *CObject = Result.Nodes.getNodeAs("c_object");
+  const Expr *CppObject = Result.Nodes.getNodeAs("cpp_object");

I'd keep the names more specific. By reading this code alone it looks like you 
are just checking for **any** ObjC object.



Comment at: lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp:111
+  QualType ObjT = (IsCpp || IsObjC)
+  ? Obj->getType().getCanonicalType().getUnqualifiedType()
+  : Obj->getType();

Why do we need a case split here? Would calling 
getCanonicalType().getUnqualifiedType() result in a wrong result for ObjC?



Comment at: lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp:129
+} else if (IsCpp) {
   OS << "; please compare the pointer to NULL or nullptr instead "
 "to suppress this warning";

Let's just recommend `nullptr` for C++, but allow both `NULL` and `nullptr`.



Comment at: lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp:152
 
-  auto OSBooleanExprM =
+  auto SuspiciousCExprM =
+  expr(ignoringParenImpCasts(

Please, use more a expressive name. I'd prefer a super long name if it's more 
expressive.



Comment at: test/Analysis/number-object-conversion.c:14
+  if (p) {} // expected-warning{{Converting 'CFNumberRef' to a plain boolean 
value for branching; please compare the pointer to NULL instead to suppress 
this warning}}
+  if (!p) {} // expected-warning{{Converting 'CFNumberRef' to a plain boolean 
value for branching; please compare the pointer to NULL instead to suppress 
this warning}}
+  p ? 1 : 2; // expected-warning{{Converting 'CFNumberRef' to a plain boolean 
value for branching; please compare the pointer to NULL instead to suppress 
this warning}}

How about:
"Converting 'CFNumberRef' pointer to a plain boolean value; instead, compare 
the pointer to NULL or compare to the encapsulated scalar value"

- I've added "pointer".
- I would remove "for branching". Does it add anything?
- Also, we should remove "please" as it makes the warning text longer.



https://reviews.llvm.org/D25731



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


r284510 - Drop a redundant ".get()" call (NFC)

2016-10-18 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Tue Oct 18 13:19:02 2016
New Revision: 284510

URL: http://llvm.org/viewvc/llvm-project?rev=284510&view=rev
Log:
Drop a redundant ".get()" call (NFC)

Pointed out by Malcolm Parsons.

Modified:
cfe/trunk/lib/Basic/SourceManager.cpp

Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=284510&r1=284509&r2=284510&view=diff
==
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Tue Oct 18 13:19:02 2016
@@ -1938,7 +1938,7 @@ SourceManager::getMacroArgExpandedLocati
   std::unique_ptr &MacroArgsCache = MacroArgsCacheMap[FID];
   if (!MacroArgsCache) {
 MacroArgsCache = llvm::make_unique();
-computeMacroArgsCache(*MacroArgsCache.get(), FID);
+computeMacroArgsCache(*MacroArgsCache, FID);
   }
 
   assert(!MacroArgsCache->empty());


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


[PATCH] D25741: [libc++] Add configuration define for off_t functions

2016-10-18 Thread Shoaib Meenai via cfe-commits
smeenai created this revision.
smeenai added reviewers: EricWF, mclow.lists.
smeenai added a subscriber: cfe-commits.

Create this define in __config and use it elsewhere, instead of checking
the operating system/library defines in other files. The aim is to
reduce the usage of _WIN32 outside __config. No functional change.


https://reviews.llvm.org/D25741

Files:
  include/__config
  include/fstream


Index: include/fstream
===
--- include/fstream
+++ include/fstream
@@ -813,7 +813,7 @@
 default:
 return pos_type(off_type(-1));
 }
-#if defined(_WIN32) || defined(_NEWLIB_VERSION)
+#if !defined(_LIBCPP_HAS_OFF_T_FUNCTIONS)
 if (fseek(__file_, __width > 0 ? __width * __off : 0, __whence))
 return pos_type(off_type(-1));
 pos_type __r = ftell(__file_);
@@ -832,7 +832,7 @@
 {
 if (__file_ == 0 || sync())
 return pos_type(off_type(-1));
-#if defined(_WIN32) || defined(_NEWLIB_VERSION)
+#if !defined(_LIBCPP_HAS_OFF_T_FUNCTIONS)
 if (fseek(__file_, __sp, SEEK_SET))
 return pos_type(off_type(-1));
 #else
@@ -896,7 +896,7 @@
 }
 }
 }
-#if defined(_WIN32) || defined(_NEWLIB_VERSION)
+#if !defined(_LIBCPP_HAS_OFF_T_FUNCTIONS)
 if (fseek(__file_, -__c, SEEK_CUR))
 return -1;
 #else
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -908,6 +908,12 @@
 #define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
 #endif
 
+#if !defined(_LIBCPP_HAS_OFF_T_FUNCTIONS)
+#if !(defined(_WIN32) || defined(_NEWLIB_VERSION))
+#define _LIBCPP_HAS_OFF_T_FUNCTIONS
+#endif
+#endif
+
 #endif // __cplusplus
 
 #endif // _LIBCPP_CONFIG


Index: include/fstream
===
--- include/fstream
+++ include/fstream
@@ -813,7 +813,7 @@
 default:
 return pos_type(off_type(-1));
 }
-#if defined(_WIN32) || defined(_NEWLIB_VERSION)
+#if !defined(_LIBCPP_HAS_OFF_T_FUNCTIONS)
 if (fseek(__file_, __width > 0 ? __width * __off : 0, __whence))
 return pos_type(off_type(-1));
 pos_type __r = ftell(__file_);
@@ -832,7 +832,7 @@
 {
 if (__file_ == 0 || sync())
 return pos_type(off_type(-1));
-#if defined(_WIN32) || defined(_NEWLIB_VERSION)
+#if !defined(_LIBCPP_HAS_OFF_T_FUNCTIONS)
 if (fseek(__file_, __sp, SEEK_SET))
 return pos_type(off_type(-1));
 #else
@@ -896,7 +896,7 @@
 }
 }
 }
-#if defined(_WIN32) || defined(_NEWLIB_VERSION)
+#if !defined(_LIBCPP_HAS_OFF_T_FUNCTIONS)
 if (fseek(__file_, -__c, SEEK_CUR))
 return -1;
 #else
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -908,6 +908,12 @@
 #define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
 #endif
 
+#if !defined(_LIBCPP_HAS_OFF_T_FUNCTIONS)
+#if !(defined(_WIN32) || defined(_NEWLIB_VERSION))
+#define _LIBCPP_HAS_OFF_T_FUNCTIONS
+#endif
+#endif
+
 #endif // __cplusplus
 
 #endif // _LIBCPP_CONFIG
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25678: [modules] Do not report missing definitions of demoted constexpr variable templates.This is a followup to regression introduced in r284284.This should fix our libstdc++ modules builds.

2016-10-18 Thread Vassil Vassilev via cfe-commits
v.g.vassilev updated this revision to Diff 75050.
v.g.vassilev marked an inline comment as done.
v.g.vassilev added a comment.

Remove assert.


https://reviews.llvm.org/D25678

Files:
  lib/Sema/SemaDecl.cpp
  test/Modules/Inputs/merge-var-template-def/a.h
  test/Modules/Inputs/merge-var-template-def/b1.h
  test/Modules/Inputs/merge-var-template-def/b2.h
  test/Modules/merge-var-template-def.cpp


Index: test/Modules/merge-var-template-def.cpp
===
--- test/Modules/merge-var-template-def.cpp
+++ test/Modules/merge-var-template-def.cpp
@@ -1,7 +1,10 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -verify -fmodules 
-Werror=undefined-internal -fmodules-local-submodule-visibility 
-fmodules-cache-path=%t -fimplicit-module-maps %s
+// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify %s
+// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify 
-fmodules -Werror=undefined-internal -fmodules-local-submodule-visibility 
-fmodules-cache-path=%t -fimplicit-module-maps %s
 // expected-no-diagnostics
 
 #include "b2.h"
 namespace { struct X; }
 void *x = get();
+
+const bool *y = &S::value;
Index: test/Modules/Inputs/merge-var-template-def/b2.h
===
--- test/Modules/Inputs/merge-var-template-def/b2.h
+++ test/Modules/Inputs/merge-var-template-def/b2.h
@@ -3,4 +3,10 @@
 template struct A { static bool b; };
 template bool A::b = false;
 template void *get() { return &(A::b); }
+
+template
+struct S { static constexpr T value = v; };
+template
+constexpr T S::value;
+
 #endif
Index: test/Modules/Inputs/merge-var-template-def/b1.h
===
--- test/Modules/Inputs/merge-var-template-def/b1.h
+++ test/Modules/Inputs/merge-var-template-def/b1.h
@@ -3,5 +3,11 @@
 template struct A { static bool b; };
 template bool A::b = false;
 template void *get() { return &(A::b); }
+
+template
+struct S { static constexpr T value = v; };
+template
+constexpr T S::value;
+
 #include "a.h"
 #endif
Index: test/Modules/Inputs/merge-var-template-def/a.h
===
--- test/Modules/Inputs/merge-var-template-def/a.h
+++ test/Modules/Inputs/merge-var-template-def/a.h
@@ -3,4 +3,10 @@
 template struct A { static bool b; };
 template bool A::b = false;
 template void *get() { return &(A::b); }
+
+template
+struct S { static constexpr T value = v; };
+template
+constexpr T S::value;
+
 #endif
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -10124,7 +10124,8 @@
 // C++11 [dcl.constexpr]p1: The constexpr specifier shall be applied only 
to
 // the definition of a variable [...] or the declaration of a static data
 // member.
-if (Var->isConstexpr() && !Var->isThisDeclarationADefinition()) {
+if (Var->isConstexpr() && !Var->isThisDeclarationADefinition() &&
+!Var->isThisDeclarationADemotedDefinition()) {
   if (Var->isStaticDataMember()) {
 // C++1z removes the relevant rule; the in-class declaration is always
 // a definition there.


Index: test/Modules/merge-var-template-def.cpp
===
--- test/Modules/merge-var-template-def.cpp
+++ test/Modules/merge-var-template-def.cpp
@@ -1,7 +1,10 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -verify -fmodules -Werror=undefined-internal -fmodules-local-submodule-visibility -fmodules-cache-path=%t -fimplicit-module-maps %s
+// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify %s
+// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify -fmodules -Werror=undefined-internal -fmodules-local-submodule-visibility -fmodules-cache-path=%t -fimplicit-module-maps %s
 // expected-no-diagnostics
 
 #include "b2.h"
 namespace { struct X; }
 void *x = get();
+
+const bool *y = &S::value;
Index: test/Modules/Inputs/merge-var-template-def/b2.h
===
--- test/Modules/Inputs/merge-var-template-def/b2.h
+++ test/Modules/Inputs/merge-var-template-def/b2.h
@@ -3,4 +3,10 @@
 template struct A { static bool b; };
 template bool A::b = false;
 template void *get() { return &(A::b); }
+
+template
+struct S { static constexpr T value = v; };
+template
+constexpr T S::value;
+
 #endif
Index: test/Modules/Inputs/merge-var-template-def/b1.h
===
--- test/Modules/Inputs/merge-var-template-def/b1.h
+++ test/Modules/Inputs/merge-var-template-def/b1.h
@@ -3,5 +3,11 @@
 template struct A { static bool b; };
 template bool A::b = false;
 template void *get() { return &(A::b); }
+
+template
+struct S { static constexpr T value = v; };
+templat

Re: Fwd: r198063 - Warn on mismatched parentheses in memcmp and friends.

2016-10-18 Thread Richard Smith via cfe-commits
On Tue, Oct 18, 2016 at 9:31 AM, Nico Weber  wrote:

> Did you find real-world code triggering this, or did you happen to see the
> implementation of the warning? I'm not sure if omitting just the note or
> the whole warning is more useful in practice. Intuitively I'd say that
> people "never" will compare the result of memcpy, so I'd guess that it
> doesn't matter much what we pick and omitting the warning completely is
> fine, but I'm not sure.
>
I found this when implementing core issue 1512, under which the suggested
"fixed" code doesn't compile any more.


> On Oct 17, 2016 1:44 PM, "Richard Smith"  wrote:
>
>> [Re-send to correct addresses.]
>>
>> On Thu, Dec 26, 2013 at 3:38 PM, Nico Weber  wrote:
>>
>>> Author: nico
>>> Date: Thu Dec 26 17:38:39 2013
>>> New Revision: 198063
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=198063&view=rev
>>> Log:
>>> Warn on mismatched parentheses in memcmp and friends.
>>>
>>> Thisadds a new warning that warns on code like this:
>>>
>>>   if (memcmp(a, b, sizeof(a) != 0))
>>>
>>> The warning looks like:
>>>
>>> test4.cc:5:30: warning: size argument in 'memcmp' call is a comparison
>>> [-Wmemsize-comparison]
>>>   if (memcmp(a, b, sizeof(a) != 0))
>>>~~^~~~
>>> test4.cc:5:7: note: did you mean to compare the result of 'memcmp'
>>> instead?
>>>   if (memcmp(a, b, sizeof(a) != 0))
>>>   ^  ~
>>> )
>>> test4.cc:5:20: note: explicitly cast the argument to size_t to silence
>>> this warning
>>>   if (memcmp(a, b, sizeof(a) != 0))
>>>^
>>>(size_t)( )
>>> 1 warning generated.
>>>
>>> This found 2 bugs in chromium and has 0 false positives on both chromium
>>> and
>>> llvm.
>>>
>>> The idea of triggering this warning on a binop in the size argument is
>>> due to
>>> rnk.
>>>
>>>
>>> Added:
>>> cfe/trunk/test/SemaCXX/warn-memsize-comparison.cpp
>>> Modified:
>>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>> cfe/trunk/lib/Sema/SemaChecking.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>>> Basic/DiagnosticSemaKinds.td?rev=198063&r1=198062&r2=198063&view=diff
>>> 
>>> ==
>>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Dec 26
>>> 17:38:39 2013
>>> @@ -390,11 +390,18 @@ def warn_sizeof_pointer_type_memaccess :
>>>"%select{destination|source}2; expected %3 or an explicit length">,
>>>InGroup;
>>>  def warn_strlcpycat_wrong_size : Warning<
>>> -  "size argument in %0 call appears to be size of the source; expected
>>> the size of "
>>> -  "the destination">,
>>> +  "size argument in %0 call appears to be size of the source; "
>>> +  "expected the size of the destination">,
>>>InGroup>;
>>>  def note_strlcpycat_wrong_size : Note<
>>>"change size argument to be the size of the destination">;
>>> +def warn_memsize_comparison : Warning<
>>> +  "size argument in %0 call is a comparison">,
>>> +  InGroup>;
>>> +def warn_memsize_comparison_paren_note : Note<
>>> +  "did you mean to compare the result of %0 instead?">;
>>> +def warn_memsize_comparison_cast_note : Note<
>>> +  "explicitly cast the argument to size_t to silence this warning">;
>>>
>>>  def warn_strncat_large_size : Warning<
>>>"the value of the size argument in 'strncat' is too large, might lead
>>> to a "
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaC
>>> hecking.cpp?rev=198063&r1=198062&r2=198063&view=diff
>>> 
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Dec 26 17:38:39 2013
>>> @@ -622,7 +622,7 @@ bool Sema::CheckARMBuiltinFunctionCall(u
>>>   RHS.get(), AA_Assigning))
>>>return true;
>>>}
>>> -
>>> +
>>>// For NEON intrinsics which take an immediate value as part of the
>>>// instruction, range check them here.
>>>unsigned i = 0, l = 0, u = 0;
>>> @@ -3560,6 +3560,40 @@ void Sema::CheckFormatString(const Strin
>>>
>>>  //===--- CHECK: Standard memory functions --
>>> ---===//
>>>
>>> +/// \brief Takes the expression passed to the size_t parameter of
>>> functions
>>> +/// such as memcmp, strncat, etc and warns if it's a comparison.
>>> +///
>>> +/// This is to catch typos like `if (memcmp(&a, &b, sizeof(a) > 0))`.
>>> +static bool CheckMemorySizeofForComparison(Sema &S, const Expr *E,
>>> +   IdentifierInfo *FnName,
>>> +   SourceLocation FnLoc,
>>> +   SourceLocation RPare

[PATCH] D25678: [modules] Do not report missing definitions of demoted constexpr variable templates.This is a followup to regression introduced in r284284.This should fix our libstdc++ modules builds.

2016-10-18 Thread Richard Smith via cfe-commits
rsmith added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:10129
+!Var->isThisDeclarationADemotedDefinition()) {
+  assert(Var->isThisDeclarationADemotedDefinition() && 
getLangOpts().Modules
+ && "Demoting decls is only in the contest of modules!");

v.g.vassilev wrote:
> manmanren wrote:
> > Is the logic correct here? The if statement says 
> > !Var->isThisDeclarationADemotedDefinition(), and we then assert 
> > Var->isThisDeclarationADemotedDefinition() && getLangOpts().Modules.
> Oops, that is an old version of the patch. Uploading the new one.
Can you just remove this assertion entirely? I don't see why it's relevant to 
what this code is checking. If we had some other reason to demote, the logic 
here would still seem to be correct.


https://reviews.llvm.org/D25678



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


[PATCH] D25475: [analyzer] Add a new SVal to support pointer-to-member operations.

2016-10-18 Thread Kirill Romanenkov via cfe-commits
kromanenkov updated this revision to Diff 75020.
kromanenkov added a comment.

Null pointer-to-member dereference is now modeled as UndefinedVal. Fixing this 
also releases us from loading from nonloc SVal.
I delete an assertion suppression in ExprEngine::performTrivialCopy because I 
can't reproduce its violation.


https://reviews.llvm.org/D25475

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SVals.def
  include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  lib/StaticAnalyzer/Core/SValBuilder.cpp
  lib/StaticAnalyzer/Core/SVals.cpp
  lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/pointer-to-member.cpp

Index: test/Analysis/pointer-to-member.cpp
===
--- test/Analysis/pointer-to-member.cpp
+++ test/Analysis/pointer-to-member.cpp
@@ -35,8 +35,7 @@
   clang_analyzer_eval(&A::getPtr == &A::getPtr); // expected-warning{{TRUE}}
   clang_analyzer_eval(&A::getPtr == 0); // expected-warning{{FALSE}}
 
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(&A::m_ptr == &A::m_ptr); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(&A::m_ptr == &A::m_ptr); // expected-warning{{TRUE}}
 }
 
 namespace PR15742 {
@@ -62,21 +61,70 @@
   }
 }
 
-// ---
-// FALSE NEGATIVES
-// ---
-
 bool testDereferencing() {
   A obj;
   obj.m_ptr = 0;
 
   A::MemberPointer member = &A::m_ptr;
 
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(obj.*member == 0); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(obj.*member == 0); // expected-warning{{TRUE}}
 
   member = 0;
 
-  // FIXME: Should emit a null dereference.
-  return obj.*member; // no-warning
+  return obj.*member; // expected-warning{{}}
 }
+
+namespace testPointerToMemberFunction {
+  struct A {
+virtual int foo() { return 1; }
+int bar() { return 2;  }
+  };
+
+  struct B : public A {
+virtual int foo() { return 3; }
+  };
+
+  typedef int (A::*AFnPointer)();
+  typedef int (B::*BFnPointer)();
+
+  void testPointerToMemberCasts() {
+AFnPointer AFP = &A::bar;
+BFnPointer StaticCastedBase2Derived = static_cast(&A::bar),
+   CCastedBase2Derived = (BFnPointer) (&A::bar);
+A a;
+B b;
+
+clang_analyzer_eval((a.*AFP)() == 2); // expected-warning{{TRUE}}
+clang_analyzer_eval((b.*StaticCastedBase2Derived)() == 2); // expected-warning{{TRUE}}
+clang_analyzer_eval(((b.*CCastedBase2Derived)() == 2)); // expected-warning{{TRUE}}
+  }
+
+  void testPointerToMemberVirtualCall() {
+A a;
+B b;
+A *APtr = &a;
+AFnPointer AFP = &A::foo;
+
+clang_analyzer_eval((APtr->*AFP)() == 1); // expected-warning{{TRUE}}
+
+APtr = &b;
+
+clang_analyzer_eval((APtr->*AFP)() == 3); // expected-warning{{TRUE}}
+  }
+} // end of testPointerToMemberFunction namespace
+
+namespace testPointerToMemberData {
+  struct A {
+int i;
+  };
+
+  void testPointerToMemberData() {
+int A::*AMdPointer = &A::i;
+A a;
+
+a.i = 42;
+a.*AMdPointer += 1;
+
+clang_analyzer_eval(a.i == 43); // expected-warning{{TRUE}}
+  }
+} // end of testPointerToMemberData namespace
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -69,6 +69,9 @@
 
   bool isLocType = Loc::isLocType(castTy);
 
+  if (val.getAs())
+return val;
+
   if (Optional LI = val.getAs()) {
 if (isLocType)
   return LI->getLoc();
@@ -335,6 +338,21 @@
 switch (lhs.getSubKind()) {
 default:
   return makeSymExprValNN(state, op, lhs, rhs, resultTy);
+case nonloc::PointerToMemberKind: {
+  assert(rhs.getSubKind() == nonloc::PointerToMemberKind &&
+ "Both SVals should have pointer-to-member-type");
+  const DeclaratorDecl *LDD =
+  lhs.castAs().getDecl(),
+  *RDD = rhs.castAs().getDecl();
+  switch (op) {
+case BO_EQ:
+  return makeTruthVal(LDD == RDD, resultTy);
+case BO_NE:
+  return makeTruthVal(LDD != RDD, resultTy);
+default:
+  return UnknownVal();
+  }
+}
 case nonloc::LocAsIntegerKind: {
   Loc lhsL = lhs.castAs().getLoc();
   switch (rhs.getSubKind()) {
@@ -857,6 +875,17 @@
 SVal SimpleSValBuilder::evalBinOpLN(ProgramStateRef state,
   BinaryOperator::Opcode op,
   Loc lhs, NonLoc rhs, QualType resultTy) {
+  if (op >= BO_PtrMemD && op <= BO_PtrMemI) {
+if (auto PTMSV = rhs.getAs()) {
+  if (PTMSV->isNullMemberPointer())
+return UndefinedVal();
+  if (const FieldDecl *FD = PTMSV->getDeclAs())
+return state->getLValue(FD, lhs);
+}
+
+return rhs;
+  }
+
   assert(!BinaryOperator::is

[PATCH] D6833: Clang-format: Braces Indent Style Whitesmith

2016-10-18 Thread Sandeep Tailor via cfe-commits
insysion added a comment.

Is this issue dead? I'm looking to use the tool for a Whitesmiths formatted 
project and would be happy to finish off the work.


https://reviews.llvm.org/D6833



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


[PATCH] D23745: [cmake] Update lit search to match the one in LLVM

2016-10-18 Thread Michał Górny via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284496: [cmake] Update lit search to match the one in LLVM 
(authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D23745?vs=73192&id=75027#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23745

Files:
  cfe/trunk/CMakeLists.txt


Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -124,6 +124,7 @@
 endif()
 
 if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
+  # Note: path not really used, except for checking if lit was found
   set(LLVM_LIT ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
   if(NOT LLVM_UTILS_PROVIDED)
 add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/FileCheck utils/FileCheck)
@@ -140,8 +141,10 @@
   endif()
 else()
   # Seek installed Lit.
-  find_program(LLVM_LIT "lit.py" ${LLVM_MAIN_SRC_DIR}/utils/lit
-DOC "Path to lit.py")
+  find_program(LLVM_LIT
+   NAMES llvm-lit lit.py lit
+   PATHS "${LLVM_MAIN_SRC_DIR}/utils/lit"
+   DOC "Path to lit.py")
 endif()
 
 if(LLVM_LIT)


Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -124,6 +124,7 @@
 endif()
 
 if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
+  # Note: path not really used, except for checking if lit was found
   set(LLVM_LIT ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
   if(NOT LLVM_UTILS_PROVIDED)
 add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/FileCheck utils/FileCheck)
@@ -140,8 +141,10 @@
   endif()
 else()
   # Seek installed Lit.
-  find_program(LLVM_LIT "lit.py" ${LLVM_MAIN_SRC_DIR}/utils/lit
-DOC "Path to lit.py")
+  find_program(LLVM_LIT
+   NAMES llvm-lit lit.py lit
+   PATHS "${LLVM_MAIN_SRC_DIR}/utils/lit"
+   DOC "Path to lit.py")
 endif()
 
 if(LLVM_LIT)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r284496 - [cmake] Update lit search to match the one in LLVM

2016-10-18 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Tue Oct 18 12:07:30 2016
New Revision: 284496

URL: http://llvm.org/viewvc/llvm-project?rev=284496&view=rev
Log:
[cmake] Update lit search to match the one in LLVM

Update the lit search logic to support all names supported in LLVM
(since r283029). The search order (i.e. PATHS vs HINTS) does no really
matter since the established path is not used, except for determining
whether lit is available.

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

Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=284496&r1=284495&r2=284496&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Tue Oct 18 12:07:30 2016
@@ -124,6 +124,7 @@ Please install Python or specify the PYT
 endif()
 
 if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
+  # Note: path not really used, except for checking if lit was found
   set(LLVM_LIT ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
   if(NOT LLVM_UTILS_PROVIDED)
 add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/FileCheck utils/FileCheck)
@@ -140,8 +141,10 @@ Please install Python or specify the PYT
   endif()
 else()
   # Seek installed Lit.
-  find_program(LLVM_LIT "lit.py" ${LLVM_MAIN_SRC_DIR}/utils/lit
-DOC "Path to lit.py")
+  find_program(LLVM_LIT
+   NAMES llvm-lit lit.py lit
+   PATHS "${LLVM_MAIN_SRC_DIR}/utils/lit"
+   DOC "Path to lit.py")
 endif()
 
 if(LLVM_LIT)


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


Re: r284265 - [Sema] Refactor context checking for availability diagnostics

2016-10-18 Thread Bob Wilson via cfe-commits
Yes. I filed rdar://problem/28812809  to report that 
problem in the SDK. I also filed rdar://problem/28825862 
 to remind us to restore the more strict checking 
after we release a version of the tvOS SDK with a fix.

Thanks, Erik!

> On Oct 18, 2016, at 9:46 AM, Erik Pilkington  
> wrote:
> 
> 
> On second thought, I think the header *is* ill-formed here. If we allowed 
> this behaviour, this would provide a way to circumvent an availability 
> diagnostic. For example, now the following compiles cleanly, where we really 
> should emit a diagnostic somewhere!
> 
> typedef int unavail_int __attribute__((availability(tvos, unavailable)));
> 
> __attribute__((availability(tvos, unavailable)))
> @interface A
> extern unavail_int foo;
> @end
> 
> int main() { (void)foo; }
> 
> I’m not so sure about the politics of this, but could you file a radar or 
> something to get the header fixed (i.e, make the variable __TVOS_PROHIBITED)? 
> I’ll make a new patch that makes this a special case for now.
> 
> Sorry for the flip-flop!
> Erik
> 
>> On Oct 18, 2016, at 11:47 AM, Erik Pilkington > > wrote:
>> 
>> Hi Bob,
>> I think the code in the header is fine here, so I reverted in r284486. 
>> Here’s a reduced version:
>> 
>> typedef int unavail_int __attribute__((availability(tvos, unavailable)));
>> 
>> __attribute__((availability(tvos, unavailable)))
>> @interface A
>> extern unavail_int foo;
>> @end
>> 
>> The problem is that ‘foo’ is actually at file context, not in the context of 
>> the interface, because we temporarily switched contexts to parse it. This 
>> means we can’t just look at DeclContexts in the DelayedDiagnostic case, 
>> which is what I was doing here. I’ll try to get a fix out for this soon!
>> 
>> Thanks for pointing this out!
>> Erik
>> 
>>> On Oct 18, 2016, at 1:37 AM, Bob Wilson >> > wrote:
>>> 
>>> Hi Erik,
>>> 
>>> This change does not work with one of the headers from the AVFoundation 
>>> framework in tvOS 10.0. We can try to get a fix into the tvOS SDK, but it 
>>> will probably be a while before we could release an SDK with that change. 
>>> In the meantime, this is kind of disruptive. Can you find a way to keep the 
>>> previous behavior, at least until we have a chance to fix that header?
>>> 
>>> The header in question is 
>>> System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h 
>>> in the AppleTVSimulator.sdk directory from Xcode 8.0. The problematic 
>>> declaration is this one:
>>> 
>>> AVF_EXPORT const AVCaptureWhiteBalanceGains 
>>> AVCaptureWhiteBalanceGainsCurrent NS_AVAILABLE_IOS(8_0);
>>> 
>>> The problem is that the type is declared like this:
>>> 
>>> typedef struct {
>>>float redGain;
>>>float greenGain;
>>>float blueGain;
>>> } AVCaptureWhiteBalanceGains NS_AVAILABLE_IOS(8_0) __TVOS_PROHIBITED;
>>> 
>>> The variable is missing the __TVOS_PROHIBITED attribute. You can reproduce 
>>> this easily:
>>> 
>>> $ cat t.m
>>> #import 
>>> $ clang -c -arch x86_64 -mtvos-simulator-version-min=10.0 -isysroot 
>>> /Applications/Xcode-8.0.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk
>>>  t.m
>>> /Applications/Xcode-8.0.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:1184:14:
>>>  error: 
>>>  'AVCaptureWhiteBalanceGains' is unavailable: not available on tvOS
>>> extern const AVCaptureWhiteBalanceGains AVCaptureWhiteBalanceGainsCurren...
>>> ^
>>> /Applications/Xcode-8.0.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:1081:3:
>>>  note: 
>>>  'AVCaptureWhiteBalanceGains' has been explicitly marked unavailable 
>>> here
>>> } AVCaptureWhiteBalanceGains __attribute__((availability(ios,introduced=...
>>>  ^
>>> 1 error generated.
>>> 
>>> Maybe we can carve out an exception based on the fact that this is just an 
>>> extern declaration of the variable — it’s not actually being used here. It 
>>> is also defined within the @interface for an Objective-C class, in case 
>>> that helps at all.
>>> 
 On Oct 14, 2016, at 12:08 PM, Erik Pilkington via cfe-commits 
 mailto:cfe-commits@lists.llvm.org>> wrote:
 
 Author: epilk
 Date: Fri Oct 14 14:08:01 2016
 New Revision: 284265
 
 URL: http://llvm.org/viewvc/llvm-project?rev=284265&view=rev 
 
 Log:
 [Sema] Refactor context checking for availability diagnostics
 
 This commit combines a couple of redundant functions that do availability
 attribute context checking into a more correct/simpler one.
 
 Differential revision: https://reviews.llvm.org/D25283 
 
 
 Modified:
   cfe/trun

[PATCH] D23745: [cmake] Update lit search to match the one in LLVM

2016-10-18 Thread Chris Bieneman via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

Gotcha. LGTM!


https://reviews.llvm.org/D23745



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


[PATCH] D25431: [libcxx] Convert Solaris support library to C++ to fix -std=c++11 build

2016-10-18 Thread Michał Górny via cfe-commits
mgorny added a comment.

Thanks for the review. Committed the prototype fix first, and followed it by 
the C++ conversion.


Repository:
  rL LLVM

https://reviews.llvm.org/D25431



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


[PATCH] D25403: [CUDA] Mark __libcpp_{isnan, isinf, isfinite} as constexpr.

2016-10-18 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Thank you, Marshall.

In https://reviews.llvm.org/D25403#572998, @mclow.lists wrote:

> My build setup is similar to yours (on Mac OS X):
>
>   cd $LLVM_BUILD ; rm -rf libcxx ; mkdir libcxx ; cd libcxx 
>   CXX=$LLVM_BIN/clang++ cmake -DLLVM_PATH=$LLVM/llvm 
> -DLIBCXX_CXX_ABI=libcxxabi -DLIBCXX_CXX_ABI_INCLUDE_PATHS=/usr/include $LIBCXX
>   make  # build libc++
>   make check-libcxx # run the tests


Ah, it's -DLIBCXX_CXX_ABI and -DLIBCXX_CXX_ABI_INCLUDE_PATHS that I was missing.

Is this the recommended way of building libcxx?  Should I update the 
documentation?

Likewise, should I update the documentation to indicate that check-cxx may fail 
with a clang built from tip of tree, due to c++17 support being experimental?  
Or do you all want to change the target so that it doesn't run the c++17 tests 
by default?  This burned about an hour of developer time yesterday, I guess 
because we couldn't believe that check-cxx would be intentionally broken like 
that, so it would be nice to have some sort of fix.

> I don't see how this can possibly be constexpr.
>  it calls isfinite(), which is hoisted from ::isfinite(), which comes from 
> the C library.
>  Since C knows nothing about constexpr, we're stuck.

Functions that call non-constexpr things can be marked constexpr; you just 
can't evaluate them in a constexpr context (as you demonstrated).

All I need is for the function to be marked as constexpr; I do not need the 
function be constexpr-evaluatable.

I think the implications of this change would be that, if you evaluated this 
function in a constexpr context, before the change would be a compile error 
when calling __libcpp_isnan, and after this change it would be a compile error 
at calling ::isnan.  Since the function should not be called outside of libc++ 
anyway, I was hoping that wouldn't make a difference to anyone.


https://reviews.llvm.org/D25403



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


[PATCH] D25431: [libcxx] Convert Solaris support library to C++ to fix -std=c++11 build

2016-10-18 Thread Michał Górny via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284493: [solaris] Fix iswxdigit_l() support function 
prototype (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D25431?vs=74996&id=75024#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25431

Files:
  libcxx/trunk/src/support/solaris/xlocale.c


Index: libcxx/trunk/src/support/solaris/xlocale.c
===
--- libcxx/trunk/src/support/solaris/xlocale.c
+++ libcxx/trunk/src/support/solaris/xlocale.c
@@ -19,7 +19,7 @@
 return isxdigit(__c);
 }
 
-int iswxdigit_l(wchar_t __c, locale_t __l) {
+int iswxdigit_l(wint_t __c, locale_t __l) {
 return isxdigit(__c);
 }
 


Index: libcxx/trunk/src/support/solaris/xlocale.c
===
--- libcxx/trunk/src/support/solaris/xlocale.c
+++ libcxx/trunk/src/support/solaris/xlocale.c
@@ -19,7 +19,7 @@
 return isxdigit(__c);
 }
 
-int iswxdigit_l(wchar_t __c, locale_t __l) {
+int iswxdigit_l(wint_t __c, locale_t __l) {
 return isxdigit(__c);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r284493 - [solaris] Fix iswxdigit_l() support function prototype

2016-10-18 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Tue Oct 18 11:54:54 2016
New Revision: 284493

URL: http://llvm.org/viewvc/llvm-project?rev=284493&view=rev
Log:
[solaris] Fix iswxdigit_l() support function prototype

Fix the iswxdigit_l() function prototype to take wint_t parameter
instead of incorrect wchar_t.

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

Modified:
libcxx/trunk/src/support/solaris/xlocale.c

Modified: libcxx/trunk/src/support/solaris/xlocale.c
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/support/solaris/xlocale.c?rev=284493&r1=284492&r2=284493&view=diff
==
--- libcxx/trunk/src/support/solaris/xlocale.c (original)
+++ libcxx/trunk/src/support/solaris/xlocale.c Tue Oct 18 11:54:54 2016
@@ -19,7 +19,7 @@ int isxdigit_l(int __c, locale_t __l) {
 return isxdigit(__c);
 }
 
-int iswxdigit_l(wchar_t __c, locale_t __l) {
+int iswxdigit_l(wint_t __c, locale_t __l) {
 return isxdigit(__c);
 }
 


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


[libcxx] r284494 - [solaris] Convert the support library to C++ to fix -std=c++11 build

2016-10-18 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Tue Oct 18 11:54:59 2016
New Revision: 284494

URL: http://llvm.org/viewvc/llvm-project?rev=284494&view=rev
Log:
[solaris] Convert the support library to C++ to fix -std=c++11 build

Convert the Solaris xlocale.c compatibility library from plain C to C++
in order to fix the build failures caused by the addition of -std=c++11
to LIBCXX_COMPILE_FLAGS. The additional flag got propagated to the C
file, resulting in error with strict compilers.

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

Added:
libcxx/trunk/src/support/solaris/xlocale.cpp
  - copied, changed from r284493, libcxx/trunk/src/support/solaris/xlocale.c
Removed:
libcxx/trunk/src/support/solaris/xlocale.c
Modified:
libcxx/trunk/lib/CMakeLists.txt

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=284494&r1=284493&r2=284494&view=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Tue Oct 18 11:54:59 2016
@@ -6,7 +6,7 @@ if(WIN32)
   file(GLOB LIBCXX_WIN32_SOURCES ../src/support/win32/*.cpp)
   list(APPEND LIBCXX_SOURCES ${LIBCXX_WIN32_SOURCES})
 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
-  file(GLOB LIBCXX_SOLARIS_SOURCES ../src/support/solaris/*.c)
+  file(GLOB LIBCXX_SOLARIS_SOURCES ../src/support/solaris/*.cpp)
   list(APPEND LIBCXX_SOURCES ${LIBCXX_SOLARIS_SOURCES})
 endif()
 

Removed: libcxx/trunk/src/support/solaris/xlocale.c
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/support/solaris/xlocale.c?rev=284493&view=auto
==
--- libcxx/trunk/src/support/solaris/xlocale.c (original)
+++ libcxx/trunk/src/support/solaris/xlocale.c (removed)
@@ -1,66 +0,0 @@
-//===--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-#ifdef __sun__
-
-#include "support/solaris/xlocale.h"
-#include 
-#include 
-#include 
-
-
-int isxdigit_l(int __c, locale_t __l) {
-return isxdigit(__c);
-}
-
-int iswxdigit_l(wint_t __c, locale_t __l) {
-return isxdigit(__c);
-}
-
-// FIXME: This disregards the locale, which is Very Wrong
-#define vsnprintf_l(__s, __n, __l, __format, __va)  \
-vsnprintf(__s, __n, __format, __va) 
-
-int snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...)
-{
-  va_list __va;
-  va_start(__va, __format);
-  int __res = vsnprintf_l(__s, __n , __l, __format, __va);
-  va_end(__va);
-  return __res;
-}
-
-int asprintf_l(char **__s, locale_t __l, const char *__format, ...) {
-  va_list __va;
-  va_start(__va, __format);
-  // FIXME:
-  int __res = vasprintf(__s, __format, __va);
-  va_end(__va);
-  return __res;
-}
-
-int sscanf_l(const char *__s, locale_t __l, const char *__format, ...) {
-  va_list __va;
-  va_start(__va, __format);
-  // FIXME:
-  int __res = vsscanf(__s, __format, __va);
-  va_end(__va);
-  return __res;
-}
-
-size_t mbrtowc_l(wchar_t *__pwc, const char *__pmb,
- size_t __max, mbstate_t *__ps, locale_t __loc) {
-  return mbrtowc(__pwc, __pmb, __max, __ps);
-}
-
-struct lconv *localeconv_l(locale_t __l) {
-  return localeconv();
-}
-
-#endif // __sun__

Copied: libcxx/trunk/src/support/solaris/xlocale.cpp (from r284493, 
libcxx/trunk/src/support/solaris/xlocale.c)
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/support/solaris/xlocale.cpp?p2=libcxx/trunk/src/support/solaris/xlocale.cpp&p1=libcxx/trunk/src/support/solaris/xlocale.c&r1=284493&r2=284494&rev=284494&view=diff
==
--- libcxx/trunk/src/support/solaris/xlocale.c (original)
+++ libcxx/trunk/src/support/solaris/xlocale.cpp Tue Oct 18 11:54:59 2016
@@ -14,6 +14,7 @@
 #include 
 #include 
 
+extern "C" {
 
 int isxdigit_l(int __c, locale_t __l) {
 return isxdigit(__c);
@@ -63,4 +64,6 @@ struct lconv *localeconv_l(locale_t __l)
   return localeconv();
 }
 
+};
+
 #endif // __sun__


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


Re: r284265 - [Sema] Refactor context checking for availability diagnostics

2016-10-18 Thread Erik Pilkington via cfe-commits

On second thought, I think the header *is* ill-formed here. If we allowed this 
behaviour, this would provide a way to circumvent an availability diagnostic. 
For example, now the following compiles cleanly, where we really should emit a 
diagnostic somewhere!

typedef int unavail_int __attribute__((availability(tvos, unavailable)));

__attribute__((availability(tvos, unavailable)))
@interface A
extern unavail_int foo;
@end

int main() { (void)foo; }

I’m not so sure about the politics of this, but could you file a radar or 
something to get the header fixed (i.e, make the variable __TVOS_PROHIBITED)? 
I’ll make a new patch that makes this a special case for now.

Sorry for the flip-flop!
Erik

> On Oct 18, 2016, at 11:47 AM, Erik Pilkington  
> wrote:
> 
> Hi Bob,
> I think the code in the header is fine here, so I reverted in r284486. Here’s 
> a reduced version:
> 
> typedef int unavail_int __attribute__((availability(tvos, unavailable)));
> 
> __attribute__((availability(tvos, unavailable)))
> @interface A
> extern unavail_int foo;
> @end
> 
> The problem is that ‘foo’ is actually at file context, not in the context of 
> the interface, because we temporarily switched contexts to parse it. This 
> means we can’t just look at DeclContexts in the DelayedDiagnostic case, which 
> is what I was doing here. I’ll try to get a fix out for this soon!
> 
> Thanks for pointing this out!
> Erik
> 
>> On Oct 18, 2016, at 1:37 AM, Bob Wilson > > wrote:
>> 
>> Hi Erik,
>> 
>> This change does not work with one of the headers from the AVFoundation 
>> framework in tvOS 10.0. We can try to get a fix into the tvOS SDK, but it 
>> will probably be a while before we could release an SDK with that change. In 
>> the meantime, this is kind of disruptive. Can you find a way to keep the 
>> previous behavior, at least until we have a chance to fix that header?
>> 
>> The header in question is 
>> System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h 
>> in the AppleTVSimulator.sdk directory from Xcode 8.0. The problematic 
>> declaration is this one:
>> 
>> AVF_EXPORT const AVCaptureWhiteBalanceGains 
>> AVCaptureWhiteBalanceGainsCurrent NS_AVAILABLE_IOS(8_0);
>> 
>> The problem is that the type is declared like this:
>> 
>> typedef struct {
>>float redGain;
>>float greenGain;
>>float blueGain;
>> } AVCaptureWhiteBalanceGains NS_AVAILABLE_IOS(8_0) __TVOS_PROHIBITED;
>> 
>> The variable is missing the __TVOS_PROHIBITED attribute. You can reproduce 
>> this easily:
>> 
>> $ cat t.m
>> #import 
>> $ clang -c -arch x86_64 -mtvos-simulator-version-min=10.0 -isysroot 
>> /Applications/Xcode-8.0.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk
>>  t.m
>> /Applications/Xcode-8.0.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:1184:14:
>>  error: 
>>  'AVCaptureWhiteBalanceGains' is unavailable: not available on tvOS
>> extern const AVCaptureWhiteBalanceGains AVCaptureWhiteBalanceGainsCurren...
>> ^
>> /Applications/Xcode-8.0.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:1081:3:
>>  note: 
>>  'AVCaptureWhiteBalanceGains' has been explicitly marked unavailable here
>> } AVCaptureWhiteBalanceGains __attribute__((availability(ios,introduced=...
>>  ^
>> 1 error generated.
>> 
>> Maybe we can carve out an exception based on the fact that this is just an 
>> extern declaration of the variable — it’s not actually being used here. It 
>> is also defined within the @interface for an Objective-C class, in case that 
>> helps at all.
>> 
>>> On Oct 14, 2016, at 12:08 PM, Erik Pilkington via cfe-commits 
>>> mailto:cfe-commits@lists.llvm.org>> wrote:
>>> 
>>> Author: epilk
>>> Date: Fri Oct 14 14:08:01 2016
>>> New Revision: 284265
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=284265&view=rev 
>>> 
>>> Log:
>>> [Sema] Refactor context checking for availability diagnostics
>>> 
>>> This commit combines a couple of redundant functions that do availability
>>> attribute context checking into a more correct/simpler one.
>>> 
>>> Differential revision: https://reviews.llvm.org/D25283 
>>> 
>>> 
>>> Modified:
>>>   cfe/trunk/include/clang/Sema/Sema.h
>>>   cfe/trunk/lib/Sema/SemaDecl.cpp
>>>   cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>>>   cfe/trunk/lib/Sema/SemaExpr.cpp
>>>   cfe/trunk/test/SemaObjC/class-unavail-warning.m
>>> 
>>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=284265&r1=284264&r2=284265&view=diff
>>>  
>>> 

Re: Fwd: r198063 - Warn on mismatched parentheses in memcmp and friends.

2016-10-18 Thread Nico Weber via cfe-commits
Did you find real-world code triggering this, or did you happen to see the
implementation of the warning? I'm not sure if omitting just the note or
the whole warning is more useful in practice. Intuitively I'd say that
people "never" will compare the result of memcpy, so I'd guess that it
doesn't matter much what we pick and omitting the warning completely is
fine, but I'm not sure.

On Oct 17, 2016 1:44 PM, "Richard Smith"  wrote:

> [Re-send to correct addresses.]
>
> On Thu, Dec 26, 2013 at 3:38 PM, Nico Weber  wrote:
>
>> Author: nico
>> Date: Thu Dec 26 17:38:39 2013
>> New Revision: 198063
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=198063&view=rev
>> Log:
>> Warn on mismatched parentheses in memcmp and friends.
>>
>> Thisadds a new warning that warns on code like this:
>>
>>   if (memcmp(a, b, sizeof(a) != 0))
>>
>> The warning looks like:
>>
>> test4.cc:5:30: warning: size argument in 'memcmp' call is a comparison
>> [-Wmemsize-comparison]
>>   if (memcmp(a, b, sizeof(a) != 0))
>>~~^~~~
>> test4.cc:5:7: note: did you mean to compare the result of 'memcmp'
>> instead?
>>   if (memcmp(a, b, sizeof(a) != 0))
>>   ^  ~
>> )
>> test4.cc:5:20: note: explicitly cast the argument to size_t to silence
>> this warning
>>   if (memcmp(a, b, sizeof(a) != 0))
>>^
>>(size_t)( )
>> 1 warning generated.
>>
>> This found 2 bugs in chromium and has 0 false positives on both chromium
>> and
>> llvm.
>>
>> The idea of triggering this warning on a binop in the size argument is
>> due to
>> rnk.
>>
>>
>> Added:
>> cfe/trunk/test/SemaCXX/warn-memsize-comparison.cpp
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/lib/Sema/SemaChecking.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Basic/DiagnosticSemaKinds.td?rev=198063&r1=198062&r2=198063&view=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Dec 26
>> 17:38:39 2013
>> @@ -390,11 +390,18 @@ def warn_sizeof_pointer_type_memaccess :
>>"%select{destination|source}2; expected %3 or an explicit length">,
>>InGroup;
>>  def warn_strlcpycat_wrong_size : Warning<
>> -  "size argument in %0 call appears to be size of the source; expected
>> the size of "
>> -  "the destination">,
>> +  "size argument in %0 call appears to be size of the source; "
>> +  "expected the size of the destination">,
>>InGroup>;
>>  def note_strlcpycat_wrong_size : Note<
>>"change size argument to be the size of the destination">;
>> +def warn_memsize_comparison : Warning<
>> +  "size argument in %0 call is a comparison">,
>> +  InGroup>;
>> +def warn_memsize_comparison_paren_note : Note<
>> +  "did you mean to compare the result of %0 instead?">;
>> +def warn_memsize_comparison_cast_note : Note<
>> +  "explicitly cast the argument to size_t to silence this warning">;
>>
>>  def warn_strncat_large_size : Warning<
>>"the value of the size argument in 'strncat' is too large, might lead
>> to a "
>>
>> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaC
>> hecking.cpp?rev=198063&r1=198062&r2=198063&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Dec 26 17:38:39 2013
>> @@ -622,7 +622,7 @@ bool Sema::CheckARMBuiltinFunctionCall(u
>>   RHS.get(), AA_Assigning))
>>return true;
>>}
>> -
>> +
>>// For NEON intrinsics which take an immediate value as part of the
>>// instruction, range check them here.
>>unsigned i = 0, l = 0, u = 0;
>> @@ -3560,6 +3560,40 @@ void Sema::CheckFormatString(const Strin
>>
>>  //===--- CHECK: Standard memory functions --
>> ---===//
>>
>> +/// \brief Takes the expression passed to the size_t parameter of
>> functions
>> +/// such as memcmp, strncat, etc and warns if it's a comparison.
>> +///
>> +/// This is to catch typos like `if (memcmp(&a, &b, sizeof(a) > 0))`.
>> +static bool CheckMemorySizeofForComparison(Sema &S, const Expr *E,
>> +   IdentifierInfo *FnName,
>> +   SourceLocation FnLoc,
>> +   SourceLocation RParenLoc) {
>> +  const BinaryOperator *Size = dyn_cast(E);
>> +  if (!Size)
>> +return false;
>> +
>> +  // if E is binop and op is >, <, >=, <=, ==, &&, ||:
>> +  if (!Size->isComparisonOp() && !Size->isEqualityOp() &&
>> !Size->isLogicalOp())
>> +return false;
>> +
>> +  Preprocessor &PP

[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-18 Thread Serge Rogatch via cfe-commits
rSerge added a comment.

@dberris , below is the list of features supported by `REQUIRES` and 
`REQUIRES-ANY` for me:

  set(['system-windows', 'nozlib', u'amdgpu-registered-target', 
'case-insensitive-filesystem', u'msp430-registered-target', 
u'sparc-registered-target', 'libgcc', 'staticanalyzer', 'native', 
u'powerpc-registered-target', 'non-ps4-sdk', 'clang-driver', 'backtrace', 
'crash-recovery', u'bpf-registered-target', u'hexagon-registered-target', 
'not_ubsan', u'x86-registered-target', u'aarch64-registered-target', 
u'arm-registered-target', 'not_asan', u'nvptx-registered-target', 
u'mips-registered-target', u'systemz-registered-target', 
u'lanai-registered-target', u'xcore-registered-target'])

So there is `system-windows`, however, there is no target CPU among the 
features. I understand that the features with `-registered-target` suffixes 
mean the targets supported with the current Clang build.
I am not submitting the tests because they do not work for the above reason. I 
also had to remove the old test because the new code checks the OS, but not 
only the CPU.


https://reviews.llvm.org/D24799



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


[PATCH] D25363: [Sema] Store a SourceRange for multi-token builtin types

2016-10-18 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.



Comment at: include/clang/AST/TypeLoc.h:513
 struct BuiltinLocInfo {
-  SourceLocation BuiltinLoc;
+  SourceRange BuiltinRange;
 };

aaron.ballman wrote:
> malcolm.parsons wrote:
> > aaron.ballman wrote:
> > > Since this doubles the size of the type loc for builtin types, do you 
> > > happen to have any data on what practical impact this has on RAM usage, 
> > > say for bootstrapping LLVM (or compiling any large source base, really)? 
> > > Hopefully it's not a lot, but it would be nice to know if it's a .1%, 1%, 
> > > 10%, etc increase in usage (or does the change get lost in the noise).
> > I don't have any data.
> > I'm not sure how to collect that data.
> It's likely platform dependent, but I was thinking something as simple as 
> looking at peak RAM usage between two different builds of the compiler. 
> Something like `top` would probably work if you're on Linux (unless someone 
> knows of a better way, I'm not strong on Linux).
Before:
/usr/bin/time clang++ ... -c llvm/tools/clang/lib/AST/ExprConstant.cpp
5.56user 0.13system 0:05.91elapsed 96%CPU (0avgtext+0avgdata 256820maxresident)k

After:
/usr/bin/time clang++ ... -c llvm/tools/clang/lib/AST/ExprConstant.cpp
5.67user 0.12system 0:05.98elapsed 97%CPU (0avgtext+0avgdata 256940maxresident)k

((256940 - 256820) / 256820) * 100 = 0.05%


https://reviews.llvm.org/D25363



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


[PATCH] D25431: [libcxx] Convert Solaris support library to C++ to fix -std=c++11 build

2016-10-18 Thread Joerg Sonnenberger via cfe-commits
joerg accepted this revision.
joerg added a reviewer: joerg.
joerg added a comment.
This revision is now accepted and ready to land.

Commit the prototype fix separately, please.


https://reviews.llvm.org/D25431



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


[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-10-18 Thread Joerg Sonnenberger via cfe-commits
joerg added a comment.

I agree that leaving out the really complicated parts is acceptable for now. 
Can you mark the comment as TODO?


https://reviews.llvm.org/D23657



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


Re: r284265 - [Sema] Refactor context checking for availability diagnostics

2016-10-18 Thread Erik Pilkington via cfe-commits
Hi Bob,
I think the code in the header is fine here, so I reverted in r284486. Here’s a 
reduced version:

typedef int unavail_int __attribute__((availability(tvos, unavailable)));

__attribute__((availability(tvos, unavailable)))
@interface A
extern unavail_int foo;
@end

The problem is that ‘foo’ is actually at file context, not in the context of 
the interface, because we temporarily switched contexts to parse it. This means 
we can’t just look at DeclContexts in the DelayedDiagnostic case, which is what 
I was doing here. I’ll try to get a fix out for this soon!

Thanks for pointing this out!
Erik

> On Oct 18, 2016, at 1:37 AM, Bob Wilson  wrote:
> 
> Hi Erik,
> 
> This change does not work with one of the headers from the AVFoundation 
> framework in tvOS 10.0. We can try to get a fix into the tvOS SDK, but it 
> will probably be a while before we could release an SDK with that change. In 
> the meantime, this is kind of disruptive. Can you find a way to keep the 
> previous behavior, at least until we have a chance to fix that header?
> 
> The header in question is 
> System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h in 
> the AppleTVSimulator.sdk directory from Xcode 8.0. The problematic 
> declaration is this one:
> 
> AVF_EXPORT const AVCaptureWhiteBalanceGains AVCaptureWhiteBalanceGainsCurrent 
> NS_AVAILABLE_IOS(8_0);
> 
> The problem is that the type is declared like this:
> 
> typedef struct {
>float redGain;
>float greenGain;
>float blueGain;
> } AVCaptureWhiteBalanceGains NS_AVAILABLE_IOS(8_0) __TVOS_PROHIBITED;
> 
> The variable is missing the __TVOS_PROHIBITED attribute. You can reproduce 
> this easily:
> 
> $ cat t.m
> #import 
> $ clang -c -arch x86_64 -mtvos-simulator-version-min=10.0 -isysroot 
> /Applications/Xcode-8.0.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk
>  t.m
> /Applications/Xcode-8.0.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:1184:14:
>  error: 
>  'AVCaptureWhiteBalanceGains' is unavailable: not available on tvOS
> extern const AVCaptureWhiteBalanceGains AVCaptureWhiteBalanceGainsCurren...
> ^
> /Applications/Xcode-8.0.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:1081:3:
>  note: 
>  'AVCaptureWhiteBalanceGains' has been explicitly marked unavailable here
> } AVCaptureWhiteBalanceGains __attribute__((availability(ios,introduced=...
>  ^
> 1 error generated.
> 
> Maybe we can carve out an exception based on the fact that this is just an 
> extern declaration of the variable — it’s not actually being used here. It is 
> also defined within the @interface for an Objective-C class, in case that 
> helps at all.
> 
>> On Oct 14, 2016, at 12:08 PM, Erik Pilkington via cfe-commits 
>>  wrote:
>> 
>> Author: epilk
>> Date: Fri Oct 14 14:08:01 2016
>> New Revision: 284265
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=284265&view=rev
>> Log:
>> [Sema] Refactor context checking for availability diagnostics
>> 
>> This commit combines a couple of redundant functions that do availability
>> attribute context checking into a more correct/simpler one.
>> 
>> Differential revision: https://reviews.llvm.org/D25283
>> 
>> Modified:
>>   cfe/trunk/include/clang/Sema/Sema.h
>>   cfe/trunk/lib/Sema/SemaDecl.cpp
>>   cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>>   cfe/trunk/lib/Sema/SemaExpr.cpp
>>   cfe/trunk/test/SemaObjC/class-unavail-warning.m
>> 
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=284265&r1=284264&r2=284265&view=diff
>> ==
>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>> +++ cfe/trunk/include/clang/Sema/Sema.h Fri Oct 14 14:08:01 2016
>> @@ -9889,23 +9889,16 @@ public:
>>return OriginalLexicalContext ? OriginalLexicalContext : CurContext;
>>  }
>> 
>> -  AvailabilityResult getCurContextAvailability() const;
>> -
>> -  /// \brief Get the verison that this context implies.
>> -  /// For instance, a method in an interface that is annotated with an
>> -  /// availability attribuite effectively has the availability of the 
>> interface.
>> -  VersionTuple getVersionForDecl(const Decl *Ctx) const;
>> -
>>  /// \brief The diagnostic we should emit for \c D, or \c AR_Available.
>>  ///
>>  /// \param D The declaration to check. Note that this may be altered to 
>> point
>>  /// to another declaration that \c D gets it's availability from. i.e., we
>>  /// walk the list of typedefs to find an availability attribute.
>>  ///
>> -  /// \param ContextVersion The version to compare availability against.
>> -  AvailabilityResult
>> -  ShouldDiagnoseAvailabilityOf

[PATCH] D25403: [CUDA] Mark __libcpp_{isnan, isinf, isfinite} as constexpr.

2016-10-18 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

> error: undefined reference to '__gxx_personality_v0'

means that you're not linking to an ABI library.

That symbol comes out of libc++abi, but you can also get that from libsupc.

My build setup is similar to yours (on Mac OS X):

  cd $LLVM_BUILD ; rm -rf libcxx ; mkdir libcxx ; cd libcxx 
  CXX=$LLVM_BIN/clang++ cmake -DLLVM_PATH=$LLVM/llvm -DLIBCXX_CXX_ABI=libcxxabi 
-DLIBCXX_CXX_ABI_INCLUDE_PATHS=/usr/include $LIBCXX
  make  # build libc++
  make check-libcxx # run the tests




Comment at: libcxx/include/cmath:615
 _LIBCPP_ALWAYS_INLINE
-typename enable_if::value, bool>::type
+_LIBCPP_CONSTEXPR typename enable_if::value, 
bool>::type
 __libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT

I don't see how this can possibly be constexpr.
it calls `isfinite()`, which is hoisted from `::isfinite()`, which comes from 
the C library.
Since C knows nothing about constexpr, we're stuck.

I just tried this:
constexpr float f = 3.2f;
static_assert(::isfinite(f), "" );

and got:
bug.cpp:9:19: error: static_assert expression is not an integral constant 
expression
static_assert(::isfinite(f), "" );
  ^



https://reviews.llvm.org/D25403



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


r284486 - Revert r284265 "[Sema] Refactor context checking for availability diagnostics"

2016-10-18 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Tue Oct 18 10:26:43 2016
New Revision: 284486

URL: http://llvm.org/viewvc/llvm-project?rev=284486&view=rev
Log:
Revert r284265 "[Sema] Refactor context checking for availability diagnostics"

This has a bug in it, pointed out by Bob Wilson!

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaObjC/class-unavail-warning.m

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=284486&r1=284485&r2=284486&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Oct 18 10:26:43 2016
@@ -9890,16 +9890,23 @@ public:
 return OriginalLexicalContext ? OriginalLexicalContext : CurContext;
   }
 
+  AvailabilityResult getCurContextAvailability() const;
+
+  /// \brief Get the verison that this context implies.
+  /// For instance, a method in an interface that is annotated with an
+  /// availability attribuite effectively has the availability of the 
interface.
+  VersionTuple getVersionForDecl(const Decl *Ctx) const;
+
   /// \brief The diagnostic we should emit for \c D, or \c AR_Available.
   ///
   /// \param D The declaration to check. Note that this may be altered to point
   /// to another declaration that \c D gets it's availability from. i.e., we
   /// walk the list of typedefs to find an availability attribute.
   ///
-  /// \param Message If non-null, this will be populated with the message from
-  /// the availability attribute that is selected.
-  AvailabilityResult ShouldDiagnoseAvailabilityOfDecl(NamedDecl *&D,
-  std::string *Message);
+  /// \param ContextVersion The version to compare availability against.
+  AvailabilityResult
+  ShouldDiagnoseAvailabilityOfDecl(NamedDecl *&D, VersionTuple ContextVersion,
+   std::string *Message);
 
   const DeclContext *getCurObjCLexicalContext() const {
 const DeclContext *DC = getCurLexicalContext();

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=284486&r1=284485&r2=284486&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Oct 18 10:26:43 2016
@@ -15628,3 +15628,29 @@ void Sema::ActOnPragmaWeakAlias(Identifi
 Decl *Sema::getObjCDeclContext() const {
   return (dyn_cast_or_null(CurContext));
 }
+
+AvailabilityResult Sema::getCurContextAvailability() const {
+  const Decl *D = cast_or_null(getCurObjCLexicalContext());
+  if (!D)
+return AR_Available;
+
+  // If we are within an Objective-C method, we should consult
+  // both the availability of the method as well as the
+  // enclosing class.  If the class is (say) deprecated,
+  // the entire method is considered deprecated from the
+  // purpose of checking if the current context is deprecated.
+  if (const ObjCMethodDecl *MD = dyn_cast(D)) {
+AvailabilityResult R = MD->getAvailability();
+if (R != AR_Available)
+  return R;
+D = MD->getClassInterface();
+  }
+  // If we are within an Objective-c @implementation, it
+  // gets the same availability context as the @interface.
+  else if (const ObjCImplementationDecl *ID =
+dyn_cast(D)) {
+D = ID->getClassInterface();
+  }
+  // Recover from user error.
+  return D ? D->getAvailability() : AR_Available;
+}

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=284486&r1=284485&r2=284486&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Oct 18 10:26:43 2016
@@ -6327,6 +6327,30 @@ static void handleDelayedForbiddenType(S
   diag.Triggered = true;
 }
 
+static bool isDeclDeprecated(Decl *D) {
+  do {
+if (D->isDeprecated())
+  return true;
+// A category implicitly has the availability of the interface.
+if (const ObjCCategoryDecl *CatD = dyn_cast(D))
+  if (const ObjCInterfaceDecl *Interface = CatD->getClassInterface())
+return Interface->isDeprecated();
+  } while ((D = cast_or_null(D->getDeclContext(;
+  return false;
+}
+
+static bool isDeclUnavailable(Decl *D) {
+  do {
+if (D->isUnavailable())
+  return true;
+// A category implicitly has the availability of the interface.
+if (const ObjCCategoryDecl *CatD = dyn_cast(D))
+  if (const ObjCInterfaceDecl *Interface = CatD->getClassInterface())
+return Interface->isUnavailable();
+  } while ((D = cast_or_null(D->getDeclContext(;
+  return false;
+}
+
 static const Availability

[PATCH] D25731: [analyzer] NumberObjectConversion: Support CFNumberRef.

2016-10-18 Thread Artem Dergachev via cfe-commits
NoQ created this revision.
NoQ added reviewers: zaks.anna, dcoughlin.
NoQ added a subscriber: cfe-commits.

`CFNumberRef`, much like `NSNumber*`, can also be accidentally mistaken for a 
numeric value, so it is worth it to support this type in our new 
`NumberObjectConversion` checker.


https://reviews.llvm.org/D25731

Files:
  lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  test/Analysis/number-object-conversion.c

Index: test/Analysis/number-object-conversion.c
===
--- /dev/null
+++ test/Analysis/number-object-conversion.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -w -analyze -analyzer-checker=osx.NumberObjectConversion %s -verify
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -w -analyze -analyzer-checker=osx.NumberObjectConversion -analyzer-config osx.NumberObjectConversion:Pedantic=true -DPEDANTIC %s -verify
+
+#define NULL ((void *)0)
+
+typedef const struct __CFNumber *CFNumberRef;
+
+
+void takes_int(int);
+
+void bad(CFNumberRef p) {
+#ifdef PEDANTIC
+  if (p) {} // expected-warning{{Converting 'CFNumberRef' to a plain boolean value for branching; please compare the pointer to NULL instead to suppress this warning}}
+  if (!p) {} // expected-warning{{Converting 'CFNumberRef' to a plain boolean value for branching; please compare the pointer to NULL instead to suppress this warning}}
+  p ? 1 : 2; // expected-warning{{Converting 'CFNumberRef' to a plain boolean value for branching; please compare the pointer to NULL instead to suppress this warning}}
+#endif
+  int x = p; // expected-warning{{Converting 'CFNumberRef' to a plain integer value; pointer value is being used instead}}
+  takes_int(p); // expected-warning{{Converting 'CFNumberRef' to a plain integer value; pointer value is being used instead}}
+  takes_int(x); // no-warning
+}
Index: lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
+++ lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
@@ -69,10 +69,12 @@
 
   const Stmt *Conv = Result.Nodes.getNodeAs("conv");
   assert(Conv);
-  const Expr *Osboolean = Result.Nodes.getNodeAs("osboolean");
-  const Expr *Nsnumber = Result.Nodes.getNodeAs("nsnumber");
-  bool IsObjC = (bool)Nsnumber;
-  const Expr *Obj = IsObjC ? Nsnumber : Osboolean;
+  const Expr *CObject = Result.Nodes.getNodeAs("c_object");
+  const Expr *CppObject = Result.Nodes.getNodeAs("cpp_object");
+  const Expr *ObjCObject = Result.Nodes.getNodeAs("objc_object");
+  bool IsCpp = (CppObject != nullptr);
+  bool IsObjC = (ObjCObject != nullptr);
+  const Expr *Obj = IsObjC ? ObjCObject : IsCpp ? CppObject : CObject;
   assert(Obj);
 
   ASTContext &ACtx = ADC->getASTContext();
@@ -104,9 +106,11 @@
 
   llvm::SmallString<64> Msg;
   llvm::raw_svector_ostream OS(Msg);
-  OS << "Converting '"
- << Obj->getType().getCanonicalType().getUnqualifiedType().getAsString()
- << "' to a plain ";
+
+  QualType ObjT = (IsCpp || IsObjC)
+  ? Obj->getType().getCanonicalType().getUnqualifiedType()
+  : Obj->getType();
+  OS << "Converting '" << ObjT.getAsString() << "' to a plain ";
 
   if (Result.Nodes.getNodeAs("int_type") != nullptr)
 OS << "integer value";
@@ -121,9 +125,12 @@
 if (IsObjC) {
   OS << "; please compare the pointer to nil instead "
 "to suppress this warning";
-} else {
+} else if (IsCpp) {
   OS << "; please compare the pointer to NULL or nullptr instead "
 "to suppress this warning";
+} else {
+  OS << "; please compare the pointer to NULL instead "
+"to suppress this warning";
 }
   } else {
 OS << "; pointer value is being used instead";
@@ -142,27 +149,41 @@
   MatchFinder F;
   Callback CB(this, BR, AM.getAnalysisDeclContext(D));
 
-  auto OSBooleanExprM =
+  auto SuspiciousCExprM =
+  expr(ignoringParenImpCasts(
+  expr(hasType(
+  typedefType(hasDeclaration(anyOf(
+  typedefDecl(hasName("CFNumberRef")),
+  typedefDecl(hasName("CFBooleanRef")))
+  .bind("c_object")));
+
+  auto SuspiciousCppExprM =
   expr(ignoringParenImpCasts(
   expr(hasType(hasCanonicalType(
   pointerType(pointee(hasCanonicalType(
   recordType(hasDeclaration(
-  cxxRecordDecl(hasName(
-  "OSBoolean")).bind("osboolean")));
+  anyOf(
+cxxRecordDecl(hasName("OSBoolean")),
+cxxRecordDecl(hasName("OSNumber")))
+  .bind("cpp_object")));
 
-  auto NSNumberExprM =
-  expr(ignoringParenImpCasts(expr(hasType(hasCanonicalType(
-  objcObjectPointerType(pointee(
-  qualType(hasCanonicalType(
-  qualTyp

[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-10-18 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 updated this revision to Diff 75007.
rogfer01 added a comment.

Ignore cases where the innermost base expression is too complicated for the 
scope of this patch.


https://reviews.llvm.org/D23657

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaChecking.cpp
  test/Sema/address-packed.c

Index: test/Sema/address-packed.c
===
--- test/Sema/address-packed.c
+++ test/Sema/address-packed.c
@@ -26,6 +26,7 @@
 struct Arguable *get_arguable();
 
 void to_void(void *);
+void to_intptr(intptr_t);
 
 void g0(void) {
   {
@@ -41,43 +42,48 @@
 
 f1((int *)(void *)&arguable.x); // no-warning
 to_void(&arguable.x);   // no-warning
-void *p = &arguable.x;  // no-warning;
+void *p = &arguable.x;  // no-warning
 to_void(p);
+to_intptr((intptr_t)p); // no-warning
   }
   {
 union UnionArguable arguable;
 f2(&arguable.c); // no-warning
 f1(&arguable.x); // expected-warning {{packed member 'x' of class or structure 'UnionArguable'}}
 
-f1((int *)(void *)&arguable.x); // no-warning
-to_void(&arguable.x);   // no-warning
+f1((int *)(void *)&arguable.x);   // no-warning
+to_void(&arguable.x); // no-warning
+to_intptr((intptr_t)&arguable.x); // no-warning
   }
   {
 ArguableT arguable;
 f2(&arguable.c0); // no-warning
 f1(&arguable.x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&arguable.c1); // no-warning
 
-f1((int *)(void *)&arguable.x); // no-warning
-to_void(&arguable.x);   // no-warning
+f1((int *)(void *)&arguable.x);   // no-warning
+to_void(&arguable.x); // no-warning
+to_intptr((intptr_t)&arguable.x); // no-warning
   }
   {
 struct Arguable *arguable = get_arguable();
 f2(&arguable->c0); // no-warning
 f1(&arguable->x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&arguable->c1); // no-warning
 
-f1((int *)(void *)&arguable->x); // no-warning
-to_void(&arguable->c1);  // no-warning
+f1((int *)(void *)&arguable->x);// no-warning
+to_void(&arguable->c1); // no-warning
+to_intptr((intptr_t)&arguable->c1); // no-warning
   }
   {
 ArguableT *arguable = get_arguable();
 f2(&(arguable->c0)); // no-warning
 f1(&(arguable->x));  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&(arguable->c1)); // no-warning
 
-f1((int *)(void *)&(arguable->x)); // no-warning
-to_void(&(arguable->c1));  // no-warning
+f1((int *)(void *)&(arguable->x));  // no-warning
+to_void(&(arguable->c1));   // no-warning
+to_intptr((intptr_t)&(arguable->c1));   // no-warning
   }
 }
 
@@ -161,3 +167,130 @@
 {
 return (struct AlignedTo2Bis*)&s->x; // no-warning
 }
+
+struct S6 {
+int a;
+int _;
+int c;
+char __;
+int d;
+} __attribute__((packed, aligned(16))) s6;
+
+void g8()
+{ 
+f1(&s6.a); // no-warning
+f1(&s6.c); // no-warning
+f1(&s6.d); // expected-warning {{packed member 'd' of class or structure 'S6'}}
+}
+
+struct __attribute__((packed, aligned(1))) MisalignedContainee { double d; };
+struct __attribute__((aligned(8))) AlignedContainer { struct MisalignedContainee b; };
+
+struct AlignedContainer *p;
+double* g9() {
+  return &p->b.d; // no-warning
+}
+
+union OneUnion
+{
+uint32_t a;
+uint32_t b:1;
+};
+
+struct __attribute__((packed)) S7 {
+uint8_t length;
+uint8_t stuff;
+uint8_t padding[2];
+union OneUnion one_union;
+};
+
+union AnotherUnion {
+long data;
+struct S7 s;
+} *au;
+
+union OneUnion* get_OneUnion(void)
+{
+return &au->s.one_union; // no-warning
+}
+
+struct __attribute__((packed)) S8 {
+uint8_t data1;
+uint8_t data2;
+	uint16_t wider_data;
+};
+
+#define LE_READ_2(p)	\
+	((uint16_t)	\
+	 const uint8_t *)(p))[0]  ) |		\
+	  (((const uint8_t *)(p))[1] <<  8)))
+
+uint32_t get_wider_data(struct S8 *s)
+{
+return LE_READ_2(&s->wider_data); // no-warning
+}
+
+struct S9 {
+  uint32_t x;
+  uint8_t y[2];
+  uint16_t z;
+} __attribute__((__packed__));
+
+typedef struct S9 __attribute__((__aligned__(16))) aligned_S9;
+
+void g10() {
+  struct S9 x;
+  struct S9 __attribute__((__aligned__(8))) y;
+  aligned_S9 z;
+
+  uint32_t *p32;
+  p32 = &x.x; // expected-warning {{packed member 'x' of class or structure 'S9'}}
+  p32 = &y.x; // no-warning
+  p32 = &z.x; // no-warning
+}
+
+typedef struct {
+  uint32_t msgh_bits;
+  uint32_t msgh_size;
+  int32_t msgh_voucher_port;
+  int32_t msgh_id;
+} S10Header;
+
+typedef struct {
+  uint32_t t;
+  uint64_t m;
+  uint32_t p;
+  union {
+struct {
+  uint32_t a;
+  double z;
+} __attribute__((aligned(8), packed)) a;
+struct {
+  uint32_t b;
+  double z;
+  uint32_t a;
+} __attribute__((aligned(8), packed)) b;
+  };

[PATCH] D25062: [x86][inline-asm][AVX512][llvm][PART-2] Introducing "k" and "Yk" constraints for extended inline assembly, enabling use of AVX512 masked vectorized instructions.

2016-10-18 Thread Matan via cfe-commits
mharoush updated this revision to Diff 75005.
mharoush added a comment.

Added default case, minor ws style.


Repository:
  rL LLVM

https://reviews.llvm.org/D25062

Files:
  lib/Target/X86/X86ISelLowering.cpp

Index: lib/Target/X86/X86ISelLowering.cpp
===
--- lib/Target/X86/X86ISelLowering.cpp
+++ lib/Target/X86/X86ISelLowering.cpp
@@ -32225,6 +32225,7 @@
 case 'Y':
 case 'l':
   return C_RegisterClass;
+case 'k': // AVX512 masking registers.
 case 'a':
 case 'b':
 case 'c':
@@ -32248,6 +32249,19 @@
   break;
 }
   }
+  else if (Constraint.size() == 2) {
+switch (Constraint[0]) {
+default:
+  break;
+case 'Y':
+  switch (Constraint[1]) {
+  default:
+break;
+  case 'k':
+return C_Register;
+  }
+}
+  }
   return TargetLowering::getConstraintType(Constraint);
 }
 
@@ -32291,16 +32305,27 @@
 if (type->isX86_MMXTy() && Subtarget.hasMMX())
   weight = CW_SpecificReg;
 break;
+  case 'Y':
+// Other "Y" (e.g. "Yk") constraints should be implemented below.
+if (constraint[1] == 'k') {
+  // Support for 'Yk' (similarly to the 'k' variant below).
+  weight = CW_SpecificReg;
+  break;
+}
+  // Else fall through (handle "Y" constraint).
   case 'v':
 if ((type->getPrimitiveSizeInBits() == 512) && Subtarget.hasAVX512())
   weight = CW_Register;
 LLVM_FALLTHROUGH;
   case 'x':
-  case 'Y':
 if (((type->getPrimitiveSizeInBits() == 128) && Subtarget.hasSSE1()) ||
 ((type->getPrimitiveSizeInBits() == 256) && Subtarget.hasFp256()))
   weight = CW_Register;
 break;
+  case 'k':
+// Enable conditional vector operations using %k<#> registers.
+weight = CW_SpecificReg;
+break;
   case 'I':
 if (ConstantInt *C = dyn_cast(info.CallOperandVal)) {
   if (C->getZExtValue() <= 31)
@@ -32577,6 +32602,24 @@
   // TODO: Slight differences here in allocation order and leaving
   // RIP in the class. Do they matter any more here than they do
   // in the normal allocation?
+case 'k':
+  if (Subtarget.hasAVX512()) {
+//  Only supported in AVX512 or later.
+switch (VT.SimpleTy) {
+default: break;
+case MVT::i32:
+  return std::make_pair(0U, &X86::VK32RegClass);
+case MVT::i16:
+  return std::make_pair(0U, &X86::VK16RegClass);
+case MVT::i8:
+  return std::make_pair(0U, &X86::VK8RegClass);
+case MVT::i1:
+  return std::make_pair(0U, &X86::VK1RegClass);
+case MVT::i64:
+  return std::make_pair(0U, &X86::VK64RegClass);
+}
+  }
+  break;
 case 'q':   // GENERAL_REGS in 64-bit mode, Q_REGS in 32-bit mode.
   if (Subtarget.is64Bit()) {
 if (VT == MVT::i32 || VT == MVT::f32)
@@ -32678,6 +32721,29 @@
   }
   break;
 }
+  } else if (Constraint.size() == 2 && Constraint[0] == 'Y') {
+switch (Constraint[1]) {
+default:
+  break;
+case 'k':
+  // This register class doesn't allocate k0 for masked vector operation.
+  if (Subtarget.hasAVX512()) { // Only supported in AVX512.
+switch (VT.SimpleTy) {
+default: break;
+case MVT::i32:
+return std::make_pair(0U, &X86::VK32WMRegClass);
+case MVT::i16:
+return std::make_pair(0U, &X86::VK16WMRegClass);
+case MVT::i8:
+return std::make_pair(0U, &X86::VK8WMRegClass);
+case MVT::i1:
+return std::make_pair(0U, &X86::VK1WMRegClass);
+case MVT::i64:
+return std::make_pair(0U, &X86::VK64WMRegClass);
+} 
+  }
+  break;
+}
   }
 
   // Use the default implementation in TargetLowering to convert the register
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25727: [analyzer] Handle case of undefined values in performTrivialCopy

2016-10-18 Thread Artem Dergachev via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

This seems correct. Loading from a garbage pointer should be modeled as 
garbage, and/or caught by a checker. `performTrivialCopy` is a high-level 
thingy that should be able to deal with any `SVal` input.

The checker's warning message looks really weird, hard to figure out where's 
the call here, s/Function/Operator/ could have been an improvement, but that's 
another story.


Repository:
  rL LLVM

https://reviews.llvm.org/D25727



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


[PATCH] D15994: Allow for unfinished #if blocks in preambles.

2016-10-18 Thread Erik Verbruggen via cfe-commits
erikjv added a comment.

Yes, the patch was not committed, because there were errors in it. So, I fixed 
it and put up a new version, but I have no idea how to reset the state.

Still waiting for rsmith to review...


https://reviews.llvm.org/D15994



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


[PATCH] D25093: [libcxx] [cmake] Allow testing against installed LLVM with no sources

2016-10-18 Thread Michał Górny via cfe-commits
mgorny added a comment.

Gentle ping.


https://reviews.llvm.org/D25093



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


[PATCH] D24869: [cfe] [test] Fix detecting LLVM zlib support in stand-alone builds

2016-10-18 Thread Michał Górny via cfe-commits
mgorny added a comment.

Gentle ping.


https://reviews.llvm.org/D24869



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


[PATCH] D25431: [libcxx] Convert Solaris support library to C++ to fix -std=c++11 build

2016-10-18 Thread David Chisnall via cfe-commits
theraven added a comment.

Looks like a much better change to me.


https://reviews.llvm.org/D25431



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


[PATCH] D25431: [libcxx] Convert Solaris support library to C++ to fix -std=c++11 build

2016-10-18 Thread Michał Górny via cfe-commits
mgorny updated the summary for this revision.
mgorny updated this revision to Diff 74996.
mgorny added a comment.

Ok, here's a minimal change necessary to fix the build. I'm not touching 
anything else not to break it ;-).


https://reviews.llvm.org/D25431

Files:
  lib/CMakeLists.txt
  src/support/solaris/xlocale.c
  src/support/solaris/xlocale.cpp


Index: src/support/solaris/xlocale.cpp
===
--- src/support/solaris/xlocale.cpp
+++ src/support/solaris/xlocale.cpp
@@ -14,12 +14,13 @@
 #include 
 #include 
 
+extern "C" {
 
 int isxdigit_l(int __c, locale_t __l) {
 return isxdigit(__c);
 }
 
-int iswxdigit_l(wchar_t __c, locale_t __l) {
+int iswxdigit_l(wint_t __c, locale_t __l) {
 return isxdigit(__c);
 }
 
@@ -63,4 +64,6 @@
   return localeconv();
 }
 
+};
+
 #endif // __sun__
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -6,7 +6,7 @@
   file(GLOB LIBCXX_WIN32_SOURCES ../src/support/win32/*.cpp)
   list(APPEND LIBCXX_SOURCES ${LIBCXX_WIN32_SOURCES})
 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
-  file(GLOB LIBCXX_SOLARIS_SOURCES ../src/support/solaris/*.c)
+  file(GLOB LIBCXX_SOLARIS_SOURCES ../src/support/solaris/*.cpp)
   list(APPEND LIBCXX_SOURCES ${LIBCXX_SOLARIS_SOURCES})
 endif()
 


Index: src/support/solaris/xlocale.cpp
===
--- src/support/solaris/xlocale.cpp
+++ src/support/solaris/xlocale.cpp
@@ -14,12 +14,13 @@
 #include 
 #include 
 
+extern "C" {
 
 int isxdigit_l(int __c, locale_t __l) {
 return isxdigit(__c);
 }
 
-int iswxdigit_l(wchar_t __c, locale_t __l) {
+int iswxdigit_l(wint_t __c, locale_t __l) {
 return isxdigit(__c);
 }
 
@@ -63,4 +64,6 @@
   return localeconv();
 }
 
+};
+
 #endif // __sun__
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -6,7 +6,7 @@
   file(GLOB LIBCXX_WIN32_SOURCES ../src/support/win32/*.cpp)
   list(APPEND LIBCXX_SOURCES ${LIBCXX_WIN32_SOURCES})
 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
-  file(GLOB LIBCXX_SOLARIS_SOURCES ../src/support/solaris/*.c)
+  file(GLOB LIBCXX_SOLARIS_SOURCES ../src/support/solaris/*.cpp)
   list(APPEND LIBCXX_SOURCES ${LIBCXX_SOLARIS_SOURCES})
 endif()
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25606: alpha.core.UnreachableCode - don't warn about unreachable code inside macro

2016-10-18 Thread Daniel Marjamäki via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284477: alpha.core.UnreachableCode - don't warn about 
unreachable code inside macro (authored by danielmarjamaki).

Changed prior to commit:
  https://reviews.llvm.org/D25606?vs=74849&id=74990#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25606

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
  cfe/trunk/test/Analysis/unreachable-code-path.c


Index: cfe/trunk/test/Analysis/unreachable-code-path.c
===
--- cfe/trunk/test/Analysis/unreachable-code-path.c
+++ cfe/trunk/test/Analysis/unreachable-code-path.c
@@ -206,3 +206,10 @@
   int x = inlineFunction(i);
   x && x < 10; // no-warning
 }
+
+// Don't warn in a macro
+#define RETURN(X)  do { return; } while (0)
+void macro(void) {
+  RETURN(1); // no-warning
+}
+
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
@@ -147,6 +147,14 @@
 PathDiagnosticLocation DL;
 SourceLocation SL;
 if (const Stmt *S = getUnreachableStmt(CB)) {
+  // In macros, 'do {...} while (0)' is often used. Don't warn about the
+  // condition 0 when it is unreachable.
+  if (S->getLocStart().isMacroID())
+if (const auto *I = dyn_cast(S))
+  if (I->getValue() == 0ULL)
+if (const Stmt *Parent = PM->getParent(S))
+  if (isa(Parent))
+continue;
   SR = S->getSourceRange();
   DL = PathDiagnosticLocation::createBegin(S, B.getSourceManager(), LC);
   SL = DL.asLocation();


Index: cfe/trunk/test/Analysis/unreachable-code-path.c
===
--- cfe/trunk/test/Analysis/unreachable-code-path.c
+++ cfe/trunk/test/Analysis/unreachable-code-path.c
@@ -206,3 +206,10 @@
   int x = inlineFunction(i);
   x && x < 10; // no-warning
 }
+
+// Don't warn in a macro
+#define RETURN(X)  do { return; } while (0)
+void macro(void) {
+  RETURN(1); // no-warning
+}
+
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
@@ -147,6 +147,14 @@
 PathDiagnosticLocation DL;
 SourceLocation SL;
 if (const Stmt *S = getUnreachableStmt(CB)) {
+  // In macros, 'do {...} while (0)' is often used. Don't warn about the
+  // condition 0 when it is unreachable.
+  if (S->getLocStart().isMacroID())
+if (const auto *I = dyn_cast(S))
+  if (I->getValue() == 0ULL)
+if (const Stmt *Parent = PM->getParent(S))
+  if (isa(Parent))
+continue;
   SR = S->getSourceRange();
   DL = PathDiagnosticLocation::createBegin(S, B.getSourceManager(), LC);
   SL = DL.asLocation();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r284477 - alpha.core.UnreachableCode - don't warn about unreachable code inside macro

2016-10-18 Thread Daniel Marjamaki via cfe-commits
Author: danielmarjamaki
Date: Tue Oct 18 08:16:53 2016
New Revision: 284477

URL: http://llvm.org/viewvc/llvm-project?rev=284477&view=rev
Log:
alpha.core.UnreachableCode - don't warn about unreachable code inside macro

In macros, 'do {...} while (0)' is often used. Don't warn about the condition 0 
when it is unreachable.

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


Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
cfe/trunk/test/Analysis/unreachable-code-path.c

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp?rev=284477&r1=284476&r2=284477&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp Tue Oct 18 
08:16:53 2016
@@ -147,6 +147,14 @@ void UnreachableCodeChecker::checkEndAna
 PathDiagnosticLocation DL;
 SourceLocation SL;
 if (const Stmt *S = getUnreachableStmt(CB)) {
+  // In macros, 'do {...} while (0)' is often used. Don't warn about the
+  // condition 0 when it is unreachable.
+  if (S->getLocStart().isMacroID())
+if (const auto *I = dyn_cast(S))
+  if (I->getValue() == 0ULL)
+if (const Stmt *Parent = PM->getParent(S))
+  if (isa(Parent))
+continue;
   SR = S->getSourceRange();
   DL = PathDiagnosticLocation::createBegin(S, B.getSourceManager(), LC);
   SL = DL.asLocation();

Modified: cfe/trunk/test/Analysis/unreachable-code-path.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/unreachable-code-path.c?rev=284477&r1=284476&r2=284477&view=diff
==
--- cfe/trunk/test/Analysis/unreachable-code-path.c (original)
+++ cfe/trunk/test/Analysis/unreachable-code-path.c Tue Oct 18 08:16:53 2016
@@ -206,3 +206,10 @@ void test13(int i) {
   int x = inlineFunction(i);
   x && x < 10; // no-warning
 }
+
+// Don't warn in a macro
+#define RETURN(X)  do { return; } while (0)
+void macro(void) {
+  RETURN(1); // no-warning
+}
+


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


[clang-tools-extra] r284476 - Fix signed/unsigned comparison warnings

2016-10-18 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue Oct 18 08:15:31 2016
New Revision: 284476

URL: http://llvm.org/viewvc/llvm-project?rev=284476&view=rev
Log:
Fix signed/unsigned comparison warnings

Modified:
clang-tools-extra/trunk/unittests/clang-tidy/NamespaceAliaserTest.cpp
clang-tools-extra/trunk/unittests/clang-tidy/UsingInserterTest.cpp

Modified: clang-tools-extra/trunk/unittests/clang-tidy/NamespaceAliaserTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/NamespaceAliaserTest.cpp?rev=284476&r1=284475&r2=284476&view=diff
==
--- clang-tools-extra/trunk/unittests/clang-tidy/NamespaceAliaserTest.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/clang-tidy/NamespaceAliaserTest.cpp Tue 
Oct 18 08:15:31 2016
@@ -51,7 +51,7 @@ private:
 };
 
 template 
-std::string runChecker(StringRef Code, int ExpectedWarningCount) {
+std::string runChecker(StringRef Code, unsigned ExpectedWarningCount) {
   std::map AdditionalFileContents = {{"foo.h",
 "namespace foo {\n"
 "namespace bar {\n"

Modified: clang-tools-extra/trunk/unittests/clang-tidy/UsingInserterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/UsingInserterTest.cpp?rev=284476&r1=284475&r2=284476&view=diff
==
--- clang-tools-extra/trunk/unittests/clang-tidy/UsingInserterTest.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/clang-tidy/UsingInserterTest.cpp Tue Oct 
18 08:15:31 2016
@@ -53,7 +53,7 @@ private:
 };
 
 template 
-std::string runChecker(StringRef Code, int ExpectedWarningCount) {
+std::string runChecker(StringRef Code, unsigned ExpectedWarningCount) {
   std::map AdditionalFileContents = {{"foo.h",
 "namespace foo {\n"
 "namespace bar {\n"


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


[PATCH] D25363: [Sema] Store a SourceRange for multi-token builtin types

2016-10-18 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/AST/TypeLoc.h:513
 struct BuiltinLocInfo {
-  SourceLocation BuiltinLoc;
+  SourceRange BuiltinRange;
 };

malcolm.parsons wrote:
> aaron.ballman wrote:
> > Since this doubles the size of the type loc for builtin types, do you 
> > happen to have any data on what practical impact this has on RAM usage, say 
> > for bootstrapping LLVM (or compiling any large source base, really)? 
> > Hopefully it's not a lot, but it would be nice to know if it's a .1%, 1%, 
> > 10%, etc increase in usage (or does the change get lost in the noise).
> I don't have any data.
> I'm not sure how to collect that data.
It's likely platform dependent, but I was thinking something as simple as 
looking at peak RAM usage between two different builds of the compiler. 
Something like `top` would probably work if you're on Linux (unless someone 
knows of a better way, I'm not strong on Linux).



Comment at: unittests/AST/SourceLocationTest.cpp:228
+}
+
 TEST(CXXConstructorDecl, NoRetFunTypeLocRange) {

malcolm.parsons wrote:
> aaron.ballman wrote:
> > Can you also add a test that the range is correct for something like `long 
> > double`  and `long double _Complex`?
> `ComplexTypeLoc` isn't implemented.
> 
> include/clang/AST/TypeLoc.h:
> ```
> // FIXME: location of the '_Complex' keyword.
> class ComplexTypeLoc : public InheritingConcreteTypeLoc ComplexTypeLoc,
> ComplexType> {
> };
> ```
Ah, neat, then don't worry about that one. :-)


https://reviews.llvm.org/D25363



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


[PATCH] D25062: [x86][inline-asm][AVX512][llvm][PART-2] Introducing "k" and "Yk" constraints for extended inline assembly, enabling use of AVX512 masked vectorized instructions.

2016-10-18 Thread Matan via cfe-commits
mharoush updated this revision to Diff 74986.
mharoush added a comment.
Herald added a subscriber: mehdi_amini.

fixed Reids comments


Repository:
  rL LLVM

https://reviews.llvm.org/D25062

Files:
  lib/Target/X86/X86ISelLowering.cpp

Index: lib/Target/X86/X86ISelLowering.cpp
===
--- lib/Target/X86/X86ISelLowering.cpp
+++ lib/Target/X86/X86ISelLowering.cpp
@@ -32225,6 +32225,7 @@
 case 'Y':
 case 'l':
   return C_RegisterClass;
+case 'k': // AVX512 masking registers.
 case 'a':
 case 'b':
 case 'c':
@@ -32248,6 +32249,19 @@
   break;
 }
   }
+  else if (Constraint.size() == 2) {
+switch (Constraint[0]) {
+default:
+  break;
+case 'Y':
+  switch (Constraint[1]) {
+  default:
+break;
+  case 'k':
+return C_Register;
+  }
+}
+  }
   return TargetLowering::getConstraintType(Constraint);
 }
 
@@ -32291,16 +32305,27 @@
 if (type->isX86_MMXTy() && Subtarget.hasMMX())
   weight = CW_SpecificReg;
 break;
+  case 'Y':
+// Other "Y" (e.g. "Yk") constraints should be implemented below.
+if (constraint[1] == 'k') {
+  // Support for 'Yk' (similarly to the 'k' variant below).
+  weight = CW_SpecificReg;
+  break;
+}
+  // Else fall through (handle "Y" constraint).
   case 'v':
 if ((type->getPrimitiveSizeInBits() == 512) && Subtarget.hasAVX512())
   weight = CW_Register;
 LLVM_FALLTHROUGH;
   case 'x':
-  case 'Y':
 if (((type->getPrimitiveSizeInBits() == 128) && Subtarget.hasSSE1()) ||
 ((type->getPrimitiveSizeInBits() == 256) && Subtarget.hasFp256()))
   weight = CW_Register;
 break;
+  case 'k':
+// Enable conditional vector operations using %k<#> registers.
+weight = CW_SpecificReg;
+break;
   case 'I':
 if (ConstantInt *C = dyn_cast(info.CallOperandVal)) {
   if (C->getZExtValue() <= 31)
@@ -32577,6 +32602,23 @@
   // TODO: Slight differences here in allocation order and leaving
   // RIP in the class. Do they matter any more here than they do
   // in the normal allocation?
+case 'k':
+  if (Subtarget.hasAVX512()) {
+//  Only supported in AVX512 or later.
+  switch (VT.SimpleTy) {
+  case MVT::i32:
+return std::make_pair(0U, &X86::VK32RegClass);
+  case MVT::i16:
+return std::make_pair(0U, &X86::VK16RegClass);
+  case MVT::i8:
+return std::make_pair(0U, &X86::VK8RegClass);
+  case MVT::i1:
+return std::make_pair(0U, &X86::VK1RegClass);
+  case MVT::i64:
+return std::make_pair(0U, &X86::VK64RegClass);
+  }
+  }
+  break;
 case 'q':   // GENERAL_REGS in 64-bit mode, Q_REGS in 32-bit mode.
   if (Subtarget.is64Bit()) {
 if (VT == MVT::i32 || VT == MVT::f32)
@@ -32678,6 +32720,28 @@
   }
   break;
 }
+  } else if (Constraint.size() == 2 && Constraint[0] == 'Y') {
+switch (Constraint[1]) {
+default:
+  break;
+case 'k':
+  // This register class doesn't allocate k0 for masked vector operation.
+  if (Subtarget.hasAVX512()) { // Only supported in AVX512.
+  switch (VT.SimpleTy) {
+  case MVT::i32:
+  return std::make_pair(0U, &X86::VK32WMRegClass);
+  case MVT::i16:
+  return std::make_pair(0U, &X86::VK16WMRegClass);
+  case MVT::i8:
+  return std::make_pair(0U, &X86::VK8WMRegClass);
+  case MVT::i1:
+  return std::make_pair(0U, &X86::VK1WMRegClass);
+  case MVT::i64:
+  return std::make_pair(0U, &X86::VK64WMRegClass);
+  } 
+  }
+  break;
+}
   }
 
   // Use the default implementation in TargetLowering to convert the register
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25717: [x86][inline-asm][clang][fixup] accept 'v' constraint

2016-10-18 Thread coby via cfe-commits
coby created this revision.
coby added a reviewer: m_zuckerman.
coby added a subscriber: cfe-commits.
coby set the repository for this revision to rL LLVM.

In respect to https://reviews.llvm.org/D25004 (reverted)


Repository:
  rL LLVM

https://reviews.llvm.org/D25717

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/x86-inline-asm-v-constraint.c


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -3949,6 +3949,7 @@
   case 'u': // Second from top of floating point stack.
   case 'q': // Any register accessible as [r]l: a, b, c, and d.
   case 'y': // Any MMX register.
+  case 'v': // Any {X,Y,Z}MM register (Arch & context dependent)
   case 'x': // Any SSE register.
   case 'Q': // Any register accessible as [r]h: a, b, c, and d.
   case 'R': // "Legacy" registers: ax, bx, cx, dx, di, si, sp, bp.
@@ -3989,6 +3990,7 @@
   case 't':
   case 'u':
 return Size <= 128;
+  case 'v':
   case 'x':
 if (SSELevel >= AVX512F)
   // 512-bit zmm registers can be used if target supports AVX512F.
Index: test/CodeGen/x86-inline-asm-v-constraint.c
===
--- test/CodeGen/x86-inline-asm-v-constraint.c
+++ test/CodeGen/x86-inline-asm-v-constraint.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu 
x86-64 -o - | FileCheck %s --check-prefix SSE
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu 
skylake -D AVX -o - | FileCheck %s --check-prefixes AVX,SSE
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu 
skylake-avx512 -D AVX512 -D AVX -o - | FileCheck %s --check-prefixes 
AVX512,AVX,SSE
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu 
knl -D AVX -D AVX512 -o - | FileCheck %s --check-prefixes AVX512,AVX,SSE
+
+typedef float __m128 __attribute__ ((vector_size (16)));
+typedef float __m256 __attribute__ ((vector_size (32)));
+typedef float __m512 __attribute__ ((vector_size (64)));
+
+// SSE: call <4 x float> asm "vmovhlps $1, $2, $0", 
"=v,v,v,~{dirflag},~{fpsr},~{flags}"
+__m128 testXMM(__m128 _xmm0, long _l) {
+  __asm__("vmovhlps %1, %2, %0" :"=v"(_xmm0) : "v"(_l), "v"(_xmm0));
+  return _xmm0;
+}
+
+// AVX: call <8 x float> asm "vmovsldup $1, $0", 
"=v,v,~{dirflag},~{fpsr},~{flags}"
+__m256 testYMM(__m256 _ymm0) {
+#ifdef AVX
+  __asm__("vmovsldup %1, %0" :"=v"(_ymm0) : "v"(_ymm0));
+#endif
+  return _ymm0;
+}
+
+// AVX512: call <16 x float> asm "vpternlogd $$0, $1, $2, $0", 
"=v,v,v,~{dirflag},~{fpsr},~{flags}"
+__m512 testZMM(__m512 _zmm0, __m512 _zmm1) {
+#ifdef AVX512
+  __asm__("vpternlogd $0, %1, %2, %0" :"=v"(_zmm0) : "v"(_zmm1), "v"(_zmm0));
+#endif
+  return _zmm0;
+}


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -3949,6 +3949,7 @@
   case 'u': // Second from top of floating point stack.
   case 'q': // Any register accessible as [r]l: a, b, c, and d.
   case 'y': // Any MMX register.
+  case 'v': // Any {X,Y,Z}MM register (Arch & context dependent)
   case 'x': // Any SSE register.
   case 'Q': // Any register accessible as [r]h: a, b, c, and d.
   case 'R': // "Legacy" registers: ax, bx, cx, dx, di, si, sp, bp.
@@ -3989,6 +3990,7 @@
   case 't':
   case 'u':
 return Size <= 128;
+  case 'v':
   case 'x':
 if (SSELevel >= AVX512F)
   // 512-bit zmm registers can be used if target supports AVX512F.
Index: test/CodeGen/x86-inline-asm-v-constraint.c
===
--- test/CodeGen/x86-inline-asm-v-constraint.c
+++ test/CodeGen/x86-inline-asm-v-constraint.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu x86-64 -o - | FileCheck %s --check-prefix SSE
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu skylake -D AVX -o - | FileCheck %s --check-prefixes AVX,SSE
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu skylake-avx512 -D AVX512 -D AVX -o - | FileCheck %s --check-prefixes AVX512,AVX,SSE
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu knl -D AVX -D AVX512 -o - | FileCheck %s --check-prefixes AVX512,AVX,SSE
+
+typedef float __m128 __attribute__ ((vector_size (16)));
+typedef float __m256 __attribute__ ((vector_size (32)));
+typedef float __m512 __attribute__ ((vector_size (64)));
+
+// SSE: call <4 x float> asm "vmovhlps $1, $2, $0", "=v,v,v,~{dirflag},~{fpsr},~{flags}"
+__m128 testXMM(__m128 _xmm0, long _l) {
+  __asm__("vmovhlps %1, %2, %0" :"=v"(_xmm0) : "v"(_l), "v"(_xmm0));
+  return _xmm0;
+}
+
+// AVX: call <8 x float> asm "vmovsldup $1, $0", "=v,v,~{dirflag},~{fpsr},~{flags}"
+__m256 testYMM(__m256 _ymm0) {
+#ifdef AVX
+  __asm__("vmovsldup %1, %0" :"=v"(_ymm0) : "v"(_ymm0));
+#endif
+  return _ymm0;
+

r284445 - [analyzer] Update alpha and potential checker documentation, esp. alpha.valist

2016-10-18 Thread Dominic Chen via cfe-commits
Author: ddcc
Date: Mon Oct 17 20:15:19 2016
New Revision: 284445

URL: http://llvm.org/viewvc/llvm-project?rev=284445&view=rev
Log:
[analyzer] Update alpha and potential checker documentation, esp. alpha.valist

Summary:
Move alpha.valist from potential to alpha since it was implemented in D15227

Cleanup some HTML comments, add a missing link

Reviewers: jordan_rose, zaks.anna

Subscribers: cfe-commits, xazax.hun

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

Modified:
cfe/trunk/www/analyzer/alpha_checks.html
cfe/trunk/www/analyzer/potential_checkers.html

Modified: cfe/trunk/www/analyzer/alpha_checks.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/analyzer/alpha_checks.html?rev=284445&r1=28&r2=284445&view=diff
==
--- cfe/trunk/www/analyzer/alpha_checks.html (original)
+++ cfe/trunk/www/analyzer/alpha_checks.html Mon Oct 17 20:15:19 2016
@@ -26,13 +26,14 @@ Patches welcome!
 
 Core Alpha Checkers
 C++ Alpha Checkers
+Variable Argument Alpha Checkers
 Dead Code Alpha Checkers
 OS X Alpha Checkers
 Security Alpha Checkers
 Unix Alpha Checkers
 
 
-
+
 Core Alpha Checkers
 
 
@@ -179,7 +180,7 @@ int test(struct s *p) {
 
 
 
-
+
 C++ Alpha Checkers
 
 
@@ -226,7 +227,76 @@ public:
 
 
 
-
+
+
+
+Variable Argument Alpha Checkers
+
+
+Name, DescriptionExample
+
+
+
+alpha.valist.CopyToSelf
+(C)
+Calls to the va_copy macro should not copy onto 
itself.
+
+
+#include 
+
+void test(int x, ...) {
+  va_list args;
+  va_start(args, x);
+  va_copy(args, args); // warn
+  va_end(args);
+}
+
+
+
+alpha.valist.Uninitialized
+(C)
+Calls to the va_arg, va_copy, or
+va_end macro must happen after calling va_start and
+before calling va_end.
+
+
+#include 
+
+void test(int x, ...) {
+  va_list args;
+  int y = va_arg(args, int); // warn
+}
+
+
+#include 
+
+void test(int x, ...) {
+  va_list args;
+  va_start(args, x);
+  va_end(args);
+  int z = va_arg(args, int); // warn
+}
+
+
+
+alpha.valist.Unterminated
+(C)
+Every va_start must be matched by a va_end. A va_list
+can only be ended once.
+
+
+#include 
+
+void test(int x, ...) {
+  va_list args;
+  va_start(args, x);
+  int y = x + va_arg(args, int);
+} // warn: missing va_end
+
+
+
+
+
 Dead Code Alpha Checkers
 
 
@@ -267,7 +337,7 @@ void test(id x) {
 
 
 
-
+
 OS X Alpha Checkers
 
 
@@ -433,7 +503,7 @@ invalidatable instance variables.<
 
 
 
-
+
 Security Alpha Checkers
 
 
@@ -584,7 +654,7 @@ void test() {
 
 
 
-
+
 Unix Alpha Checkers
 
 

Modified: cfe/trunk/www/analyzer/potential_checkers.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/analyzer/potential_checkers.html?rev=284445&r1=28&r2=284445&view=diff
==
--- cfe/trunk/www/analyzer/potential_checkers.html (original)
+++ cfe/trunk/www/analyzer/potential_checkers.html Mon Oct 17 20:15:19 2016
@@ -180,64 +180,6 @@ void test(A *dst, A *src) {
 
 
 
-
-va_list
-
-
-Name, 
DescriptionExampleProgress
-
-
-valist.Uninitialized
-(C)
-Calls to the va_arg, va_copy, or
-va_end macro must happen after calling va_start and
-before calling va_end.
-
-
-#include 
-
-void test(int x, ...) {
-  va_list args;
-  int y = va_arg(args, int); // warn
-}
-
-
-#include 
-
-void test(int x, ...) {
-  va_list args;
-  va_start(args, x); 
-  va_end(args);
-  int z = va_arg(args, int); // warn
-}
-
-http://llvm.org/bugs/show_bug.cgi?id=16812";>
-PR16811
-
-
-valist.Unterminated
-(C)
-Every va_start must be matched by a va_end. A va_list
-can only be ended once.
-
-This should be folded into the generalized "ownership checker"
-described on the 
-Open Projects page.
-
-
-#include 
-
-void test(int x, ...) {
-  va_list args;
-  va_start(args, x);
-  int y = x + va_arg(args, int);
-} // warn: missing va_end
-
-http://llvm.org/bugs/show_bug.cgi?id=16812";>
-PR16812
-
-
-
 
 exceptions
 
@@ -384,7 +326,8 @@ void test() {
// warn: the right operand to '-' is always 0
 }
 
-removed from alpha.deadcode.* at r198476
+removed from alpha.deadcode.* at
+https://reviews.llvm.org/rL198476";>r198476
 
 
 


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


[PATCH] D25663: [analyzer] Update alpha and potential checker documentation, esp. alpha.valist

2016-10-18 Thread Dominic Chen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284445: [analyzer] Update alpha and potential checker 
documentation, esp. alpha.valist (authored by ddcc).

Changed prior to commit:
  https://reviews.llvm.org/D25663?vs=74807&id=74941#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25663

Files:
  cfe/trunk/www/analyzer/alpha_checks.html
  cfe/trunk/www/analyzer/potential_checkers.html

Index: cfe/trunk/www/analyzer/potential_checkers.html
===
--- cfe/trunk/www/analyzer/potential_checkers.html
+++ cfe/trunk/www/analyzer/potential_checkers.html
@@ -180,64 +180,6 @@
 
 
 
-
-va_list
-
-
-Name, DescriptionExampleProgress
-
-
-valist.Uninitialized
-(C)
-Calls to the va_arg, va_copy, or
-va_end macro must happen after calling va_start and
-before calling va_end.
-
-
-#include 
-
-void test(int x, ...) {
-  va_list args;
-  int y = va_arg(args, int); // warn
-}
-
-
-#include 
-
-void test(int x, ...) {
-  va_list args;
-  va_start(args, x); 
-  va_end(args);
-  int z = va_arg(args, int); // warn
-}
-
-http://llvm.org/bugs/show_bug.cgi?id=16812";>
-PR16811
-
-
-valist.Unterminated
-(C)
-Every va_start must be matched by a va_end. A va_list
-can only be ended once.
-
-This should be folded into the generalized "ownership checker"
-described on the 
-Open Projects page.
-
-
-#include 
-
-void test(int x, ...) {
-  va_list args;
-  va_start(args, x);
-  int y = x + va_arg(args, int);
-} // warn: missing va_end
-
-http://llvm.org/bugs/show_bug.cgi?id=16812";>
-PR16812
-
-
-
 
 exceptions
 
@@ -384,7 +326,8 @@
// warn: the right operand to '-' is always 0
 }
 
-removed from alpha.deadcode.* at r198476
+removed from alpha.deadcode.* at
+https://reviews.llvm.org/rL198476";>r198476
 
 
 
Index: cfe/trunk/www/analyzer/alpha_checks.html
===
--- cfe/trunk/www/analyzer/alpha_checks.html
+++ cfe/trunk/www/analyzer/alpha_checks.html
@@ -26,13 +26,14 @@
 
 Core Alpha Checkers
 C++ Alpha Checkers
+Variable Argument Alpha Checkers
 Dead Code Alpha Checkers
 OS X Alpha Checkers
 Security Alpha Checkers
 Unix Alpha Checkers
 
 
-
+
 Core Alpha Checkers
 
 
@@ -179,7 +180,7 @@
 
 
 
-
+
 C++ Alpha Checkers
 
 
@@ -226,7 +227,76 @@
 
 
 
-
+
+
+
+Variable Argument Alpha Checkers
+
+
+Name, DescriptionExample
+
+
+
+alpha.valist.CopyToSelf
+(C)
+Calls to the va_copy macro should not copy onto itself.
+
+
+#include 
+
+void test(int x, ...) {
+  va_list args;
+  va_start(args, x);
+  va_copy(args, args); // warn
+  va_end(args);
+}
+
+
+
+alpha.valist.Uninitialized
+(C)
+Calls to the va_arg, va_copy, or
+va_end macro must happen after calling va_start and
+before calling va_end.
+
+
+#include 
+
+void test(int x, ...) {
+  va_list args;
+  int y = va_arg(args, int); // warn
+}
+
+
+#include 
+
+void test(int x, ...) {
+  va_list args;
+  va_start(args, x);
+  va_end(args);
+  int z = va_arg(args, int); // warn
+}
+
+
+
+alpha.valist.Unterminated
+(C)
+Every va_start must be matched by a va_end. A va_list
+can only be ended once.
+
+
+#include 
+
+void test(int x, ...) {
+  va_list args;
+  va_start(args, x);
+  int y = x + va_arg(args, int);
+} // warn: missing va_end
+
+
+
+
+
 Dead Code Alpha Checkers
 
 
@@ -267,7 +337,7 @@
 
 
 
-
+
 OS X Alpha Checkers
 
 
@@ -433,7 +503,7 @@
 
 
 
-
+
 Security Alpha Checkers
 
 
@@ -584,7 +654,7 @@
 
 
 
-
+
 Unix Alpha Checkers
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25024: [clang-tidy] Add check for detecting declarations with multiple names

2016-10-18 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.



Comment at: test/clang-tidy/cppcoreguidelines-one-name-per-declaration.cpp:8
+  {
+int x = 42, y = 43;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Do not declare multiple names 
per declaration [cppcoreguidelines-one-name-per-declaration]

aaron.ballman wrote:
> malcolm.parsons wrote:
> > omtcyfz wrote:
> > > malcolm.parsons wrote:
> > > > The guideline says "Flag non-function arguments with multiple 
> > > > declarators involving declarator operators (e.g., int* p, q;)".
> > > > 
> > > > There are no declarator operators in this test, so there should be no 
> > > > warning.
> > > The guideline says
> > > 
> > > > Reason: One-declaration-per line increases readability and avoids 
> > > > mistakes related to the C/C++ grammar. It also leaves room for a more 
> > > > descriptive end-of-line comment.
> > > 
> > > > Exception: a function declaration can contain several function argument 
> > > > declarations.
> > > 
> > > I'm not sure why what you copied is written in "Enforcement" section, but 
> > > I do not think that is how it should be handled. I am concerned not only 
> > > about that specific case and I see no reason to cut off cases already 
> > > presented in this test.
> > "mistakes related to the C/C++ grammar" only occur when declarator 
> > operators are involved. e.g. in `int* p, q` a reader might incorrectly 
> > think that q was a pointer.
> > 
> > I see reasons not to warn about cases like
> > `for (auto i = c.begin(), e = someExpensiveFn(); i != e; i++)`
> > `for (int i = 0, j = someExpensiveFn(); i < j; i++);`
> > because the alternatives increase variable scope, or for
> > `int x = 42, y = 43;`
> > because it's not difficult to read.
> > 
> > As we disagree on this, can it be made configurable?
> We usually try to ensure that the check matches the behavior required by the 
> normative wording of coding rules we follow. Based on that, the C++ core 
> guideline rule only cares about declarator operators while the CERT 
> recommendation kind of does not care about them. If you think the C++ core 
> guideline enforcement is wrong, you can file a bug against that project to 
> see if the editors agree, but I think the check should match the documented 
> behavior from the guidelines. FWIW, I'm happy to work on the CERT semantics 
> if you don't want to deal with those beyond what you've already done (or you 
> can tackle the semantic differences if you want).
The CERT recommendation does care about declarator operators:

"Multiple, simple variable declarations can be declared on the same line given 
that there are no initializations. A simple variable declaration is one that is 
not a pointer or array."

|Declaration| CERT |CppCoreGuidelines| Me   |
|int i; | GOOD | GOOD| GOOD |
|int i = 1; | GOOD | GOOD| GOOD |
|int *p;| GOOD | GOOD| GOOD |
|int *p, q; | BAD  | BAD | BAD  |
|int i, j;  | GOOD | GOOD| GOOD |
|int i, j = 1;  | BAD  | GOOD| BAD  |
|int i = 1, j = 1;  | BAD  | GOOD| GOOD |
|int i = 1, j;  | BAD  | GOOD| BAD  |
|int *i, *j;| BAD  | BAD | BAD  |
|for (int i = 0, j = size; i != j; i++) | GOOD | GOOD| GOOD |
|for (int *p = a, *q = a+size; p != q; p++) | GOOD | BAD | GOOD |

I agree with CERT for most cases.



Comment at: test/clang-tidy/cppcoreguidelines-one-name-per-declaration.cpp:16
+  return 0;
+}

malcolm.parsons wrote:
> aaron.ballman wrote:
> > Please add tests that show the exceptions in the C++ Core Guidelines are 
> > properly handled. Also, I'd like to see tests with other named 
> > declarations, such as typedefs, template parameter lists, for loop 
> > initializers, etc.
> and structured bindings (no warning).
and global variables.


https://reviews.llvm.org/D25024



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


Re: [PATCH] D24572: [clang-tidy] Clean up code after applying replacements.

2016-10-18 Thread Malcolm Parsons via cfe-commits
On 18 October 2016 at 12:08, Eric Liu  wrote:

> clang-apply-replacements has some legacy code and needs some refactoring
> in order to take advantage of the cleanup feature (because of the new
> tooling::Replacements implementation). I had a plan to refactor it but
> thought it was a low priority since most refactoring tools are using
> replacements application functions in tooling::RefactoringTool, and I also
> have a plan to replace clang-apply-replacements with a better
> infrastructure that can supports more refactoring actions.
>

I use run-clang-tidy.py to run clang-tidy and clang-apply-replacements.
D24339 needs cleanupAroundReplacements to avoid creating syntax errors.
So it would be helpful if clang-apply-replacements did this cleanup.

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


[PATCH] D22638: Module: add debug_type to dump debugging messages related to modules being out of date

2016-10-18 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added a comment.

Also, creduce (I've specialized it a bit for modules) helps reducing the 
modules complexity 
(https://github.com/vgvassilev/creduce/blob/master/USAGE.md#reducing-clang-c-modules-bugs).
 After reduction, the debugger is much more useful.


https://reviews.llvm.org/D22638



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


[PATCH] D22638: Module: add debug_type to dump debugging messages related to modules being out of date

2016-10-18 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added a comment.

I am not sure whether that's useful for debugging out-of-date issues but this 
is what I use and it is helpful.

Some debugging aids (suggested by Richard Smith):

  -fdiagnostics-show-note-include-stack will tell you which module a note comes 
from
  #pragma clang __debug dump X allows you to produce an AST dump from within a 
source file, so you can see which modules declare a given name
  #pragma clang __debug macro M allows you to dump a macro, which can be useful 
to see which module(s) export visible include guards for a header

If a name is not visible in a modules build but is visible in a non-modules 
build, i usually find that's due to one of two things

  some part of the machinery that provides it depends on macro definitions 
leaking into a modular header from outside, or
  there is an include cycle involving a modular header and a non-modular header


https://reviews.llvm.org/D22638



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


[PATCH] D25024: [clang-tidy] Add check for detecting declarations with multiple names

2016-10-18 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a comment.

Opened an [[ https://github.com/isocpp/CppCoreGuidelines/issues/770 | issue  
]]in CppCoreGuidelines Github repo.


https://reviews.llvm.org/D25024



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


[PATCH] D25017: [mips][msa] Range check MSA intrinsics with immediates

2016-10-18 Thread Vasileios Kalintiris via cfe-commits
vkalintiris added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:1633-1637
+  if (!m)
+return SemaBuiltinConstantArgRange(TheCall, i, l, u);
+
+return SemaBuiltinConstantArgRange(TheCall, i, l, u) ||
+   SemaBuiltinConstantArgMultiple(TheCall, i, m);

Also, can you fix the indentation here and check with clang-format for long 
lines in the code?


https://reviews.llvm.org/D25017



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


[PATCH] D25017: [mips][msa] Range check MSA intrinsics with immediates

2016-10-18 Thread Vasileios Kalintiris via cfe-commits
vkalintiris accepted this revision.
vkalintiris added a comment.
This revision is now accepted and ready to land.

LGTM. See inline comments for a few small changes.

The only issue I've found with test/CodeGen/builtins-mips-msa-error.c is that 
GCC checks strictly the signedness of the arguments passed to the builtins. 
Having a FIXME comment in order to make Clang follow the same behaviour in the 
future would be nice.




Comment at: test/CodeGen/builtins-mips-msa-error.c:24-35
+  v16u8 v16u8_a = (v16u8) {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 
15};
+  v16u8 v16u8_b = (v16u8) {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 
16};
+  v16u8 v16u8_r;
+  v8u16 v8u16_a = (v8u16) {0, 1, 2, 3, 4, 5, 6, 7};
+  v8u16 v8u16_b = (v8u16) {1, 2, 3, 4, 5, 6, 7, 8};
+  v8u16 v8u16_r;
+  v4u32 v4u32_a = (v4u32) {0, 1, 2, 3};

We don't use the `v_b` vectors anywhere.



Comment at: test/CodeGen/builtins-mips-msa-error.c:37-45
+  v8f16 v8f16_a = (v8f16) {0.5, 1, 2, 3, 4, 5, 6, 7};
+  v8f16 v8f16_b = (v8f16) {1.5, 2, 3, 4, 5, 6, 7, 8};
+  v8f16 v8f16_r;
+  v4f32 v4f32_a = (v4f32) {0.5, 1, 2, 3};
+  v4f32 v4f32_b = (v4f32) {1.5, 2, 3, 4};
+  v4f32 v4f32_r;
+  v2f64 v2f64_a = (v2f64) {0.5, 1};

We don't test anything with these. We can delete them along with the typedef 
above.



Comment at: test/CodeGen/builtins-mips-msa-error.c:49
+  long long ll_r;
+  int int_a = 0;
+

Unused as well.



Comment at: test/CodeGen/builtins-mips-msa-error.c:119
+  int_r = __msa_copy_s_h(v8i16_a, 8);// expected-error 
{{argument should be a value from 0 to 7}}
+  int_r = __msa_copy_s_w(v4i32_a, 3);// expected-error 
{{argument should be a value from 0 to 3}}
+  ll_r  = __msa_copy_s_d(v2i64_a, 2);// expected-error 
{{argument should be a value from 0 to 1}}

The passed argument is in the valid value range.



Comment at: test/CodeGen/builtins-mips-msa-error.c:308-311
+  v16i8_r = __msa_clti_s_b(v16i8_a, -1); // expected-error 
{{argument should be a value from -16 to 15}}
+  v8i16_r = __msa_clti_s_h(v8i16_a, -1); // expected-error 
{{argument should be a value from -16 to 15}}
+  v4i32_r = __msa_clti_s_w(v4i32_a, -1); // expected-error 
{{argument should be a value from -16 to 15}}
+  v2i64_r = __msa_clti_s_d(v2i64_a, -1); // expected-error 
{{argument should be a value from -16 to 15}}

The passed argument is in the valid range of values.


https://reviews.llvm.org/D25017



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


r284473 - [analyzer] Add NumberObjectConversion checker.

2016-10-18 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Oct 18 06:06:28 2016
New Revision: 284473

URL: http://llvm.org/viewvc/llvm-project?rev=284473&view=rev
Log:
[analyzer] Add NumberObjectConversion checker.

When dealing with objects that represent numbers, such as Objective-C NSNumber,
the language provides little protection from accidentally interpreting
the value of a pointer to such object as the value of the number represented
by the object. Results of such mis-interpretation may be unexpected.

The checker attempts to fill this gap in cases when the code is obviously
incorrect.

With "Pedantic" option enabled, this checker enforces a coding style to
completely prevent errors of this kind (off by default).

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

Added:
cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
cfe/trunk/test/Analysis/number-object-conversion.cpp
cfe/trunk/test/Analysis/number-object-conversion.m
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
cfe/trunk/test/Analysis/Inputs/system-header-simulator-objc.h

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=284473&r1=284472&r2=284473&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Tue Oct 18 
06:06:28 2016
@@ -474,6 +474,11 @@ def CStringNotNullTerm : Checker<"NotNul
 
 let ParentPackage = OSX in {
 
+def NumberObjectConversionChecker : Checker<"NumberObjectConversion">,
+  InPackage,
+  HelpText<"Check for erroneous conversions of objects representing numbers 
into numbers">,
+  DescFile<"NumberObjectConversionChecker.cpp">;
+
 def MacOSXAPIChecker : Checker<"API">,
   InPackage,
   HelpText<"Check for proper uses of various Apple APIs">,

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=284473&r1=284472&r2=284473&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Tue Oct 18 06:06:28 
2016
@@ -54,6 +54,7 @@ add_clang_library(clangStaticAnalyzerChe
   NoReturnFunctionChecker.cpp
   NonNullParamChecker.cpp
   NullabilityChecker.cpp
+  NumberObjectConversionChecker.cpp
   ObjCAtSyncChecker.cpp
   ObjCContainersASTChecker.cpp
   ObjCContainersChecker.cpp

Added: cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp?rev=284473&view=auto
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp 
(added)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp Tue 
Oct 18 06:06:28 2016
@@ -0,0 +1,267 @@
+//===- NumberObjectConversionChecker.cpp -*- C++ 
-*-==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file defines NumberObjectConversionChecker, which checks for a
+// particular common mistake when dealing with numbers represented as objects
+// passed around by pointers. Namely, the language allows to reinterpret the
+// pointer as a number directly, often without throwing any warnings,
+// but in most cases the result of such conversion is clearly unexpected,
+// as pointer value, rather than number value represented by the pointee 
object,
+// becomes the result of such operation.
+//
+// Currently the checker supports the Objective-C NSNumber class,
+// and the OSBoolean class found in macOS low-level code; the latter
+// can only hold boolean values.
+//
+// This checker has an option "Pedantic" (boolean), which enables detection of
+// more conversion patterns (which are most likely more harmless, and therefore
+// are more likely to produce false positives) - disabled by default,
+// enabled with `-analyzer-config osx.NumberObjectConversion:Pedantic=true'.
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
+#inclu

[PATCH] D22968: [analyzer] A checker for macOS-specific bool- and number-like objects.

2016-10-18 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284473: [analyzer] Add NumberObjectConversion checker. 
(authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D22968?vs=74969&id=74979#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22968

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
  cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  cfe/trunk/test/Analysis/Inputs/system-header-simulator-objc.h
  cfe/trunk/test/Analysis/number-object-conversion.cpp
  cfe/trunk/test/Analysis/number-object-conversion.m

Index: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
===
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -474,6 +474,11 @@
 
 let ParentPackage = OSX in {
 
+def NumberObjectConversionChecker : Checker<"NumberObjectConversion">,
+  InPackage,
+  HelpText<"Check for erroneous conversions of objects representing numbers into numbers">,
+  DescFile<"NumberObjectConversionChecker.cpp">;
+
 def MacOSXAPIChecker : Checker<"API">,
   InPackage,
   HelpText<"Check for proper uses of various Apple APIs">,
Index: cfe/trunk/test/Analysis/Inputs/system-header-simulator-objc.h
===
--- cfe/trunk/test/Analysis/Inputs/system-header-simulator-objc.h
+++ cfe/trunk/test/Analysis/Inputs/system-header-simulator-objc.h
@@ -10,10 +10,16 @@
 
 typedef signed long CFIndex;
 typedef signed char BOOL;
+#define YES ((BOOL)1)
+#define NO ((BOOL)0)
+
 typedef unsigned long NSUInteger;
 typedef unsigned short unichar;
 typedef UInt16 UniChar;
 
+#define NULL ((void *)0)
+#define nil ((id)0)
+
 enum {
 NSASCIIStringEncoding = 1,
 NSNEXTSTEPStringEncoding = 2,
@@ -72,6 +78,7 @@
 @end
 @interface NSNumber : NSValue  - (char)charValue;
 - (id)initWithInt:(int)value;
+- (BOOL)boolValue;
 @end   @class NSString;
 @interface NSArray : NSObject   - (NSUInteger)count;
 @end  @interface NSArray (NSArrayCreation)  + (id)array;
Index: cfe/trunk/test/Analysis/number-object-conversion.cpp
===
--- cfe/trunk/test/Analysis/number-object-conversion.cpp
+++ cfe/trunk/test/Analysis/number-object-conversion.cpp
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -w -std=c++11 -analyze -analyzer-checker=osx.NumberObjectConversion %s -verify
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -w -std=c++11 -analyze -analyzer-checker=osx.NumberObjectConversion -analyzer-config osx.NumberObjectConversion:Pedantic=true -DPEDANTIC %s -verify
+
+#define NULL ((void *)0)
+#include "Inputs/system-header-simulator-cxx.h" // for nullptr
+
+class OSBoolean {
+public:
+  virtual bool isTrue() const;
+  virtual bool isFalse() const;
+};
+
+extern const OSBoolean *const &kOSBooleanFalse;
+extern const OSBoolean *const &kOSBooleanTrue;
+
+void takes_bool(bool);
+
+void bad(const OSBoolean *p) {
+#ifdef PEDANTIC
+  if (p) {} // expected-warning{{Converting 'const class OSBoolean *' to a plain boolean value for branching; please compare the pointer to NULL or nullptr instead to suppress this warning}}
+  if (!p) {} // expected-warning{{Converting 'const class OSBoolean *' to a plain boolean value for branching; please compare the pointer to NULL or nullptr instead to suppress this warning}}
+  p ? 1 : 2; // expected-warning{{Converting 'const class OSBoolean *' to a plain boolean value for branching; please compare the pointer to NULL or nullptr instead to suppress this warning}}
+  (bool)p; // expected-warning{{Converting 'const class OSBoolean *' to a plain bool value; please compare the pointer to NULL or nullptr instead to suppress this warning}}
+#endif
+  bool x = p; // expected-warning{{Converting 'const class OSBoolean *' to a plain bool value; pointer value is being used instead}}
+  x = p; // expected-warning{{Converting 'const class OSBoolean *' to a plain bool value; pointer value is being used instead}}
+  takes_bool(p); // expected-warning{{Converting 'const class OSBoolean *' to a plain bool value; pointer value is being used instead}}
+  takes_bool(x); // no-warning
+}
+
+typedef bool sugared_bool;
+typedef const OSBoolean *sugared_OSBoolean;
+void bad_sugared(sugared_OSBoolean p) {
+  sugared_bool x = p; // expected-warning{{Converting 'const class OSBoolean *' to a plain bool value; pointer value is being used instead}}
+}
+
+void good(const OSBoolean *p) {
+  bool x = p->isTrue(); // no-warning
+  (bool)p->isFalse(); // no-warning
+  if (p == kOSBooleanTrue) {} // no-warning
+}
+
+void suppression(const OSBoolean *p) {
+  if (p == NULL) {} // no-warning
+  bool y = (p == nullptr); // no-warning
+}
+
+// Conversion of a pointer to an intptr_t is fine.
+typedef long intptr_t;
+typedef un

Re: [PATCH] D24572: [clang-tidy] Clean up code after applying replacements.

2016-10-18 Thread Eric Liu via cfe-commits
clang-apply-replacements has some legacy code and needs some refactoring in
order to take advantage of the cleanup feature (because of the new
tooling::Replacements implementation). I had a plan to refactor it but
thought it was a low priority since most refactoring tools are using
replacements application functions in tooling::RefactoringTool, and I also
have a plan to replace clang-apply-replacements with a better
infrastructure that can supports more refactoring actions.

On Tue, Oct 18, 2016 at 11:46 AM Malcolm Parsons 
wrote:

> malcolm.parsons added a comment.
>
> Does clang-apply-replacements need a similar change?
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D24572
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25520: [CodeCompletion] Add block placeholders when completing member access for Objective-C block property setters

2016-10-18 Thread Alex Lorenz via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284472: [CodeCompletion] Add a block property setter 
completion result (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D25520?vs=74528&id=74977#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25520

Files:
  cfe/trunk/include/clang/Parse/Parser.h
  cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Parse/ParseExpr.cpp
  cfe/trunk/lib/Parse/ParseStmt.cpp
  cfe/trunk/lib/Sema/SemaCodeComplete.cpp
  cfe/trunk/test/Index/complete-block-property-assignment.m

Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
===
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp
@@ -2212,6 +2212,7 @@
 static std::string
 formatBlockPlaceholder(const PrintingPolicy &Policy, const NamedDecl *BlockDecl,
FunctionTypeLoc &Block, FunctionProtoTypeLoc &BlockProto,
+   bool SuppressBlockName = false,
bool SuppressBlock = false,
Optional> ObjCSubsts = None);
 
@@ -2277,7 +2278,8 @@
 
   // We have the function prototype behind the block pointer type, as it was
   // written in the source.
-  return formatBlockPlaceholder(Policy, Param, Block, BlockProto, SuppressBlock,
+  return formatBlockPlaceholder(Policy, Param, Block, BlockProto,
+/*SuppressBlockName=*/false, SuppressBlock,
 ObjCSubsts);
 }
 
@@ -2293,7 +2295,7 @@
 static std::string
 formatBlockPlaceholder(const PrintingPolicy &Policy, const NamedDecl *BlockDecl,
FunctionTypeLoc &Block, FunctionProtoTypeLoc &BlockProto,
-   bool SuppressBlock,
+   bool SuppressBlockName, bool SuppressBlock,
Optional> ObjCSubsts) {
   std::string Result;
   QualType ResultType = Block.getTypePtr()->getReturnType();
@@ -2329,16 +2331,16 @@
   if (SuppressBlock) {
 // Format as a parameter.
 Result = Result + " (^";
-if (BlockDecl->getIdentifier())
+if (!SuppressBlockName && BlockDecl->getIdentifier())
   Result += BlockDecl->getIdentifier()->getName();
 Result += ")";
 Result += Params;
   } else {
 // Format as a block literal argument.
 Result = '^' + Result;
 Result += Params;
 
-if (BlockDecl->getIdentifier())
+if (!SuppressBlockName && BlockDecl->getIdentifier())
   Result += BlockDecl->getIdentifier()->getName();
   }
 
@@ -3611,21 +3613,59 @@
 
 static void AddObjCProperties(const CodeCompletionContext &CCContext,
   ObjCContainerDecl *Container,
-  bool AllowCategories,
-  bool AllowNullaryMethods,
+  bool AllowCategories, bool AllowNullaryMethods,
   DeclContext *CurContext,
   AddedPropertiesSet &AddedProperties,
-  ResultBuilder &Results) {
+  ResultBuilder &Results,
+  bool IsBaseExprStatement = false) {
   typedef CodeCompletionResult Result;
 
   // Retrieve the definition.
   Container = getContainerDef(Container);
   
   // Add properties in this container.
-  for (const auto *P : Container->instance_properties())
-if (AddedProperties.insert(P->getIdentifier()).second)
-  Results.MaybeAddResult(Result(P, Results.getBasePriority(P), nullptr),
- CurContext);
+  for (const auto *P : Container->instance_properties()) {
+if (!AddedProperties.insert(P->getIdentifier()).second)
+  continue;
+
+Results.MaybeAddResult(Result(P, Results.getBasePriority(P), nullptr),
+   CurContext);
+
+// Provide additional block setter completion iff the base expression is a
+// statement.
+if (!P->isReadOnly() && IsBaseExprStatement &&
+P->getType().getTypePtr()->isBlockPointerType()) {
+  FunctionTypeLoc BlockLoc;
+  FunctionProtoTypeLoc BlockProtoLoc;
+  findTypeLocationForBlockDecl(P->getTypeSourceInfo(), BlockLoc,
+   BlockProtoLoc);
+
+  // Provide block setter completion only when we are able to find
+  // the FunctionProtoTypeLoc with parameter names for the block.
+  if (BlockLoc) {
+CodeCompletionBuilder Builder(Results.getAllocator(),
+  Results.getCodeCompletionTUInfo());
+AddResultTypeChunk(Container->getASTContext(),
+   getCompletionPrintingPolicy(Results.getSema()), P,
+   CCContext.getBaseType(), Builder);
+Builder.AddTypedTextChunk(
+Results.getAllocator().CopyString(P->getName()));
+Builder.AddChunk(Co

r284472 - [CodeCompletion] Add a block property setter completion result

2016-10-18 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Oct 18 05:55:01 2016
New Revision: 284472

URL: http://llvm.org/viewvc/llvm-project?rev=284472&view=rev
Log:
[CodeCompletion] Add a block property setter completion result

This commit changes code completion results for Objective-C block properties:
clang now suggests an additional completion result that displays the block
property together with '=' and the block literal placeholder for the appropriate
readwrite block properties.

This commit uses a simple heuristic to determine when it's appropriate to
suggest a setter completion for block properties: the additional block setter
completion is provided iff the member access that's being completed is a
standalone statement.

rdar://28481726

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

Added:
cfe/trunk/test/Index/complete-block-property-assignment.m
Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=284472&r1=284471&r2=284472&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Tue Oct 18 05:55:01 2016
@@ -247,6 +247,11 @@ class Parser : public CodeCompletionHand
 
   bool SkipFunctionBodies;
 
+  /// The location of the expression statement that is being parsed right now.
+  /// Used to determine if an expression that is being parsed is a statement or
+  /// just a regular sub-expression.
+  SourceLocation ExprStatementTokLoc;
+
 public:
   Parser(Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies);
   ~Parser() override;

Modified: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h?rev=284472&r1=284471&r2=284472&view=diff
==
--- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h (original)
+++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h Tue Oct 18 05:55:01 2016
@@ -90,7 +90,11 @@ enum {
   CCD_ProbablyNotObjCCollection = 15,
 
   /// \brief An Objective-C method being used as a property.
-  CCD_MethodAsProperty = 2
+  CCD_MethodAsProperty = 2,
+
+  /// \brief An Objective-C block property completed as a setter with a
+  /// block placeholder.
+  CCD_BlockPropertySetter = 3
 };
 
 /// \brief Priority value factors by which we will divide or multiply the

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=284472&r1=284471&r2=284472&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Oct 18 05:55:01 2016
@@ -9538,8 +9538,8 @@ public:
   void CodeCompleteExpression(Scope *S,
   const CodeCompleteExpressionData &Data);
   void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
-   SourceLocation OpLoc,
-   bool IsArrow);
+   SourceLocation OpLoc, bool IsArrow,
+   bool IsBaseExprStatement);
   void CodeCompletePostfixExpression(Scope *S, ExprResult LHS);
   void CodeCompleteTag(Scope *S, unsigned TagSpec);
   void CodeCompleteTypeQualifiers(DeclSpec &DS);

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=284472&r1=284471&r2=284472&view=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Tue Oct 18 05:55:01 2016
@@ -1646,9 +1646,10 @@ Parser::ParsePostfixExpressionSuffix(Exp
 
   if (Tok.is(tok::code_completion)) {
 // Code completion for a member access expression.
-Actions.CodeCompleteMemberReferenceExpr(getCurScope(), LHS.get(),
-OpLoc, OpKind == tok::arrow);
-
+Actions.CodeCompleteMemberReferenceExpr(
+getCurScope(), LHS.get(), OpLoc, OpKind == tok::arrow,
+ExprStatementTokLoc == LHS.get()->getLocStart());
+
 cutOffParsing();
 return ExprError();
   }

Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=284472&r1=284471&r2=284472&view=diff
==
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/Pars

[PATCH] D25363: Store a SourceRange for multi-token builtin types

2016-10-18 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 74975.
malcolm.parsons added a comment.

Add unit tests for long double.


https://reviews.llvm.org/D25363

Files:
  include/clang/AST/TypeLoc.h
  include/clang/Sema/DeclSpec.h
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaType.cpp
  unittests/AST/SourceLocationTest.cpp

Index: unittests/AST/SourceLocationTest.cpp
===
--- unittests/AST/SourceLocationTest.cpp
+++ unittests/AST/SourceLocationTest.cpp
@@ -148,6 +148,96 @@
  varDecl(), Lang_C89));
 }
 
+TEST(TypeLoc, IntRange) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(1, 1, 1, 1);
+  EXPECT_TRUE(Verifier.match("int a;", typeLoc()));
+}
+
+TEST(TypeLoc, LongRange) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(1, 1, 1, 1);
+  EXPECT_TRUE(Verifier.match("long a;", typeLoc()));
+}
+
+TEST(TypeLoc, LongDoubleRange) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(1, 1, 1, 6);
+  EXPECT_TRUE(Verifier.match("long double a;", typeLoc()));
+}
+
+TEST(TypeLoc, DoubleLongRange) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(1, 1, 1, 8);
+  EXPECT_TRUE(Verifier.match("double long a;", typeLoc()));
+}
+
+TEST(TypeLoc, LongIntRange) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(1, 1, 1, 6);
+  EXPECT_TRUE(Verifier.match("long int a;", typeLoc()));
+}
+
+TEST(TypeLoc, IntLongRange) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(1, 1, 1, 5);
+  EXPECT_TRUE(Verifier.match("int long a;", typeLoc()));
+}
+
+TEST(TypeLoc, UnsignedIntRange) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(1, 1, 1, 10);
+  EXPECT_TRUE(Verifier.match("unsigned int a;", typeLoc()));
+}
+
+TEST(TypeLoc, IntUnsignedRange) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(1, 1, 1, 5);
+  EXPECT_TRUE(Verifier.match("int unsigned a;", typeLoc()));
+}
+
+TEST(TypeLoc, LongLongRange) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(1, 1, 1, 6);
+  EXPECT_TRUE(Verifier.match("long long a;", typeLoc()));
+}
+
+TEST(TypeLoc, UnsignedLongLongRange) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(1, 1, 1, 15);
+  EXPECT_TRUE(Verifier.match("unsigned long long a;", typeLoc()));
+}
+
+TEST(TypeLoc, LongUnsignedLongRange) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(1, 1, 1, 15);
+  EXPECT_TRUE(Verifier.match("long unsigned long a;", typeLoc()));
+}
+
+TEST(TypeLoc, LongLongUnsignedRange) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(1, 1, 1, 11);
+  EXPECT_TRUE(Verifier.match("long long unsigned a;", typeLoc()));
+}
+
+TEST(TypeLoc, ConstLongLongRange) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(1, 7, 1, 12);
+  EXPECT_TRUE(Verifier.match("const long long a = 0;", typeLoc()));
+}
+
+TEST(TypeLoc, LongConstLongRange) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(1, 1, 1, 12);
+  EXPECT_TRUE(Verifier.match("long const long a = 0;", typeLoc()));
+}
+
+TEST(TypeLoc, LongLongConstRange) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(1, 1, 1, 6);
+  EXPECT_TRUE(Verifier.match("long long const a = 0;", typeLoc()));
+}
+
 TEST(CXXConstructorDecl, NoRetFunTypeLocRange) {
   RangeVerifier Verifier;
   Verifier.expectRange(1, 11, 1, 13);
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -4907,11 +4907,9 @@
 TL.getWrittenBuiltinSpecs() = DS.getWrittenBuiltinSpecs();
 // Try to have a meaningful source location.
 if (TL.getWrittenSignSpec() != TSS_unspecified)
-  // Sign spec loc overrides the others (e.g., 'unsigned long').
-  TL.setBuiltinLoc(DS.getTypeSpecSignLoc());
-else if (TL.getWrittenWidthSpec() != TSW_unspecified)
-  // Width spec loc overrides type spec loc (e.g., 'short int').
-  TL.setBuiltinLoc(DS.getTypeSpecWidthLoc());
+  TL.expandBuiltinRange(DS.getTypeSpecSignLoc());
+if (TL.getWrittenWidthSpec() != TSW_unspecified)
+  TL.expandBuiltinRange(DS.getTypeSpecWidthRange());
   }
 }
 void VisitElaboratedTypeLoc(ElaboratedTypeLoc TL) {
Index: lib/Sema/DeclSpec.cpp
===
--- lib/Sema/DeclSpec.cpp
+++ lib/Sema/DeclSpec.cpp
@@ -610,14 +610,16 @@
 const char *&PrevSpec,
 unsigned &DiagID,
 const PrintingPolicy &Policy) {
-  // Overwrite TSWLoc only if TypeSpecWidth was unspecified, so that
+  // Overwrite TSWRange.Begin only if TypeSpecWidth was unspecified, so that
   // for 'long long' we will keep the source location of the first 'long'.
   if (TypeSpecWidth == TSW_unspecified)
-TSWLoc = Loc;
+TSWRange.setBegin(Loc);
   // Allow turning long -> long long.
   else if (W != TSW_longlong || TypeSpecWidth != TSW_long)
 return BadSpecifier(W, (TSW)TypeSpecWidth, PrevSpec, DiagID);
   TypeSpecWidth = W;
+  // Remember location of the las

[PATCH] D25520: [CodeCompletion] Add block placeholders when completing member access for Objective-C block property setters

2016-10-18 Thread Alex Lorenz via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D25520#569389, @akyrtzi wrote:

> >   What do you think of the following possible priority heuristic
>
> SGTM.
>
> Changes LGTM. I'd also recommend that as a follow-up patch it would be great 
> to extend the setter completion to variables as well (global variables, 
> fields, ivars, etc.)


Thanks, I will commit this as it is. I will post a follow-up patch that uses 
the priority heuristic that I described above, and will work on related patches 
that you mentioned as well.


Repository:
  rL LLVM

https://reviews.llvm.org/D25520



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


[PATCH] D25363: Store a SourceRange for multi-token builtin types

2016-10-18 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.



Comment at: unittests/AST/SourceLocationTest.cpp:228
+}
+
 TEST(CXXConstructorDecl, NoRetFunTypeLocRange) {

aaron.ballman wrote:
> Can you also add a test that the range is correct for something like `long 
> double`  and `long double _Complex`?
`ComplexTypeLoc` isn't implemented.

include/clang/AST/TypeLoc.h:
```
// FIXME: location of the '_Complex' keyword.
class ComplexTypeLoc : public InheritingConcreteTypeLoc {
};
```


https://reviews.llvm.org/D25363



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


r284468 - [CodeCompletion][NFC] Extract a function that formats block placeholders.

2016-10-18 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Oct 18 05:38:58 2016
New Revision: 284468

URL: http://llvm.org/viewvc/llvm-project?rev=284468&view=rev
Log:
[CodeCompletion][NFC] Extract a function that formats block placeholders.

This commit extracts a new function named `formatBlockPlaceholder` from
the function `FormatFunctionParameter` so that it can be reused in follow-up
commits that improve code completion for block property setters.

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

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=284468&r1=284467&r2=284468&view=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Tue Oct 18 05:38:58 2016
@@ -2209,6 +2209,12 @@ static void findTypeLocationForBlockDecl
   }
 }
 
+static std::string
+formatBlockPlaceholder(const PrintingPolicy &Policy, const NamedDecl 
*BlockDecl,
+   FunctionTypeLoc &Block, FunctionProtoTypeLoc 
&BlockProto,
+   bool SuppressBlock = false,
+   Optional> ObjCSubsts = None);
+
 static std::string FormatFunctionParameter(const PrintingPolicy &Policy,
const ParmVarDecl *Param,
bool SuppressName = false,
@@ -2271,12 +2277,30 @@ static std::string FormatFunctionParamet
 
   // We have the function prototype behind the block pointer type, as it was
   // written in the source.
+  return formatBlockPlaceholder(Policy, Param, Block, BlockProto, 
SuppressBlock,
+ObjCSubsts);
+}
+
+/// \brief Returns a placeholder string that corresponds to an Objective-C 
block
+/// declaration.
+///
+/// \param BlockDecl A declaration with an Objective-C block type.
+///
+/// \param Block The most relevant type location for that block type.
+///
+/// \param SuppressBlockName Determines wether or not the name of the block
+/// declaration is included in the resulting string.
+static std::string
+formatBlockPlaceholder(const PrintingPolicy &Policy, const NamedDecl 
*BlockDecl,
+   FunctionTypeLoc &Block, FunctionProtoTypeLoc 
&BlockProto,
+   bool SuppressBlock,
+   Optional> ObjCSubsts) {
   std::string Result;
   QualType ResultType = Block.getTypePtr()->getReturnType();
   if (ObjCSubsts)
-ResultType = ResultType.substObjCTypeArgs(Param->getASTContext(),
-  *ObjCSubsts,
-  ObjCSubstitutionContext::Result);
+ResultType =
+ResultType.substObjCTypeArgs(BlockDecl->getASTContext(), *ObjCSubsts,
+ ObjCSubstitutionContext::Result);
   if (!ResultType->isVoidType() || SuppressBlock)
 ResultType.getAsStringInternal(Result, Policy);
 
@@ -2294,31 +2318,30 @@ static std::string FormatFunctionParamet
 Params += ", ";
   Params += FormatFunctionParameter(Policy, Block.getParam(I),
 /*SuppressName=*/false,
-/*SuppressBlock=*/true,
-ObjCSubsts);
+/*SuppressBlock=*/true, ObjCSubsts);
 
   if (I == N - 1 && BlockProto.getTypePtr()->isVariadic())
 Params += ", ...";
 }
 Params += ")";
   }
-  
+
   if (SuppressBlock) {
 // Format as a parameter.
 Result = Result + " (^";
-if (Param->getIdentifier())
-  Result += Param->getIdentifier()->getName();
+if (BlockDecl->getIdentifier())
+  Result += BlockDecl->getIdentifier()->getName();
 Result += ")";
 Result += Params;
   } else {
 // Format as a block literal argument.
 Result = '^' + Result;
 Result += Params;
-
-if (Param->getIdentifier())
-  Result += Param->getIdentifier()->getName();
+
+if (BlockDecl->getIdentifier())
+  Result += BlockDecl->getIdentifier()->getName();
   }
-  
+
   return Result;
 }
 


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


[PATCH] D25519: [CodeCompletion] Refactor: Extract two Objective-C block formatting related functions from FormatFunctionParameter

2016-10-18 Thread Alex Lorenz via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284467: [CodeCompletion][NFC] Extract a function that looks 
for block decl type locs. (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D25519?vs=74520&id=74972#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25519

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

Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
===
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp
@@ -2162,6 +2162,53 @@
   return Result;
 }
 
+/// \brief Tries to find the most appropriate type location for an Objective-C
+/// block placeholder.
+///
+/// This function ignores things like typedefs and qualifiers in order to
+/// present the most relevant and accurate block placeholders in code completion
+/// results.
+static void findTypeLocationForBlockDecl(const TypeSourceInfo *TSInfo,
+ FunctionTypeLoc &Block,
+ FunctionProtoTypeLoc &BlockProto,
+ bool SuppressBlock = false) {
+  if (!TSInfo)
+return;
+  TypeLoc TL = TSInfo->getTypeLoc().getUnqualifiedLoc();
+  while (true) {
+// Look through typedefs.
+if (!SuppressBlock) {
+  if (TypedefTypeLoc TypedefTL = TL.getAs()) {
+if (TypeSourceInfo *InnerTSInfo =
+TypedefTL.getTypedefNameDecl()->getTypeSourceInfo()) {
+  TL = InnerTSInfo->getTypeLoc().getUnqualifiedLoc();
+  continue;
+}
+  }
+
+  // Look through qualified types
+  if (QualifiedTypeLoc QualifiedTL = TL.getAs()) {
+TL = QualifiedTL.getUnqualifiedLoc();
+continue;
+  }
+
+  if (AttributedTypeLoc AttrTL = TL.getAs()) {
+TL = AttrTL.getModifiedLoc();
+continue;
+  }
+}
+
+// Try to get the function prototype behind the block pointer type,
+// then we're done.
+if (BlockPointerTypeLoc BlockPtr = TL.getAs()) {
+  TL = BlockPtr.getPointeeLoc().IgnoreParens();
+  Block = TL.getAs();
+  BlockProto = TL.getAs();
+}
+break;
+  }
+}
+
 static std::string FormatFunctionParameter(const PrintingPolicy &Policy,
const ParmVarDecl *Param,
bool SuppressName = false,
@@ -2192,47 +2239,13 @@
 }
 return Result;
   }
-  
+
   // The argument for a block pointer parameter is a block literal with
   // the appropriate type.
   FunctionTypeLoc Block;
   FunctionProtoTypeLoc BlockProto;
-  TypeLoc TL;
-  if (TypeSourceInfo *TSInfo = Param->getTypeSourceInfo()) {
-TL = TSInfo->getTypeLoc().getUnqualifiedLoc();
-while (true) {
-  // Look through typedefs.
-  if (!SuppressBlock) {
-if (TypedefTypeLoc TypedefTL = TL.getAs()) {
-  if (TypeSourceInfo *InnerTSInfo =
-  TypedefTL.getTypedefNameDecl()->getTypeSourceInfo()) {
-TL = InnerTSInfo->getTypeLoc().getUnqualifiedLoc();
-continue;
-  }
-}
-
-// Look through qualified types
-if (QualifiedTypeLoc QualifiedTL = TL.getAs()) {
-  TL = QualifiedTL.getUnqualifiedLoc();
-  continue;
-}
-
-if (AttributedTypeLoc AttrTL = TL.getAs()) {
-  TL = AttrTL.getModifiedLoc();
-  continue;
-}
-  }
-  
-  // Try to get the function prototype behind the block pointer type,
-  // then we're done.
-  if (BlockPointerTypeLoc BlockPtr = TL.getAs()) {
-TL = BlockPtr.getPointeeLoc().IgnoreParens();
-Block = TL.getAs();
-BlockProto = TL.getAs();
-  }
-  break;
-}
-  }
+  findTypeLocationForBlockDecl(Param->getTypeSourceInfo(), Block, BlockProto,
+   SuppressBlock);
 
   if (!Block) {
 // We were unable to find a FunctionProtoTypeLoc with parameter names
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r284467 - [CodeCompletion][NFC] Extract a function that looks for block decl type locs.

2016-10-18 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Oct 18 05:35:27 2016
New Revision: 284467

URL: http://llvm.org/viewvc/llvm-project?rev=284467&view=rev
Log:
[CodeCompletion][NFC] Extract a function that looks for block decl type locs.

This commit extracts a new function named `findTypeLocationForBlockDecl` from
the function `FormatFunctionParameter` so that it can be reused in follow-up
commits that improve code completion for block property setters.

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

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=284467&r1=284466&r2=284467&view=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Tue Oct 18 05:35:27 2016
@@ -2162,6 +2162,53 @@ static std::string formatObjCParamQualif
   return Result;
 }
 
+/// \brief Tries to find the most appropriate type location for an Objective-C
+/// block placeholder.
+///
+/// This function ignores things like typedefs and qualifiers in order to
+/// present the most relevant and accurate block placeholders in code 
completion
+/// results.
+static void findTypeLocationForBlockDecl(const TypeSourceInfo *TSInfo,
+ FunctionTypeLoc &Block,
+ FunctionProtoTypeLoc &BlockProto,
+ bool SuppressBlock = false) {
+  if (!TSInfo)
+return;
+  TypeLoc TL = TSInfo->getTypeLoc().getUnqualifiedLoc();
+  while (true) {
+// Look through typedefs.
+if (!SuppressBlock) {
+  if (TypedefTypeLoc TypedefTL = TL.getAs()) {
+if (TypeSourceInfo *InnerTSInfo =
+TypedefTL.getTypedefNameDecl()->getTypeSourceInfo()) {
+  TL = InnerTSInfo->getTypeLoc().getUnqualifiedLoc();
+  continue;
+}
+  }
+
+  // Look through qualified types
+  if (QualifiedTypeLoc QualifiedTL = TL.getAs()) {
+TL = QualifiedTL.getUnqualifiedLoc();
+continue;
+  }
+
+  if (AttributedTypeLoc AttrTL = TL.getAs()) {
+TL = AttrTL.getModifiedLoc();
+continue;
+  }
+}
+
+// Try to get the function prototype behind the block pointer type,
+// then we're done.
+if (BlockPointerTypeLoc BlockPtr = TL.getAs()) {
+  TL = BlockPtr.getPointeeLoc().IgnoreParens();
+  Block = TL.getAs();
+  BlockProto = TL.getAs();
+}
+break;
+  }
+}
+
 static std::string FormatFunctionParameter(const PrintingPolicy &Policy,
const ParmVarDecl *Param,
bool SuppressName = false,
@@ -2192,47 +2239,13 @@ static std::string FormatFunctionParamet
 }
 return Result;
   }
-  
+
   // The argument for a block pointer parameter is a block literal with
   // the appropriate type.
   FunctionTypeLoc Block;
   FunctionProtoTypeLoc BlockProto;
-  TypeLoc TL;
-  if (TypeSourceInfo *TSInfo = Param->getTypeSourceInfo()) {
-TL = TSInfo->getTypeLoc().getUnqualifiedLoc();
-while (true) {
-  // Look through typedefs.
-  if (!SuppressBlock) {
-if (TypedefTypeLoc TypedefTL = TL.getAs()) {
-  if (TypeSourceInfo *InnerTSInfo =
-  TypedefTL.getTypedefNameDecl()->getTypeSourceInfo()) {
-TL = InnerTSInfo->getTypeLoc().getUnqualifiedLoc();
-continue;
-  }
-}
-
-// Look through qualified types
-if (QualifiedTypeLoc QualifiedTL = TL.getAs()) {
-  TL = QualifiedTL.getUnqualifiedLoc();
-  continue;
-}
-
-if (AttributedTypeLoc AttrTL = TL.getAs()) {
-  TL = AttrTL.getModifiedLoc();
-  continue;
-}
-  }
-  
-  // Try to get the function prototype behind the block pointer type,
-  // then we're done.
-  if (BlockPointerTypeLoc BlockPtr = TL.getAs()) {
-TL = BlockPtr.getPointeeLoc().IgnoreParens();
-Block = TL.getAs();
-BlockProto = TL.getAs();
-  }
-  break;
-}
-  }
+  findTypeLocationForBlockDecl(Param->getTypeSourceInfo(), Block, BlockProto,
+   SuppressBlock);
 
   if (!Block) {
 // We were unable to find a FunctionProtoTypeLoc with parameter names


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


[PATCH] D22968: [analyzer] A checker for macOS-specific bool- and number-like objects.

2016-10-18 Thread Artem Dergachev via cfe-commits
NoQ updated this revision to Diff 74969.
NoQ added a comment.

- Support conversion though function calls.
- Move "if (x == 0)" to pedantic for now (too loud).


https://reviews.llvm.org/D22968

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  test/Analysis/Inputs/system-header-simulator-objc.h
  test/Analysis/number-object-conversion.cpp
  test/Analysis/number-object-conversion.m

Index: test/Analysis/number-object-conversion.m
===
--- /dev/null
+++ test/Analysis/number-object-conversion.m
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -fblocks -w -analyze -analyzer-checker=osx.NumberObjectConversion %s -verify
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -fblocks -w -analyze -analyzer-checker=osx.NumberObjectConversion -analyzer-config osx.NumberObjectConversion:Pedantic=true -DPEDANTIC %s -verify
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -fblocks -fobjc-arc -w -analyze -analyzer-checker=osx.NumberObjectConversion %s -verify
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -fblocks -fobjc-arc -w -analyze -analyzer-checker=osx.NumberObjectConversion -analyzer-config osx.NumberObjectConversion:Pedantic=true -DPEDANTIC %s -verify
+
+#include "Inputs/system-header-simulator-objc.h"
+
+void takes_boolean(BOOL);
+void takes_integer(int);
+
+void bad(NSNumber *p) {
+#ifdef PEDANTIC
+  if (p) {} // expected-warning{{Converting 'NSNumber *' to a plain boolean value for branching; please compare the pointer to nil instead to suppress this warning}}
+  if (!p) {} // expected-warning{{Converting 'NSNumber *' to a plain boolean value for branching; please compare the pointer to nil instead to suppress this warning}}
+  (!p) ? 1 : 2; // expected-warning{{Converting 'NSNumber *' to a plain boolean value for branching; please compare the pointer to nil instead to suppress this warning}}
+  (BOOL)p; // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; please compare the pointer to nil instead to suppress this warning}}
+  if (p == 0) {} // expected-warning{{Converting 'NSNumber *' to a plain integer value; please compare the pointer to nil instead to suppress this warning}}
+  if (p > 0) {} // expected-warning{{Converting 'NSNumber *' to a plain integer value; pointer value is being used instead}}
+#endif
+  if (p == YES) {} // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; pointer value is being used instead}}
+  if (p == NO) {} // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; pointer value is being used instead}}
+  BOOL x = p; // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; pointer value is being used instead}}
+  x = p; // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; pointer value is being used instead}}
+  x = (p == YES); // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; pointer value is being used instead}}
+  if (p == 1) {} // expected-warning{{Converting 'NSNumber *' to a plain integer value; pointer value is being used instead}}
+  int y = p; // expected-warning{{Converting 'NSNumber *' to a plain integer value; pointer value is being used instead}}
+  y = p; // expected-warning{{Converting 'NSNumber *' to a plain integer value; pointer value is being used instead}}
+  takes_boolean(p); // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; pointer value is being used instead}}
+  takes_integer(p); // expected-warning{{Converting 'NSNumber *' to a plain integer value; pointer value is being used instead}}
+  takes_boolean(x); // no-warning
+  takes_integer(y); // no-warning
+}
+
+typedef NSNumber *SugaredNumber;
+void bad_sugared(SugaredNumber p) {
+  p == YES; // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; pointer value is being used instead}}
+}
+
+@interface I : NSObject {
+@public
+  NSNumber *ivar;
+  NSNumber *prop;
+}
+- (NSNumber *)foo;
+@property(copy) NSNumber *prop;
+@end
+
+@implementation I
+@synthesize prop;
+@end
+
+void bad_ivar(I *i) {
+  i->ivar == YES; // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; pointer value is being used instead}}
+  i->prop == YES; // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; pointer value is being used instead}}
+  [i foo] == YES; // expected-warning{{Converting 'NSNumber *' to a plain BOOL value; pointer value is being used instead}}
+}
+
+void good(NSNumber *p) {
+  if ([p boolValue] == NO) {} // no-warning
+  if ([p boolValue] == YES) {} // no-warning
+  BOOL x = [p boolValue]; // no-warning
+}
+
+void suppression(NSNumber *p) {
+  if (p == NULL) {} // no-warning
+  if (p == nil) {} // no-warning
+}
+
+// Conversion of a pointer to an intptr_t is fine.
+typedef long intptr_t;
+typedef unsigned long uintptr_t;
+typedef long fintptr_t; // Fake, for testing the regex.
+void test

[PATCH] D25363: Store a SourceRange for multi-token builtin types

2016-10-18 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.



Comment at: include/clang/AST/TypeLoc.h:513
 struct BuiltinLocInfo {
-  SourceLocation BuiltinLoc;
+  SourceRange BuiltinRange;
 };

aaron.ballman wrote:
> Since this doubles the size of the type loc for builtin types, do you happen 
> to have any data on what practical impact this has on RAM usage, say for 
> bootstrapping LLVM (or compiling any large source base, really)? Hopefully 
> it's not a lot, but it would be nice to know if it's a .1%, 1%, 10%, etc 
> increase in usage (or does the change get lost in the noise).
I don't have any data.
I'm not sure how to collect that data.


https://reviews.llvm.org/D25363



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


[PATCH] D25719: [Sema] Fix PR30664

2016-10-18 Thread Alex Lorenz via cfe-commits
arphaman created this revision.
arphaman added a reviewer: rsmith.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

This patch fixes an assertion failure crash that happens when a constant record 
reference member is initialized using an empty initializer list.


Repository:
  rL LLVM

https://reviews.llvm.org/D25719

Files:
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/cxx11-crashes.cpp


Index: test/SemaCXX/cxx11-crashes.cpp
===
--- test/SemaCXX/cxx11-crashes.cpp
+++ test/SemaCXX/cxx11-crashes.cpp
@@ -91,3 +91,33 @@
   Foo(lambda);
 }
 }
+
+namespace pr30664 {
+struct foo {
+  int x;
+  foo() : x(42) { }
+};
+
+struct bar {
+  const foo &o;  // expected-note {{reference member declared here}}
+  bar() : o{} {} // expected-warning {{binding reference member 'o' to a 
temporary value}}
+};
+
+struct outer {
+  struct inner {
+const outer &o;// expected-note {{reference member declared here}}
+inner() : o({}) {} // expected-warning {{binding reference member 'o' to a 
temporary value}}
+  };
+};
+
+outer::inner i;
+
+struct foobar {
+  foobar(void) { }
+  struct inner {
+int y;
+const foobar &o; // expected-note {{reference member declared here}}
+inner() : y(21), o({}) {} // expected-warning {{binding reference member 
'o' to a temporary value}}
+  };
+};
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -3426,8 +3426,12 @@
 if (!ICS.UserDefined.EllipsisConversion) {
   // If the user-defined conversion is specified by a constructor, the
   // initial standard conversion sequence converts the source type to
-  // the type required by the argument of the constructor
-  BeforeToType = 
Ctor->getParamDecl(0)->getType().getNonReferenceType();
+  // the type required by the argument of the constructor or the 'void'
+  // type if the argument has no constructors.
+  BeforeToType =
+  Ctor->param_empty()
+  ? Context.VoidTy
+  : Ctor->getParamDecl(0)->getType().getNonReferenceType();
 }
   }
   // Watch out for ellipsis conversion.


Index: test/SemaCXX/cxx11-crashes.cpp
===
--- test/SemaCXX/cxx11-crashes.cpp
+++ test/SemaCXX/cxx11-crashes.cpp
@@ -91,3 +91,33 @@
   Foo(lambda);
 }
 }
+
+namespace pr30664 {
+struct foo {
+  int x;
+  foo() : x(42) { }
+};
+
+struct bar {
+  const foo &o;  // expected-note {{reference member declared here}}
+  bar() : o{} {} // expected-warning {{binding reference member 'o' to a temporary value}}
+};
+
+struct outer {
+  struct inner {
+const outer &o;// expected-note {{reference member declared here}}
+inner() : o({}) {} // expected-warning {{binding reference member 'o' to a temporary value}}
+  };
+};
+
+outer::inner i;
+
+struct foobar {
+  foobar(void) { }
+  struct inner {
+int y;
+const foobar &o; // expected-note {{reference member declared here}}
+inner() : y(21), o({}) {} // expected-warning {{binding reference member 'o' to a temporary value}}
+  };
+};
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -3426,8 +3426,12 @@
 if (!ICS.UserDefined.EllipsisConversion) {
   // If the user-defined conversion is specified by a constructor, the
   // initial standard conversion sequence converts the source type to
-  // the type required by the argument of the constructor
-  BeforeToType = Ctor->getParamDecl(0)->getType().getNonReferenceType();
+  // the type required by the argument of the constructor or the 'void'
+  // type if the argument has no constructors.
+  BeforeToType =
+  Ctor->param_empty()
+  ? Context.VoidTy
+  : Ctor->getParamDecl(0)->getType().getNonReferenceType();
 }
   }
   // Watch out for ellipsis conversion.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r284464 - [libclang] Add missing cursor kinds to python bindings.

2016-10-18 Thread Igor Kudrin via cfe-commits
Author: ikudrin
Date: Tue Oct 18 04:42:03 2016
New Revision: 284464

URL: http://llvm.org/viewvc/llvm-project?rev=284464&view=rev
Log:
[libclang] Add missing cursor kinds to python bindings.

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

Modified:
cfe/trunk/bindings/python/clang/cindex.py

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=284464&r1=284463&r2=284464&view=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Tue Oct 18 04:42:03 2016
@@ -1008,6 +1008,12 @@ CursorKind.OBJ_BOOL_LITERAL_EXPR = Curso
 # Represents the "self" expression in a ObjC method.
 CursorKind.OBJ_SELF_EXPR = CursorKind(146)
 
+# OpenMP 4.0 [2.4, Array Section].
+CursorKind.OMP_ARRAY_SECTION_EXPR = CursorKind(147)
+
+# Represents an @available(...) check.
+CursorKind.OBJC_AVAILABILITY_CHECK_EXPR = CursorKind(148)
+
 
 # A statement whose specific kind is not exposed via this interface.
 #
@@ -1109,6 +1115,126 @@ CursorKind.NULL_STMT = CursorKind(230)
 # Adaptor class for mixing declarations with statements and expressions.
 CursorKind.DECL_STMT = CursorKind(231)
 
+# OpenMP parallel directive.
+CursorKind.OMP_PARALLEL_DIRECTIVE = CursorKind(232)
+
+# OpenMP SIMD directive.
+CursorKind.OMP_SIMD_DIRECTIVE = CursorKind(233)
+
+# OpenMP for directive.
+CursorKind.OMP_FOR_DIRECTIVE = CursorKind(234)
+
+# OpenMP sections directive.
+CursorKind.OMP_SECTIONS_DIRECTIVE = CursorKind(235)
+
+# OpenMP section directive.
+CursorKind.OMP_SECTION_DIRECTIVE = CursorKind(236)
+
+# OpenMP single directive.
+CursorKind.OMP_SINGLE_DIRECTIVE = CursorKind(237)
+
+# OpenMP parallel for directive.
+CursorKind.OMP_PARALLEL_FOR_DIRECTIVE = CursorKind(238)
+
+# OpenMP parallel sections directive.
+CursorKind.OMP_PARALLEL_SECTIONS_DIRECTIVE = CursorKind(239)
+
+# OpenMP task directive.
+CursorKind.OMP_TASK_DIRECTIVE = CursorKind(240)
+
+# OpenMP master directive.
+CursorKind.OMP_MASTER_DIRECTIVE = CursorKind(241)
+
+# OpenMP critical directive.
+CursorKind.OMP_CRITICAL_DIRECTIVE = CursorKind(242)
+
+# OpenMP taskyield directive.
+CursorKind.OMP_TASKYIELD_DIRECTIVE = CursorKind(243)
+
+# OpenMP barrier directive.
+CursorKind.OMP_BARRIER_DIRECTIVE = CursorKind(244)
+
+# OpenMP taskwait directive.
+CursorKind.OMP_TASKWAIT_DIRECTIVE = CursorKind(245)
+
+# OpenMP flush directive.
+CursorKind.OMP_FLUSH_DIRECTIVE = CursorKind(246)
+
+# Windows Structured Exception Handling's leave statement.
+CursorKind.SEH_LEAVE_STMT = CursorKind(247)
+
+# OpenMP ordered directive.
+CursorKind.OMP_ORDERED_DIRECTIVE = CursorKind(248)
+
+# OpenMP atomic directive.
+CursorKind.OMP_ATOMIC_DIRECTIVE = CursorKind(249)
+
+# OpenMP for SIMD directive.
+CursorKind.OMP_FOR_SIMD_DIRECTIVE = CursorKind(250)
+
+# OpenMP parallel for SIMD directive.
+CursorKind.OMP_PARALLELFORSIMD_DIRECTIVE = CursorKind(251)
+
+# OpenMP target directive.
+CursorKind.OMP_TARGET_DIRECTIVE = CursorKind(252)
+
+# OpenMP teams directive.
+CursorKind.OMP_TEAMS_DIRECTIVE = CursorKind(253)
+
+# OpenMP taskgroup directive.
+CursorKind.OMP_TASKGROUP_DIRECTIVE = CursorKind(254)
+
+# OpenMP cancellation point directive.
+CursorKind.OMP_CANCELLATION_POINT_DIRECTIVE = CursorKind(255)
+
+# OpenMP cancel directive.
+CursorKind.OMP_CANCEL_DIRECTIVE = CursorKind(256)
+
+# OpenMP target data directive.
+CursorKind.OMP_TARGET_DATA_DIRECTIVE = CursorKind(257)
+
+# OpenMP taskloop directive.
+CursorKind.OMP_TASK_LOOP_DIRECTIVE = CursorKind(258)
+
+# OpenMP taskloop simd directive.
+CursorKind.OMP_TASK_LOOP_SIMD_DIRECTIVE = CursorKind(259)
+
+# OpenMP distribute directive.
+CursorKind.OMP_DISTRIBUTE_DIRECTIVE = CursorKind(260)
+
+# OpenMP target enter data directive.
+CursorKind.OMP_TARGET_ENTER_DATA_DIRECTIVE = CursorKind(261)
+
+# OpenMP target exit data directive.
+CursorKind.OMP_TARGET_EXIT_DATA_DIRECTIVE = CursorKind(262)
+
+# OpenMP target parallel directive.
+CursorKind.OMP_TARGET_PARALLEL_DIRECTIVE = CursorKind(263)
+
+# OpenMP target parallel for directive.
+CursorKind.OMP_TARGET_PARALLELFOR_DIRECTIVE = CursorKind(264)
+
+# OpenMP target update directive.
+CursorKind.OMP_TARGET_UPDATE_DIRECTIVE = CursorKind(265)
+
+# OpenMP distribute parallel for directive.
+CursorKind.OMP_DISTRIBUTE_PARALLELFOR_DIRECTIVE = CursorKind(266)
+
+# OpenMP distribute parallel for simd directive.
+CursorKind.OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE = CursorKind(267)
+
+# OpenMP distribute simd directive.
+CursorKind.OMP_DISTRIBUTE_SIMD_DIRECTIVE = CursorKind(268)
+
+# OpenMP target parallel for simd directive.
+CursorKind.OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE = CursorKind(269)
+
+# OpenMP target simd directive.
+CursorKind.OMP_TARGET_SIMD_DIRECTIVE = CursorKind(270)
+
+# OpenMP teams distribute directive.
+CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE = CursorKind(271)
+
 ###
 # Other Kinds
 
@@ -1161,6 +1287

[PATCH] D25673: [libclang] Add missing cursor kinds to python bindings.

2016-10-18 Thread Igor Kudrin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284464: [libclang] Add missing cursor kinds to python 
bindings. (authored by ikudrin).

Changed prior to commit:
  https://reviews.llvm.org/D25673?vs=74834&id=74960#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25673

Files:
  cfe/trunk/bindings/python/clang/cindex.py

Index: cfe/trunk/bindings/python/clang/cindex.py
===
--- cfe/trunk/bindings/python/clang/cindex.py
+++ cfe/trunk/bindings/python/clang/cindex.py
@@ -1008,6 +1008,12 @@
 # Represents the "self" expression in a ObjC method.
 CursorKind.OBJ_SELF_EXPR = CursorKind(146)
 
+# OpenMP 4.0 [2.4, Array Section].
+CursorKind.OMP_ARRAY_SECTION_EXPR = CursorKind(147)
+
+# Represents an @available(...) check.
+CursorKind.OBJC_AVAILABILITY_CHECK_EXPR = CursorKind(148)
+
 
 # A statement whose specific kind is not exposed via this interface.
 #
@@ -1109,6 +1115,126 @@
 # Adaptor class for mixing declarations with statements and expressions.
 CursorKind.DECL_STMT = CursorKind(231)
 
+# OpenMP parallel directive.
+CursorKind.OMP_PARALLEL_DIRECTIVE = CursorKind(232)
+
+# OpenMP SIMD directive.
+CursorKind.OMP_SIMD_DIRECTIVE = CursorKind(233)
+
+# OpenMP for directive.
+CursorKind.OMP_FOR_DIRECTIVE = CursorKind(234)
+
+# OpenMP sections directive.
+CursorKind.OMP_SECTIONS_DIRECTIVE = CursorKind(235)
+
+# OpenMP section directive.
+CursorKind.OMP_SECTION_DIRECTIVE = CursorKind(236)
+
+# OpenMP single directive.
+CursorKind.OMP_SINGLE_DIRECTIVE = CursorKind(237)
+
+# OpenMP parallel for directive.
+CursorKind.OMP_PARALLEL_FOR_DIRECTIVE = CursorKind(238)
+
+# OpenMP parallel sections directive.
+CursorKind.OMP_PARALLEL_SECTIONS_DIRECTIVE = CursorKind(239)
+
+# OpenMP task directive.
+CursorKind.OMP_TASK_DIRECTIVE = CursorKind(240)
+
+# OpenMP master directive.
+CursorKind.OMP_MASTER_DIRECTIVE = CursorKind(241)
+
+# OpenMP critical directive.
+CursorKind.OMP_CRITICAL_DIRECTIVE = CursorKind(242)
+
+# OpenMP taskyield directive.
+CursorKind.OMP_TASKYIELD_DIRECTIVE = CursorKind(243)
+
+# OpenMP barrier directive.
+CursorKind.OMP_BARRIER_DIRECTIVE = CursorKind(244)
+
+# OpenMP taskwait directive.
+CursorKind.OMP_TASKWAIT_DIRECTIVE = CursorKind(245)
+
+# OpenMP flush directive.
+CursorKind.OMP_FLUSH_DIRECTIVE = CursorKind(246)
+
+# Windows Structured Exception Handling's leave statement.
+CursorKind.SEH_LEAVE_STMT = CursorKind(247)
+
+# OpenMP ordered directive.
+CursorKind.OMP_ORDERED_DIRECTIVE = CursorKind(248)
+
+# OpenMP atomic directive.
+CursorKind.OMP_ATOMIC_DIRECTIVE = CursorKind(249)
+
+# OpenMP for SIMD directive.
+CursorKind.OMP_FOR_SIMD_DIRECTIVE = CursorKind(250)
+
+# OpenMP parallel for SIMD directive.
+CursorKind.OMP_PARALLELFORSIMD_DIRECTIVE = CursorKind(251)
+
+# OpenMP target directive.
+CursorKind.OMP_TARGET_DIRECTIVE = CursorKind(252)
+
+# OpenMP teams directive.
+CursorKind.OMP_TEAMS_DIRECTIVE = CursorKind(253)
+
+# OpenMP taskgroup directive.
+CursorKind.OMP_TASKGROUP_DIRECTIVE = CursorKind(254)
+
+# OpenMP cancellation point directive.
+CursorKind.OMP_CANCELLATION_POINT_DIRECTIVE = CursorKind(255)
+
+# OpenMP cancel directive.
+CursorKind.OMP_CANCEL_DIRECTIVE = CursorKind(256)
+
+# OpenMP target data directive.
+CursorKind.OMP_TARGET_DATA_DIRECTIVE = CursorKind(257)
+
+# OpenMP taskloop directive.
+CursorKind.OMP_TASK_LOOP_DIRECTIVE = CursorKind(258)
+
+# OpenMP taskloop simd directive.
+CursorKind.OMP_TASK_LOOP_SIMD_DIRECTIVE = CursorKind(259)
+
+# OpenMP distribute directive.
+CursorKind.OMP_DISTRIBUTE_DIRECTIVE = CursorKind(260)
+
+# OpenMP target enter data directive.
+CursorKind.OMP_TARGET_ENTER_DATA_DIRECTIVE = CursorKind(261)
+
+# OpenMP target exit data directive.
+CursorKind.OMP_TARGET_EXIT_DATA_DIRECTIVE = CursorKind(262)
+
+# OpenMP target parallel directive.
+CursorKind.OMP_TARGET_PARALLEL_DIRECTIVE = CursorKind(263)
+
+# OpenMP target parallel for directive.
+CursorKind.OMP_TARGET_PARALLELFOR_DIRECTIVE = CursorKind(264)
+
+# OpenMP target update directive.
+CursorKind.OMP_TARGET_UPDATE_DIRECTIVE = CursorKind(265)
+
+# OpenMP distribute parallel for directive.
+CursorKind.OMP_DISTRIBUTE_PARALLELFOR_DIRECTIVE = CursorKind(266)
+
+# OpenMP distribute parallel for simd directive.
+CursorKind.OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE = CursorKind(267)
+
+# OpenMP distribute simd directive.
+CursorKind.OMP_DISTRIBUTE_SIMD_DIRECTIVE = CursorKind(268)
+
+# OpenMP target parallel for simd directive.
+CursorKind.OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE = CursorKind(269)
+
+# OpenMP target simd directive.
+CursorKind.OMP_TARGET_SIMD_DIRECTIVE = CursorKind(270)
+
+# OpenMP teams distribute directive.
+CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE = CursorKind(271)
+
 ###
 # Other Kinds
 
@@ -1161,6 +1287,8 @@
 CursorKind.MODULE_IMPORT_DECL = CursorKind(600)
 # A type alias template declaration
 CursorKind.TYPE_ALIAS_TEMPLATE_DECL = CursorKind(601)
+# A static_assert or _Static_assert node

[PATCH] D24572: [clang-tidy] Clean up code after applying replacements.

2016-10-18 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

Does clang-apply-replacements need a similar change?


Repository:
  rL LLVM

https://reviews.llvm.org/D24572



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


[PATCH] D25470: [libclang] Fix a failure in a test for python bindings on CursorKind.OVERLOAD_CANDIDATE.

2016-10-18 Thread Igor Kudrin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284463: [libclang] Fix a failure in a test for python 
bindings on CursorKind. (authored by ikudrin).

Changed prior to commit:
  https://reviews.llvm.org/D25470?vs=74237&id=74959#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25470

Files:
  cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py


Index: cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py
+++ cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py
@@ -42,7 +42,8 @@
 CursorKind.MACRO_DEFINITION,
 CursorKind.MACRO_INSTANTIATION,
 CursorKind.INCLUSION_DIRECTIVE,
-CursorKind.PREPROCESSING_DIRECTIVE):
+CursorKind.PREPROCESSING_DIRECTIVE,
+CursorKind.OVERLOAD_CANDIDATE):
 assert len(group) == 0
 else:
 assert len(group) == 1


Index: cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py
+++ cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py
@@ -42,7 +42,8 @@
 CursorKind.MACRO_DEFINITION,
 CursorKind.MACRO_INSTANTIATION,
 CursorKind.INCLUSION_DIRECTIVE,
-CursorKind.PREPROCESSING_DIRECTIVE):
+CursorKind.PREPROCESSING_DIRECTIVE,
+CursorKind.OVERLOAD_CANDIDATE):
 assert len(group) == 0
 else:
 assert len(group) == 1
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r284463 - [libclang] Fix a failure in a test for python bindings on CursorKind.OVERLOAD_CANDIDATE.

2016-10-18 Thread Igor Kudrin via cfe-commits
Author: ikudrin
Date: Tue Oct 18 04:30:33 2016
New Revision: 284463

URL: http://llvm.org/viewvc/llvm-project?rev=284463&view=rev
Log:
[libclang] Fix a failure in a test for python bindings on 
CursorKind.OVERLOAD_CANDIDATE.

The test fails because the value does not lay in any existing group.

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


Modified:
cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py

Modified: cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py?rev=284463&r1=284462&r2=284463&view=diff
==
--- cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py Tue Oct 18 
04:30:33 2016
@@ -42,7 +42,8 @@ def test_kind_groups():
 CursorKind.MACRO_DEFINITION,
 CursorKind.MACRO_INSTANTIATION,
 CursorKind.INCLUSION_DIRECTIVE,
-CursorKind.PREPROCESSING_DIRECTIVE):
+CursorKind.PREPROCESSING_DIRECTIVE,
+CursorKind.OVERLOAD_CANDIDATE):
 assert len(group) == 0
 else:
 assert len(group) == 1


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


[PATCH] D25660: [Analyzer] Checker for iterators dereferenced beyond their range.

2016-10-18 Thread Artem Dergachev via cfe-commits
NoQ added a subscriber: a.sidorin.
NoQ added a comment.

Wow, you managed to check something that could be checked without going through 
a hell of modeling dozens of STL methods, and probably even without stepping on 
poor C++ temporary object modeling in the analyzer, which sounds great.

These comments are incomplete because i didn't yet take my time to understand 
how your program state traits work; hope to come back to this a bit later.

Adding Alexey because he's fond of iterators.




Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:115
+
+typedef std::pair RegionOrSymbol;
+

Maybe `llvm::PointerUnion`?



Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:175
+  const auto *LCtx = C.getLocationContext();
+  if (LCtx->getKind() != LocationContext::StackFrame)
+return;

I think functions should always begin with a stack frame context, not sure, 
does this ever get violated? Do we have `checkBeginBlock`? Sorry if i'm wrong.



Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:183
+  const auto *Site =
+  static_cast(LCtx)->getCallSite();
+  if (!Site)

LLVM `cast<>` should be used, because it asserts cast correctness through 
LLVM's custom RTTI (and `LocationContext` child classes do support that).



Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:195
+auto Param = State->getLValue(P, LCtx);
+auto Arg = State->getSVal(CE->getArg(idx++), LCtx->getParent());
+const auto *Pos = getIteratorPosition(State, Arg);

I think this trick needs more comments/explaining. It is very unusual. Are you 
trying to model effects of passing an iterator by value into a function? What 
part of these effects are not modeled magically by the core?



Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:358
+
+bool IteratorPastEndChecker::evalCall(const CallExpr *CE,
+  CheckerContext &C) const {

So the thing about `evalCall` is that every call can only be eval'ed by only 
one checker. So if you're doing this, you should be sure that your checker is 
modelling //all// effects of the call on //everything// in the program state, 
//manually//, and any checker that relies on that modelling should make sure 
that your checker is turned on.

Because the functions you are modelling are pure, i think it's, in general, a 
good idea to `evalCall()` them. Other checkers should be able to rely on 
PreCall/PostCall events to model their state changes.

So the question is, in what checker do we want this modelling to happen. 
Because your checker is looking for very specific errors, it might be a good 
idea to eventually split it into a separate checker. I think, at least, a FIXME 
for this task should be left around. I'm also currently tackling with a single 
checker to model all standard library functions (D20811), maybe i'd come up 
with a way to merge it there.



Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:443
+  if (Pos && Pos->isOutofRange()) {
+auto *N = C.generateNonFatalErrorNode(State);
+if (!N)

Accessing end() is a UB, we should probably generate a fatal error node here.



Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:446
+  return;
+reportPastEndBug("Iterator possibly accessed past its end.", Val, C, N);
+  }

I think path-sensitive checkers should present their findings proudly. After 
all, they did their best to find a single execution path on which the problem 
//certainly// manifests.



Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:521
+  auto RetVal = svalBuilder.conjureSymbolVal(nullptr, CE, LCtx, 
C.blockCount());
+  auto SecondParam = state->getSVal(CE->getArg(1), C.getLocationContext());
+

Number of arguments of `CE` should be checked beforehand. Yes, it is UB to 
modify namespace `std::` to introduce functions with same names but less 
arguments, but we still should not crash when we see such code.



Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:568
+  // We also should check for copy assignment operator, but for some reason
+  // it is not provided implicitly in Clang Static Analyzer
+  for (const auto *M : CRD->methods()) {

It's not analyzer's fault :) We're inspecting the AST here.

Anyway, does `CXXRecordDecl::needsImplicitCopyAssignment()` look useful?



Comment at: test/Analysis/iterator-past-end.cpp:3
+
+template  struct __iterator {
+  typedef __iterator iterator;

We should probably separate this into an #include-able header in 
`test/Analysis/Inputs/`.

Also, there's always a bit of concern that it wasn't copy-pasted from a 
standard library impl

  1   2   >