[PATCH] D22034: [MSVC][DLL] use local vftable mangling only exported classes with virtual destructor

2016-07-06 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin created this revision.
DmitryPolukhin added a reviewer: rnk.
DmitryPolukhin added a subscriber: cfe-commits.

MSVC uses non-local mangling for vftable if class with dllexport attribute has 
no virtual destructor. I checked all examples that I fixed with MSVC and it 
uses '_7' in all cases. For more info see old thread in 
microsoft.public.vc.language: 
https://groups.google.com/d/msg/microsoft.public.vc.language/atSh_2VSc2w/EgJ3r_7OzVUJ

http://reviews.llvm.org/D22034

Files:
  lib/AST/MicrosoftMangle.cpp
  test/CodeGenCXX/PR26569.cpp
  test/CodeGenCXX/dllimport-rtti.cpp
  test/CodeGenCXX/dllimport.cpp

Index: test/CodeGenCXX/dllimport.cpp
===
--- test/CodeGenCXX/dllimport.cpp
+++ test/CodeGenCXX/dllimport.cpp
@@ -620,9 +620,18 @@
 struct __declspec(dllimport) W { virtual void foo() {} };
 USECLASS(W)
 // vftable:
-// MO1-DAG: @"\01??_SW@@6B@" = linkonce_odr unnamed_addr constant [1 x i8*] 
[i8* bitcast (void (%struct.W*)* @"\01?foo@W@@UAEXXZ" to i8*)]
+// MO1-DAG: @"\01??_7W@@6B@" = linkonce_odr unnamed_addr constant [1 x i8*] 
[i8* bitcast (void (%struct.W*)* @"\01?foo@W@@UAEXXZ" to i8*)]
 // GO1-DAG: @_ZTV1W = available_externally dllimport unnamed_addr constant [3 
x i8*] [i8* null, i8* null, i8* bitcast (void (%struct.W*)* @_ZN1W3fooEv to 
i8*)]
 
+struct __declspec(dllimport) W2 {
+  virtual ~W2();
+  virtual void foo() {}
+};
+USECLASS(W2)
+// vftable:
+// MO1-DAG: @"\01??_SW2@@6B@" = linkonce_odr unnamed_addr constant [2 x i8*]
+// GO1-DAG: @_ZTV2W2 = external dllimport unnamed_addr constant [5 x i8*]
+
 struct __declspec(dllimport) KeyFuncClass {
   constexpr KeyFuncClass() {}
   virtual void foo();
Index: test/CodeGenCXX/dllimport-rtti.cpp
===
--- test/CodeGenCXX/dllimport-rtti.cpp
+++ test/CodeGenCXX/dllimport-rtti.cpp
@@ -4,8 +4,8 @@
 struct __declspec(dllimport) S {
   virtual void f() {}
 } s;
-// MSVC: [[VF_S:.*]] = private unnamed_addr constant [2 x i8*]
-// MSVC-DAG: @"\01??_SS@@6B@" = unnamed_addr alias i8*, getelementptr inbounds 
([2 x i8*], [2 x i8*]* [[VF_S]], i32 0, i32 1)
+// MSVC: [[VF_7:.*]] = private unnamed_addr constant [2 x i8*]
+// MSVC-DAG: @"\01??_7S@@6B@" = unnamed_addr alias i8*, getelementptr inbounds 
([2 x i8*], [2 x i8*]* [[VF_7]], i32 0, i32 1)
 // MSVC-DAG: @"\01??_R0?AUS@@@8" = linkonce_odr
 // MSVC-DAG: @"\01??_R1A@?0A@EA@S@@8" = linkonce_odr
 // MSVC-DAG: @"\01??_R2S@@8" = linkonce_odr
Index: test/CodeGenCXX/PR26569.cpp
===
--- test/CodeGenCXX/PR26569.cpp
+++ test/CodeGenCXX/PR26569.cpp
@@ -4,17 +4,17 @@
   virtual void m_fn1();
 };
 template 
-class B : virtual A {};
+class B : public virtual A {};
 
 extern template class __declspec(dllimport) B;
 class __declspec(dllexport) C : B {};
 
 // CHECK-DAG: @[[VTABLE_C:.*]] = private unnamed_addr constant [2 x i8*] [i8* 
bitcast (%rtti.CompleteObjectLocator* @"\01??_R4C@@6B@" to i8*), i8* bitcast 
(void (%class.A*)* @"\01?m_fn1@A@@EAEXXZ" to i8*)]
-// CHECK-DAG: @[[VTABLE_B:.*]] = private unnamed_addr constant [2 x i8*] [i8* 
bitcast (%rtti.CompleteObjectLocator* @"\01??_R4?$B@H@@6B@" to i8*), i8* 
bitcast (void (%class.A*)* @"\01?m_fn1@A@@EAEXXZ" to i8*)], 
comdat($"\01??_S?$B@H@@6B@")
+// CHECK-DAG: @[[VTABLE_B:.*]] = private unnamed_addr constant [2 x i8*] [i8* 
bitcast (%rtti.CompleteObjectLocator* @"\01??_R4?$B@H@@6B@" to i8*), i8* 
bitcast (void (%class.A*)* @"\01?m_fn1@A@@EAEXXZ" to i8*)], 
comdat($"\01??_7?$B@H@@6B@")
 // CHECK-DAG: @[[VTABLE_A:.*]] = private unnamed_addr constant [2 x i8*] [i8* 
bitcast (%rtti.CompleteObjectLocator* @"\01??_R4A@@6B@" to i8*), i8* bitcast 
(void (%class.A*)* @"\01?m_fn1@A@@EAEXXZ" to i8*)], comdat($"\01??_7A@@6B@")
 
 // CHECK-DAG: @"\01??_7C@@6B@" = dllexport unnamed_addr alias i8*, 
getelementptr inbounds ([2 x i8*], [2 x i8*]* @[[VTABLE_C]], i32 0, i32 1)
-// CHECK-DAG: @"\01??_S?$B@H@@6B@" = unnamed_addr alias i8*, getelementptr 
inbounds ([2 x i8*], [2 x i8*]* @[[VTABLE_B]], i32 0, i32 1)
+// CHECK-DAG: @"\01??_7?$B@H@@6B@" = unnamed_addr alias i8*, getelementptr 
inbounds ([2 x i8*], [2 x i8*]* @[[VTABLE_B]], i32 0, i32 1)
 // CHECK-DAG: @"\01??_7A@@6B@" = unnamed_addr alias i8*, getelementptr 
inbounds ([2 x i8*], [2 x i8*]* @[[VTABLE_A]], i32 0, i32 1)
 
 // CHECK-DAG: @"\01??_8?$B@H@@7B@" = available_externally dllimport 
unnamed_addr constant [2 x i32] [i32 0, i32 4]
Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -2601,7 +2601,15 @@
   // is always '6' for vftables.
   msvc_hashing_ostream MHO(Out);
   MicrosoftCXXNameMangler Mangler(*this, MHO);
-  if (Derived->hasAttr())
+  bool NeedLocalVFT = false;
+  if (Derived->hasAttr()) {
+// Only dllimported classes with virtual d-tor may need local vtbl
+// for proper memory deallocation wi

Re: [libcxx] r274605 - Fix typo in #ifdef, and re-enable tests now that the green-dragon bots are no more

2016-07-06 Thread Diana Picus via cfe-commits
Hi Marhsall,

This seems to be breaking our libcxx bot:
http://lab.llvm.org:8011/builders/libcxx-libcxxabi-arm-linux/builds/1126
I'm a bit confused by that comment you removed, do we need to update
our bot in any way?

Thanks,
Diana

On 6 July 2016 at 08:28, Marshall Clow via cfe-commits
 wrote:
> Author: marshall
> Date: Wed Jul  6 00:28:44 2016
> New Revision: 274605
>
> URL: http://llvm.org/viewvc/llvm-project?rev=274605&view=rev
> Log:
> Fix typo in #ifdef, and re-enable tests now that the green-dragon bots are no 
> more
>
> Modified:
> 
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
>
> Modified: 
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp?rev=274605&r1=274604&r2=274605&view=diff
> ==
> --- 
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
>  (original)
> +++ 
> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
>  Wed Jul  6 00:28:44 2016
> @@ -103,11 +103,11 @@ int main()
>  test_is_not_constructible ();
>
>  //  LWG 2560  -- postpone this test until bots updated
> -// test_is_not_constructible ();
> -// #if TEST_STD_VERS > 11
> -// test_is_not_constructible ();
> -// test_is_not_constructible ();
> -// test_is_not_constructible ();
> -// test_is_not_constructible ();
> -// #endif
> +test_is_not_constructible ();
> +#if TEST_STD_VER > 11
> +test_is_not_constructible ();
> +test_is_not_constructible ();
> +test_is_not_constructible ();
> +test_is_not_constructible ();
> +#endif
>  }
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r274610 - Add negative test for TBAA

2016-07-06 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Wed Jul  6 02:13:49 2016
New Revision: 274610

URL: http://llvm.org/viewvc/llvm-project?rev=274610&view=rev
Log:
Add negative test for TBAA

Revision r178818 added tests for TBAA but was missing negative tests to ensure
that TBAA markers are not emitted when TBAA is off.

Differential Revision: http://reviews.llvm.org/D21295



Modified:
cfe/trunk/test/CodeGen/tbaa.cpp

Modified: cfe/trunk/test/CodeGen/tbaa.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/tbaa.cpp?rev=274610&r1=274609&r2=274610&view=diff
==
--- cfe/trunk/test/CodeGen/tbaa.cpp (original)
+++ cfe/trunk/test/CodeGen/tbaa.cpp Wed Jul  6 02:13:49 2016
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -no-struct-path-tbaa 
-disable-llvm-optzns %s -emit-llvm -o - | FileCheck %s
 // RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -disable-llvm-optzns %s 
-emit-llvm -o - | FileCheck %s -check-prefix=PATH
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -O0 -disable-llvm-optzns %s 
-emit-llvm -o - | FileCheck %s -check-prefix=NO-TBAA
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -relaxed-aliasing 
-disable-llvm-optzns %s -emit-llvm -o - | FileCheck %s -check-prefix=NO-TBAA
 // Test TBAA metadata generated by front-end.
+//
+// NO-TBAA-NOT: !tbaa
 
 typedef unsigned char uint8_t;
 typedef unsigned short uint16_t;


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


Re: [PATCH] D21295: Add a negative TBAA test

2016-07-06 Thread Roger Ferrer Ibanez via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL274610: Add negative test for TBAA (authored by rogfer01).

Changed prior to commit:
  http://reviews.llvm.org/D21295?vs=60667&id=62827#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21295

Files:
  cfe/trunk/test/CodeGen/tbaa.cpp

Index: cfe/trunk/test/CodeGen/tbaa.cpp
===
--- cfe/trunk/test/CodeGen/tbaa.cpp
+++ cfe/trunk/test/CodeGen/tbaa.cpp
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -no-struct-path-tbaa 
-disable-llvm-optzns %s -emit-llvm -o - | FileCheck %s
 // RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -disable-llvm-optzns %s 
-emit-llvm -o - | FileCheck %s -check-prefix=PATH
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -O0 -disable-llvm-optzns %s 
-emit-llvm -o - | FileCheck %s -check-prefix=NO-TBAA
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -relaxed-aliasing 
-disable-llvm-optzns %s -emit-llvm -o - | FileCheck %s -check-prefix=NO-TBAA
 // Test TBAA metadata generated by front-end.
+//
+// NO-TBAA-NOT: !tbaa
 
 typedef unsigned char uint8_t;
 typedef unsigned short uint16_t;


Index: cfe/trunk/test/CodeGen/tbaa.cpp
===
--- cfe/trunk/test/CodeGen/tbaa.cpp
+++ cfe/trunk/test/CodeGen/tbaa.cpp
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -no-struct-path-tbaa -disable-llvm-optzns %s -emit-llvm -o - | FileCheck %s
 // RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -disable-llvm-optzns %s -emit-llvm -o - | FileCheck %s -check-prefix=PATH
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -O0 -disable-llvm-optzns %s -emit-llvm -o - | FileCheck %s -check-prefix=NO-TBAA
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -relaxed-aliasing -disable-llvm-optzns %s -emit-llvm -o - | FileCheck %s -check-prefix=NO-TBAA
 // Test TBAA metadata generated by front-end.
+//
+// NO-TBAA-NOT: !tbaa
 
 typedef unsigned char uint8_t;
 typedef unsigned short uint16_t;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22034: [MSVC][DLL] use local vftable mangling only exported classes with virtual destructor

2016-07-06 Thread David Majnemer via cfe-commits
majnemer added a comment.

Hmm, I'm not so sure this will work with constexpr:

  #include 
  struct __declspec(dllimport) S {
  virtual void fn() const {printf("%s\n", "hi");}
  constexpr S() = default;
  };
  
  constexpr S s;
  auto &x = s;
  
  int main() {
  x.fn();
  }

Before my change we would reference the imported vftable symbol from the .rdata 
section which will fail at link time.
IIRC, MSVC will miscompile this example.

Your change, if I understand correctly, will cause us to import the vftable 
symbol which would cause this example to break again.


http://reviews.llvm.org/D22034



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


Re: [PATCH] D22034: [MSVC][DLL] use local vftable mangling only exported classes with virtual destructor

2016-07-06 Thread David Majnemer via cfe-commits
majnemer added a comment.

FWIW, I think that we would be OK to import vftables (and thus use the _7 
mangling) in contexts where their construction doesn't need to be constant.  It 
seemed pretty complex to implement but I'd be open to such an implementation.


http://reviews.llvm.org/D22034



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


Re: [PATCH] D21991: [libunwind][ARM] Improve unwinder stack usage - Make WMMX support optional

2016-07-06 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In http://reviews.llvm.org/D21991#474736, @compnerd wrote:

> I don't think that clang nor LLVM have much in terms of support for XScale.  
> Can we do something more convoluted perhaps?  I like the preprocessor based 
> approach.  However, if the compiler doesn't define it with the correct 
> target, we define it and push it into the CPPFLAGS.  This way, in the future, 
> we can rely on the compiler to do the right thing and eventually lose the 
> cmake magic.


Sounds good to me.

Just to confirm, we keep the cmake option and make it define `__ARM_WMMX` 
instead of `_LIBUNWIND_ARM_WMMX`? Or did you mean we try to figure it out based 
on the target? I think the latter would be very complicated; WMMX is not an 
architectural feature but an extension supported on some processors (like the 
PXA series: http://www.marvell.com/application-processors/pxa-family/).

WDYT?

Thanks.

/ Asiri


http://reviews.llvm.org/D21991



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


Re: [PATCH] D22034: [MSVC][DLL] use local vftable mangling only exported classes with virtual destructor

2016-07-06 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

David, do you know real programs that relay on constexpr and dllexport semantic 
that doesn't work on MSVC? If not, I think we might want to report error 
message instead of miss-compile it as MSVC does. Anyway current implementation 
is not compatible with MSVC in much more common case without constexp. At the 
moment my patch works with your example just because it only changes mangling 
but don't use imported vftable that seems to be wrong. Is it you changes 
somewhere that prevent using imported vftable?


http://reviews.llvm.org/D22034



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


Re: [PATCH] D22034: [MSVC][DLL] use local vftable mangling only exported classes with virtual destructor

2016-07-06 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

I found the patch that prevents using imported vftable, 
http://llvm.org/viewvc/llvm-project?view=revision&revision=260548 but the patch 
has no examples of constexpr + dllimport.


http://reviews.llvm.org/D22034



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


Re: [PATCH] D21895: CFGBuilder: Fix crash when visiting a range-based for over a dependent type

2016-07-06 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D21895



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


Re: [PATCH] D21799: [ASTMatchers] Add missing forEachArgumentWithParam() to code sample

2016-07-06 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D21799



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


Re: [PATCH] D22034: [MSVC][DLL] use local vftable mangling only exported classes with virtual destructor

2016-07-06 Thread David Majnemer via cfe-commits
majnemer added a comment.

In http://reviews.llvm.org/D22034#474937, @DmitryPolukhin wrote:

> David, do you know real programs that relay on constexpr and dllexport 
> semantic that doesn't work on MSVC?


Yes, Chrome relied on these semantics.

> Anyway current implementation is not compatible with MSVC in much more common 
> case without constexp.


I don't see how it is not compatible.  The address of the vftable is not 
observable as far as I know...

> At the moment my patch works with your example just because it only changes 
> mangling but don't use imported vftable that seems to be wrong.


Why is it //wrong//?  It should obey the ABI in all practical matters but it 
might be less efficient space-wise.


http://reviews.llvm.org/D22034



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


Re: [PATCH] D21075: Correct invalid end location in diagnostics for some identifiers.

2016-07-06 Thread Manuel Klimek via cfe-commits
klimek added a reviewer: rsmith.


Comment at: lib/Sema/SemaType.cpp:1339
@@ +1338,3 @@
+auto R = DS.getSourceRange();
+if (R.getEnd().isInvalid())
+  R.setEnd(R.getBegin());

erikjv wrote:
> klimek wrote:
> > Do you know in which cases we get source ranges that are half valid?
> In Parser::ParseTypeofSpecifier the 'cast range' for a typeof(...) is parsed, 
> but is found to be invalid. Then it explicitly sets the DeclSpec's end 
> location to an invalid location.
Ok, in this case, we'll need Richard to verify whether he intended half-valid 
source locations something that users need to deal with.


http://reviews.llvm.org/D21075



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


Re: [PATCH] D22034: [MSVC][DLL] use local vftable mangling only exported classes with virtual destructor

2016-07-06 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

In http://reviews.llvm.org/D22034#474985, @majnemer wrote:

> In http://reviews.llvm.org/D22034#474937, @DmitryPolukhin wrote:
>
> > David, do you know real programs that relay on constexpr and dllexport 
> > semantic that doesn't work on MSVC?
>
>
> Yes, Chrome relied on these semantics.


Hm, does it mean that Chrome has some workaround to bypass that MSVC doesn't 
support it?

> > Anyway current implementation is not compatible with MSVC in much more 
> > common case without constexp.

> 

> 

> I don't see how it is not compatible.  The address of the vftable is not 
> observable as far as I know...


You can easily observe the difference if vftable is exported from DLL but some 
virtual functions are not (for example, private). MSVC will uses imported 
vftable and Clang will try to rebuild fvtable that will fail on link time.

> > At the moment my patch works with your example just because it only changes 
> > mangling but don't use imported vftable that seems to be wrong.

> 

> 

> Why is it //wrong//?  It should obey the ABI in all practical matters but it 
> might be less efficient space-wise.


I think it is not ABI compatible use local vftable when MSVC uses imported. The 
easy way to observe the difference I already described but it might be other 
side effect if user start unloading DLL from address space. So user may expect 
that it is safe to unload library #1 that created object from library #2 
because it doesn't have references to library #1 addresses but due to local 
fvtable it might result in crash.


http://reviews.llvm.org/D22034



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


Re: [PATCH] D21968: [libcxx] Externally threaded libc++ variant - Take 2

2016-07-06 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 62844.
rmaprath added a comment.

Addressed review comments from @bcraig:

- Got rid of some of the option name cleanups (done to make them more 
consistent, but not relevant to the patch)
- Arranged it so that `libc++` vendors can drop in `__external_threading` 
header to override the default api
  - The default api declares the function prototypes and relies on pthread 
types - this makes it possible to build+test an externally-threaded libc++ 
variant with vanilla sources. The implementation of the thread api (in 
`test/support/external_threads.cpp`) is separate from the library, the two are 
glued together by `__threading_support`.


http://reviews.llvm.org/D21968

Files:
  CMakeLists.txt
  include/__config
  include/__config_site.in
  include/__threading_support
  lib/CMakeLists.txt
  test/CMakeLists.txt
  test/libcxx/test/config.py
  
test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
  
test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
  
test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
  
test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
  test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp
  test/lit.site.cfg.in
  test/support/external_threads.cpp

Index: test/support/external_threads.cpp
===
--- /dev/null
+++ test/support/external_threads.cpp
@@ -0,0 +1,172 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+#ifndef SUPPORT_EXTERNAL_THREADS
+#define SUPPORT_EXTERNAL_THREADS
+
+#include <__threading_support>
+#include 
+#include 
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+//-- Mutex --//
+
+int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m)
+{
+// Initialize the allocated pthread_mutex_t object as a recursive mutex
+pthread_mutexattr_t attr;
+int __ec = pthread_mutexattr_init(&attr);
+if (__ec)
+  goto fail;
+
+__ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+if (__ec)
+{
+pthread_mutexattr_destroy(&attr);
+goto fail;
+}
+
+__ec = pthread_mutex_init(__m, &attr);
+if (__ec)
+{
+pthread_mutexattr_destroy(&attr);
+goto fail;
+}
+
+__ec = pthread_mutexattr_destroy(&attr);
+if (__ec)
+{
+pthread_mutex_destroy(__m);
+goto fail;
+}
+
+return 0;
+
+fail:
+return __ec;
+}
+
+int __libcpp_mutex_lock(__libcpp_mutex_t* __m)
+{
+return pthread_mutex_lock(__m);
+}
+
+int __libcpp_mutex_trylock(__libcpp_mutex_t* __m)
+{
+return pthread_mutex_trylock(__m);
+}
+
+int __libcpp_mutex_unlock(__libcpp_mutex_t* __m)
+{
+return pthread_mutex_unlock(__m);
+}
+
+int __libcpp_mutex_destroy(__libcpp_mutex_t* __m) {
+return pthread_mutex_destroy(__m);
+}
+
+//-- Condition variable --//
+
+int __libcpp_condvar_signal(__libcpp_condvar_t* __cv)
+{
+return pthread_cond_signal(__cv);
+}
+
+int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv)
+{
+return pthread_cond_broadcast(__cv);
+}
+
+int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m)
+{
+return pthread_cond_wait(__cv, __m);
+}
+
+int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, timespec* __ts)
+{
+return pthread_cond_timedwait(__cv, __m, __ts);
+}
+
+int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv)
+{
+return pthread_cond_destroy(__cv);
+}
+
+//-- Thread --//
+
+bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2) {
+return pthread_equal(t1, t2) != 0;
+}
+
+bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2) {
+return t1 < t2;
+}
+
+int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg)
+{
+return pthread_create(__t, 0, __func, __arg);
+}
+
+__libcpp_thread_id __libcpp_thread_get_current_id()
+{
+return static_cast<__libcpp_thread_id>(pthread_self());
+}
+
+__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t)
+{
+return *__t;
+}
+
+int __libcpp_thread_join(__libcpp_thread_t* __t)
+{
+// Must return non-zero if the internal state has already been invalidated
+// This can happen for example, if std::thread::join() has been called
+// before.
+if (*__t == 0)
+return -1;
+
+return pthread_join(*__t, 0);
+}
+
+int __libcpp_thread_detach(__libcpp_thread_t* __t)
+{
+// Must return non-zero if the internal state has already been

Re: [PATCH] D21992: [clang-tidy] new cppcoreguidelines-slicing

2016-07-06 Thread Clement Courbet via cfe-commits
courbet updated this revision to Diff 62845.
courbet added a comment.

Update release notes.


http://reviews.llvm.org/D21992

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/SlicingCheck.cpp
  clang-tidy/cppcoreguidelines/SlicingCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-slicing.rst
  test/clang-tidy/cppcoreguidelines-slicing.cpp

Index: test/clang-tidy/cppcoreguidelines-slicing.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-slicing.cpp
@@ -0,0 +1,93 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-slicing %t
+
+class Base {
+  int i;
+  void f() {}
+  virtual void g() {}
+};
+
+class DerivedWithMemberVariables : public Base {
+  void f();
+  int j;
+};
+
+class TwiceDerivedWithNoMemberVariables : public DerivedWithMemberVariables {
+  void f();
+};
+
+class DerivedWithOverride : public Base {
+  void f();
+  void g() override {}
+};
+
+class TwiceDerivedWithNoOverride : public DerivedWithOverride {
+  void f();
+};
+
+void TakesBaseByValue(Base base);
+
+void positivesWithMemberVariables() {
+  DerivedWithMemberVariables b;
+  Base a{b};
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: slicing object from type 'DerivedWithMemberVariables' to 'Base' discards {{[0-9]*}}*sizeof(char) bytes of state [cppcoreguidelines-slicing]
+  a = b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: slicing object from type 'DerivedWithMemberVariables' to 'Base' discards {{[0-9]*}}*sizeof(char) bytes of state
+  TakesBaseByValue(b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: slicing object from type 'DerivedWithMemberVariables' to 'Base' discards {{[0-9]*}}*sizeof(char) bytes of state
+
+  TwiceDerivedWithNoMemberVariables c;
+  a = c;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: slicing object from type 'TwiceDerivedWithNoMemberVariables' to 'Base' discards {{[0-9]*}}*sizeof(char) bytes of state
+}
+
+void positivesWithOverride() {
+  DerivedWithOverride b;
+  Base a{b};
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: slicing object from type 'DerivedWithOverride' to 'Base' discards override 'g'
+  a = b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: slicing object from type 'DerivedWithOverride' to 'Base' discards override 'g'
+  TakesBaseByValue(b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: slicing object from type 'DerivedWithOverride' to 'Base' discards override 'g'
+
+  TwiceDerivedWithNoOverride c;
+  a = c;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: slicing object from type 'DerivedWithOverride' to 'Base' discards override 'g'
+}
+
+void TakesBaseByReference(Base &base);
+
+class DerivedThatAddsVirtualH : public Base {
+  virtual void h();
+};
+
+class DerivedThatOverridesH : public DerivedThatAddsVirtualH {
+  void h() override;
+};
+
+void negatives() {
+  // OK, simple copying from the same type.
+  Base a;
+  TakesBaseByValue(a);
+  DerivedWithMemberVariables b;
+  DerivedWithMemberVariables c{b};
+  b = c;
+
+  // OK, derived type does not have extra state.
+  TwiceDerivedWithNoMemberVariables d;
+  DerivedWithMemberVariables e{d};
+  e = d;
+
+  // OK, derived does not override any method.
+  TwiceDerivedWithNoOverride f;
+  DerivedWithOverride g{f};
+  g = f;
+
+  // OK, no copying.
+  TakesBaseByReference(d);
+  TakesBaseByReference(f);
+
+  // OK, derived type overrides methods, but these methods are not in the base
+  // type, so cannot be called accidentally.
+  DerivedThatOverridesH h;
+  a = h;
+}
Index: docs/clang-tidy/checks/cppcoreguidelines-slicing.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cppcoreguidelines-slicing.rst
@@ -0,0 +1,10 @@
+.. title:: clang-tidy - cppcoreguidelines-slicing
+
+cppcoreguidelines-slicing
+=
+
+Flags slicing of member variables or vtable. See the relevant CppCoreGuidelines
+sections for details:
+https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es63-dont-slice
+https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c145-access-polymorphic-objects-through-pointers-and-references
+
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -101,6 +101,11 @@
   Flags user-defined constructor definitions that do not initialize all builtin
   and pointer fields which leaves their memory in an undefined state.
 
+- New `cppcoreguidelines-slicing
+  `_ check
+
+  Flags slicing of member variables or vtable.
+
 - New `google-default-arguments
   `_ check
 
Index: clang-tidy/cppcoreguidelines/SlicingCheck.h
===
---

Re: [PATCH] D21603: [include-fixer] Add missing namespace qualifiers after inserting a missing header.

2016-07-06 Thread Benjamin Kramer via cfe-commits
bkramer added a comment.

In the future I'd prefer to have patches like this split up in a part that 
refactors and a part that contains the actual change. Having that in one patch 
makes it really hard to review.



Comment at: include-fixer/IncludeFixer.cpp:73
@@ -72,2 +72,3 @@
 clang::ASTContext &context = getCompilerInstance().getASTContext();
-query(T.getUnqualifiedType().getAsString(context.getPrintingPolicy()), 
Loc);
+llvm::StringRef QueryString =
+T.getUnqualifiedType().getAsString(context.getPrintingPolicy());

std::string, otherwise this will be a user after free.


Comment at: include-fixer/IncludeFixerContext.h:76
@@ +75,3 @@
+
+  /// \brief The scoped qualifiers of SymbolIndentifier.
+  std::string SymbolScopedQualifiers;

Explain what a scoped qualifier is in this comment.


Comment at: include-fixer/IncludeFixerContext.h:86
@@ +85,3 @@
+
+  /// \breif The replacement range of SymbolIdentifier.
+  tooling::Range SymbolRange;

typo: breif


http://reviews.llvm.org/D21603



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


Re: [PATCH] D21968: [libcxx] Externally threaded libc++ variant - Take 2

2016-07-06 Thread Asiri Rathnayake via cfe-commits
rmaprath marked 2 inline comments as done.
rmaprath added a comment.

http://reviews.llvm.org/D21968



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


Re: [PATCH] D21968: [libcxx] Externally threaded libc++ variant - Take 2

2016-07-06 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 62847.
rmaprath added a comment.

Improve comment. NFC.


http://reviews.llvm.org/D21968

Files:
  CMakeLists.txt
  include/__config
  include/__config_site.in
  include/__threading_support
  lib/CMakeLists.txt
  test/CMakeLists.txt
  test/libcxx/test/config.py
  
test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
  
test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
  
test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
  
test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
  test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp
  test/lit.site.cfg.in
  test/support/external_threads.cpp

Index: test/support/external_threads.cpp
===
--- /dev/null
+++ test/support/external_threads.cpp
@@ -0,0 +1,172 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+#ifndef SUPPORT_EXTERNAL_THREADS
+#define SUPPORT_EXTERNAL_THREADS
+
+#include <__threading_support>
+#include 
+#include 
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+//-- Mutex --//
+
+int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m)
+{
+// Initialize the allocated pthread_mutex_t object as a recursive mutex
+pthread_mutexattr_t attr;
+int __ec = pthread_mutexattr_init(&attr);
+if (__ec)
+  goto fail;
+
+__ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+if (__ec)
+{
+pthread_mutexattr_destroy(&attr);
+goto fail;
+}
+
+__ec = pthread_mutex_init(__m, &attr);
+if (__ec)
+{
+pthread_mutexattr_destroy(&attr);
+goto fail;
+}
+
+__ec = pthread_mutexattr_destroy(&attr);
+if (__ec)
+{
+pthread_mutex_destroy(__m);
+goto fail;
+}
+
+return 0;
+
+fail:
+return __ec;
+}
+
+int __libcpp_mutex_lock(__libcpp_mutex_t* __m)
+{
+return pthread_mutex_lock(__m);
+}
+
+int __libcpp_mutex_trylock(__libcpp_mutex_t* __m)
+{
+return pthread_mutex_trylock(__m);
+}
+
+int __libcpp_mutex_unlock(__libcpp_mutex_t* __m)
+{
+return pthread_mutex_unlock(__m);
+}
+
+int __libcpp_mutex_destroy(__libcpp_mutex_t* __m) {
+return pthread_mutex_destroy(__m);
+}
+
+//-- Condition variable --//
+
+int __libcpp_condvar_signal(__libcpp_condvar_t* __cv)
+{
+return pthread_cond_signal(__cv);
+}
+
+int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv)
+{
+return pthread_cond_broadcast(__cv);
+}
+
+int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m)
+{
+return pthread_cond_wait(__cv, __m);
+}
+
+int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, timespec* __ts)
+{
+return pthread_cond_timedwait(__cv, __m, __ts);
+}
+
+int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv)
+{
+return pthread_cond_destroy(__cv);
+}
+
+//-- Thread --//
+
+bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2) {
+return pthread_equal(t1, t2) != 0;
+}
+
+bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2) {
+return t1 < t2;
+}
+
+int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg)
+{
+return pthread_create(__t, 0, __func, __arg);
+}
+
+__libcpp_thread_id __libcpp_thread_get_current_id()
+{
+return static_cast<__libcpp_thread_id>(pthread_self());
+}
+
+__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t)
+{
+return *__t;
+}
+
+int __libcpp_thread_join(__libcpp_thread_t* __t)
+{
+// Must return non-zero if the internal state has already been invalidated
+// This can happen for example, if std::thread::join() has been called
+// before.
+if (*__t == 0)
+return -1;
+
+return pthread_join(*__t, 0);
+}
+
+int __libcpp_thread_detach(__libcpp_thread_t* __t)
+{
+// Must return non-zero if the internal state has already been invalidated
+// This can happen for example, if std::thread::detach() has been called
+// before.
+if (*__t == 0)
+return -1;
+
+return pthread_detach(*__t);
+}
+
+void __libcpp_thread_yield()
+{
+sched_yield();
+}
+
+//-- TLS --//
+
+int __libcpp_tl_create(__libcpp_tl_key* __key, void (*__at_exit)(void*))
+{
+return pthread_key_create(__key, __at_exit);
+}
+
+void* __libcpp_tl_get(__libcpp_tl_key __key)
+{
+return pthread_getspecific(__key);
+}
+
+void __libcpp_tl_set(__libcpp_tl_key __key, void* __p)
+{
+pthread_setspecific(__key, __p);
+}

Re: [PATCH] D21603: [include-fixer] Add missing namespace qualifiers after inserting a missing header.

2016-07-06 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 62849.
hokein marked 2 inline comments as done.
hokein added a comment.

Address Ben's comments.


http://reviews.llvm.org/D21603

Files:
  include-fixer/IncludeFixer.cpp
  include-fixer/IncludeFixerContext.h
  include-fixer/SymbolIndexManager.cpp
  include-fixer/SymbolIndexManager.h
  include-fixer/find-all-symbols/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h
  include-fixer/tool/ClangIncludeFixer.cpp
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -50,7 +50,7 @@
 }
 
 static std::string runIncludeFixer(
-StringRef Code,
+StringRef Code, bool FixNamespaceQualifiers = false,
 const std::vector &ExtraArgs = std::vector()) {
   std::vector Symbols = {
   SymbolInfo("string", SymbolInfo::SymbolKind::Class, "", 1,
@@ -82,14 +82,17 @@
   IncludeFixerContext FixerContext;
   IncludeFixerActionFactory Factory(*SymbolIndexMgr, FixerContext, "llvm");
 
-  runOnCode(&Factory, Code, "input.cc", ExtraArgs);
-  if (FixerContext.Headers.empty())
+  std::string FakeFileName = "input.cc";
+  runOnCode(&Factory, Code, FakeFileName, ExtraArgs);
+  if (FixerContext.getMatchedSymbols().empty())
 return Code;
   tooling::Replacements Replacements =
   clang::include_fixer::createInsertHeaderReplacements(
-  Code, "input.cc", FixerContext.Headers.front());
+  Code, FakeFileName, FixerContext.getHeaders().front());
   clang::RewriterTestContext Context;
-  clang::FileID ID = Context.createInMemoryFile("input.cc", Code);
+  clang::FileID ID = Context.createInMemoryFile(FakeFileName, Code);
+  if (FixNamespaceQualifiers && FixerContext.getSymbolRange().getLength() > 0)
+Replacements.insert(FixerContext.createSymbolReplacement(FakeFileName, 0));
   clang::tooling::applyAllReplacements(Replacements, Context.Rewrite);
   return Context.getRewrittenText(ID);
 }
@@ -137,19 +140,23 @@
 TEST(IncludeFixer, MinimizeInclude) {
   std::vector IncludePath = {"-Idir/"};
   EXPECT_EQ("#include \"otherdir/qux.h\"\na::b::foo bar;\n",
-runIncludeFixer("a::b::foo bar;\n", IncludePath));
+runIncludeFixer("a::b::foo bar;\n",
+/*FixNamespaceQualifiers=*/true, IncludePath));
 
   IncludePath = {"-isystemdir"};
   EXPECT_EQ("#include \na::b::foo bar;\n",
-runIncludeFixer("a::b::foo bar;\n", IncludePath));
+runIncludeFixer("a::b::foo bar;\n",
+/*FixNamespaceQualifiers=*/true, IncludePath));
 
   IncludePath = {"-iquotedir"};
   EXPECT_EQ("#include \"otherdir/qux.h\"\na::b::foo bar;\n",
-runIncludeFixer("a::b::foo bar;\n", IncludePath));
+runIncludeFixer("a::b::foo bar;\n",
+/*FixNamespaceQualifiers=*/true, IncludePath));
 
   IncludePath = {"-Idir", "-Idir/otherdir"};
   EXPECT_EQ("#include \"qux.h\"\na::b::foo bar;\n",
-runIncludeFixer("a::b::foo bar;\n", IncludePath));
+runIncludeFixer("a::b::foo bar;\n",
+/*FixNamespaceQualifiers=*/true, IncludePath));
 }
 
 TEST(IncludeFixer, NestedName) {
@@ -221,6 +228,44 @@
 runIncludeFixer("a::Vector v;"));
 }
 
+TEST(IncludeFixer, FixNamespaceQualifiers) {
+  EXPECT_EQ("#include \"bar.h\"\na::b::bar b;\n",
+runIncludeFixer("b::bar b;\n", /*FixNamespaceQualifiers=*/true));
+  EXPECT_EQ("#include \"bar.h\"\na::b::bar b;\n",
+runIncludeFixer("a::b::bar b;\n", /*FixNamespaceQualifiers=*/true));
+  EXPECT_EQ("#include \"bar.h\"\na::b::bar b;\n",
+runIncludeFixer("bar b;\n", /*FixNamespaceQualifiers=*/true));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar b;\n}\n",
+runIncludeFixer("namespace a {\nb::bar b;\n}\n",
+/*FixNamespaceQualifiers==*/true));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar b;\n}\n",
+runIncludeFixer("namespace a {\nbar b;\n}\n",
+/*FixNamespaceQualifiers==*/true));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nnamespace b{\nbar b;\n}\n}\n",
+runIncludeFixer("namespace a {\nnamespace b{\nbar b;\n}\n}\n",
+/*FixNamespaceQualifiers==*/true));
+  EXPECT_EQ("c::b::bar b;\n",
+runIncludeFixer("c::b::bar b;\n", /*FixNamespaceQualifiers=*/true));
+  EXPECT_EQ("#include \"bar.h\"\nnamespace c {\na::b::bar b;\n}\n",
+runIncludeFixer("namespace c {\nbar b;\n}\n",
+/*FixNamespaceQualifiers=*/true));
+
+  EXPECT_EQ(
+  "#include \"color.h\"\nint test = a::b::Green;\n",
+  runIncludeFixer("int test = Green;\n", /*FixNamespaceQualifiers=*/true));
+  EXPECT_EQ("#include \"color.h\"\nnamespace d {\nint test = a::b::Green;\n}\n",
+runInclud

Re: [PATCH] D21603: [include-fixer] Add missing namespace qualifiers after inserting a missing header.

2016-07-06 Thread Haojian Wu via cfe-commits
hokein added a comment.

In http://reviews.llvm.org/D21603#475011, @bkramer wrote:

> In the future I'd prefer to have patches like this split up in a part that 
> refactors and a part that contains the actual change. Having that in one 
> patch makes it really hard to review.


Acknowledged. I'm sorry for it. I didn't foresee that I would change so much 
code before I implementing this.

So let me summarize the changes of this patch:

1. Instead of returning raw string headers, make `SymbolIndexManager::search` 
return `Symbolnfos`.
2. Move `rankByPopularity`  unique SymbolInfo code from 
`SymbolIndexManager.cpp` to `IncludeFixerContext.cpp`.
3. Extend `IncludeFixerContext` to track more `SymbolInfo` information (e.g. 
`SymbolRange`, `SymbolScopedQualifiers`).
4. Some move stuff in `Action::query` API.
5. Create `adding namespace qualifiers` replacement for the unidentified symbol.



Comment at: include-fixer/IncludeFixer.cpp:73
@@ -72,2 +72,3 @@
 clang::ASTContext &context = getCompilerInstance().getASTContext();
-query(T.getUnqualifiedType().getAsString(context.getPrintingPolicy()), 
Loc);
+llvm::StringRef QueryString =
+T.getUnqualifiedType().getAsString(context.getPrintingPolicy());

bkramer wrote:
> std::string, otherwise this will be a user after free.
Good catch. Done.


http://reviews.llvm.org/D21603



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


Re: [PATCH] D17990: [clang-tidy] minor improvements in modernise-deprecated-headers check

2016-07-06 Thread Kirill Bobyrev via cfe-commits
omtcyf0 updated this revision to Diff 62850.
omtcyf0 marked 3 inline comments as done.

http://reviews.llvm.org/D17990

Files:
  clang-tidy/modernize/DeprecatedHeadersCheck.cpp
  docs/clang-tidy/checks/modernize-deprecated-headers.rst
  test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
  test/clang-tidy/modernize-deprecated-headers-cxx11.cpp

Index: test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
===
--- test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
+++ test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
@@ -7,15 +7,12 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -27,49 +24,43 @@
 #include 
 #include 
 
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'complex.h'; consider using 'ccomplex' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'ctype.h'; consider using 'cctype' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'errno.h'; consider using 'cerrno' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'fenv.h'; consider using 'cfenv' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'float.h'; consider using 'cfloat' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'inttypes.h'; consider using 'cinttypes' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'iso646.h'; consider using 'ciso646' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'limits.h'; consider using 'climits' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'locale.h'; consider using 'clocale' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'math.h'; consider using 'cmath' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'setjmp.h'; consider using 'csetjmp' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'signal.h'; consider using 'csignal' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdalign.h'; consider using 'cstdalign' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdarg.h'; consider using 'cstdarg' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdbool.h'; consider using 'cstdbool' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stddef.h'; consider using 'cstddef' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdint.h'; consider using 'cstdint' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdio.h'; consider using 'cstdio' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'stdlib.h'; consider using 'cstdlib' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'string.h'; consider using 'cstring' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'tgmath.h'; consider using 'ctgmath' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'time.h'; consider using 'ctime' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'uchar.h'; consider using 'cuchar' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'wchar.h'; consider using 'cwchar' instead
-// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: inclusion of deprecated C++ header 'wctype.h'; consider using 'cwctype' instead
+// CHECK-MESSAGES: :[[@LINE-24]]:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-24]]:10: warning: inclusion of deprecated C++ header 'complex.h'; consider using 'complex' instead
+// CHECK-MESSAGES: :[[@LINE-24]]:10: warning: inclusion of deprecated C++ header 'ctype.h'; consider using 'cctype' instead
+// CHECK-MESSAGES: :[[@LINE-24]]:10: warning: inclusion of deprecated C++ header 'errno.h'; consider using 'cerrno' instead
+// CHECK-MESSAGES: :[[@LINE-24]]:10: warning: inclusion of deprecated C++ header 'fenv.h'; consider using 'cfenv' instead
+// CHECK-MESSAGES: :[[@LINE-24]]:10: warning: inclusion of deprecated C++ header 'float.h'; consider using 'cfloat' instead
+// CHECK-MESSAGES: :[[@LINE-24]]:10: warning: inclusion of deprecate

Re: [PATCH] D17990: [clang-tidy] minor improvements in modernise-deprecated-headers check

2016-07-06 Thread Kirill Bobyrev via cfe-commits
omtcyf0 added a comment.

resolved small problems


http://reviews.llvm.org/D17990



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


Re: [PATCH] D21603: [include-fixer] Add missing namespace qualifiers after inserting a missing header.

2016-07-06 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a reviewer: bkramer.
bkramer added a comment.
This revision is now accepted and ready to land.

I think this can go in now.


http://reviews.llvm.org/D21603



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


Re: [PATCH] D21329: Rename and rework `_LIBCPP_TRIVIAL_PAIR_COPY_CTOR`. Move FreeBSD configuration in-tree.

2016-07-06 Thread David Chisnall via cfe-commits
theraven added a comment.

Looks fine to me, though I wonder if we want to move to the new ABI for 
FreeBSD11 and use the old one for <=10.


http://reviews.llvm.org/D21329



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


Re: [PATCH] D21603: [include-fixer] Add missing namespace qualifiers after inserting a missing header.

2016-07-06 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: include-fixer/IncludeFixer.cpp:166
@@ -159,1 +165,3 @@
   QueryString = ExtendNestedNameSpecifier(Range);
+  SymbolRange = 
tooling::Range(SM.getDecomposedLoc(Range.getBegin()).second,
+   QueryString.size());

Lots of code duplication. Maybe pull out function/lambda?


Comment at: include-fixer/IncludeFixer.cpp:259
@@ +258,3 @@
+// Query the symbol based on C++ name Lookup rules.
+// Firstly, lookup the identifier with scoped namespace contexts; If fails,
+// falls back to look up the identifier directly.

"If that fails, .."


Comment at: unittests/include-fixer/IncludeFixerTest.cpp:144
@@ -141,1 +143,3 @@
+runIncludeFixer("a::b::foo bar;\n",
+/*FixNamespaceQualifiers=*/true, IncludePath));
 

I think we should set this to true everywhere or more precisely completely 
remove this parameter. Now that the flag is gone, we are starting to test 
implementation details IMO.


http://reviews.llvm.org/D21603



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


Re: [PATCH] D17990: [clang-tidy] minor improvements in modernise-deprecated-headers check

2016-07-06 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: docs/clang-tidy/checks/modernize-deprecated-headers.rst:39
@@ +38,3 @@
+* `` -> ``
+* `` -> `` // deprecated since C++11
+* `` -> ``

alexfh wrote:
> Not sure if "deprecated" is the right word here. The wording seems to be 
> slightly different: "This header simply includes  and ."
What about this comment? (was on the'  -> ` line)


Comment at: docs/clang-tidy/checks/modernize-deprecated-headers.rst:41
@@ +40,3 @@
+* `` -> ``
+* `` -> ``   // deprecated since C++11
+* `` -> ``

alexfh wrote:
> It's not exactly "deprecated". It has appeared in C++11 and is not 
> particularly useful (just contains a couple of feature macros). Maybe we 
> should just remove #includes of this header as well.
What about this comment? (was on the'  -> ` line)


http://reviews.llvm.org/D17990



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


Re: [PATCH] D17990: [clang-tidy] minor improvements in modernise-deprecated-headers check

2016-07-06 Thread Kirill Bobyrev via cfe-commits
omtcyf0 added a comment.

@alexfh same applies to the other headers. All of them are marked as 
"deprecated" there.

Not sure if I should also mark  and  since they are in 
"has no effect in C++" section now, though.


http://reviews.llvm.org/D17990



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


Re: [PATCH] D21968: [libcxx] Externally threaded libc++ variant - Take 2

2016-07-06 Thread Ben Craig via cfe-commits
bcraig added a comment.

LGTM.  As usual, you'll want to get one of the code owner's sign off first 
though.


http://reviews.llvm.org/D21968



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


Re: [PATCH] D20352: Add XRay flags to Clang

2016-07-06 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/Basic/Attr.td:436
@@ +435,3 @@
+   CXX11<"clang", "xray_never_instrument">];
+  let Subjects = SubjectList<[CXXMethod, ObjCMethod, Function], WarnDiag,
+  "ExpectedFunctionOrMethod">;

That's fine by me (it's also fine to do as part of this patch since this patch 
will be what exercises that functionality anyway). Your choice. :-)


Comment at: include/clang/Basic/AttrDocs.td:2457
@@ +2456,3 @@
+  let Content = [{
+``__attribute__((xray_always_instrument))`` or 
``[[clang:xray_always_instrument]]`` is used to mark member functions (in C++), 
methods (in Objective C), and free functions (in C, C++, and Objective C) to be 
instrumented with XRay. This will cause the function to always have space at 
the beginning and exit points to allow for runtime patching.
+

I think that makes sense. I mostly want to avoid having multiple user-facing 
attributes that do very similar operations under different names. That makes it 
confusing for users, and makes for possibly more-complicated code (are these 
mutually exclusive attributes, etc). I am less worried about whether the 
backend has multiple attributes, though I suspect the same concerns may apply 
there as well.


http://reviews.llvm.org/D20352



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


Re: [PATCH] D17990: [clang-tidy] minor improvements in modernise-deprecated-headers check

2016-07-06 Thread Kirill Bobyrev via cfe-commits
omtcyf0 added a comment.

http://en.cppreference.com/w/cpp/header for reference


http://reviews.llvm.org/D17990



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


Re: [PATCH] D19586: Misleading Indentation check

2016-07-06 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Gergely, it seems that the last diff is missing 
clang-tidy/readability/MisleadingIndentationCheck.cpp. A few more comments 
below.



Comment at: docs/clang-tidy/checks/readability-misleading-indentation.rst:13
@@ +12,3 @@
+
+The way to avoid dangling else is to always check that an "else" belongs
+to the "if" that begins in the same column.

nit: Please use double backquotes to mark inline code fragments.


Comment at: test/clang-tidy/readability-misleading-indentation.cpp:16
@@ +15,3 @@
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: wrong indentation, else belongs 
to
+  // if(cond2) statement
+  // CHECK-FIXES: {{^}}  // comment

1. This is not a part of the previous CHECK-MESSAGES. Is it intended? It's fine 
to have long lines in tests.
2. Code snippets in the message should be enclosed in single quotes ('else', 
'if(cond2)' ...).
3. Please specify each unique message once completely (including the 
[check-name] part).


Comment at: test/clang-tidy/readability-misleading-indentation.cpp:17
@@ +16,3 @@
+  // if(cond2) statement
+  // CHECK-FIXES: {{^}}  // comment
+

These `CHECK-FIXES:` are totally unreliable, since they are all matching the 
same pattern. FileCheck (which is used to verify the output against these CHECK 
lines) maintains no implicit relation between the check line location and the 
line number matched in the output. The two things that matter to FileCheck are 
the order of the matched lines and their content. So the patterns need to be 
unique to avoid matches to incorrect lines. Change them to, e.g. `// comment1`, 
`// comment2`, ...


Comment at: test/clang-tidy/readability-misleading-indentation.cpp:63
@@ +62,3 @@
+foo2();
+  }
+

What about this comment?


Comment at: test/clang-tidy/readability-misleading-indentation.cpp:63
@@ +62,3 @@
+foo2();
+  }
+

alexfh wrote:
> What about this comment?
What about this comment?


http://reviews.llvm.org/D19586



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


[PATCH] D22045: [X86] Support of no_caller_saved_registers attribute (Clang part)

2016-07-06 Thread Amjad Aboud via cfe-commits
aaboud created this revision.
aaboud added reviewers: ABataev, DavidKreitzer, hjl.tools, qcolombet.
aaboud added a subscriber: cfe-commits.

This patch implements the Clang part for no_caller_saved_registers attribute as 
appear in [[ 
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5ed3cc7b66af4758f7849ed6f65f4365be8223be
 | interrupt and exception handler proposal ]]


http://reviews.llvm.org/D22045

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/CGCall.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenCXX/attr-x86-no_caller_saved_registers.cpp
  test/SemaCXX/attr-x86-no_caller_saved_registers.cpp

Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1673,6 +1673,8 @@
   RetAttrs.addAttribute(llvm::Attribute::NoAlias);
 if (TargetDecl->hasAttr())
   RetAttrs.addAttribute(llvm::Attribute::NonNull);
+if (TargetDecl->hasAttr())
+  FuncAttrs.addAttribute("no_caller_saved_registers");
 
 HasAnyX86InterruptAttr = TargetDecl->hasAttr();
 HasOptnone = TargetDecl->hasAttr();
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5910,6 +5910,10 @@
 handleTypeTagForDatatypeAttr(S, D, Attr);
 break;
 
+  case AttributeList::AT_AnyX86NoCallerSavedRegisters:
+handleSimpleAttribute(S, D, Attr);
+break;
+
   case AttributeList::AT_RenderScriptKernel:
 handleSimpleAttribute(S, D, Attr);
 break;
Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -2170,6 +2170,20 @@
   }];
 }
 
+def AnyX86NoCallerSavedRegistersDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Use this attribute to indicate that the specified function has no
+caller-saved registers.  That is, all registers are callee-saved.
+The compiler generates proper function entry and exit sequences to
+save and restore any modified registers.
+
+The user can call functions specified with the 'no_caller_saved_registers'
+attribute from an interrupt handler without saving and restoring all
+call clobbered registers.
+  }];
+}
+
 def SwiftCallDocs : Documentation {
   let Category = DocCatVariable;
   let Content = [{
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -1652,6 +1652,13 @@
   let Documentation = [AnyX86InterruptDocs];
 }
 
+def AnyX86NoCallerSavedRegisters : InheritableAttr,
+   TargetSpecificAttr {
+  let Spellings = [GNU<"no_caller_saved_registers">];
+  let Subjects = SubjectList<[FunctionLike], WarnDiag, "ExpectedFunction">;
+  let Documentation = [AnyX86NoCallerSavedRegistersDocs];
+}
+
 def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GNU<"force_align_arg_pointer">];
   // Technically, this appertains to a FunctionDecl, but the target-specific
Index: test/SemaCXX/attr-x86-no_caller_saved_registers.cpp
===
--- test/SemaCXX/attr-x86-no_caller_saved_registers.cpp
+++ test/SemaCXX/attr-x86-no_caller_saved_registers.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-win32 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnux32 -fsyntax-only -verify %s
+
+struct a {
+  int b __attribute__((no_caller_saved_registers)); // expected-warning {{'no_caller_saved_registers' attribute only applies to functions}}
+  static void foo(int *a) __attribute__((no_caller_saved_registers)) {}
+};
+
+struct a test __attribute__((no_caller_saved_registers)); // expected-warning {{'no_caller_saved_registers' attribute only applies to functions}}
+
+__attribute__((no_caller_saved_registers)) void foo(int *) {}
+
+int main(int argc, char **argv) {
+  a::foo(&argc);
+  foo(&argc);
+  return 0;
+}
Index: test/CodeGenCXX/attr-x86-no_caller_saved_registers.cpp
===
--- test/CodeGenCXX/attr-x86-no_caller_saved_registers.cpp
+++ test/CodeGenCXX/attr-x86-no_caller_saved_registers.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-win32 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i386-pc-win32 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnux32 %

Re: [PATCH] D22034: [MSVC][DLL] use local vftable mangling only exported classes with virtual destructor

2016-07-06 Thread Reid Kleckner via cfe-commits
rnk added a comment.

In http://reviews.llvm.org/D22034#474889, @majnemer wrote:

> Hmm, I'm not so sure this will work with constexpr:
>  ...


Hah, my version of MSVC fails to install the vtable into 's', and crashes on 
the call to x.fn().


http://reviews.llvm.org/D22034



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


[PATCH] D22046: [clang-tidy] Add dependency on clang-headers

2016-07-06 Thread Nico Weber via cfe-commits
thakis created this revision.
thakis added a reviewer: alexfh.
thakis added a subscriber: cfe-commits.

Currently, to be able to process a source file including e.g. stddef.h with 
clang-tidy, one has to build both clang-tidy and the clang-headers target.  
Since stddef.h is needed for virtually any source file, let clang-tidy depend 
on clang-headers, so that it Just Works after it has been built.

http://reviews.llvm.org/D22046

Files:
  clang-tidy/tool/CMakeLists.txt

Index: clang-tidy/tool/CMakeLists.txt
===
--- clang-tidy/tool/CMakeLists.txt
+++ clang-tidy/tool/CMakeLists.txt
@@ -5,6 +5,9 @@
 add_clang_executable(clang-tidy
   ClangTidyMain.cpp
   )
+add_dependencies(clang-tidy
+  clang-headers
+  )
 target_link_libraries(clang-tidy
   clangAST
   clangASTMatchers


Index: clang-tidy/tool/CMakeLists.txt
===
--- clang-tidy/tool/CMakeLists.txt
+++ clang-tidy/tool/CMakeLists.txt
@@ -5,6 +5,9 @@
 add_clang_executable(clang-tidy
   ClangTidyMain.cpp
   )
+add_dependencies(clang-tidy
+  clang-headers
+  )
 target_link_libraries(clang-tidy
   clangAST
   clangASTMatchers
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21991: [libunwind][ARM] Improve unwinder stack usage - Make WMMX support optional

2016-07-06 Thread Saleem Abdulrasool via cfe-commits
compnerd added a comment.

Right, we make it a cmake define corresponding to the AEABI name.  In the 
future when clang knows to correctly emit the macro, we just rely on that.  
Figuring it out based on the target in my case means: `${CMAKE_C_COMPILER} -x c 
-E - -dM <<< "__ARM_WMMX"`.  Thats not too terrible to do, but since the 
support for WMMX is rare, I think skimping on that bit of preparation is 
acceptable too.


http://reviews.llvm.org/D21991



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


Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-06 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.


Comment at: include/clang/AST/BuiltinTypes.def:164
@@ +163,3 @@
+// Internal OpenCL sampler initializer type.
+BUILTIN_TYPE(OCLSamplerInit, OCLSamplerInitTy)
+

Anastasia wrote:
> yaxunl wrote:
> > Anastasia wrote:
> > > I can't get why is this necessary to represent initializer as a special 
> > > Clang type? Could we avoid this additional complexity?
> > If we don't change the type in AST, we need to translate the sampler type 
> > in AST to different types based on whether the entry is a variable or a 
> > function argument. This needs some ugly hacking of the codegen.
> I don't understand why this is needed. Surely, sampler type is just a sampler 
> type independently from the context it's being used. Could you elaborate or 
> give me an example please.
For example, 

  constant sampler_t a = 0;
  kernel void f(sampler_t b) {
 g(a);
 g(b);
   }

Let's say we don't introduce a `OCLSamplerInitTy` in AST.  We only introduce 
`OCLSamplerTy` to represent `sampler_t` in AST. Then both variables `a` and `b` 
have `OCLSamplerTy` type in AST.

In codegen, type translation is done by `CodeGenTypes::ConvertType`, which only 
accepts a `QualType` argument, which means we can only translate an AST type to 
an LLVM type based on the AST type itself. Therefore we can only translate 
`OCLSamplerTy` to one LLVM type. Let's say we translate `OCLSamplerTy` to 
`__sampler*` type. Then variable `a` will be translated to `__sampler*` type. 
However, we want it to be translated to `__sampler_initializer*` type. To do 
that, we have to customize `CodeGenModule::EmitGlobalVarDefinition` to 
translate global variables with `OCLSamplerTy` type specially, which will be 
ugly.

Basically we cannot avoid the complexity of translating the type for variable 
`a`. The complexity is only moved from AST to Codegen. If we introduce 
`OCLSamplerInitTy` in AST, we don't need to translate the type of variable `a` 
specially. It seems to be a more elegant solution to me.




Comment at: include/clang/AST/OperationKinds.def:328
@@ +327,3 @@
+// Convert an integer initializer to an OpenCL sampler initializer.
+CAST_OPERATION(IntToOCLSamplerInitializer)
+

Anastasia wrote:
> yaxunl wrote:
> > Anastasia wrote:
> > > Could we just have only int->sampler conversion? Without having an extra 
> > > type for initializer?
> > If we don't insert the sampler initializer to sampler cast in AST, when we 
> > want to insert the function call __translate_sampler_initializer in 
> > codegen, we have to hacking the generic translation of function call 
> > instruction and other instructions which may have a sampler variable as 
> > operand to insert the function call, which would be ugly.
> > 
> > Or we could do a post-processing of the llvm module at the end of codegen 
> > to insert the function calls, if this approach is acceptable.
> I don't understand why this is needed? The initialization function only 
> replaces the initializer of a sampler type. So this call only has to be 
> emitted on the conversion int->sampler.
Let's consider this example:

  constant sampler_t a = 0;
  kernel void f() {
 g(a);
   }

In codegen, we want to insert a call of `__transform_sampler_initializer` for 
the reference of variable `a`, not the definition of variable `a`. If we 
introduce a cast `SamplerInitializerToSamplerCast`, we can represent that in 
AST equivalent to:

  __sampler_initializer *a = IntToSamplerInitializerCast(0);
  kernel void f() {
 g(SamplerInitializerToSamplerCast(a));
  }

We can do a straight forward translation by translating 
`SamplerInitializerToSamplerCast` to function call of 
`__transform_sampler_initializer`.

If we do not have `SamplerInitializerToSamplerCast`, the AST will be equivalent 
to:

  __sampler *a = IntToSamplerCast(0);
  kernel void f() {
 g(a);
  }

Can we translate `IntToSamplerCast` to `__transform_sampler_initializer`? No. 
Because translation of `IntToSamplerCast` is done at translating global 
variable `a`, which happens before translating instructions belonging to a 
function, whereas we need to insert a function call of 
`__transform_sampler_initializer` when translating function call of `g`. Since 
we do not have a landmark for inserting function call of 
`__transform_sampler_initializer`, we have to customize 
`CodeGenFunction::EmitCall` to handle argument being a global variable of type 
`__sampler` specially, which will be ugly.

However we do have a simple solution for this if we do a post-processing of the 
generated LLVM IR in `CodeGenModule::Release`. Basically we iterate all uses of 
global variable `a` and replace them with a function call of 
`__transform_sampler_initializer`. By doing this we can use a simple AST 
without introducing the sampler initializer type and the cast from sampler 
initializer to sampler. Since `CodeGenModule::Release` already contains quite a 
few post-prcessing's for LL

Re: [PATCH] D21700: [SemaExpr] Support lax conversions in assignments with vector and scalars with same size

2016-07-06 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm Seems OK for now. :)


http://reviews.llvm.org/D21700



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


r274628 - Include debug info for nested structs and classes

2016-07-06 Thread Adrian McCarthy via cfe-commits
Author: amccarth
Date: Wed Jul  6 09:46:42 2016
New Revision: 274628

URL: http://llvm.org/viewvc/llvm-project?rev=274628&view=rev
Log:
Include debug info for nested structs and classes

This includes nested types in the member list, even if there are no members of 
that type. Note that structs and classes have themselves as an "implicit 
struct" as the first member, so we skip implicit ones.

Differential Revision: http://reviews.llvm.org/D21705

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp
cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=274628&r1=274627&r2=274628&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Jul  6 09:46:42 2016
@@ -1095,6 +1095,13 @@ void CGDebugInfo::CollectRecordNormalFie
   elements.push_back(FieldType);
 }
 
+void CGDebugInfo::CollectRecordNestedRecord(
+const RecordDecl *RD, SmallVectorImpl &elements) {
+  QualType Ty = CGM.getContext().getTypeDeclType(RD);
+  llvm::DIType *nestedType = getOrCreateType(Ty, getOrCreateMainFile());
+  elements.push_back(nestedType);
+}
+
 void CGDebugInfo::CollectRecordFields(
 const RecordDecl *record, llvm::DIFile *tunit,
 SmallVectorImpl &elements,
@@ -1131,6 +1138,9 @@ void CGDebugInfo::CollectRecordFields(
 
 // Bump field number for next field.
 ++fieldNo;
+  } else if (const auto *nestedRec = dyn_cast(I)) {
+if (!nestedRec->isImplicit() && nestedRec->getDeclContext() == record)
+  CollectRecordNestedRecord(nestedRec, elements);
   }
   }
 }
@@ -3633,8 +3643,8 @@ void CGDebugInfo::EmitUsingDirective(con
   if (CGM.getCodeGenOpts().getDebugInfo() < codegenoptions::LimitedDebugInfo)
 return;
   const NamespaceDecl *NSDecl = UD.getNominatedNamespace();
-  if (!NSDecl->isAnonymousNamespace() || 
-  CGM.getCodeGenOpts().DebugExplicitImport) { 
+  if (!NSDecl->isAnonymousNamespace() ||
+  CGM.getCodeGenOpts().DebugExplicitImport) {
 DBuilder.createImportedModule(
 getCurrentContextDescriptor(cast(UD.getDeclContext())),
 getOrCreateNameSpace(NSDecl),

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=274628&r1=274627&r2=274628&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Wed Jul  6 09:46:42 2016
@@ -254,6 +254,8 @@ class CGDebugInfo {
 llvm::DIFile *F,
 SmallVectorImpl &E,
 llvm::DIType *RecordTy, const RecordDecl *RD);
+  void CollectRecordNestedRecord(const RecordDecl *RD,
+ SmallVectorImpl &E);
   void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile *F,
SmallVectorImpl &E,
llvm::DICompositeType *RecordTy);

Modified: cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp?rev=274628&r1=274627&r2=274628&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp Wed Jul  6 09:46:42 
2016
@@ -19,6 +19,6 @@ protected:
 
 Test t;
 
-// CHECK: !DIDerivedType(tag: DW_TAG_pointer_type
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "data"
+// CHECK: !DIDerivedType(tag: DW_TAG_pointer_type
 // CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "data"

Modified: cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp?rev=274628&r1=274627&r2=274628&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp Wed Jul  6 
09:46:42 2016
@@ -8,18 +8,18 @@ template  class Fo
 struct Bar {
   int i1;
   // CHECK: ![[INT:[0-9]+]] = !DIBasicType(name: "int"
-  // CHECK: !DIDerivedType(tag: DW_TAG_member, scope:
-  // CHECK-SAME:   line: [[@LINE+4]]
-  // CHECK-SAME:   baseType: ![[UNION:[0-9]+]]
-  // CHECK-SAME:   size: 32, align: 32, offset: 32
-  // CHECK: ![[UNION]] = distinct !DICompositeType(tag: 
DW_TAG_union_type,{{.*}} identifier: "_ZTSN3BarUt_E")
+  // CHECK: ![[UNION:[0

Re: [PATCH] D21705: Include debug info for nested structs and classes

2016-07-06 Thread Adrian McCarthy via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL274628: Include debug info for nested structs and classes 
(authored by amccarth).

Changed prior to commit:
  http://reviews.llvm.org/D21705?vs=62283&id=62869#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21705

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.h
  cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp

Index: cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp
@@ -14,6 +14,9 @@
 // CHECK: ![[Foo:[^ ]*]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo",
 // CHECK-SAME: identifier: ".?AUFoo@@"
 
+// CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Nested",
+// CHECK-SAME: identifier: ".?AUNested@Foo@@"
+
 // CHECK: !DISubprogram(name: "f",
 // CHECK-SAME: containingType: ![[Foo]], virtuality: DW_VIRTUALITY_virtual, virtualIndex: 0,
 // CHECK-SAME: flags: DIFlagPrototyped | DIFlagIntroducedVirtual,
@@ -25,6 +28,3 @@
 // CHECK: !DISubprogram(name: "h",
 // CHECK-SAME: containingType: ![[Foo]], virtuality: DW_VIRTUALITY_virtual, virtualIndex: 2,
 // CHECK-SAME: flags: DIFlagPrototyped | DIFlagIntroducedVirtual,
-
-// CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Nested",
-// CHECK-SAME: identifier: ".?AUNested@Foo@@"
Index: cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp
@@ -8,18 +8,18 @@
 struct Bar {
   int i1;
   // CHECK: ![[INT:[0-9]+]] = !DIBasicType(name: "int"
-  // CHECK: !DIDerivedType(tag: DW_TAG_member, scope:
-  // CHECK-SAME:   line: [[@LINE+4]]
-  // CHECK-SAME:   baseType: ![[UNION:[0-9]+]]
-  // CHECK-SAME:   size: 32, align: 32, offset: 32
-  // CHECK: ![[UNION]] = distinct !DICompositeType(tag: DW_TAG_union_type,{{.*}} identifier: "_ZTSN3BarUt_E")
+  // CHECK: ![[UNION:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_union_type,{{.*}} identifier: "_ZTSN3BarUt_E")
   union {
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "i2",
-// CHECK-SAME:   line: [[@LINE+5]]
+// CHECK-SAME:   line: [[@LINE+9]]
 // CHECK-SAME:   baseType: ![[INT]]
 // CHECK-SAME:   size: 32, align: 32
 // CHECK-NOT:offset:
 // CHECK-SAME:   ){{$}}
+// CHECK: !DIDerivedType(tag: DW_TAG_member, scope:
+// CHECK-SAME:   line: [[@LINE-8]]
+// CHECK-SAME:   baseType: ![[UNION]]
+// CHECK-SAME:   size: 32, align: 32, offset: 32
 int i2;
   };
 };
Index: cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
@@ -19,6 +19,6 @@
 
 Test t;
 
-// CHECK: !DIDerivedType(tag: DW_TAG_pointer_type
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "data"
+// CHECK: !DIDerivedType(tag: DW_TAG_pointer_type
 // CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "data"
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -1095,6 +1095,13 @@
   elements.push_back(FieldType);
 }
 
+void CGDebugInfo::CollectRecordNestedRecord(
+const RecordDecl *RD, SmallVectorImpl &elements) {
+  QualType Ty = CGM.getContext().getTypeDeclType(RD);
+  llvm::DIType *nestedType = getOrCreateType(Ty, getOrCreateMainFile());
+  elements.push_back(nestedType);
+}
+
 void CGDebugInfo::CollectRecordFields(
 const RecordDecl *record, llvm::DIFile *tunit,
 SmallVectorImpl &elements,
@@ -1131,6 +1138,9 @@
 
 // Bump field number for next field.
 ++fieldNo;
+  } else if (const auto *nestedRec = dyn_cast(I)) {
+if (!nestedRec->isImplicit() && nestedRec->getDeclContext() == record)
+  CollectRecordNestedRecord(nestedRec, elements);
   }
   }
 }
@@ -3633,8 +3643,8 @@
   if (CGM.getCodeGenOpts().getDebugInfo() < codegenoptions::LimitedDebugInfo)
 return;
   const NamespaceDecl *NSDecl = UD.getNominatedNamespace();
-  if (!NSDecl->isAnonymousNamespace() || 
-  CGM.getCodeGenOpts().DebugExplicitImport) { 
+  if (!NSDecl->isAnonymousNamespace() ||
+  CGM.getCodeGenOpts().DebugExplicitImport) {
 DBuilder.createImportedModule(
 getCurrentContextDescriptor(cast(UD.getDeclContext())),
 getOrCreateNameSpace(NSDecl),
In

Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-07-06 Thread Carlo Bertolli via cfe-commits
carlo.bertolli marked 4 inline comments as done.
carlo.bertolli added a comment.

Repository:
  rL LLVM

http://reviews.llvm.org/D21904



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


Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-07-06 Thread Carlo Bertolli via cfe-commits
carlo.bertolli updated this revision to Diff 62878.
carlo.bertolli added a comment.

[OpenMP] Remove 'brief' comment tags and change error report to standard 
'expected' form.


Repository:
  rL LLVM

http://reviews.llvm.org/D21904

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Sema/Sema.h
  lib/AST/OpenMPClause.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/target_data_use_device_ptr_messages.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -2275,6 +2275,9 @@
 void OMPClauseEnqueue::VisitOMPFromClause(const OMPFromClause *C) {
   VisitOMPClauseList(C);
 }
+void OMPClauseEnqueue::VisitOMPUseDevicePtrClause(const OMPUseDevicePtrClause *C) {
+  VisitOMPClauseList(C);
+}
 }
 
 void EnqueueVisitor::EnqueueChildren(const OMPClause *S) {
Index: test/OpenMP/target_data_use_device_ptr_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_data_use_device_ptr_messages.cpp
@@ -0,0 +1,206 @@
+// RUN: %clang_cc1 -std=c++11 -verify -fopenmp -ferror-limit 200 %s
+struct ST {
+  int *a;
+};
+struct SA {
+  const int d = 5;
+  const int da[5] = { 0 };
+  ST e;
+  ST g[10];
+  int i;
+  int &j = i;
+  int *k = &j;
+  int *&z = k;
+  int aa[10];
+  void func(int arg) {
+#pragma omp target data map(i) use_device_ptr // expected-error {{expected '(' after 'use_device_ptr'}}
+{}
+#pragma omp target data map(i) use_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
+{}
+#pragma omp target data map(i) use_device_ptr() // expected-error {{expected expression}}
+{}
+#pragma omp target data map(i) use_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
+{}
+#pragma omp target data map(i) use_device_ptr(arg // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(i) // expected-error {{expected pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(j) // expected-error {{expected pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(k) // OK
+{}
+#pragma omp target data map(i) use_device_ptr(z) // OK
+{}
+#pragma omp target data map(i) use_device_ptr(aa) // expected-error{{expected pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(e) // expected-error{{expected pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(g) // expected-error{{expected pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(k,i,j) // expected-error2 {{expected pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(d) // expected-error{{expected pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(da) // expected-error{{expected pointer in 'use_device_ptr' clause}}
+{}
+  return;
+ }
+};
+struct SB {
+  unsigned A;
+  unsigned B;
+  float Arr[100];
+  float *Ptr;
+  float *foo() {
+return &Arr[0];
+  }
+};
+
+struct SC {
+  unsigned A : 2;
+  unsigned B : 3;
+  unsigned C;
+  unsigned D;
+  float Arr[100];
+  SB S;
+  SB ArrS[100];
+  SB *PtrS;
+  SB *&RPtrS;
+  float *Ptr;
+
+  SC(SB *&_RPtrS) : RPtrS(_RPtrS) {}
+};
+
+union SD {
+  unsigned A;
+  float B;
+};
+
+struct S1;
+extern S1 a;
+class S2 {
+  mutable int a;
+public:
+  S2():a(0) { }
+  S2(S2 &s2):a(s2.a) { }
+  static float S2s;
+  static const float S2sc;
+};
+const float S2::S2sc = 0;
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+public:
+  S3():a(0) { }
+  S3(S3 &s3):a(s3.a) { }
+};
+const S3 c;
+const S3 ca[5];
+extern const int f;
+class S4 {
+  int a;
+  S4();
+  S4(const S4 &s4);
+public:
+  S4(int v):a(v) { }
+};
+class S5 {
+  int a;
+  S5():a(0) {}
+  S5(const S5 &s5):a(s5.a) { }
+public:
+  S5(int v):a(v) { }
+};
+
+S3 h;
+#pragma omp threadprivate(h)
+
+typedef int from;
+
+template 
+T tmain(T argc) {
+  const T d = 5;
+  const T da[5] = { 0 };
+  S4 e(4);
+  S5 g(5);
+  T i;
+  T &j = i;
+  T *k = &j;
+  T *&z = k;
+  T aa[10];
+#pragma omp target data map(i) use_device_ptr // expected-error {{expected '(' after 'use_device_ptr'}}
+  {}
+#pragma omp target data map(i) use_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expre

Re: [PATCH] D20795: Added basic capabilities to detect source code clones.

2016-07-06 Thread Raphael Isemann via cfe-commits
teemperor retitled this revision from "Added ASTStructure for analyzing the 
structure of Stmts." to "Added basic capabilities to detect source code 
clones.".
teemperor updated the summary for this revision.
teemperor updated this revision to Diff 62877.
teemperor added a comment.

- Patch now only provides basic generic hashing and is smaller.
- Code style is now respecting LLVM/clang guidelines.
- Documented all non-trivial functions.
- Moved testing from unittests to normal tests.
- Added tests for false-positives.
- Fixed the problems pointed out by Vassil (beside "Is that the LLVM/Clang 
common notion for documenting private members: (i.e. doxygen disabled) instead 
of /").
- No longer patching SourceManager.h.


http://reviews.llvm.org/D20795

Files:
  include/clang/AST/CloneDetection.h
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/AST/CMakeLists.txt
  lib/AST/CloneDetection.cpp
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  test/Analysis/copypaste/test-min-max.cpp
  test/Analysis/copypaste/test-sub-sequences.cpp

Index: test/Analysis/copypaste/test-sub-sequences.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-sub-sequences.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=clone.CloneChecker -verify %s
+
+// We test if sub-sequences can match with normal sequences containing only
+// a single statement.
+
+void log2(int a);
+void log();
+
+int max(int a, int b) {
+  log2(a);
+  log(); // expected-warning{{Detected code clone.}}
+  if (a > b)
+return a;
+  return b;
+}
+
+int maxClone(int a, int b) {
+  log(); // expected-note{{Related code clone is here.}}
+  if (a > b)
+return a;
+  return b;
+}
+
+// Functions below are not clones and should not be reported.
+
+int foo(int a, int b) {
+  return a + b;
+}
Index: test/Analysis/copypaste/test-min-max.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-min-max.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=clone.CloneChecker -verify %s
+
+void log();
+
+int max(int a, int b) { // expected-warning{{Detected code clone.}}
+  log();
+  if (a > b)
+return a;
+  return b;
+}
+
+int maxClone(int a, int b) { // expected-note{{Related code clone is here.}}
+  log();
+  if (a > b)
+return a;
+  return b;
+}
+
+// False positives below. These clones should not be reported.
+
+// FIXME: Detect different binary operator kinds.
+int min1(int a, int b) { // expected-note{{Related code clone is here.}}
+  log();
+  if (a < b)
+return a;
+  return b;
+}
+
+// FIXME: Detect different variable patterns.
+int min2(int a, int b) { // expected-note{{Related code clone is here.}}
+  log();
+  if (b > a)
+return a;
+  return b;
+}
+
+// Functions below are not clones and should not be reported.
+
+int foo(int a, int b) {
+  return a + b;
+}
Index: lib/StaticAnalyzer/Checkers/CloneChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/CloneChecker.cpp
@@ -0,0 +1,67 @@
+//===--- CloneDetection.cpp - Clone detection checkers --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// CloneChecker is a checker that reports clones in the current translation
+/// unit.
+///
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/AST/CloneDetection.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+class CloneChecker : public Checker {
+
+public:
+  void checkEndOfTranslationUnit(const TranslationUnitDecl *TU,
+ AnalysisManager &Mgr, BugReporter &BR) const;
+};
+} // end anonymous namespace
+
+void CloneChecker::checkEndOfTranslationUnit(const TranslationUnitDecl *TU,
+ AnalysisManager &Mgr,
+ BugReporter &BR) const {
+  CloneDetector CloneDetector;
+  CloneDetector.AnalyzeTranslationUnitDecl(
+  TU->getASTContext().getTranslationUnitDecl());
+
+  std::vector CloneGroups =
+  CloneDetector.findClones();
+
+  DiagnosticsEngine &DiagEngine = Mgr.getDiagnostic();
+
+  unsigned WarnID = DiagEngine.getCustomDiagID(DiagnosticsEngine::Warning,
+   "Detected code clone.");
+
+  unsigned NoteID = DiagEngine.getCustomDiagID(Diagnos

r274633 - Revert "Include debug info for nested structs and classes"

2016-07-06 Thread Adrian McCarthy via cfe-commits
Author: amccarth
Date: Wed Jul  6 10:15:38 2016
New Revision: 274633

URL: http://llvm.org/viewvc/llvm-project?rev=274633&view=rev
Log:
Revert "Include debug info for nested structs and classes"

This reverts commit 0af5ee9631c7c167dc40498b415876553e314c95.

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp
cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=274633&r1=274632&r2=274633&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Jul  6 10:15:38 2016
@@ -1095,13 +1095,6 @@ void CGDebugInfo::CollectRecordNormalFie
   elements.push_back(FieldType);
 }
 
-void CGDebugInfo::CollectRecordNestedRecord(
-const RecordDecl *RD, SmallVectorImpl &elements) {
-  QualType Ty = CGM.getContext().getTypeDeclType(RD);
-  llvm::DIType *nestedType = getOrCreateType(Ty, getOrCreateMainFile());
-  elements.push_back(nestedType);
-}
-
 void CGDebugInfo::CollectRecordFields(
 const RecordDecl *record, llvm::DIFile *tunit,
 SmallVectorImpl &elements,
@@ -1138,9 +1131,6 @@ void CGDebugInfo::CollectRecordFields(
 
 // Bump field number for next field.
 ++fieldNo;
-  } else if (const auto *nestedRec = dyn_cast(I)) {
-if (!nestedRec->isImplicit() && nestedRec->getDeclContext() == record)
-  CollectRecordNestedRecord(nestedRec, elements);
   }
   }
 }
@@ -3643,8 +3633,8 @@ void CGDebugInfo::EmitUsingDirective(con
   if (CGM.getCodeGenOpts().getDebugInfo() < codegenoptions::LimitedDebugInfo)
 return;
   const NamespaceDecl *NSDecl = UD.getNominatedNamespace();
-  if (!NSDecl->isAnonymousNamespace() ||
-  CGM.getCodeGenOpts().DebugExplicitImport) {
+  if (!NSDecl->isAnonymousNamespace() || 
+  CGM.getCodeGenOpts().DebugExplicitImport) { 
 DBuilder.createImportedModule(
 getCurrentContextDescriptor(cast(UD.getDeclContext())),
 getOrCreateNameSpace(NSDecl),

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=274633&r1=274632&r2=274633&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Wed Jul  6 10:15:38 2016
@@ -254,8 +254,6 @@ class CGDebugInfo {
 llvm::DIFile *F,
 SmallVectorImpl &E,
 llvm::DIType *RecordTy, const RecordDecl *RD);
-  void CollectRecordNestedRecord(const RecordDecl *RD,
- SmallVectorImpl &E);
   void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile *F,
SmallVectorImpl &E,
llvm::DICompositeType *RecordTy);

Modified: cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp?rev=274633&r1=274632&r2=274633&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp Wed Jul  6 10:15:38 
2016
@@ -19,6 +19,6 @@ protected:
 
 Test t;
 
-// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "data"
 // CHECK: !DIDerivedType(tag: DW_TAG_pointer_type
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "data"
 // CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "data"

Modified: cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp?rev=274633&r1=274632&r2=274633&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp Wed Jul  6 
10:15:38 2016
@@ -8,18 +8,18 @@ template  class Fo
 struct Bar {
   int i1;
   // CHECK: ![[INT:[0-9]+]] = !DIBasicType(name: "int"
-  // CHECK: ![[UNION:[0-9]+]] = distinct !DICompositeType(tag: 
DW_TAG_union_type,{{.*}} identifier: "_ZTSN3BarUt_E")
+  // CHECK: !DIDerivedType(tag: DW_TAG_member, scope:
+  // CHECK-SAME:   line: [[@LINE+4]]
+  // CHECK-SAME:   baseType: ![[UNION:[0-9]+]]
+  // CHECK-SAME:   size: 32, align: 32, offset: 32
+  // CHECK: ![[UNION]] = distinct !DICompositeType(tag: 
DW_TAG_union_type,{{.*}} identifier: "_ZTSN3BarUt_E")
   union {
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "i2",
-//

Re: [PATCH] D21989: [OpenCL] Improve diagnostics of OpenCL types

2016-07-06 Thread Anastasia Stulova via cfe-commits
Anastasia updated this revision to Diff 62880.
Anastasia added a comment.

- Fixed misc formatting issues
- Added restrictions and testing for return types


http://reviews.llvm.org/D21989

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaType.cpp
  test/SemaOpenCL/invalid-block.cl
  test/SemaOpenCL/invalid-image.cl
  test/SemaOpenCL/invalid-pipes-cl2.0.cl
  test/SemaOpenCL/sampler_t.cl

Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -5,16 +5,27 @@
 void foo(sampler_t);
 
 constant struct sampler_s {
-  sampler_t smp; // expected-error {{the 'sampler_t' type cannot be used to declare a structure or union field}}
+  sampler_t smp; // expected-error{{the 'sampler_t' type cannot be used to declare a structure or union field}}
 } sampler_str = {0};
 
 void kernel ker(sampler_t argsmp) {
-  local sampler_t smp; // expected-error {{sampler type cannot be used with the __local and __global address space qualifiers}}
+  local sampler_t smp; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}}
   const sampler_t const_smp = 7;
   foo(glb_smp);
   foo(const_smp);
-  foo(5); // expected-error {{sampler_t variable required - got 'int'}}
+  foo(5); // expected-error{{sampler_t variable required - got 'int'}}
   sampler_t sa[] = {argsmp, const_smp}; // expected-error {{array of 'sampler_t' type is invalid in OpenCL}}
 }
 
-void bad(sampler_t*); // expected-error {{pointer to type 'sampler_t' is invalid in OpenCL}}
+void bad(sampler_t*); // expected-error{{pointer to type 'sampler_t' is invalid in OpenCL}}
+
+void bar() {
+  sampler_t smp1 = 7;
+  sampler_t smp2 = 2;
+  smp1=smp2; //expected-error{{invalid operands to binary expression ('sampler_t' and 'sampler_t')}}
+  smp1+1; //expected-error{{invalid operands to binary expression ('sampler_t' and 'int')}}
+  &smp1; //expected-error{{invalid argument type 'sampler_t' to unary expression}}
+  *smp2; //expected-error{{invalid argument type 'sampler_t' to unary expression}}
+}
+
+sampler_t bad(); //expected-error{{declaring function return value of type 'sampler_t' is not allowed}}
Index: test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -1,11 +1,22 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
 
-void test1(pipe int *p){// expected-error {{pipes packet types cannot be of reference type}}
+void test1(pipe int *p) {// expected-error {{pipes packet types cannot be of reference type}}
 }
-void test2(pipe p){// expected-error {{missing actual type specifier for pipe}}
+void test2(pipe p) {// expected-error {{missing actual type specifier for pipe}}
 }
-void test3(int pipe p){// expected-error {{cannot combine with previous 'int' declaration specifier}}
+void test3(int pipe p) {// expected-error {{cannot combine with previous 'int' declaration specifier}}
 }
 void test4() {
   pipe int p; // expected-error {{type 'pipe int' can only be used as a function parameter}}
+  //TODO: fix parsing of this pipe int (*p);
 }
+
+void test5(pipe int p) {
+  p+p; // expected-error{{invalid operands to binary expression ('pipe int' and 'pipe int')}}
+  p=p; // expected-error{{invalid operands to binary expression ('pipe int' and 'pipe int')}}
+  &p; // expected-error{{invalid argument type 'pipe int' to unary expression}}
+  *p; // expected-error{{invalid argument type 'pipe int' to unary expression}}
+}
+
+typedef pipe int pipe_int_t;
+pipe_int_t test6() {} // expected-error{{declaring function return value of type 'pipe_int_t' (aka 'pipe int') is not allowed}}
Index: test/SemaOpenCL/invalid-image.cl
===
--- test/SemaOpenCL/invalid-image.cl
+++ test/SemaOpenCL/invalid-image.cl
@@ -1,8 +1,14 @@
 // RUN: %clang_cc1 -verify %s
 
-void test1(image1d_t *i) {} // expected-error {{pointer to type '__read_only image1d_t' is invalid in OpenCL}}
+void test1(image1d_t *i) {} // expected-error{{pointer to type '__read_only image1d_t' is invalid in OpenCL}}
 
 void test2(image1d_t i) {
-  image1d_t ti;// expected-error {{type '__read_only image1d_t' can only be used as a function parameter}}
-  image1d_t ai[] = {i, i}; // expected-error {{array of '__read_only image1d_t' type is invalid in OpenCL}}
+  image1d_t ti;// expected-error{{type '__read_only image1d_t' can only be used as a function parameter}}
+  image1d_t ai[] = {i, i}; // expected-error{{array of '__read_only image1d_t' type is invalid in OpenCL}}
+  i=i; // expected-error{{invalid operands to binary expression ('__read_only image1d_t' and '__read_only image1d_t')}}
+  i+1; // expected-error{{invalid operands to binary expression ('__read_only imag

Re: r274633 - Revert "Include debug info for nested structs and classes"

2016-07-06 Thread Nico Weber via cfe-commits
When reverting something, please say why in the commit description.

On Wed, Jul 6, 2016 at 11:15 AM, Adrian McCarthy via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: amccarth
> Date: Wed Jul  6 10:15:38 2016
> New Revision: 274633
>
> URL: http://llvm.org/viewvc/llvm-project?rev=274633&view=rev
> Log:
> Revert "Include debug info for nested structs and classes"
>
> This reverts commit 0af5ee9631c7c167dc40498b415876553e314c95.
>
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CGDebugInfo.h
> cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
> cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp
> cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=274633&r1=274632&r2=274633&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Jul  6 10:15:38 2016
> @@ -1095,13 +1095,6 @@ void CGDebugInfo::CollectRecordNormalFie
>elements.push_back(FieldType);
>  }
>
> -void CGDebugInfo::CollectRecordNestedRecord(
> -const RecordDecl *RD, SmallVectorImpl &elements) {
> -  QualType Ty = CGM.getContext().getTypeDeclType(RD);
> -  llvm::DIType *nestedType = getOrCreateType(Ty, getOrCreateMainFile());
> -  elements.push_back(nestedType);
> -}
> -
>  void CGDebugInfo::CollectRecordFields(
>  const RecordDecl *record, llvm::DIFile *tunit,
>  SmallVectorImpl &elements,
> @@ -1138,9 +1131,6 @@ void CGDebugInfo::CollectRecordFields(
>
>  // Bump field number for next field.
>  ++fieldNo;
> -  } else if (const auto *nestedRec = dyn_cast(I)) {
> -if (!nestedRec->isImplicit() && nestedRec->getDeclContext() ==
> record)
> -  CollectRecordNestedRecord(nestedRec, elements);
>}
>}
>  }
> @@ -3643,8 +3633,8 @@ void CGDebugInfo::EmitUsingDirective(con
>if (CGM.getCodeGenOpts().getDebugInfo() <
> codegenoptions::LimitedDebugInfo)
>  return;
>const NamespaceDecl *NSDecl = UD.getNominatedNamespace();
> -  if (!NSDecl->isAnonymousNamespace() ||
> -  CGM.getCodeGenOpts().DebugExplicitImport) {
> +  if (!NSDecl->isAnonymousNamespace() ||
> +  CGM.getCodeGenOpts().DebugExplicitImport) {
>  DBuilder.createImportedModule(
>  getCurrentContextDescriptor(cast(UD.getDeclContext())),
>  getOrCreateNameSpace(NSDecl),
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=274633&r1=274632&r2=274633&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Wed Jul  6 10:15:38 2016
> @@ -254,8 +254,6 @@ class CGDebugInfo {
>  llvm::DIFile *F,
>  SmallVectorImpl &E,
>  llvm::DIType *RecordTy, const RecordDecl
> *RD);
> -  void CollectRecordNestedRecord(const RecordDecl *RD,
> - SmallVectorImpl &E);
>void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile *F,
> SmallVectorImpl &E,
> llvm::DICompositeType *RecordTy);
>
> Modified: cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp?rev=274633&r1=274632&r2=274633&view=diff
>
> ==
> --- cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp Wed Jul  6
> 10:15:38 2016
> @@ -19,6 +19,6 @@ protected:
>
>  Test t;
>
> -// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "data"
>  // CHECK: !DIDerivedType(tag: DW_TAG_pointer_type
> +// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "data"
>  // CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "data"
>
> Modified: cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp?rev=274633&r1=274632&r2=274633&view=diff
>
> ==
> --- cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp Wed Jul
> 6 10:15:38 2016
> @@ -8,18 +8,18 @@ template  class Fo
>  struct Bar {
>int i1;
>// CHECK: ![[INT:[0-9]+]] = !DIBasicType(name: "int"
> -  // CHECK: ![[UNION:[0-9]+]] = distinct !DICompositeType(tag:
> DW_TAG_union_type,{{.*}} identifier: "_ZTSN3BarUt_E")
> +  // CHECK: !DIDerivedType(tag: DW_TA

Re: [PATCH] D21814: clang-rename: support multiple renames with one invocation

2016-07-06 Thread Manuel Klimek via cfe-commits
klimek added a reviewer: bkramer.
klimek added a comment.

I think we really want 2 tools:
a) one that is optimized for oldname->newname renames, and supports the 
multi-TU case really well
b) one that is meant to be integrated with editors and works mainly off of a 
location in a file

I'm a bit torn whether putting those 2 into the same executable is a good idea. 
Looping in Benjamin for additional ideas.


http://reviews.llvm.org/D21814



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


Re: [PATCH] D21989: [OpenCL] Improve diagnostics of OpenCL types

2016-07-06 Thread Yaxun Liu via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.

LGTM. Thanks!


http://reviews.llvm.org/D21989



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


Re: [PATCH] D22034: [MSVC][DLL] use local vftable mangling only exported classes with virtual destructor

2016-07-06 Thread David Majnemer via cfe-commits
majnemer added a comment.

In http://reviews.llvm.org/D22034#475002, @DmitryPolukhin wrote:

> In http://reviews.llvm.org/D22034#474985, @majnemer wrote:
>
> > In http://reviews.llvm.org/D22034#474937, @DmitryPolukhin wrote:
> >
> > > David, do you know real programs that relay on constexpr and dllexport 
> > > semantic that doesn't work on MSVC?
> >
> >
> > Yes, Chrome relied on these semantics.
>
>
> Hm, does it mean that Chrome has some workaround to bypass that MSVC doesn't 
> support it?


Not an explicit workaround, other MSVC bugs prevent them from miscompiling the 
exact sequence used in Chrome.

> 

> 

> > > Anyway current implementation is not compatible with MSVC in much more 
> > > common case without constexp.

> 

> > 

> 

> > 

> 

> > I don't see how it is not compatible.  The address of the vftable is not 
> > observable as far as I know...

> 

> 

> You can easily observe the difference if vftable is exported from DLL but 
> some virtual functions are not (for example, private). MSVC will uses 
> imported vftable and Clang will try to rebuild fvtable that will fail on link 
> time.


Wait, can you give an example of MSVC exporting a vftable but not all the 
virtual methods (other than the deleting destructor)?  I don't believe I've 
ever come across an example of this.


http://reviews.llvm.org/D22034



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


[PATCH] D22048: [analyzer] Suppress false positives in std::shared_ptr

2016-07-06 Thread Devin Coughlin via cfe-commits
dcoughlin created this revision.
dcoughlin added reviewers: zaks.anna, NoQ.
dcoughlin added a subscriber: cfe-commits.
Herald added a subscriber: aemerson.

The analyzer does not model C++ temporary destructors completely and so reports 
false alarms about leaks of memory allocated by the internals of shared_ptr:

  std::shared_ptr p(new int(1));
  p = nullptr; // 'Potential leak of memory pointed to by field __cntrl_'

To avoid these spurious diagnostics, this patch suppresses all diagnostics 
where the end of the path is inside a method in std::shared_ptr.

rdar://problem/23652766

http://reviews.llvm.org/D22048

Files:
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  test/Analysis/Inputs/system-header-simulator-cxx.h
  test/Analysis/inlining/stl.cpp

Index: test/Analysis/inlining/stl.cpp
===
--- test/Analysis/inlining/stl.cpp
+++ test/Analysis/inlining/stl.cpp
@@ -52,3 +52,9 @@
 void testSupprerssion_independent_bits_engine(MyEngine& e) {
   std::__independent_bits_engine x(e, 64); // 
no-warning
 }
+
+void testSuppression_std_shared_pointer() {
+  std::shared_ptr p(new int(1));
+
+  p = nullptr; // no-warning
+}
Index: test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- test/Analysis/Inputs/system-header-simulator-cxx.h
+++ test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -329,6 +329,36 @@
   z = 5/z;
 }
 
+#if __has_feature(cxx_decltype)
+typedef decltype(nullptr) nullptr_t;
+
+template
+class shared_ptr
+{
+public:
+  constexpr shared_ptr(nullptr_t);
+  explicit shared_ptr(_Tp* __p);
+
+  shared_ptr(shared_ptr&& __r) { }
+
+  ~shared_ptr();
+
+  shared_ptr& operator=(shared_ptr&& __r) {
+// Fake error trigger.
+// No warning is expected as we are suppressing warning coming
+// out of std::basic_string.
+int z = 0;
+z = 5/z;
+  }
+};
+
+template
+inline
+constexpr
+shared_ptr<_Tp>::shared_ptr(nullptr_t) {
+}
+
+#endif // __has_feature(cxx_decltype)
 }
 
 void* operator new(std::size_t, const std::nothrow_t&) throw();
Index: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1596,23 +1596,31 @@
 }
   }
 
-  // The analyzer issues a false positive on
-  //   std::basic_string v; v.push_back(1);
-  // and
-  //   std::u16string s; s += u'a';
-  // because we cannot reason about the internal invariants of the
-  // datastructure.
   for (const LocationContext *LCtx = N->getLocationContext(); LCtx;
LCtx = LCtx->getParent()) {
 const CXXMethodDecl *MD = dyn_cast(LCtx->getDecl());
 if (!MD)
   continue;
 
 const CXXRecordDecl *CD = MD->getParent();
+// The analyzer issues a false positive on
+//   std::basic_string v; v.push_back(1);
+// and
+//   std::u16string s; s += u'a';
+// because we cannot reason about the internal invariants of the
+// datastructure.
 if (CD->getName() == "basic_string") {
   BR.markInvalid(getTag(), nullptr);
   return nullptr;
 }
+
+// The analyzer issues a false positive on
+//std::shared_ptr p(new int(1)); p = nullptr;
+// because it does not reason properly about temporary destructors.
+if (CD->getName() == "shared_ptr") {
+  BR.markInvalid(getTag(), nullptr);
+  return nullptr;
+}
   }
 }
   }


Index: test/Analysis/inlining/stl.cpp
===
--- test/Analysis/inlining/stl.cpp
+++ test/Analysis/inlining/stl.cpp
@@ -52,3 +52,9 @@
 void testSupprerssion_independent_bits_engine(MyEngine& e) {
   std::__independent_bits_engine x(e, 64); // no-warning
 }
+
+void testSuppression_std_shared_pointer() {
+  std::shared_ptr p(new int(1));
+
+  p = nullptr; // no-warning
+}
Index: test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- test/Analysis/Inputs/system-header-simulator-cxx.h
+++ test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -329,6 +329,36 @@
   z = 5/z;
 }
 
+#if __has_feature(cxx_decltype)
+typedef decltype(nullptr) nullptr_t;
+
+template
+class shared_ptr
+{
+public:
+  constexpr shared_ptr(nullptr_t);
+  explicit shared_ptr(_Tp* __p);
+
+  shared_ptr(shared_ptr&& __r) { }
+
+  ~shared_ptr();
+
+  shared_ptr& operator=(shared_ptr&& __r) {
+// Fake error trigger.
+// No warning is expected as we are suppressing warning coming
+// out of std::basic_string.
+int z = 0;
+z = 5/z;
+  }
+};
+
+template
+inline
+constexpr
+shared_ptr<_Tp>::shared_ptr(nullptr_t) {
+}
+
+#endif // __has_feature(cxx_decltype)
 }
 
 void* operator new(std::size_t, const std::noth

Re: [PATCH] D21349: [libcxx] [test] Fix a typo in commented-out code.

2016-07-06 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT closed this revision.
STL_MSFT added a comment.

Closing - Marshall fixed the typo and uncommented the code.


http://reviews.llvm.org/D21349



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


Re: [PATCH] D20795: Added basic capabilities to detect source code clones.

2016-07-06 Thread Raphael Isemann via cfe-commits
teemperor updated this revision to Diff 62888.
teemperor added a comment.

- Using doxygen-style comments for all private members.


http://reviews.llvm.org/D20795

Files:
  include/clang/AST/CloneDetection.h
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/AST/CMakeLists.txt
  lib/AST/CloneDetection.cpp
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  test/Analysis/copypaste/test-min-max.cpp
  test/Analysis/copypaste/test-sub-sequences.cpp

Index: test/Analysis/copypaste/test-sub-sequences.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-sub-sequences.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=clone.CloneChecker -verify %s
+
+// We test if sub-sequences can match with normal sequences containing only
+// a single statement.
+
+void log2(int a);
+void log();
+
+int max(int a, int b) {
+  log2(a);
+  log(); // expected-warning{{Detected code clone.}}
+  if (a > b)
+return a;
+  return b;
+}
+
+int maxClone(int a, int b) {
+  log(); // expected-note{{Related code clone is here.}}
+  if (a > b)
+return a;
+  return b;
+}
+
+// Functions below are not clones and should not be reported.
+
+int foo(int a, int b) {
+  return a + b;
+}
Index: test/Analysis/copypaste/test-min-max.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-min-max.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=clone.CloneChecker -verify %s
+
+void log();
+
+int max(int a, int b) { // expected-warning{{Detected code clone.}}
+  log();
+  if (a > b)
+return a;
+  return b;
+}
+
+int maxClone(int a, int b) { // expected-note{{Related code clone is here.}}
+  log();
+  if (a > b)
+return a;
+  return b;
+}
+
+// False positives below. These clones should not be reported.
+
+// FIXME: Detect different binary operator kinds.
+int min1(int a, int b) { // expected-note{{Related code clone is here.}}
+  log();
+  if (a < b)
+return a;
+  return b;
+}
+
+// FIXME: Detect different variable patterns.
+int min2(int a, int b) { // expected-note{{Related code clone is here.}}
+  log();
+  if (b > a)
+return a;
+  return b;
+}
+
+// Functions below are not clones and should not be reported.
+
+int foo(int a, int b) {
+  return a + b;
+}
Index: lib/StaticAnalyzer/Checkers/CloneChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/CloneChecker.cpp
@@ -0,0 +1,67 @@
+//===--- CloneDetection.cpp - Clone detection checkers --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// CloneChecker is a checker that reports clones in the current translation
+/// unit.
+///
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/AST/CloneDetection.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+class CloneChecker : public Checker {
+
+public:
+  void checkEndOfTranslationUnit(const TranslationUnitDecl *TU,
+ AnalysisManager &Mgr, BugReporter &BR) const;
+};
+} // end anonymous namespace
+
+void CloneChecker::checkEndOfTranslationUnit(const TranslationUnitDecl *TU,
+ AnalysisManager &Mgr,
+ BugReporter &BR) const {
+  CloneDetector CloneDetector;
+  CloneDetector.AnalyzeTranslationUnitDecl(
+  TU->getASTContext().getTranslationUnitDecl());
+
+  std::vector CloneGroups =
+  CloneDetector.findClones();
+
+  DiagnosticsEngine &DiagEngine = Mgr.getDiagnostic();
+
+  unsigned WarnID = DiagEngine.getCustomDiagID(DiagnosticsEngine::Warning,
+   "Detected code clone.");
+
+  unsigned NoteID = DiagEngine.getCustomDiagID(DiagnosticsEngine::Note,
+   "Related code clone is here.");
+
+  for (CloneDetector::CloneGroup &Group : CloneGroups) {
+DiagEngine.Report(Group.front().getStartLoc(), WarnID);
+for (unsigned J = 1; J < Group.size(); ++J) {
+  DiagEngine.Report(Group[J].getStartLoc(), NoteID);
+}
+  }
+}
+
+//===--===//
+// Register CloneChecker
+//===--===//
+
+void ento::registerCloneChecker(CheckerManager &Mgr) {
+  

Re: [PATCH] D21991: [libunwind][ARM] Improve unwinder stack usage - Make WMMX support optional

2016-07-06 Thread Asiri Rathnayake via cfe-commits
rmaprath added a reviewer: compnerd.
rmaprath removed a subscriber: compnerd.
rmaprath updated this revision to Diff 62890.
rmaprath added a comment.

- Use `__ARM_WMMX` instead of `_LIBUNWIND_ARM_WMMX`
- Add a comment to the cmake option `LIBUNWIND_ENABLE_ARM_WMMX` to explain why 
it is done this way


http://reviews.llvm.org/D21991

Files:
  CMakeLists.txt
  include/__libunwind_config.h
  src/Registers.hpp
  src/Unwind-EHABI.cpp
  src/UnwindRegistersRestore.S
  src/UnwindRegistersSave.S

Index: src/UnwindRegistersSave.S
===
--- src/UnwindRegistersSave.S
+++ src/UnwindRegistersSave.S
@@ -378,15 +378,16 @@
   vstmia r0, {d16-d31}
   JMP(lr)
 
+#if defined(_LIBUNWIND_ARM_WMMX)
+
 @
 @ static void libunwind::Registers_arm::saveiWMMX(unw_fpreg_t* values)
 @
 @ On entry:
 @  values pointer is in r0
 @
   .p2align 2
 DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm9saveiWMMXEPy)
-#if (!defined(__ARM_ARCH_6M__) && !defined(__ARM_ARCH_6SM__)) || defined(__ARM_WMMX)
   stcl p1, cr0, [r0], #8  @ wstrd wR0, [r0], #8
   stcl p1, cr1, [r0], #8  @ wstrd wR1, [r0], #8
   stcl p1, cr2, [r0], #8  @ wstrd wR2, [r0], #8
@@ -403,7 +404,6 @@
   stcl p1, cr13, [r0], #8  @ wstrd wR13, [r0], #8
   stcl p1, cr14, [r0], #8  @ wstrd wR14, [r0], #8
   stcl p1, cr15, [r0], #8  @ wstrd wR15, [r0], #8
-#endif
   JMP(lr)
 
 @
@@ -414,14 +414,14 @@
 @
   .p2align 2
 DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveiWMMXControlEPj)
-#if (!defined(__ARM_ARCH_6M__) && !defined(__ARM_ARCH_6SM__)) || defined(__ARM_WMMX)
   stc2 p1, cr8, [r0], #4  @ wstrw wCGR0, [r0], #4
   stc2 p1, cr9, [r0], #4  @ wstrw wCGR1, [r0], #4
   stc2 p1, cr10, [r0], #4  @ wstrw wCGR2, [r0], #4
   stc2 p1, cr11, [r0], #4  @ wstrw wCGR3, [r0], #4
-#endif
   JMP(lr)
 
+#endif
+
 #elif defined(__or1k__)
 
 #
Index: src/UnwindRegistersRestore.S
===
--- src/UnwindRegistersRestore.S
+++ src/UnwindRegistersRestore.S
@@ -383,15 +383,16 @@
   vldmia r0, {d16-d31}
   JMP(lr)
 
+#if defined(__ARM_WMMX)
+
 @
 @ static void libunwind::Registers_arm::restoreiWMMX(unw_fpreg_t* values)
 @
 @ On entry:
 @  values pointer is in r0
 @
   .p2align 2
 DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm12restoreiWMMXEPy)
-#if (!defined(__ARM_ARCH_6M__) && !defined(__ARM_ARCH_6SM__)) || defined(__ARM_WMMX)
   ldcl p1, cr0, [r0], #8  @ wldrd wR0, [r0], #8
   ldcl p1, cr1, [r0], #8  @ wldrd wR1, [r0], #8
   ldcl p1, cr2, [r0], #8  @ wldrd wR2, [r0], #8
@@ -408,7 +409,6 @@
   ldcl p1, cr13, [r0], #8  @ wldrd wR13, [r0], #8
   ldcl p1, cr14, [r0], #8  @ wldrd wR14, [r0], #8
   ldcl p1, cr15, [r0], #8  @ wldrd wR15, [r0], #8
-#endif
   JMP(lr)
 
 @
@@ -419,14 +419,14 @@
 @
   .p2align 2
 DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm19restoreiWMMXControlEPj)
-#if (!defined(__ARM_ARCH_6M__) && !defined(__ARM_ARCH_6SM__)) || defined(__ARM_WMMX)
   ldc2 p1, cr8, [r0], #4  @ wldrw wCGR0, [r0], #4
   ldc2 p1, cr9, [r0], #4  @ wldrw wCGR1, [r0], #4
   ldc2 p1, cr10, [r0], #4  @ wldrw wCGR2, [r0], #4
   ldc2 p1, cr11, [r0], #4  @ wldrw wCGR3, [r0], #4
-#endif
   JMP(lr)
 
+#endif
+
 #elif defined(__or1k__)
 
 DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind14Registers_or1k6jumptoEv)
Index: src/Unwind-EHABI.cpp
===
--- src/Unwind-EHABI.cpp
+++ src/Unwind-EHABI.cpp
@@ -351,6 +351,7 @@
 }
 case 0xc0: {
   switch (byte) {
+#if defined(__ARM_WMMX)
 case 0xc0:
 case 0xc1:
 case 0xc2:
@@ -378,6 +379,7 @@
   _Unwind_VRS_Pop(context, _UVRSC_WMMXC, v, _UVRSD_DOUBLE);
   break;
 }
+#endif
 case 0xc8:
 case 0xc9: {
   uint8_t v = getByte(data, offset++);
@@ -771,13 +773,6 @@
  *(unw_word_t *)valuep) == UNW_ESUCCESS
  ? _UVRSR_OK
  : _UVRSR_FAILED;
-case _UVRSC_WMMXC:
-  if (representation != _UVRSD_UINT32 || regno > 3)
-return _UVRSR_FAILED;
-  return unw_set_reg(cursor, (unw_regnum_t)(UNW_ARM_WC0 + regno),
- *(unw_word_t *)valuep) == UNW_ESUCCESS
- ? _UVRSR_OK
- : _UVRSR_FAILED;
 case _UVRSC_VFP:
   if (representation != _UVRSD_VFPX && representation != _UVRSD_DOUBLE)
 return _UVRSR_FAILED;
@@ -794,13 +789,22 @@
*(unw_fpreg_t *)valuep) == UNW_ESUCCESS
  ? _UVRSR_OK
  : _UVRSR_FAILED;
+#if defined(__ARM_WMMX)
+case _UVRSC_WMMXC:
+  if (representation != _UVRSD_UINT32 || regno > 3)
+return _UVRSR_FAILED;
+  return unw_set_reg(cursor, (unw_regnum_t)(UNW_ARM_WC0 + regno),
+ *(unw_word_t *)valuep) == UNW_ESUCCESS
+ ? _UVRSR_OK
+ : _UVRSR_FAILED;
 case _UVRSC

[PATCH] D22053: [Sema] Fix a C++1z bug where initializer for static constexpr data member was not instantiated

2016-07-06 Thread Erik Pilkington via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: rsmith, faisalv.
erik.pilkington added a subscriber: cfe-commits.

This is a regression that only affects -std=c++1z, introduced in r273754. The 
following test case (thanks rsmith!) fails to compile:

```
template struct X {};

template struct Y {
  static constexpr int s_v[] = {0};
  X<*s_v> x; // Clang incorrectly says: error, *s_v is not a constant expression
};

template struct Y;
```

The problem is that the initializer for `s_v` (an implicitly inline variable in 
c++1z) is not instantiated. This patch requires that the initializer for an 
IncompleteArrayType is instantiated, which is the same rule as an initializer 
for an `auto` type.

Fixes PR28385.

Thanks!

http://reviews.llvm.org/D22053

Files:
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CXX/temp/temp.spec/temp.inst/p1.cpp

Index: test/CXX/temp/temp.spec/temp.inst/p1.cpp
===
--- test/CXX/temp/temp.spec/temp.inst/p1.cpp
+++ test/CXX/temp/temp.spec/temp.inst/p1.cpp
@@ -109,5 +109,16 @@
   int test2 = g(); // expected-note {{here}}
 }
 
+namespace PR28385 {
+template  struct X {};
+
+template  struct Y {
+  static constexpr int s_v[] = {0};
+  X<*s_v> x;
+};
+
+template struct Y;
+}
+
 // FIXME:
 //- - member anonymous unions
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3858,11 +3858,12 @@
 
   // Delay instantiation of the initializer for variable templates or inline
   // static data members until a definition of the variable is needed. We need
-  // it right away if the type contains 'auto'.
+  // it right away if the type contains 'auto' or is an IncompleteArrayType.
   if ((!isa(NewVar) &&
!InstantiatingVarTemplate &&
!(OldVar->isInline() && OldVar->isThisDeclarationADefinition())) ||
-  NewVar->getType()->isUndeducedType())
+  NewVar->getType()->isUndeducedType() ||
+  NewVar->getType()->isIncompleteArrayType())
 InstantiateVariableInitializer(NewVar, OldVar, TemplateArgs);
 
   // Diagnose unused local variables with dependent types, where the diagnostic


Index: test/CXX/temp/temp.spec/temp.inst/p1.cpp
===
--- test/CXX/temp/temp.spec/temp.inst/p1.cpp
+++ test/CXX/temp/temp.spec/temp.inst/p1.cpp
@@ -109,5 +109,16 @@
   int test2 = g(); // expected-note {{here}}
 }
 
+namespace PR28385 {
+template  struct X {};
+
+template  struct Y {
+  static constexpr int s_v[] = {0};
+  X<*s_v> x;
+};
+
+template struct Y;
+}
+
 // FIXME:
 //- - member anonymous unions
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3858,11 +3858,12 @@
 
   // Delay instantiation of the initializer for variable templates or inline
   // static data members until a definition of the variable is needed. We need
-  // it right away if the type contains 'auto'.
+  // it right away if the type contains 'auto' or is an IncompleteArrayType.
   if ((!isa(NewVar) &&
!InstantiatingVarTemplate &&
!(OldVar->isInline() && OldVar->isThisDeclarationADefinition())) ||
-  NewVar->getType()->isUndeducedType())
+  NewVar->getType()->isUndeducedType() ||
+  NewVar->getType()->isIncompleteArrayType())
 InstantiateVariableInitializer(NewVar, OldVar, TemplateArgs);
 
   // Diagnose unused local variables with dependent types, where the diagnostic
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21913: [CUDA] Add additional testcases for EraseUnwantedCUDAMatches.

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

LGTM.


http://reviews.llvm.org/D21913



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


Re: [PATCH] D20795: Added basic capabilities to detect source code clones.

2016-07-06 Thread Raphael Isemann via cfe-commits
teemperor updated this revision to Diff 62899.
teemperor added a comment.

- Fixed a few typos in comments and documentation.


http://reviews.llvm.org/D20795

Files:
  include/clang/AST/CloneDetection.h
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/AST/CMakeLists.txt
  lib/AST/CloneDetection.cpp
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  test/Analysis/copypaste/test-min-max.cpp
  test/Analysis/copypaste/test-sub-sequences.cpp

Index: test/Analysis/copypaste/test-sub-sequences.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-sub-sequences.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=clone.CloneChecker -verify %s
+
+// We test if sub-sequences can match with normal sequences containing only
+// a single statement.
+
+void log2(int a);
+void log();
+
+int max(int a, int b) {
+  log2(a);
+  log(); // expected-warning{{Detected code clone.}}
+  if (a > b)
+return a;
+  return b;
+}
+
+int maxClone(int a, int b) {
+  log(); // expected-note{{Related code clone is here.}}
+  if (a > b)
+return a;
+  return b;
+}
+
+// Functions below are not clones and should not be reported.
+
+int foo(int a, int b) {
+  return a + b;
+}
Index: test/Analysis/copypaste/test-min-max.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/test-min-max.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=clone.CloneChecker -verify %s
+
+void log();
+
+int max(int a, int b) { // expected-warning{{Detected code clone.}}
+  log();
+  if (a > b)
+return a;
+  return b;
+}
+
+int maxClone(int a, int b) { // expected-note{{Related code clone is here.}}
+  log();
+  if (a > b)
+return a;
+  return b;
+}
+
+// False positives below. These clones should not be reported.
+
+// FIXME: Detect different binary operator kinds.
+int min1(int a, int b) { // expected-note{{Related code clone is here.}}
+  log();
+  if (a < b)
+return a;
+  return b;
+}
+
+// FIXME: Detect different variable patterns.
+int min2(int a, int b) { // expected-note{{Related code clone is here.}}
+  log();
+  if (b > a)
+return a;
+  return b;
+}
+
+// Functions below are not clones and should not be reported.
+
+int foo(int a, int b) {
+  return a + b;
+}
Index: lib/StaticAnalyzer/Checkers/CloneChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/CloneChecker.cpp
@@ -0,0 +1,67 @@
+//===--- CloneDetection.cpp - Clone detection checkers --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// CloneChecker is a checker that reports clones in the current translation
+/// unit.
+///
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/AST/CloneDetection.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+class CloneChecker : public Checker {
+
+public:
+  void checkEndOfTranslationUnit(const TranslationUnitDecl *TU,
+ AnalysisManager &Mgr, BugReporter &BR) const;
+};
+} // end anonymous namespace
+
+void CloneChecker::checkEndOfTranslationUnit(const TranslationUnitDecl *TU,
+ AnalysisManager &Mgr,
+ BugReporter &BR) const {
+  CloneDetector CloneDetector;
+  CloneDetector.AnalyzeTranslationUnitDecl(
+  TU->getASTContext().getTranslationUnitDecl());
+
+  std::vector CloneGroups =
+  CloneDetector.findClones();
+
+  DiagnosticsEngine &DiagEngine = Mgr.getDiagnostic();
+
+  unsigned WarnID = DiagEngine.getCustomDiagID(DiagnosticsEngine::Warning,
+   "Detected code clone.");
+
+  unsigned NoteID = DiagEngine.getCustomDiagID(DiagnosticsEngine::Note,
+   "Related code clone is here.");
+
+  for (CloneDetector::CloneGroup &Group : CloneGroups) {
+DiagEngine.Report(Group.front().getStartLoc(), WarnID);
+for (unsigned J = 1; J < Group.size(); ++J) {
+  DiagEngine.Report(Group[J].getStartLoc(), NoteID);
+}
+  }
+}
+
+//===--===//
+// Register CloneChecker
+//===--===//
+
+void ento::registerCloneChecker(CheckerManager &Mgr) {
+  Mgr.r

Re: [PATCH] D21914: [CUDA] Use the multi-element remove function in EraseUnwantedCUDAMatches.

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

LGTM.


http://reviews.llvm.org/D21914



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


Re: [PATCH] D21778: [CUDA] Add support for CUDA 8 and sm_60-62.

2016-07-06 Thread Artem Belevich via cfe-commits
tra added a comment.

The changes look good.
They will need to wait for corresponding patch on LLVM side to deal with new SM 
variants, though.



Comment at: lib/Driver/ToolChains.cpp:1715
@@ -1714,2 +1714,3 @@
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda");
+CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-8.0");
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-7.5");

This is a bit premature as we can't compile CUDA-8 headers yet. Let's drop it 
until we're ready.


http://reviews.llvm.org/D21778



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


Re: [PATCH] D21778: [CUDA] Add support for CUDA 8 and sm_60-62.

2016-07-06 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 62908.
jlebar marked an inline comment as done.
jlebar added a comment.

Don't pull in the cuda 8 headers by default.


http://reviews.llvm.org/D21778

Files:
  lib/Basic/Targets.cpp
  lib/Driver/Action.cpp
  lib/Driver/ToolChains.cpp

Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1715,6 +1715,8 @@
 Args.getLastArgValue(options::OPT_cuda_path_EQ));
   else {
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda");
+// FIXME: Uncomment this once we can compile the cuda 8 headers.
+// CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-8.0");
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-7.5");
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-7.0");
   }
@@ -1761,6 +1763,9 @@
 CudaLibDeviceMap["sm_50"] = FilePath;
 CudaLibDeviceMap["sm_52"] = FilePath;
 CudaLibDeviceMap["sm_53"] = FilePath;
+CudaLibDeviceMap["sm_60"] = FilePath;
+CudaLibDeviceMap["sm_61"] = FilePath;
+CudaLibDeviceMap["sm_62"] = FilePath;
   }
 }
 
Index: lib/Driver/Action.cpp
===
--- lib/Driver/Action.cpp
+++ lib/Driver/Action.cpp
@@ -66,6 +66,9 @@
   .Case("sm_50", "compute_50")
   .Case("sm_52", "compute_52")
   .Case("sm_53", "compute_53")
+  .Case("sm_60", "compute_60")
+  .Case("sm_61", "compute_61")
+  .Case("sm_62", "compute_62")
   .Default(nullptr);
 }
 
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -1701,11 +1701,15 @@
 GK_SM20,
 GK_SM21,
 GK_SM30,
+GK_SM32,
 GK_SM35,
 GK_SM37,
 GK_SM50,
 GK_SM52,
 GK_SM53,
+GK_SM60,
+GK_SM61,
+GK_SM62,
   } GPU;
 
 public:
@@ -1787,35 +1791,37 @@
 Builder.defineMacro("__NVPTX__");
 if (Opts.CUDAIsDevice) {
   // Set __CUDA_ARCH__ for the GPU specified.
-  std::string CUDAArchCode;
-  switch (GPU) {
-  case GK_SM20:
-CUDAArchCode = "200";
-break;
-  case GK_SM21:
-CUDAArchCode = "210";
-break;
-  case GK_SM30:
-CUDAArchCode = "300";
-break;
-  case GK_SM35:
-CUDAArchCode = "350";
-break;
-  case GK_SM37:
-CUDAArchCode = "370";
-break;
-  case GK_SM50:
-CUDAArchCode = "500";
-break;
-  case GK_SM52:
-CUDAArchCode = "520";
-break;
-  case GK_SM53:
-CUDAArchCode = "530";
-break;
-  default:
-llvm_unreachable("Unhandled target CPU");
-  }
+  std::string CUDAArchCode = [this] {
+switch (GPU) {
+case GK_NONE:
+  assert(false && "No GPU arch when compiling CUDA device code.");
+  return "";
+case GK_SM20:
+  return "200";
+case GK_SM21:
+  return "210";
+case GK_SM30:
+  return "300";
+case GK_SM32:
+  return "320";
+case GK_SM35:
+  return "350";
+case GK_SM37:
+  return "370";
+case GK_SM50:
+  return "500";
+case GK_SM52:
+  return "520";
+case GK_SM53:
+  return "530";
+case GK_SM60:
+  return "600";
+case GK_SM61:
+  return "610";
+case GK_SM62:
+  return "620";
+}
+  }();
   Builder.defineMacro("__CUDA_ARCH__", CUDAArchCode);
 }
   }
@@ -1860,11 +1866,15 @@
   .Case("sm_20", GK_SM20)
   .Case("sm_21", GK_SM21)
   .Case("sm_30", GK_SM30)
+  .Case("sm_32", GK_SM32)
   .Case("sm_35", GK_SM35)
   .Case("sm_37", GK_SM37)
   .Case("sm_50", GK_SM50)
   .Case("sm_52", GK_SM52)
   .Case("sm_53", GK_SM53)
+  .Case("sm_60", GK_SM60)
+  .Case("sm_61", GK_SM61)
+  .Case("sm_62", GK_SM62)
   .Default(GK_NONE);
 
 return GPU != GK_NONE;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D22057: Prevent devirtualization of calls to un-instantiated functions.

2016-07-06 Thread Sunil Srivastava via cfe-commits
Sunil_Srivastava created this revision.
Sunil_Srivastava added a reviewer: rsmith.
Sunil_Srivastava added a subscriber: cfe-commits.

This review is for a fix for PR 27895, but it requires some discussion. The 
bugzilla and the email exchange with Richard Smith in 
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160530/161107.html 
contain more details.

The basic problem: When the front end sees a call to a virtual function of a 
template class, it treats that as an odr use, therefore requiring the 
instantiation; except, for some reason, when it is an operator and used with an 
operator syntax. In those cases, if the call gets devirtualized later, it will 
generate a direct call to a function that has not been instantiated. Most of 
the time it will still work because someone else will instantiate it for some 
other reason, but if not, then we have converted a potentially dead code to a 
link time error of a missing definition.

As discussed in the email exchange, there are two alternative ways to fix the 
problem. Either will be sufficient, but we want to do both.

The first fix will be in the front end to force the instantiation on virtual 
calls that are potentially devirtualizable. For reasons described below I plan 
on submitting this in a later checkin.

The second fix, the matter of this review, is to avoid devirtualization under 
certain conditions. The conditions that I am choosing is to prevent 
devirtualization if the function could be implicitly instantiated but front end 
chose to not mark it for instantiation. I welcome any suggestions about 
improvement to this condition.

The reason I am planning on submitting them in this order, is that, once the 
first fix is checked in, there will be no way, known to me, to write a test for 
the second, devirtualization fix.

Now some discussion about the way I am testing the avoid-devirtualization 
condition: I have added a bit to FunctionDecl that I am setting whenever a 
function is put on the PendingInstantiations list. Then, at the time of 
devirtualization, if the target function isImplictlyInstantiable and does not 
have that bit set, I avoid the devirtualization. This change adds one bit to 
FunctionDecl, but the test is quite fast. However, it duplicates the 
information between this bit and the PendingInstantiationsList.

We have considered an alternate implementation which replaces the call (in 
CGClass.cpp) to 
isMarkedForPendingInstantiation with
   - explcitly-test-whether-it-is-on-the-PendingInstations-list ||
   - has-already-been-instantiated.

This alternate implementation does not add anything to FunctionDecl, avoids 
information duplication, but the test for its presence in the list will be 
expensive; it will require a search in the list. It will be done only for 
devirtualizable calls though, which is not that common.

A related point that I am not sure about is: Are there circumstances where a 
function on the PendingInstantiations list can fails to be instantiated for 
reasons other than errors? If so then this checkin is not perfect, though it is 
still better than nothing.

I am open to suggestion as to which of these implementations makes more sense.

Once this change has been approved and submitted, I will open another review 
for the first fix, which will force the instantiation of functions that are 
target of potentially devirtualizable calls.



http://reviews.llvm.org/D22057

Files:
  include/clang/AST/Decl.h
  lib/CodeGen/CGClass.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CodeGen/no-devirt.cpp

Index: test/CodeGen/no-devirt.cpp
===
--- test/CodeGen/no-devirt.cpp
+++ test/CodeGen/no-devirt.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s
+template < typename T, int N = 0 > class TmplWithArray {
+public:
+  virtual T& operator [] (int idx);
+  virtual T& func1 (int idx);
+  virtual T& func2 (int idx);
+  T ar[N+1];
+};
+class Wrapper {
+  TmplWithArray data;
+  bool indexIt(int a);
+};
+bool Wrapper::indexIt(int a)
+{
+   if (a > 6) return data[a] ;  // Should not devirtualize
+   if (a > 4) return data.func1(a); // Should devirtualize
+   return data.func2(a);// Should devirtualize
+}
+template  T& TmplWithArray::operator[](int idx) {
+  return ar[idx];
+}
+template  T& TmplWithArray::func1(int idx) {
+  return ar[idx];
+}
+// CHECK-NOT: call {{.*}} @_ZN13TmplWithArrayIbLi10EEixEi
+// CHECK-DAG: call {{.*}} @_ZN13TmplWithArrayIbLi10EE5func1Ei
+// CHECK-DAG: call {{.*}} @_ZN13TmplWithArrayIbLi10EE5func2Ei
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3531,6 +3531,7 @@
   // Postpone late parsed template instantiations.
   if (PatternDecl->isLateTemplateParsed() &&

Re: [PATCH] D22034: [MSVC][DLL] use local vftable mangling only exported classes with virtual destructor

2016-07-06 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

In http://reviews.llvm.org/D22034#475331, @majnemer wrote:

> Wait, can you give an example of MSVC exporting a vftable but not all the 
> virtual methods (other than the deleting destructor)?  I don't believe I've 
> ever come across an example of this.


It is possible in code like this:
class B {

  virtual void foo();

public:

  virtual void bar();

};

class __declspec(dllexport) D : public B {
public:

  virtual void bar();

};

void B::foo() {}
void B::bar() {}
void D::bar() {}

Here is B::foo is not exported but required to build vftable for D. Also user 
may want to explicitly control what should be exported from his library and may 
decide to remove some functions from exported interface.


http://reviews.llvm.org/D22034



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


Re: [PATCH] D22034: [MSVC][DLL] use local vftable mangling only exported classes with virtual destructor

2016-07-06 Thread David Majnemer via cfe-commits
majnemer added a comment.

In http://reviews.llvm.org/D22034#475540, @DmitryPolukhin wrote:

> In http://reviews.llvm.org/D22034#475331, @majnemer wrote:
>
> > Wait, can you give an example of MSVC exporting a vftable but not all the 
> > virtual methods (other than the deleting destructor)?  I don't believe I've 
> > ever come across an example of this.
>
>
> It is possible in code like this:
>  class B {
>
>   virtual void foo();
>   
>
> public:
>
>   virtual void bar();
>
> };
>
> class __declspec(dllexport) D : public B {
> public:
>
>   virtual void bar();
>
> };
>
> void B::foo() {}
>  void B::bar() {}
>  void D::bar() {}
>
> Here is B::foo is not exported but required to build vftable for D.


What happens if D also had a virtual destructor?


http://reviews.llvm.org/D22034



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


[PATCH] D22059: [libcxx] [test] Fix MSVC "warning C4100: 'val': unreferenced formal parameter".

2016-07-06 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.

Fix MSVC "warning C4100: 'val': unreferenced formal parameter".

http://reviews.llvm.org/D22059

Files:
  test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp

Index: test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
===
--- test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
+++ test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
@@ -39,7 +39,7 @@
 
 struct E {
   E() = default;
-  E& operator=(int val) {
+  E& operator=(int) {
   return *this;
   }
 };


Index: test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
===
--- test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
+++ test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
@@ -39,7 +39,7 @@
 
 struct E {
   E() = default;
-  E& operator=(int val) {
+  E& operator=(int) {
   return *this;
   }
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11360: Proposed patch to prevent the creation of empty (forwarding) blocks resulting from nested ifs.

2016-07-06 Thread Wolfgang Pieb via cfe-commits
wolfgangp updated this revision to Diff 62916.
wolfgangp added a comment.

Addressed review comments: documented changes and clang-formatted the test case.


http://reviews.llvm.org/D11360

Files:
  lib/CodeGen/CGStmt.cpp
  test/CodeGen/forwarding-blocks-if.c

Index: test/CodeGen/forwarding-blocks-if.c
===
--- test/CodeGen/forwarding-blocks-if.c
+++ test/CodeGen/forwarding-blocks-if.c
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// Check that no empty blocks are generated for nested ifs.
+
+extern void func();
+
+int f0(int val) {
+  if (val == 0) {
+func();
+  } else if (val == 1) {
+func();
+  }
+  return 0;
+}
+
+// CHECK-LABEL: define i32 @f0
+// CHECK: call void {{.*}} @func
+// CHECK: call void {{.*}} @func
+// CHECK: br label %[[RETBLOCK1:[^ ]*]]
+// CHECK: [[RETBLOCK1]]:
+// CHECK-NOT: br label
+// CHECK: ret i32
+
+int f1(int val, int g) {
+  if (val == 0)
+if (g == 1) {
+  func();
+}
+  return 0;
+}
+
+// CHECK-LABEL: define i32 @f1
+// CHECK: call void {{.*}} @func
+// CHECK: br label %[[RETBLOCK2:[^ ]*]]
+// CHECK: [[RETBLOCK2]]:
+// CHECK-NOT: br label
+// CHECK: ret i32
Index: lib/CodeGen/CGStmt.cpp
===
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -610,7 +610,14 @@
 RunCleanupsScope ThenScope(*this);
 EmitStmt(S.getThen());
   }
-  EmitBranch(ContBlock);
+  {
+auto CurBlock = Builder.GetInsertBlock();
+EmitBranch(ContBlock);
+// Eliminate any empty blocks that may have been created by nested
+// control flow statements in the 'then' clause.
+if (CurBlock)
+  SimplifyForwardingBlocks(CurBlock); 
+  }
 
   // Emit the 'else' code if present.
   if (const Stmt *Else = S.getElse()) {
@@ -626,7 +633,12 @@
 {
   // There is no need to emit line number for an unconditional branch.
   auto NL = ApplyDebugLocation::CreateEmpty(*this);
+  auto CurBlock = Builder.GetInsertBlock();
   EmitBranch(ContBlock);
+  // Eliminate any empty blocks that may have been created by nested
+  // control flow statements emitted in the 'else' clause.
+  if (CurBlock)
+SimplifyForwardingBlocks(CurBlock); 
 }
   }
 


Index: test/CodeGen/forwarding-blocks-if.c
===
--- test/CodeGen/forwarding-blocks-if.c
+++ test/CodeGen/forwarding-blocks-if.c
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// Check that no empty blocks are generated for nested ifs.
+
+extern void func();
+
+int f0(int val) {
+  if (val == 0) {
+func();
+  } else if (val == 1) {
+func();
+  }
+  return 0;
+}
+
+// CHECK-LABEL: define i32 @f0
+// CHECK: call void {{.*}} @func
+// CHECK: call void {{.*}} @func
+// CHECK: br label %[[RETBLOCK1:[^ ]*]]
+// CHECK: [[RETBLOCK1]]:
+// CHECK-NOT: br label
+// CHECK: ret i32
+
+int f1(int val, int g) {
+  if (val == 0)
+if (g == 1) {
+  func();
+}
+  return 0;
+}
+
+// CHECK-LABEL: define i32 @f1
+// CHECK: call void {{.*}} @func
+// CHECK: br label %[[RETBLOCK2:[^ ]*]]
+// CHECK: [[RETBLOCK2]]:
+// CHECK-NOT: br label
+// CHECK: ret i32
Index: lib/CodeGen/CGStmt.cpp
===
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -610,7 +610,14 @@
 RunCleanupsScope ThenScope(*this);
 EmitStmt(S.getThen());
   }
-  EmitBranch(ContBlock);
+  {
+auto CurBlock = Builder.GetInsertBlock();
+EmitBranch(ContBlock);
+// Eliminate any empty blocks that may have been created by nested
+// control flow statements in the 'then' clause.
+if (CurBlock)
+  SimplifyForwardingBlocks(CurBlock); 
+  }
 
   // Emit the 'else' code if present.
   if (const Stmt *Else = S.getElse()) {
@@ -626,7 +633,12 @@
 {
   // There is no need to emit line number for an unconditional branch.
   auto NL = ApplyDebugLocation::CreateEmpty(*this);
+  auto CurBlock = Builder.GetInsertBlock();
   EmitBranch(ContBlock);
+  // Eliminate any empty blocks that may have been created by nested
+  // control flow statements emitted in the 'else' clause.
+  if (CurBlock)
+SimplifyForwardingBlocks(CurBlock); 
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11360: Proposed patch to prevent the creation of empty (forwarding) blocks resulting from nested ifs.

2016-07-06 Thread Wolfgang Pieb via cfe-commits
wolfgangp added inline comments.


Comment at: test/CodeGen/forwarding-blocks-if.c:17
@@ +16,3 @@
+return 0;
+}
+

mehdi_amini wrote:
> Any reason to not stick with LLVM coding convention here?
No reason, thanks for pointing this out.


http://reviews.llvm.org/D11360



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


Re: [PATCH] D22034: [MSVC][DLL] use local vftable mangling only exported classes with virtual destructor

2016-07-06 Thread Reid Kleckner via cfe-commits
rnk added a comment.

In http://reviews.llvm.org/D22034#475540, @DmitryPolukhin wrote:

> Here is B::foo is not exported but required to build vftable for D. Also user 
> may want to explicitly control what should be exported from his library and 
> may decide to remove some functions from exported interface.


Sure, but there are other ways for clients of D to end up referencing the 
unexported symbol for B::foo, such as devirtualization. Surely you aren't 
proposing that we power that down just so that we can get the same 
import/export list as MSVC?


http://reviews.llvm.org/D22034



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


r274646 - [SemaExpr] Support assignments from vector to scalars with same size

2016-07-06 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Jul  6 13:05:23 2016
New Revision: 274646

URL: http://llvm.org/viewvc/llvm-project?rev=274646&view=rev
Log:
[SemaExpr] Support assignments from vector to scalars with same size

Before r266366, clang used to support constructs like:

  typedef __attribute__((vector_size(8))) double float64x1_t;
  typedef __attribute__((vector_size(16))) double float64x2_t;
  float64x1_t vget_low_f64(float64x2_t __p0);

  double y = 3.0 + vget_low_f64(v);

But it would reject:

  double y = vget_low_f64(v) + 3.0;

It also always rejected assignments:

  double y = vget_low_f64(v);

This patch: (a) revivies the behavior of `3.0 + vget_low_f64(v)` prior to
r266366, (b) add support for `vget_low_f64(v) + 3.0` and (c) add support for
assignments.

These vector semantics have never really been tied up but it seems
odd that we used to support some binop froms but do not support
assignment. If we did support scalar for the purposes of arithmetic, we
should probably be able to reinterpret as scalar for the purposes of
assignment too.

Differential Revision: http://reviews.llvm.org/D21700

rdar://problem/26093791

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/vector-cast.c

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=274646&r1=274645&r2=274646&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Jul  6 13:05:23 2016
@@ -7394,6 +7394,22 @@ Sema::CheckAssignmentConstraints(QualTyp
 return IncompatibleVectors;
   }
 }
+
+// When the RHS comes from another lax conversion (e.g. binops between
+// scalars and vectors) the result is canonicalized as a vector. When the
+// LHS is also a vector, the lax is allowed by the condition above. Handle
+// the case where LHS is a scalar.
+if (LHSType->isScalarType()) {
+  const VectorType *VecType = RHSType->getAs();
+  if (VecType && VecType->getNumElements() == 1 &&
+  isLaxVectorConversion(RHSType, LHSType)) {
+ExprResult *VecExpr = &RHS;
+*VecExpr = ImpCastExprToType(VecExpr->get(), LHSType, CK_BitCast);
+Kind = CK_BitCast;
+return Compatible;
+  }
+}
+
 return Incompatible;
   }
 

Modified: cfe/trunk/test/Sema/vector-cast.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vector-cast.c?rev=274646&r1=274645&r2=274646&view=diff
==
--- cfe/trunk/test/Sema/vector-cast.c (original)
+++ cfe/trunk/test/Sema/vector-cast.c Wed Jul  6 13:05:23 2016
@@ -45,15 +45,23 @@ void f3(t3 Y) {
 }
 
 typedef float float2 __attribute__ ((vector_size (8)));
+typedef __attribute__((vector_size(8))) double float64x1_t;
+typedef __attribute__((vector_size(16))) double float64x2_t;
+float64x1_t vget_low_f64(float64x2_t __p0);
 
 void f4() {
   float2 f2;
-  double d;
+  double d, a, b, c;
+  float64x2_t v = {0.0, 1.0};
   f2 += d;
-  // We used to allow the next statement, but we've always rejected the next 
two
-  // statements
+  a = 3.0 + vget_low_f64(v);
+  b = vget_low_f64(v) + 3.0;
+  c = vget_low_f64(v);
+  // LAX conversions within compound assignments are not supported.
   // FIXME: This diagnostic is inaccurate.
   d += f2; // expected-error {{cannot convert between vector values of 
different size}}
+  c -= vget_low_f64(v); // expected-error {{cannot convert between vector 
values of different size}}
+  // LAX conversions between scalar and vector types require same size and one 
element sized vectors.
   d = f2; // expected-error {{assigning to 'double' from incompatible type 
'float2'}}
   d = d + f2; // expected-error {{assigning to 'double' from incompatible type 
'float2'}}
 }


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


Re: [PATCH] D21700: [SemaExpr] Support lax conversions in assignments with vector and scalars with same size

2016-07-06 Thread Bruno Cardoso Lopes via cfe-commits
bruno closed this revision.
bruno added a comment.

Thanks Reid,

Committed r274646.


http://reviews.llvm.org/D21700



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


Re: r274633 - Revert "Include debug info for nested structs and classes"

2016-07-06 Thread Adrian McCarthy via cfe-commits
Reverted because this depended upon an LLVM patch that was reverted because
of test failures on the buildbots.  I'm still investigating the root cause.

SVN revision was rL274628.

On Wed, Jul 6, 2016 at 8:15 AM, Adrian McCarthy via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: amccarth
> Date: Wed Jul  6 10:15:38 2016
> New Revision: 274633
>
> URL: http://llvm.org/viewvc/llvm-project?rev=274633&view=rev
> Log:
> Revert "Include debug info for nested structs and classes"
>
> This reverts commit 0af5ee9631c7c167dc40498b415876553e314c95.
>
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CGDebugInfo.h
> cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
> cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp
> cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=274633&r1=274632&r2=274633&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Jul  6 10:15:38 2016
> @@ -1095,13 +1095,6 @@ void CGDebugInfo::CollectRecordNormalFie
>elements.push_back(FieldType);
>  }
>
> -void CGDebugInfo::CollectRecordNestedRecord(
> -const RecordDecl *RD, SmallVectorImpl &elements) {
> -  QualType Ty = CGM.getContext().getTypeDeclType(RD);
> -  llvm::DIType *nestedType = getOrCreateType(Ty, getOrCreateMainFile());
> -  elements.push_back(nestedType);
> -}
> -
>  void CGDebugInfo::CollectRecordFields(
>  const RecordDecl *record, llvm::DIFile *tunit,
>  SmallVectorImpl &elements,
> @@ -1138,9 +1131,6 @@ void CGDebugInfo::CollectRecordFields(
>
>  // Bump field number for next field.
>  ++fieldNo;
> -  } else if (const auto *nestedRec = dyn_cast(I)) {
> -if (!nestedRec->isImplicit() && nestedRec->getDeclContext() ==
> record)
> -  CollectRecordNestedRecord(nestedRec, elements);
>}
>}
>  }
> @@ -3643,8 +3633,8 @@ void CGDebugInfo::EmitUsingDirective(con
>if (CGM.getCodeGenOpts().getDebugInfo() <
> codegenoptions::LimitedDebugInfo)
>  return;
>const NamespaceDecl *NSDecl = UD.getNominatedNamespace();
> -  if (!NSDecl->isAnonymousNamespace() ||
> -  CGM.getCodeGenOpts().DebugExplicitImport) {
> +  if (!NSDecl->isAnonymousNamespace() ||
> +  CGM.getCodeGenOpts().DebugExplicitImport) {
>  DBuilder.createImportedModule(
>  getCurrentContextDescriptor(cast(UD.getDeclContext())),
>  getOrCreateNameSpace(NSDecl),
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=274633&r1=274632&r2=274633&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Wed Jul  6 10:15:38 2016
> @@ -254,8 +254,6 @@ class CGDebugInfo {
>  llvm::DIFile *F,
>  SmallVectorImpl &E,
>  llvm::DIType *RecordTy, const RecordDecl
> *RD);
> -  void CollectRecordNestedRecord(const RecordDecl *RD,
> - SmallVectorImpl &E);
>void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile *F,
> SmallVectorImpl &E,
> llvm::DICompositeType *RecordTy);
>
> Modified: cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp?rev=274633&r1=274632&r2=274633&view=diff
>
> ==
> --- cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp Wed Jul  6
> 10:15:38 2016
> @@ -19,6 +19,6 @@ protected:
>
>  Test t;
>
> -// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "data"
>  // CHECK: !DIDerivedType(tag: DW_TAG_pointer_type
> +// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "data"
>  // CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "data"
>
> Modified: cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp?rev=274633&r1=274632&r2=274633&view=diff
>
> ==
> --- cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp Wed Jul
> 6 10:15:38 2016
> @@ -8,18 +8,18 @@ template  class Fo
>  struct Bar {
>int i1;
>// CHECK: ![[INT:[0-9]+]] = !DIBasicType(name: "int"
> -  // CHECK: ![[UNION:[0-9]+]] = distinct !DIComp

Re: [PATCH] D22034: [MSVC][DLL] use local vftable mangling only exported classes with virtual destructor

2016-07-06 Thread David Majnemer via cfe-commits
majnemer added a comment.

Thinking about this some more, it is possible for clang to emit code that will 
make everybody happy:

If a class is being constructed in a constexpr context and all the vftable 
entries it references are marked import, emit local vftables and reference them 
in the object.  If a vftable entry it references is not marked import, report 
an error.

If a class is constructed via operator new and all the vftable entries it 
references are marked import, emit local vftables and store it in the object 
after the constructors run.  If a vftable entry it references is not marked 
import, report an error.

If a class is constructed via a local or global variable and all the vftable 
entries it references are marked import, create a `dllimport 
available_externally` vftable.  Otherwise create a normal `dllimport external` 
vftable.

I believe this behavior captures the best behavior across the spectrum of 
functionality we all care about: it supports devirtualization, constexpr and 
importing classes which don't have all their vftable methods exported.


http://reviews.llvm.org/D22034



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


Re: [PATCH] D22034: [MSVC][DLL] use local vftable mangling only exported classes with virtual destructor

2016-07-06 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

In http://reviews.llvm.org/D22034#475551, @majnemer wrote:

> In http://reviews.llvm.org/D22034#475540, @DmitryPolukhin wrote:
>
> > Here is B::foo is not exported but required to build vftable for D.
>
>
> What happens if D also had a virtual destructor?


It seems that in this case MSVC never inline x-tors so there is no problem with 
using local vftable. I don't propose to do the same inline decisions like MSVC 
does so Clang may need/use different set of exported members and MSVC depending 
on optimization levels and other things may change these sets. But it seems 
that never use exported vftable is not aligned with ABI. MSVC seems to be very 
consistent about uses exported vftable when it is possible.


http://reviews.llvm.org/D22034



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


r274652 - Add AST matchers for handling bit-fields and narrowing based on their width.

2016-07-06 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Jul  6 13:25:16 2016
New Revision: 274652

URL: http://llvm.org/viewvc/llvm-project?rev=274652&view=rev
Log:
Add AST matchers for handling bit-fields and narrowing based on their width.

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=274652&r1=274651&r2=274652&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Wed Jul  6 13:25:16 2016
@@ -1453,7 +1453,7 @@ c and d.
 
 Given
   enum C { Green };
-  enum S { Red };
+  enum class S { Red };
 
   C c;
   S s;
@@ -2418,6 +2418,33 @@ designatorCountIs(2)
 
 
 
+MatcherFieldDecl>hasBitWidthunsigned Width
+Matches non-static data 
members that are bit-fields.
+
+Given
+  class C {
+int a : 2;
+int b : 4;
+int c : 2;
+  };
+fieldDecl(isBitField())
+  matches 'int a;' and 'int c;' but not 'int b;'.
+
+
+
+MatcherFieldDecl>isBitField
+Matches non-static data 
members that are bit-fields.
+
+Given
+  class C {
+int a : 2;
+int b;
+  };
+fieldDecl(isBitField())
+  matches 'int a;' but not 'int b;'.
+
+
+
 MatcherFloatingLiteral>equalsValueT  Value
 Matches literals that are 
equal to the given value.
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=274652&r1=274651&r2=274652&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Wed Jul  6 13:25:16 2016
@@ -519,6 +519,38 @@ AST_MATCHER(Decl, isPrivate) {
   return Node.getAccess() == AS_private;
 }
 
+/// \brief Matches non-static data members that are bit-fields.
+///
+/// Given
+/// \code
+///   class C {
+/// int a : 2;
+/// int b;
+///   };
+/// \endcode
+/// fieldDecl(isBitField())
+///   matches 'int a;' but not 'int b;'.
+AST_MATCHER(FieldDecl, isBitField) {
+  return Node.isBitField();
+}
+
+/// \brief Matches non-static data members that are bit-fields.
+///
+/// Given
+/// \code
+///   class C {
+/// int a : 2;
+/// int b : 4;
+/// int c : 2;
+///   };
+/// \endcode
+/// fieldDecl(isBitField())
+///   matches 'int a;' and 'int c;' but not 'int b;'.
+AST_MATCHER_P(FieldDecl, hasBitWidth, unsigned, Width) {
+  return Node.isBitField() &&
+ Node.getBitWidthValue(Finder->getASTContext()) == Width;
+}
+
 /// \brief Matches a declaration that has been implicitly added
 /// by the compiler (eg. implicit default/copy constructors).
 AST_MATCHER(Decl, isImplicit) {

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=274652&r1=274651&r2=274652&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Wed Jul  6 13:25:16 2016
@@ -208,6 +208,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(hasAttr);
   REGISTER_MATCHER(hasAutomaticStorageDuration);
   REGISTER_MATCHER(hasBase);
+  REGISTER_MATCHER(hasBitWidth);
   REGISTER_MATCHER(hasBody);
   REGISTER_MATCHER(hasCanonicalType);
   REGISTER_MATCHER(hasCaseConstant);
@@ -283,6 +284,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(isAnyPointer);
   REGISTER_MATCHER(isArrow);
   REGISTER_MATCHER(isBaseInitializer);
+  REGISTER_MATCHER(isBitField);
   REGISTER_MATCHER(isCatchAll);
   REGISTER_MATCHER(isClass);
   REGISTER_MATCHER(isConst);

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp?rev=274652&r1=274651&r2=274652&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp Wed Jul  6 
13:25:16 2016
@@ -1366,6 +1366,14 @@ TEST(Member, MatchesMember) {
 memberExpr(hasDeclaration(fieldDecl(hasType(isInteger()));
 }
 
+TEST(Member, BitFields) {
+  EXPECT_TRUE(matches("class C { int a : 2; int b; };",
+  fieldDecl(isBitField(), hasName("a";
+  EXPECT_TRUE(notMatches("class C { int a : 2; int b; };",
+

[libcxx] r274651 - Revert r274605 due to bot failure: http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/244/

2016-07-06 Thread Manman Ren via cfe-commits
Author: mren
Date: Wed Jul  6 13:24:53 2016
New Revision: 274651

URL: http://llvm.org/viewvc/llvm-project?rev=274651&view=rev
Log:
Revert r274605 due to bot failure: 
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/244/

Modified:

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp?rev=274651&r1=274650&r2=274651&view=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
 Wed Jul  6 13:24:53 2016
@@ -103,11 +103,11 @@ int main()
 test_is_not_constructible ();
 
 //  LWG 2560  -- postpone this test until bots updated
-test_is_not_constructible ();
-#if TEST_STD_VER > 11
-test_is_not_constructible ();
-test_is_not_constructible ();
-test_is_not_constructible ();
-test_is_not_constructible ();
-#endif
+// test_is_not_constructible ();
+// #if TEST_STD_VERS > 11
+// test_is_not_constructible ();
+// test_is_not_constructible ();
+// test_is_not_constructible ();
+// test_is_not_constructible ();
+// #endif
 }


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


Re: [libcxx] r274605 - Fix typo in #ifdef, and re-enable tests now that the green-dragon bots are no more

2016-07-06 Thread Manman Ren via cfe-commits
Hi Marshall,

I reverted this in r274651, since it broke a bot. Feel free to re-commit it 
later.

Manman

> On Jul 6, 2016, at 12:16 AM, Diana Picus via cfe-commits 
>  wrote:
> 
> Hi Marhsall,
> 
> This seems to be breaking our libcxx bot:
> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-arm-linux/builds/1126
> I'm a bit confused by that comment you removed, do we need to update
> our bot in any way?
> 
> Thanks,
> Diana
> 
> On 6 July 2016 at 08:28, Marshall Clow via cfe-commits
>  wrote:
>> Author: marshall
>> Date: Wed Jul  6 00:28:44 2016
>> New Revision: 274605
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=274605&view=rev
>> Log:
>> Fix typo in #ifdef, and re-enable tests now that the green-dragon bots are 
>> no more
>> 
>> Modified:
>>
>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
>> 
>> Modified: 
>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp?rev=274605&r1=274604&r2=274605&view=diff
>> ==
>> --- 
>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
>>  (original)
>> +++ 
>> libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
>>  Wed Jul  6 00:28:44 2016
>> @@ -103,11 +103,11 @@ int main()
>> test_is_not_constructible ();
>> 
>> //  LWG 2560  -- postpone this test until bots updated
>> -// test_is_not_constructible ();
>> -// #if TEST_STD_VERS > 11
>> -// test_is_not_constructible ();
>> -// test_is_not_constructible ();
>> -// test_is_not_constructible ();
>> -// test_is_not_constructible ();
>> -// #endif
>> +test_is_not_constructible ();
>> +#if TEST_STD_VER > 11
>> +test_is_not_constructible ();
>> +test_is_not_constructible ();
>> +test_is_not_constructible ();
>> +test_is_not_constructible ();
>> +#endif
>> }
>> 
>> 
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


r274654 - Ensuring the bit-fields have the same type; MSVC will place the fields in different allocation units otherwise.

2016-07-06 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Jul  6 13:33:01 2016
New Revision: 274654

URL: http://llvm.org/viewvc/llvm-project?rev=274654&view=rev
Log:
Ensuring the bit-fields have the same type; MSVC will place the fields in 
different allocation units otherwise.

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

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=274654&r1=274653&r2=274654&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Jul  6 13:33:01 2016
@@ -8892,7 +8892,7 @@ class SequenceChecker : public Evaluated
 struct Value {
   explicit Value(unsigned Parent) : Parent(Parent), Merged(false) {}
   unsigned Parent : 31;
-  bool Merged : 1;
+  unsigned Merged : 1;
 };
 SmallVector Values;
 


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


r274663 - NVPTX: Rename __builtin_ptx_shfl -> __nvvm_shfl

2016-07-06 Thread Justin Bogner via cfe-commits
Author: bogner
Date: Wed Jul  6 14:52:32 2016
New Revision: 274663

URL: http://llvm.org/viewvc/llvm-project?rev=274663&view=rev
Log:
NVPTX: Rename __builtin_ptx_shfl -> __nvvm_shfl

To match "NVPTX: Make the llvm.nvvm.shfl intrinsics and builtin names
consistent" in LLVM.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h

Modified: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def?rev=274663&r1=274662&r2=274663&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def Wed Jul  6 14:52:32 2016
@@ -404,14 +404,14 @@ BUILTIN(__nvvm_bar0_or, "ii", "")
 
 // Shuffle
 
-BUILTIN(__builtin_ptx_shfl_down_i32, "", "")
-BUILTIN(__builtin_ptx_shfl_down_f32, "ffii", "")
-BUILTIN(__builtin_ptx_shfl_up_i32, "", "")
-BUILTIN(__builtin_ptx_shfl_up_f32, "ffii", "")
-BUILTIN(__builtin_ptx_shfl_bfly_i32, "", "")
-BUILTIN(__builtin_ptx_shfl_bfly_f32, "ffii", "")
-BUILTIN(__builtin_ptx_shfl_idx_i32, "", "")
-BUILTIN(__builtin_ptx_shfl_idx_f32, "ffii", "")
+BUILTIN(__nvvm_shfl_down_i32, "", "")
+BUILTIN(__nvvm_shfl_down_f32, "ffii", "")
+BUILTIN(__nvvm_shfl_up_i32, "", "")
+BUILTIN(__nvvm_shfl_up_f32, "ffii", "")
+BUILTIN(__nvvm_shfl_bfly_i32, "", "")
+BUILTIN(__nvvm_shfl_bfly_f32, "ffii", "")
+BUILTIN(__nvvm_shfl_idx_i32, "", "")
+BUILTIN(__nvvm_shfl_idx_f32, "ffii", "")
 
 // Membar
 

Modified: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h?rev=274663&r1=274662&r2=274663&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h Wed Jul  6 14:52:32 2016
@@ -81,16 +81,12 @@
 return __out;  
\
   }
 
-__MAKE_SHUFFLES(__shfl, __builtin_ptx_shfl_idx_i32, __builtin_ptx_shfl_idx_f32,
-0x1f);
+__MAKE_SHUFFLES(__shfl, __nvvm_shfl_idx_i32, __nvvm_shfl_idx_f32, 0x1f);
 // We use 0 rather than 31 as our mask, because shfl.up applies to lanes >=
 // maxLane.
-__MAKE_SHUFFLES(__shfl_up, __builtin_ptx_shfl_up_i32, 
__builtin_ptx_shfl_up_f32,
-0);
-__MAKE_SHUFFLES(__shfl_down, __builtin_ptx_shfl_down_i32,
-__builtin_ptx_shfl_down_f32, 0x1f);
-__MAKE_SHUFFLES(__shfl_xor, __builtin_ptx_shfl_bfly_i32,
-__builtin_ptx_shfl_bfly_f32, 0x1f);
+__MAKE_SHUFFLES(__shfl_up, __nvvm_shfl_up_i32, __nvvm_shfl_up_f32, 0);
+__MAKE_SHUFFLES(__shfl_down, __nvvm_shfl_down_i32, __nvvm_shfl_down_f32, 0x1f);
+__MAKE_SHUFFLES(__shfl_xor, __nvvm_shfl_bfly_i32, __nvvm_shfl_bfly_f32, 0x1f);
 
 #pragma pop_macro("__MAKE_SHUFFLES")
 


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


Re: r274663 - NVPTX: Rename __builtin_ptx_shfl -> __nvvm_shfl

2016-07-06 Thread Justin Bogner via cfe-commits
Justin Bogner via cfe-commits  writes:
> Author: bogner
> Date: Wed Jul  6 14:52:32 2016
> New Revision: 274663
>
> URL: http://llvm.org/viewvc/llvm-project?rev=274663&view=rev
> Log:
> NVPTX: Rename __builtin_ptx_shfl -> __nvvm_shfl
>
> To match "NVPTX: Make the llvm.nvvm.shfl intrinsics and builtin names
> consistent" in LLVM.

Forgot to update the commit message - this is to match r274662.

> Modified:
> cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
> cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
>
> Modified: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def?rev=274663&r1=274662&r2=274663&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def (original)
> +++ cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def Wed Jul  6 14:52:32 2016
> @@ -404,14 +404,14 @@ BUILTIN(__nvvm_bar0_or, "ii", "")
>  
>  // Shuffle
>  
> -BUILTIN(__builtin_ptx_shfl_down_i32, "", "")
> -BUILTIN(__builtin_ptx_shfl_down_f32, "ffii", "")
> -BUILTIN(__builtin_ptx_shfl_up_i32, "", "")
> -BUILTIN(__builtin_ptx_shfl_up_f32, "ffii", "")
> -BUILTIN(__builtin_ptx_shfl_bfly_i32, "", "")
> -BUILTIN(__builtin_ptx_shfl_bfly_f32, "ffii", "")
> -BUILTIN(__builtin_ptx_shfl_idx_i32, "", "")
> -BUILTIN(__builtin_ptx_shfl_idx_f32, "ffii", "")
> +BUILTIN(__nvvm_shfl_down_i32, "", "")
> +BUILTIN(__nvvm_shfl_down_f32, "ffii", "")
> +BUILTIN(__nvvm_shfl_up_i32, "", "")
> +BUILTIN(__nvvm_shfl_up_f32, "ffii", "")
> +BUILTIN(__nvvm_shfl_bfly_i32, "", "")
> +BUILTIN(__nvvm_shfl_bfly_f32, "ffii", "")
> +BUILTIN(__nvvm_shfl_idx_i32, "", "")
> +BUILTIN(__nvvm_shfl_idx_f32, "ffii", "")
>  
>  // Membar
>  
>
> Modified: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h?rev=274663&r1=274662&r2=274663&view=diff
> ==
> --- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h (original)
> +++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h Wed Jul  6 14:52:32 2016
> @@ -81,16 +81,12 @@
>  return __out;
>   \
>}
>  
> -__MAKE_SHUFFLES(__shfl, __builtin_ptx_shfl_idx_i32, 
> __builtin_ptx_shfl_idx_f32,
> -0x1f);
> +__MAKE_SHUFFLES(__shfl, __nvvm_shfl_idx_i32, __nvvm_shfl_idx_f32, 0x1f);
>  // We use 0 rather than 31 as our mask, because shfl.up applies to lanes >=
>  // maxLane.
> -__MAKE_SHUFFLES(__shfl_up, __builtin_ptx_shfl_up_i32, 
> __builtin_ptx_shfl_up_f32,
> -0);
> -__MAKE_SHUFFLES(__shfl_down, __builtin_ptx_shfl_down_i32,
> -__builtin_ptx_shfl_down_f32, 0x1f);
> -__MAKE_SHUFFLES(__shfl_xor, __builtin_ptx_shfl_bfly_i32,
> -__builtin_ptx_shfl_bfly_f32, 0x1f);
> +__MAKE_SHUFFLES(__shfl_up, __nvvm_shfl_up_i32, __nvvm_shfl_up_f32, 0);
> +__MAKE_SHUFFLES(__shfl_down, __nvvm_shfl_down_i32, __nvvm_shfl_down_f32, 
> 0x1f);
> +__MAKE_SHUFFLES(__shfl_xor, __nvvm_shfl_bfly_i32, __nvvm_shfl_bfly_f32, 
> 0x1f);
>  
>  #pragma pop_macro("__MAKE_SHUFFLES")
>  
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22048: [analyzer] Suppress false positives in std::shared_ptr

2016-07-06 Thread Anna Zaks via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D22048



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


Re: [PATCH] D22048: [analyzer] Suppress false positives in std::shared_ptr

2016-07-06 Thread Artem Dergachev via cfe-commits
NoQ added inline comments.


Comment at: test/Analysis/Inputs/system-header-simulator-cxx.h:349
@@ +348,3 @@
+// No warning is expected as we are suppressing warning coming
+// out of std::basic_string.
+int z = 0;

You mean std::shared_ptr here?

Also, perhaps it's better to move this example into  separate fake method; if 
this header emulator is used in another test, wouldn't the author of that test 
be surprised to see that operator=() is modeled that way?


http://reviews.llvm.org/D22048



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


[PATCH] D22067: [OpenCL] Add missing -cl-no-signed-zeros option into driver

2016-07-06 Thread Aaron En Ye Shi via cfe-commits
ashi1 created this revision.
ashi1 added reviewers: Anastasia, jvesely.
ashi1 added subscribers: yaxunl, nhaustov, rsmith, bader, pxli168, cfe-commits.
ashi1 set the repository for this revision to rL LLVM.

Add OCL option -cl-no-signed-zeros to driver options.

Also added to opencl.cl testcases.

Repository:
  rL LLVM

http://reviews.llvm.org/D22067

Files:
  include/clang/Driver/Options.td
  lib/Driver/Tools.cpp
  test/Driver/opencl.cl

Index: test/Driver/opencl.cl
===
--- test/Driver/opencl.cl
+++ test/Driver/opencl.cl
@@ -14,6 +14,7 @@
 // RUN: %clang -S -### -cl-unsafe-math-optimizations %s | FileCheck 
--check-prefix=CHECK-UNSAFE-MATH-OPT %s
 // RUN: %clang -S -### -cl-fast-relaxed-math %s | FileCheck 
--check-prefix=CHECK-FAST-RELAXED-MATH %s
 // RUN: %clang -S -### -cl-mad-enable %s | FileCheck 
--check-prefix=CHECK-MAD-ENABLE %s
+// RUN: %clang -S -### -cl-no-signed-zeros %s | FileCheck 
--check-prefix=CHECK-NO-SIGNED-ZEROS %s
 // RUN: %clang -S -### -cl-denorms-are-zero %s | FileCheck 
--check-prefix=CHECK-DENORMS-ARE-ZERO %s
 // RUN: not %clang_cc1 -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-C99 %s
 // RUN: not %clang_cc1 -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID %s
@@ -33,6 +34,7 @@
 // CHECK-UNSAFE-MATH-OPT: .*clang.* "-cc1" .* "-cl-unsafe-math-optimizations"
 // CHECK-FAST-RELAXED-MATH: .*clang.* "-cc1" .* "-cl-fast-relaxed-math"
 // CHECK-MAD-ENABLE: .*clang.* "-cc1" .* "-cl-mad-enable"
+// CHECK-NO-SIGNED-ZEROS: .*clang.* "-cc1" .* "-cl-no-signed-zeros"
 // CHECK-DENORMS-ARE-ZERO: .*clang.* "-cc1" .* "-cl-denorms-are-zero"
 // CHECK-C99: error: invalid argument '-cl-std=c99' not allowed with 'OpenCL'
 // CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5139,6 +5139,9 @@
   if (Args.getLastArg(options::OPT_cl_mad_enable)) {
 CmdArgs.push_back("-cl-mad-enable");
   }
+  if (Args.getLastArg(options::OPT_cl_no_signed_zeros)) {
+CmdArgs.push_back("-cl-no-signed-zeros");
+  }
   if (Arg *A = Args.getLastArg(options::OPT_cl_std_EQ)) {
 std::string CLStdStr = "-cl-std=";
 CLStdStr += A->getValue();
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -383,6 +383,8 @@
   HelpText<"OpenCL only. Sets -cl-finite-math-only and 
-cl-unsafe-math-optimizations, and defines __FAST_RELAXED_MATH__.">;
 def cl_mad_enable : Flag<["-"], "cl-mad-enable">, Group, 
Flags<[CC1Option]>,
   HelpText<"OpenCL only. Allow use of less precise MAD computations in the 
generated binary.">;
+def cl_no_signed_zeros : Flag<["-"], "cl-no-signed-zeros">, 
Group, Flags<[CC1Option]>,
+  HelpText<"OpenCL only. Allow use of less precise no signed zeros 
computations in the generated binary.">;
 def cl_std_EQ : Joined<["-"], "cl-std=">, Group, 
Flags<[CC1Option]>,
   HelpText<"OpenCL language standard to compile for.">;
 def cl_denorms_are_zero : Flag<["-"], "cl-denorms-are-zero">, 
Group, Flags<[CC1Option]>,


Index: test/Driver/opencl.cl
===
--- test/Driver/opencl.cl
+++ test/Driver/opencl.cl
@@ -14,6 +14,7 @@
 // RUN: %clang -S -### -cl-unsafe-math-optimizations %s | FileCheck --check-prefix=CHECK-UNSAFE-MATH-OPT %s
 // RUN: %clang -S -### -cl-fast-relaxed-math %s | FileCheck --check-prefix=CHECK-FAST-RELAXED-MATH %s
 // RUN: %clang -S -### -cl-mad-enable %s | FileCheck --check-prefix=CHECK-MAD-ENABLE %s
+// RUN: %clang -S -### -cl-no-signed-zeros %s | FileCheck --check-prefix=CHECK-NO-SIGNED-ZEROS %s
 // RUN: %clang -S -### -cl-denorms-are-zero %s | FileCheck --check-prefix=CHECK-DENORMS-ARE-ZERO %s
 // RUN: not %clang_cc1 -cl-std=c99 -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-C99 %s
 // RUN: not %clang_cc1 -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID %s
@@ -33,6 +34,7 @@
 // CHECK-UNSAFE-MATH-OPT: .*clang.* "-cc1" .* "-cl-unsafe-math-optimizations"
 // CHECK-FAST-RELAXED-MATH: .*clang.* "-cc1" .* "-cl-fast-relaxed-math"
 // CHECK-MAD-ENABLE: .*clang.* "-cc1" .* "-cl-mad-enable"
+// CHECK-NO-SIGNED-ZEROS: .*clang.* "-cc1" .* "-cl-no-signed-zeros"
 // CHECK-DENORMS-ARE-ZERO: .*clang.* "-cc1" .* "-cl-denorms-are-zero"
 // CHECK-C99: error: invalid argument '-cl-std=c99' not allowed with 'OpenCL'
 // CHECK-INVALID: error: invalid value 'invalid' in '-cl-std=invalid'
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5139,6 +5139,9 @@
   if (Args.getLastArg(options::OPT_cl_mad_enable)) {
 CmdArgs.push_back("-cl-mad-enable");
   }
+  if (Args.getLastArg(options::OPT_cl_no_signed_zeros)) {
+CmdArgs.push_back("-c

Re: [PATCH] D22048: [analyzer] Suppress false positives in std::shared_ptr

2016-07-06 Thread Devin Coughlin via cfe-commits
dcoughlin added inline comments.


Comment at: test/Analysis/Inputs/system-header-simulator-cxx.h:349
@@ +348,3 @@
+// No warning is expected as we are suppressing warning coming
+// out of std::basic_string.
+int z = 0;

NoQ wrote:
> You mean std::shared_ptr here?
> 
> Also, perhaps it's better to move this example into  separate fake method; if 
> this header emulator is used in another test, wouldn't the author of that 
> test be surprised to see that operator=() is modeled that way?
Yes, this is copy pasta!


Comment at: test/Analysis/Inputs/system-header-simulator-cxx.h:349
@@ +348,3 @@
+// No warning is expected as we are suppressing warning coming
+// out of std::basic_string.
+int z = 0;

dcoughlin wrote:
> NoQ wrote:
> > You mean std::shared_ptr here?
> > 
> > Also, perhaps it's better to move this example into  separate fake method; 
> > if this header emulator is used in another test, wouldn't the author of 
> > that test be surprised to see that operator=() is modeled that way?
> Yes, this is copy pasta!
> Also, perhaps it's better to move this example into separate fake method; if 
> this header emulator is used in another test, wouldn't the author of that 
> test be surprised to see that operator=() is modeled that way?

We don't really model much in this this fake header, but I could move all the 
truly gross suppression stuff (basic string, _independent_bits_engine, 
shared_ptr) into a separate header and name it something that clearly indicates 
other tests shouldn't use it.

I'll update the patch.


http://reviews.llvm.org/D22048



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


Re: [PATCH] D22067: [OpenCL] Add missing -cl-no-signed-zeros option into driver

2016-07-06 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

I think you also need to set Opts.NoSignedZeros in CompilerInvocation.cpp.


Repository:
  rL LLVM

http://reviews.llvm.org/D22067



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


[PATCH] D22069: clang-tidy modernize-loop-convert: preserve type of alias declaration (bug 28341)

2016-07-06 Thread Matthias Gehre via cfe-commits
mgehre created this revision.
mgehre added reviewers: alexfh, klimek.
mgehre added a subscriber: cfe-commits.

Previoly, the added test failed with the fillowing fixit:

 char v[5];

-for(size_t i = 0; i < 5; ++i)
+for(char value : v)
 {
-unsigned char value = v[i];
 if (value > 127)

i.e. the variable 'value' changes from unsigned char to signed char. And
thus the following 'if' does not work anymore.

With this commit, the fixit is changed to:
 char v[5];

-for(size_t i = 0; i < 5; ++i)
+for(unsigned char value : v)
 {
-unsigned char value = v[i];
 if (value > 127)

http://reviews.llvm.org/D22069

Files:
  clang-tidy/modernize/LoopConvertCheck.cpp
  test/clang-tidy/modernize-loop-convert-extra.cpp

Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -1060,3 +1060,15 @@
 }
 
 } // namespace InitLists
+
+void bug28341() {
+  char v[5];
+  for(int i = 0; i < 5; ++i) {
+  unsigned char value = v[i];
+  // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for(unsigned char value : v)
+  // CHECK-FIXES-NOT: unsigned char value = v[i];
+  if (value > 127)
+;
+  }
+}
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -517,6 +517,15 @@
   if (VarNameFromAlias) {
 const auto *AliasVar = cast(AliasDecl->getSingleDecl());
 VarName = AliasVar->getName().str();
+
+// Use the type of the alias if it's not the same
+QualType DeclarationType = AliasVar->getType();
+if (!DeclarationType.isNull() && DeclarationType->isReferenceType())
+  DeclarationType = DeclarationType.getNonReferenceType();
+if (Descriptor.ElemType.isNull() || DeclarationType.isNull() ||
+!Context->hasSameUnqualifiedType(DeclarationType, Descriptor.ElemType))
+  Descriptor.ElemType = AliasVar->getType();
+
 AliasVarIsRef = AliasVar->getType()->isReferenceType();
 
 // We keep along the entire DeclStmt to keep the correct range here.


Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -1060,3 +1060,15 @@
 }
 
 } // namespace InitLists
+
+void bug28341() {
+  char v[5];
+  for(int i = 0; i < 5; ++i) {
+  unsigned char value = v[i];
+  // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for(unsigned char value : v)
+  // CHECK-FIXES-NOT: unsigned char value = v[i];
+  if (value > 127)
+;
+  }
+}
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -517,6 +517,15 @@
   if (VarNameFromAlias) {
 const auto *AliasVar = cast(AliasDecl->getSingleDecl());
 VarName = AliasVar->getName().str();
+
+// Use the type of the alias if it's not the same
+QualType DeclarationType = AliasVar->getType();
+if (!DeclarationType.isNull() && DeclarationType->isReferenceType())
+  DeclarationType = DeclarationType.getNonReferenceType();
+if (Descriptor.ElemType.isNull() || DeclarationType.isNull() ||
+!Context->hasSameUnqualifiedType(DeclarationType, Descriptor.ElemType))
+  Descriptor.ElemType = AliasVar->getType();
+
 AliasVarIsRef = AliasVar->getType()->isReferenceType();
 
 // We keep along the entire DeclStmt to keep the correct range here.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r274677 - [CodeGen, DebugInfo] Use hasLocalLinkage instead of hasInternalLinkage

2016-07-06 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Wed Jul  6 16:07:53 2016
New Revision: 274677

URL: http://llvm.org/viewvc/llvm-project?rev=274677&view=rev
Log:
[CodeGen, DebugInfo] Use hasLocalLinkage instead of hasInternalLinkage

For the purpose of emitting debug info, entities with private linkage
should be treated the same as internal linkage.  While this doesn't
change anything in practice, it makes the code a little less confusing.

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

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=274677&r1=274676&r2=274677&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Jul  6 16:07:53 2016
@@ -2923,7 +2923,7 @@ void CGDebugInfo::EmitFunctionStart(Glob
   // are emitted as CU level entities by the backend.
   llvm::DISubprogram *SP = DBuilder.createFunction(
   FDContext, Name, LinkageName, Unit, LineNo,
-  getOrCreateFunctionType(D, FnType, Unit), Fn->hasInternalLinkage(),
+  getOrCreateFunctionType(D, FnType, Unit), Fn->hasLocalLinkage(),
   true /*definition*/, ScopeLine, Flags, CGM.getLangOpts().Optimize,
   TParamsArray.get(), getFunctionDeclaration(D));
   Fn->setSubprogram(SP);
@@ -3537,7 +3537,7 @@ llvm::DIGlobalVariable *CGDebugInfo::Col
 // Use VarDecl's Tag, Scope and Line number.
 GV = DBuilder.createGlobalVariable(DContext, FieldName, LinkageName, Unit,
LineNo, FieldTy,
-   Var->hasInternalLinkage(), Var, 
nullptr);
+   Var->hasLocalLinkage(), Var, nullptr);
   }
   return GV;
 }
@@ -3570,7 +3570,7 @@ void CGDebugInfo::EmitGlobalVariable(llv
   } else {
 GV = DBuilder.createGlobalVariable(
 DContext, DeclName, LinkageName, Unit, LineNo, getOrCreateType(T, 
Unit),
-Var->hasInternalLinkage(), Var,
+Var->hasLocalLinkage(), Var,
 getOrCreateStaticDataMemberDeclarationOrNull(D));
   }
   DeclCache[D->getCanonicalDecl()].reset(static_cast(GV));


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


Re: [PATCH] D21778: [CUDA] Add support for CUDA 8 and sm_60-62.

2016-07-06 Thread Justin Lebar via cfe-commits
jlebar added a comment.

> They will need to wait for corresponding patch on LLVM side to deal with new 
> SM variants, though.


This is in now, http://reviews.llvm.org/D22068.



Comment at: lib/Driver/ToolChains.cpp:1715
@@ -1714,2 +1714,3 @@
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda");
+CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-8.0");
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-7.5");

tra wrote:
> This is a bit premature as we can't compile CUDA-8 headers yet. Let's drop it 
> until we're ready.
sgtm, removed.


http://reviews.llvm.org/D21778



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


Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer

2016-07-06 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 62966.
yaxunl added a comment.

Removed the old representation of sampler type by i32.


http://reviews.llvm.org/D21567

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/AST/OperationKinds.def
  include/clang/AST/Type.h
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Overload.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Index/USRGeneration.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaOverload.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/CodeGenOpenCL/opencl_types.cl
  test/CodeGenOpenCL/sampler.cl
  test/SemaOpenCL/sampler_t.cl
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1466,6 +1466,7 @@
   case BuiltinType::Id:
 #include "clang/Basic/OpenCLImageTypes.def"
   case BuiltinType::OCLSampler:
+  case BuiltinType::OCLSamplerInit:
   case BuiltinType::OCLEvent:
   case BuiltinType::OCLClkEvent:
   case BuiltinType::OCLQueue:
Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -13,6 +13,7 @@
   const sampler_t const_smp = 7;
   foo(glb_smp);
   foo(const_smp);
+  foo(argsmp);
   foo(5); // expected-error {{sampler_t variable required - got 'int'}}
   sampler_t sa[] = {argsmp, const_smp}; // expected-error {{array of 'sampler_t' type is invalid in OpenCL}}
 }
Index: test/CodeGenOpenCL/sampler.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/sampler.cl
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple spir-unknown-unknown -o - -O0 | FileCheck %s
+
+#define CLK_ADDRESS_CLAMP_TO_EDGE   2
+#define CLK_NORMALIZED_COORDS_TRUE  1
+#define CLK_FILTER_NEAREST  0x10
+#define CLK_FILTER_LINEAR   0x20
+
+constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+
+// CHECK: %__sampler_initializer = type { i32, i32, i32 }
+// CHECK: %__sampler = type opaque
+// CHECK: [[glb_smp_init:@[-a-zA-Z$._][-a-zA-Z$._0-9]*]] = internal addrspace(2) constant %__sampler_initializer { i32 1, i32 1, i32 1 }
+// CHECK: @glb_smp = global %__sampler_initializer addrspace(2)* [[glb_smp_init]]
+// CHECK: [[smp_init:@[-a-zA-Z$._][-a-zA-Z$._0-9]*]] = internal addrspace(2) constant %__sampler_initializer { i32 1, i32 1, i32 0 }
+
+void fnc4smp(sampler_t s) {}
+// CHECK: define spir_func void @fnc4smp(%__sampler addrspace(2)* %
+
+kernel void foo() {
+  sampler_t smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST;
+  // CHECK-LABEL: define spir_kernel void @foo()
+  // CHECK: [[smp_ptr:%[A-Za-z0-9_\.]+]] = alloca %__sampler_initializer addrspace(2)*
+  // CHECK: store %__sampler_initializer addrspace(2)* [[smp_init]], %__sampler_initializer addrspace(2)** [[smp_ptr]]
+
+  fnc4smp(smp);
+  // CHECK: [[SINIT:%[0-9]+]] = load %__sampler_initializer addrspace(2)*, %__sampler_initializer addrspace(2)** [[smp_ptr]]
+  // CHECK: [[SAMP:%[0-9]+]] = call %__sampler addrspace(2)* @__translate_sampler_initializer(%__sampler_initializer addrspace(2)* [[SINIT]])
+  // CHECK: call spir_func void @fnc4smp(%__sampler addrspace(2)* [[SAMP]])
+
+  fnc4smp(glb_smp);
+  // CHECK: [[SINIT:%[0-9]+]] = load %__sampler_initializer addrspace(2)*, %__sampler_initializer addrspace(2)** @glb_smp
+  // CHECK: [[SAMP:%[0-9]+]] = call %__sampler addrspace(2)* @__translate_sampler_initializer(%__sampler_initializer addrspace(2)* [[SINIT]])
+  // CHECK: call spir_func void @fnc4smp(%__sampler addrspace(2)* [[SAMP]])
+}
Index: test/CodeGenOpenCL/opencl_types.cl
===
--- test/CodeGenOpenCL/opencl_types.cl
+++ test/CodeGenOpenCL/opencl_types.cl
@@ -1,39 +1,46 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 | FileCheck %s
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -emit-llvm -o - -O0 | FileCheck %s
 
-constant sampler_t glb_smp = 7;
-// CHECK: constant i32 7
+#define CLK_ADDRESS_CLAMP_TO_EDGE   2

Re: [PATCH] D21724: [RFC] Enhance synchscope representation (clang)

2016-07-06 Thread Konstantin Zhuravlyov via cfe-commits
kzhuravl updated this revision to Diff 62971.
kzhuravl added a comment.

Rebase


http://reviews.llvm.org/D21724

Files:
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGen/synchscopes.cpp

Index: test/CodeGen/synchscopes.cpp
===
--- test/CodeGen/synchscopes.cpp
+++ test/CodeGen/synchscopes.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang -emit-llvm -S -std=c++11 %s -o - | FileCheck %s
+
+// CHECK: !synchscopes = !{!0, !1}
+// CHECK: !0 = !{i32 0, !"System"}
+// CHECK: !1 = !{i32 -1, !"SingleThread"}
+
+#include 
+
+void synchscopes_acquire() {
+  atomic_thread_fence(std::memory_order_acquire);
+  atomic_signal_fence(std::memory_order_acquire);
+}
+
+void synchscopes_release() {
+  atomic_thread_fence(std::memory_order_release);
+  atomic_signal_fence(std::memory_order_release);
+}
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -374,6 +374,9 @@
   llvm::DenseMap AtomicSetterHelperFnMap;
   llvm::DenseMap AtomicGetterHelperFnMap;
 
+  /// \brief Mapping from synchronization scope to it's string representation.
+  std::map SynchScopeMap;
+
   /// Map used to get unique type descriptor constants for sanitizers.
   llvm::DenseMap TypeDescriptorMap;
 
@@ -582,6 +585,8 @@
 AtomicGetterHelperFnMap[Ty] = Fn;
   }
 
+  void setSynchScopeMap(unsigned SynchScope, const std::string &SynchScopeName);
+
   llvm::Constant *getTypeDescriptorFromMap(QualType Ty) {
 return TypeDescriptorMap[Ty];
   }
@@ -1233,6 +1238,9 @@
 
   void EmitDeclMetadata();
 
+  /// \brief Emit synchronization scope metadata.
+  void EmitSynchScopeMetadata();
+
   /// \brief Emit the Clang version as llvm.ident metadata.
   void EmitVersionIdentMetadata();
 
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -495,6 +495,8 @@
   if (DebugInfo)
 DebugInfo->finalize();
 
+  EmitSynchScopeMetadata();
+
   EmitVersionIdentMetadata();
 
   EmitTargetMetadata();
@@ -4079,6 +4081,15 @@
   return true;
 }
 
+void CodeGenModule::setSynchScopeMap(unsigned SynchScope,
+ const std::string &SynchScopeName) {
+  auto Res = SynchScopeMap.find(SynchScope);
+  if (Res == SynchScopeMap.end())
+SynchScopeMap.insert(std::make_pair(SynchScope, SynchScopeName));
+  else
+assert(Res->second == SynchScopeName);
+}
+
 /// Emits metadata nodes associating all the global values in the
 /// current module with the Decls they came from.  This is useful for
 /// projects using IR gen as a subroutine.
@@ -4125,6 +4136,22 @@
   }
 }
 
+void CodeGenModule::EmitSynchScopeMetadata() {
+  if (!SynchScopeMap.size())
+return;
+
+  llvm::LLVMContext &Ctx = TheModule.getContext();
+  llvm::NamedMDNode *SynchScopeMetadata =
+TheModule.getOrInsertNamedMetadata("synchscopes");
+  for (auto &I : SynchScopeMap) {
+llvm::Metadata *SynchScopeNode[2] = {
+  llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, I.first)),
+  llvm::MDString::get(Ctx, I.second)
+};
+SynchScopeMetadata->addOperand(llvm::MDNode::get(Ctx, SynchScopeNode));
+  }
+}
+
 void CodeGenModule::EmitVersionIdentMetadata() {
   llvm::NamedMDNode *IdentMetadata =
 TheModule.getOrInsertNamedMetadata("llvm.ident");
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -1527,12 +1527,17 @@
   case Builtin::BI__atomic_signal_fence:
   case Builtin::BI__c11_atomic_thread_fence:
   case Builtin::BI__c11_atomic_signal_fence: {
-llvm::SynchronizationScope Scope;
+unsigned Scope;
+std::string ScopeName;
 if (BuiltinID == Builtin::BI__atomic_signal_fence ||
-BuiltinID == Builtin::BI__c11_atomic_signal_fence)
-  Scope = llvm::SingleThread;
-else
-  Scope = llvm::CrossThread;
+BuiltinID == Builtin::BI__c11_atomic_signal_fence) {
+  Scope = llvm::SynchScopeSingleThread;
+  ScopeName = "SingleThread";
+} else {
+  Scope = llvm::SynchScopeSystem;
+  ScopeName = "System";
+}
+CGM.setSynchScopeMap(Scope, ScopeName);
 Value *Order = EmitScalarExpr(E->getArg(0));
 if (isa(Order)) {
   int ord = cast(Order)->getZExtValue();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22069: clang-tidy modernize-loop-convert: preserve type of alias declaration (bug 28341)

2016-07-06 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Thank you for fixing the bug! One comment below.



Comment at: clang-tidy/modernize/LoopConvertCheck.cpp:525
@@ +524,3 @@
+  DeclarationType = DeclarationType.getNonReferenceType();
+if (Descriptor.ElemType.isNull() || DeclarationType.isNull() ||
+!Context->hasSameUnqualifiedType(DeclarationType, Descriptor.ElemType))

1. Can the `AliasVar->getType().isNull()` condition be true?
2. If it can, consider `!Descriptor.ElemType.isNull().isNull()` and 
`AliasVar->getType().isNull()`. In this case setting `Descriptor.ElemType` to 
`AliasVar->getType()` (which is null) doesn't make much sense.

I'd probably just wrap the added code in `if (!AliasVar->getType().isNull())`.


http://reviews.llvm.org/D22069



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


Re: [PATCH] D22046: [clang-tidy] Add dependency on clang-headers

2016-07-06 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG


http://reviews.llvm.org/D22046



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


Re: [PATCH] D21778: [CUDA] Add support for CUDA 8 and sm_60-62.

2016-07-06 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL274680: [CUDA] Add support for CUDA 8 and sm_60-62. 
(authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D21778?vs=62908&id=62974#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21778

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Driver/Action.cpp
  cfe/trunk/lib/Driver/ToolChains.cpp

Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -1715,6 +1715,8 @@
 Args.getLastArgValue(options::OPT_cuda_path_EQ));
   else {
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda");
+// FIXME: Uncomment this once we can compile the cuda 8 headers.
+// CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-8.0");
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-7.5");
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-7.0");
   }
@@ -1761,6 +1763,9 @@
 CudaLibDeviceMap["sm_50"] = FilePath;
 CudaLibDeviceMap["sm_52"] = FilePath;
 CudaLibDeviceMap["sm_53"] = FilePath;
+CudaLibDeviceMap["sm_60"] = FilePath;
+CudaLibDeviceMap["sm_61"] = FilePath;
+CudaLibDeviceMap["sm_62"] = FilePath;
   }
 }
 
Index: cfe/trunk/lib/Driver/Action.cpp
===
--- cfe/trunk/lib/Driver/Action.cpp
+++ cfe/trunk/lib/Driver/Action.cpp
@@ -66,6 +66,9 @@
   .Case("sm_50", "compute_50")
   .Case("sm_52", "compute_52")
   .Case("sm_53", "compute_53")
+  .Case("sm_60", "compute_60")
+  .Case("sm_61", "compute_61")
+  .Case("sm_62", "compute_62")
   .Default(nullptr);
 }
 
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -1701,11 +1701,15 @@
 GK_SM20,
 GK_SM21,
 GK_SM30,
+GK_SM32,
 GK_SM35,
 GK_SM37,
 GK_SM50,
 GK_SM52,
 GK_SM53,
+GK_SM60,
+GK_SM61,
+GK_SM62,
   } GPU;
 
 public:
@@ -1787,35 +1791,37 @@
 Builder.defineMacro("__NVPTX__");
 if (Opts.CUDAIsDevice) {
   // Set __CUDA_ARCH__ for the GPU specified.
-  std::string CUDAArchCode;
-  switch (GPU) {
-  case GK_SM20:
-CUDAArchCode = "200";
-break;
-  case GK_SM21:
-CUDAArchCode = "210";
-break;
-  case GK_SM30:
-CUDAArchCode = "300";
-break;
-  case GK_SM35:
-CUDAArchCode = "350";
-break;
-  case GK_SM37:
-CUDAArchCode = "370";
-break;
-  case GK_SM50:
-CUDAArchCode = "500";
-break;
-  case GK_SM52:
-CUDAArchCode = "520";
-break;
-  case GK_SM53:
-CUDAArchCode = "530";
-break;
-  default:
-llvm_unreachable("Unhandled target CPU");
-  }
+  std::string CUDAArchCode = [this] {
+switch (GPU) {
+case GK_NONE:
+  assert(false && "No GPU arch when compiling CUDA device code.");
+  return "";
+case GK_SM20:
+  return "200";
+case GK_SM21:
+  return "210";
+case GK_SM30:
+  return "300";
+case GK_SM32:
+  return "320";
+case GK_SM35:
+  return "350";
+case GK_SM37:
+  return "370";
+case GK_SM50:
+  return "500";
+case GK_SM52:
+  return "520";
+case GK_SM53:
+  return "530";
+case GK_SM60:
+  return "600";
+case GK_SM61:
+  return "610";
+case GK_SM62:
+  return "620";
+}
+  }();
   Builder.defineMacro("__CUDA_ARCH__", CUDAArchCode);
 }
   }
@@ -1860,11 +1866,15 @@
   .Case("sm_20", GK_SM20)
   .Case("sm_21", GK_SM21)
   .Case("sm_30", GK_SM30)
+  .Case("sm_32", GK_SM32)
   .Case("sm_35", GK_SM35)
   .Case("sm_37", GK_SM37)
   .Case("sm_50", GK_SM50)
   .Case("sm_52", GK_SM52)
   .Case("sm_53", GK_SM53)
+  .Case("sm_60", GK_SM60)
+  .Case("sm_61", GK_SM61)
+  .Case("sm_62", GK_SM62)
   .Default(GK_NONE);
 
 return GPU != GK_NONE;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r274680 - [CUDA] Add support for CUDA 8 and sm_60-62.

2016-07-06 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Jul  6 16:21:14 2016
New Revision: 274680

URL: http://llvm.org/viewvc/llvm-project?rev=274680&view=rev
Log:
[CUDA] Add support for CUDA 8 and sm_60-62.

Summary: Also add sm_32, which was missing.

Reviewers: tra

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D21778

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/Action.cpp
cfe/trunk/lib/Driver/ToolChains.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=274680&r1=274679&r2=274680&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Jul  6 16:21:14 2016
@@ -1701,11 +1701,15 @@ class NVPTXTargetInfo : public TargetInf
 GK_SM20,
 GK_SM21,
 GK_SM30,
+GK_SM32,
 GK_SM35,
 GK_SM37,
 GK_SM50,
 GK_SM52,
 GK_SM53,
+GK_SM60,
+GK_SM61,
+GK_SM62,
   } GPU;
 
 public:
@@ -1787,35 +1791,37 @@ public:
 Builder.defineMacro("__NVPTX__");
 if (Opts.CUDAIsDevice) {
   // Set __CUDA_ARCH__ for the GPU specified.
-  std::string CUDAArchCode;
-  switch (GPU) {
-  case GK_SM20:
-CUDAArchCode = "200";
-break;
-  case GK_SM21:
-CUDAArchCode = "210";
-break;
-  case GK_SM30:
-CUDAArchCode = "300";
-break;
-  case GK_SM35:
-CUDAArchCode = "350";
-break;
-  case GK_SM37:
-CUDAArchCode = "370";
-break;
-  case GK_SM50:
-CUDAArchCode = "500";
-break;
-  case GK_SM52:
-CUDAArchCode = "520";
-break;
-  case GK_SM53:
-CUDAArchCode = "530";
-break;
-  default:
-llvm_unreachable("Unhandled target CPU");
-  }
+  std::string CUDAArchCode = [this] {
+switch (GPU) {
+case GK_NONE:
+  assert(false && "No GPU arch when compiling CUDA device code.");
+  return "";
+case GK_SM20:
+  return "200";
+case GK_SM21:
+  return "210";
+case GK_SM30:
+  return "300";
+case GK_SM32:
+  return "320";
+case GK_SM35:
+  return "350";
+case GK_SM37:
+  return "370";
+case GK_SM50:
+  return "500";
+case GK_SM52:
+  return "520";
+case GK_SM53:
+  return "530";
+case GK_SM60:
+  return "600";
+case GK_SM61:
+  return "610";
+case GK_SM62:
+  return "620";
+}
+  }();
   Builder.defineMacro("__CUDA_ARCH__", CUDAArchCode);
 }
   }
@@ -1860,11 +1866,15 @@ public:
   .Case("sm_20", GK_SM20)
   .Case("sm_21", GK_SM21)
   .Case("sm_30", GK_SM30)
+  .Case("sm_32", GK_SM32)
   .Case("sm_35", GK_SM35)
   .Case("sm_37", GK_SM37)
   .Case("sm_50", GK_SM50)
   .Case("sm_52", GK_SM52)
   .Case("sm_53", GK_SM53)
+  .Case("sm_60", GK_SM60)
+  .Case("sm_61", GK_SM61)
+  .Case("sm_62", GK_SM62)
   .Default(GK_NONE);
 
 return GPU != GK_NONE;

Modified: cfe/trunk/lib/Driver/Action.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Action.cpp?rev=274680&r1=274679&r2=274680&view=diff
==
--- cfe/trunk/lib/Driver/Action.cpp (original)
+++ cfe/trunk/lib/Driver/Action.cpp Wed Jul  6 16:21:14 2016
@@ -66,6 +66,9 @@ static const char* GpuArchToComputeName(
   .Case("sm_50", "compute_50")
   .Case("sm_52", "compute_52")
   .Case("sm_53", "compute_53")
+  .Case("sm_60", "compute_60")
+  .Case("sm_61", "compute_61")
+  .Case("sm_62", "compute_62")
   .Default(nullptr);
 }
 

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=274680&r1=274679&r2=274680&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Jul  6 16:21:14 2016
@@ -1715,6 +1715,8 @@ void Generic_GCC::CudaInstallationDetect
 Args.getLastArgValue(options::OPT_cuda_path_EQ));
   else {
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda");
+// FIXME: Uncomment this once we can compile the cuda 8 headers.
+// CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-8.0");
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-7.5");
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-7.0");
   }
@@ -1761,6 +1763,9 @@ void Generic_GCC::CudaInstallationDetect
 CudaLibDeviceMap["sm_50"] = FilePath;
 CudaLibDeviceMap["sm_52"] = FilePath;
 CudaLibDeviceMap["sm_53"] = FilePath;
+ 

r274681 - [CUDA] Add utility functions for dealing with CUDA versions / architectures.

2016-07-06 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Jul  6 16:21:39 2016
New Revision: 274681

URL: http://llvm.org/viewvc/llvm-project?rev=274681&view=rev
Log:
[CUDA] Add utility functions for dealing with CUDA versions / architectures.

Summary:
Currently our handling of CUDA architectures is scattered all around
clang.  This patch centralizes it.

A key advantage of this centralization is that you can now write a C++
switch on e.g. CudaArch and get a compile error if you don't handle one
of the enum values.

Reviewers: tra

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D21867

Added:
cfe/trunk/include/clang/Basic/Cuda.h
cfe/trunk/lib/Basic/Cuda.cpp
Modified:
cfe/trunk/include/clang/Driver/Action.h
cfe/trunk/lib/Basic/CMakeLists.txt
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/Action.cpp
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/Tools.cpp

Added: cfe/trunk/include/clang/Basic/Cuda.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Cuda.h?rev=274681&view=auto
==
--- cfe/trunk/include/clang/Basic/Cuda.h (added)
+++ cfe/trunk/include/clang/Basic/Cuda.h Wed Jul  6 16:21:39 2016
@@ -0,0 +1,77 @@
+//===--- Cuda.h - Utilities for compiling CUDA code  *- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_CUDA_H
+#define LLVM_CLANG_BASIC_CUDA_H
+
+namespace llvm {
+class StringRef;
+} // namespace llvm
+
+namespace clang {
+
+enum class CudaVersion {
+  UNKNOWN,
+  CUDA_70,
+  CUDA_75,
+  CUDA_80,
+};
+const char *CudaVersionToString(CudaVersion V);
+
+// No string -> CudaVersion conversion function because there's no canonical
+// spelling of the various CUDA versions.
+
+enum class CudaArch {
+  UNKNOWN,
+  SM_20,
+  SM_21,
+  SM_30,
+  SM_32,
+  SM_35,
+  SM_37,
+  SM_50,
+  SM_52,
+  SM_53,
+  SM_60,
+  SM_61,
+  SM_62,
+};
+const char *CudaArchToString(CudaArch A);
+
+// The input should have the form "sm_20".
+CudaArch StringToCudaArch(llvm::StringRef S);
+
+enum class CudaVirtualArch {
+  UNKNOWN,
+  COMPUTE_20,
+  COMPUTE_30,
+  COMPUTE_32,
+  COMPUTE_35,
+  COMPUTE_37,
+  COMPUTE_50,
+  COMPUTE_52,
+  COMPUTE_53,
+  COMPUTE_60,
+  COMPUTE_61,
+  COMPUTE_62,
+};
+const char *CudaVirtualArchToString(CudaVirtualArch A);
+
+// The input should have the form "compute_20".
+CudaVirtualArch StringToCudaVirtualArch(llvm::StringRef S);
+
+/// Get the compute_xx corresponding to an sm_yy.
+CudaVirtualArch VirtualArchForCudaArch(CudaArch A);
+
+/// Get the earliest CudaVersion that supports the given CudaArch.
+CudaVersion MinVersionForCudaArch(CudaArch A);
+
+} // namespace clang
+
+#endif

Modified: cfe/trunk/include/clang/Driver/Action.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Action.h?rev=274681&r1=274680&r2=274681&view=diff
==
--- cfe/trunk/include/clang/Driver/Action.h (original)
+++ cfe/trunk/include/clang/Driver/Action.h Wed Jul  6 16:21:39 2016
@@ -10,6 +10,7 @@
 #ifndef LLVM_CLANG_DRIVER_ACTION_H
 #define LLVM_CLANG_DRIVER_ACTION_H
 
+#include "clang/Basic/Cuda.h"
 #include "clang/Driver/Types.h"
 #include "clang/Driver/Util.h"
 #include "llvm/ADT/SmallVector.h"
@@ -157,26 +158,22 @@ public:
 
 class CudaDeviceAction : public Action {
   virtual void anchor();
-  /// GPU architecture to bind.  Always of the form /sm_\d+/ or null (when the
-  /// action applies to multiple architectures).
-  const char *GpuArchName;
+
+  const CudaArch GpuArch;
+
   /// True when action results are not consumed by the host action (e.g when
   /// -fsyntax-only or --cuda-device-only options are used).
   bool AtTopLevel;
 
 public:
-  CudaDeviceAction(Action *Input, const char *ArchName, bool AtTopLevel);
+  CudaDeviceAction(Action *Input, CudaArch Arch, bool AtTopLevel);
 
-  const char *getGpuArchName() const { return GpuArchName; }
-
-  /// Gets the compute_XX that corresponds to getGpuArchName().  Returns null
-  /// when getGpuArchName() is null.
-  const char *getComputeArchName() const;
+  /// Get the CUDA GPU architecture to which this Action corresponds.  Returns
+  /// UNKNOWN if this Action corresponds to multiple architectures.
+  CudaArch getGpuArch() const { return GpuArch; }
 
   bool isAtTopLevel() const { return AtTopLevel; }
 
-  static bool IsValidGpuArchName(llvm::StringRef ArchName);
-
   static bool classof(const Action *A) {
 return A->getKind() == CudaDeviceClass;
   }

Modified: cfe/trunk/lib/Basic/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/CMakeLists.txt?rev=274681&r1=274680&r2=274681&view=diff

r274682 - [CUDA] Rename member variables in CudaInstallationDetector.

2016-07-06 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Jul  6 16:21:43 2016
New Revision: 274682

URL: http://llvm.org/viewvc/llvm-project?rev=274682&view=rev
Log:
[CUDA] Rename member variables in CudaInstallationDetector.

Summary:
Remove the "Cuda" prefix from these variables -- it's clear that they
related to CUDA given their containing type.

Reviewers: tra

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D21868

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=274682&r1=274681&r2=274682&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Jul  6 16:21:43 2016
@@ -1725,20 +1725,19 @@ void Generic_GCC::CudaInstallationDetect
 if (CudaPath.empty() || !D.getVFS().exists(CudaPath))
   continue;
 
-CudaInstallPath = CudaPath;
-CudaBinPath = CudaPath + "/bin";
-CudaIncludePath = CudaInstallPath + "/include";
-CudaLibDevicePath = CudaInstallPath + "/nvvm/libdevice";
-CudaLibPath =
-CudaInstallPath + (TargetTriple.isArch64Bit() ? "/lib64" : "/lib");
-
-if (!(D.getVFS().exists(CudaIncludePath) &&
-  D.getVFS().exists(CudaBinPath) && D.getVFS().exists(CudaLibPath) &&
-  D.getVFS().exists(CudaLibDevicePath)))
+InstallPath = CudaPath;
+BinPath = CudaPath + "/bin";
+IncludePath = InstallPath + "/include";
+LibDevicePath = InstallPath + "/nvvm/libdevice";
+LibPath = InstallPath + (TargetTriple.isArch64Bit() ? "/lib64" : "/lib");
+
+auto &FS = D.getVFS();
+if (!(FS.exists(IncludePath) && FS.exists(BinPath) && FS.exists(LibPath) &&
+  FS.exists(LibDevicePath)))
   continue;
 
 std::error_code EC;
-for (llvm::sys::fs::directory_iterator LI(CudaLibDevicePath, EC), LE;
+for (llvm::sys::fs::directory_iterator LI(LibDevicePath, EC), LE;
  !EC && LI != LE; LI = LI.increment(EC)) {
   StringRef FilePath = LI->path();
   StringRef FileName = llvm::sys::path::filename(FilePath);
@@ -1748,24 +1747,24 @@ void Generic_GCC::CudaInstallationDetect
 continue;
   StringRef GpuArch = FileName.slice(
   LibDeviceName.size(), FileName.find('.', LibDeviceName.size()));
-  CudaLibDeviceMap[GpuArch] = FilePath.str();
+  LibDeviceMap[GpuArch] = FilePath.str();
   // Insert map entries for specifc devices with this compute capability.
   if (GpuArch == "compute_20") {
-CudaLibDeviceMap["sm_20"] = FilePath;
-CudaLibDeviceMap["sm_21"] = FilePath;
+LibDeviceMap["sm_20"] = FilePath;
+LibDeviceMap["sm_21"] = FilePath;
   } else if (GpuArch == "compute_30") {
-CudaLibDeviceMap["sm_30"] = FilePath;
-CudaLibDeviceMap["sm_32"] = FilePath;
+LibDeviceMap["sm_30"] = FilePath;
+LibDeviceMap["sm_32"] = FilePath;
   } else if (GpuArch == "compute_35") {
-CudaLibDeviceMap["sm_35"] = FilePath;
-CudaLibDeviceMap["sm_37"] = FilePath;
+LibDeviceMap["sm_35"] = FilePath;
+LibDeviceMap["sm_37"] = FilePath;
   } else if (GpuArch == "compute_50") {
-CudaLibDeviceMap["sm_50"] = FilePath;
-CudaLibDeviceMap["sm_52"] = FilePath;
-CudaLibDeviceMap["sm_53"] = FilePath;
-CudaLibDeviceMap["sm_60"] = FilePath;
-CudaLibDeviceMap["sm_61"] = FilePath;
-CudaLibDeviceMap["sm_62"] = FilePath;
+LibDeviceMap["sm_50"] = FilePath;
+LibDeviceMap["sm_52"] = FilePath;
+LibDeviceMap["sm_53"] = FilePath;
+LibDeviceMap["sm_60"] = FilePath;
+LibDeviceMap["sm_61"] = FilePath;
+LibDeviceMap["sm_62"] = FilePath;
   }
 }
 
@@ -1776,7 +1775,7 @@ void Generic_GCC::CudaInstallationDetect
 
 void Generic_GCC::CudaInstallationDetector::print(raw_ostream &OS) const {
   if (isValid())
-OS << "Found CUDA installation: " << CudaInstallPath << "\n";
+OS << "Found CUDA installation: " << InstallPath << "\n";
 }
 
 namespace {

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=274682&r1=274681&r2=274682&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Wed Jul  6 16:21:43 2016
@@ -158,19 +158,19 @@ protected:
   GCCInstallationDetector GCCInstallation;
 
   // \brief A class to find a viable CUDA installation
-
   class CudaInstallationDetector {
-bool IsValid;
+  private:
 const Driver &D;
-std::string CudaInstallPath;
-std::string CudaBinPath;
-std::string CudaLibPath;
-std::string CudaLibDevicePath;
-std::string CudaIncludePath;
-llvm::StringMap CudaLibDeviceMap;
+bool IsValid = false;
+std::string Install

Re: [PATCH] D21868: [CUDA] Rename member variables in CudaInstallationDetector.

2016-07-06 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL274682: [CUDA] Rename member variables in 
CudaInstallationDetector. (authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D21868?vs=62300&id=62976#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21868

Files:
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/lib/Driver/ToolChains.h

Index: cfe/trunk/lib/Driver/ToolChains.h
===
--- cfe/trunk/lib/Driver/ToolChains.h
+++ cfe/trunk/lib/Driver/ToolChains.h
@@ -158,39 +158,39 @@
   GCCInstallationDetector GCCInstallation;
 
   // \brief A class to find a viable CUDA installation
-
   class CudaInstallationDetector {
-bool IsValid;
+  private:
 const Driver &D;
-std::string CudaInstallPath;
-std::string CudaBinPath;
-std::string CudaLibPath;
-std::string CudaLibDevicePath;
-std::string CudaIncludePath;
-llvm::StringMap CudaLibDeviceMap;
+bool IsValid = false;
+std::string InstallPath;
+std::string BinPath;
+std::string LibPath;
+std::string LibDevicePath;
+std::string IncludePath;
+llvm::StringMap LibDeviceMap;
 
   public:
-CudaInstallationDetector(const Driver &D) : IsValid(false), D(D) {}
+CudaInstallationDetector(const Driver &D) : D(D) {}
 void init(const llvm::Triple &TargetTriple, const llvm::opt::ArgList &Args);
 
 /// \brief Check whether we detected a valid Cuda install.
 bool isValid() const { return IsValid; }
 /// \brief Print information about the detected CUDA installation.
 void print(raw_ostream &OS) const;
 
 /// \brief Get the detected Cuda installation path.
-StringRef getInstallPath() const { return CudaInstallPath; }
+StringRef getInstallPath() const { return InstallPath; }
 /// \brief Get the detected path to Cuda's bin directory.
-StringRef getBinPath() const { return CudaBinPath; }
+StringRef getBinPath() const { return BinPath; }
 /// \brief Get the detected Cuda Include path.
-StringRef getIncludePath() const { return CudaIncludePath; }
+StringRef getIncludePath() const { return IncludePath; }
 /// \brief Get the detected Cuda library path.
-StringRef getLibPath() const { return CudaLibPath; }
+StringRef getLibPath() const { return LibPath; }
 /// \brief Get the detected Cuda device library path.
-StringRef getLibDevicePath() const { return CudaLibDevicePath; }
+StringRef getLibDevicePath() const { return LibDevicePath; }
 /// \brief Get libdevice file for given architecture
 std::string getLibDeviceFile(StringRef Gpu) const {
-  return CudaLibDeviceMap.lookup(Gpu);
+  return LibDeviceMap.lookup(Gpu);
 }
   };
 
Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -1725,20 +1725,19 @@
 if (CudaPath.empty() || !D.getVFS().exists(CudaPath))
   continue;
 
-CudaInstallPath = CudaPath;
-CudaBinPath = CudaPath + "/bin";
-CudaIncludePath = CudaInstallPath + "/include";
-CudaLibDevicePath = CudaInstallPath + "/nvvm/libdevice";
-CudaLibPath =
-CudaInstallPath + (TargetTriple.isArch64Bit() ? "/lib64" : "/lib");
-
-if (!(D.getVFS().exists(CudaIncludePath) &&
-  D.getVFS().exists(CudaBinPath) && D.getVFS().exists(CudaLibPath) &&
-  D.getVFS().exists(CudaLibDevicePath)))
+InstallPath = CudaPath;
+BinPath = CudaPath + "/bin";
+IncludePath = InstallPath + "/include";
+LibDevicePath = InstallPath + "/nvvm/libdevice";
+LibPath = InstallPath + (TargetTriple.isArch64Bit() ? "/lib64" : "/lib");
+
+auto &FS = D.getVFS();
+if (!(FS.exists(IncludePath) && FS.exists(BinPath) && FS.exists(LibPath) &&
+  FS.exists(LibDevicePath)))
   continue;
 
 std::error_code EC;
-for (llvm::sys::fs::directory_iterator LI(CudaLibDevicePath, EC), LE;
+for (llvm::sys::fs::directory_iterator LI(LibDevicePath, EC), LE;
  !EC && LI != LE; LI = LI.increment(EC)) {
   StringRef FilePath = LI->path();
   StringRef FileName = llvm::sys::path::filename(FilePath);
@@ -1748,24 +1747,24 @@
 continue;
   StringRef GpuArch = FileName.slice(
   LibDeviceName.size(), FileName.find('.', LibDeviceName.size()));
-  CudaLibDeviceMap[GpuArch] = FilePath.str();
+  LibDeviceMap[GpuArch] = FilePath.str();
   // Insert map entries for specifc devices with this compute capability.
   if (GpuArch == "compute_20") {
-CudaLibDeviceMap["sm_20"] = FilePath;
-CudaLibDeviceMap["sm_21"] = FilePath;
+LibDeviceMap["sm_20"] = FilePath;
+LibDeviceMap["sm_21"] = FilePath;
   } else if (GpuArch == "compute_30") {
-CudaLibDeviceMap["sm_30"] = FilePath;
-CudaLibDeviceMap["sm_32"] = FilePath;
+LibDeviceMap["sm_30"] = Fi

Re: [PATCH] D21867: [CUDA] Add utility functions for dealing with CUDA versions / architectures.

2016-07-06 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL274681: [CUDA] Add utility functions for dealing with CUDA 
versions / architectures. (authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D21867?vs=62409&id=62975#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21867

Files:
  cfe/trunk/include/clang/Basic/Cuda.h
  cfe/trunk/include/clang/Driver/Action.h
  cfe/trunk/lib/Basic/CMakeLists.txt
  cfe/trunk/lib/Basic/Cuda.cpp
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Driver/Action.cpp
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/lib/Driver/Tools.cpp

Index: cfe/trunk/include/clang/Driver/Action.h
===
--- cfe/trunk/include/clang/Driver/Action.h
+++ cfe/trunk/include/clang/Driver/Action.h
@@ -10,6 +10,7 @@
 #ifndef LLVM_CLANG_DRIVER_ACTION_H
 #define LLVM_CLANG_DRIVER_ACTION_H
 
+#include "clang/Basic/Cuda.h"
 #include "clang/Driver/Types.h"
 #include "clang/Driver/Util.h"
 #include "llvm/ADT/SmallVector.h"
@@ -157,26 +158,22 @@
 
 class CudaDeviceAction : public Action {
   virtual void anchor();
-  /// GPU architecture to bind.  Always of the form /sm_\d+/ or null (when the
-  /// action applies to multiple architectures).
-  const char *GpuArchName;
+
+  const CudaArch GpuArch;
+
   /// True when action results are not consumed by the host action (e.g when
   /// -fsyntax-only or --cuda-device-only options are used).
   bool AtTopLevel;
 
 public:
-  CudaDeviceAction(Action *Input, const char *ArchName, bool AtTopLevel);
+  CudaDeviceAction(Action *Input, CudaArch Arch, bool AtTopLevel);
 
-  const char *getGpuArchName() const { return GpuArchName; }
-
-  /// Gets the compute_XX that corresponds to getGpuArchName().  Returns null
-  /// when getGpuArchName() is null.
-  const char *getComputeArchName() const;
+  /// Get the CUDA GPU architecture to which this Action corresponds.  Returns
+  /// UNKNOWN if this Action corresponds to multiple architectures.
+  CudaArch getGpuArch() const { return GpuArch; }
 
   bool isAtTopLevel() const { return AtTopLevel; }
 
-  static bool IsValidGpuArchName(llvm::StringRef ArchName);
-
   static bool classof(const Action *A) {
 return A->getKind() == CudaDeviceClass;
   }
Index: cfe/trunk/include/clang/Basic/Cuda.h
===
--- cfe/trunk/include/clang/Basic/Cuda.h
+++ cfe/trunk/include/clang/Basic/Cuda.h
@@ -0,0 +1,77 @@
+//===--- Cuda.h - Utilities for compiling CUDA code  *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_CUDA_H
+#define LLVM_CLANG_BASIC_CUDA_H
+
+namespace llvm {
+class StringRef;
+} // namespace llvm
+
+namespace clang {
+
+enum class CudaVersion {
+  UNKNOWN,
+  CUDA_70,
+  CUDA_75,
+  CUDA_80,
+};
+const char *CudaVersionToString(CudaVersion V);
+
+// No string -> CudaVersion conversion function because there's no canonical
+// spelling of the various CUDA versions.
+
+enum class CudaArch {
+  UNKNOWN,
+  SM_20,
+  SM_21,
+  SM_30,
+  SM_32,
+  SM_35,
+  SM_37,
+  SM_50,
+  SM_52,
+  SM_53,
+  SM_60,
+  SM_61,
+  SM_62,
+};
+const char *CudaArchToString(CudaArch A);
+
+// The input should have the form "sm_20".
+CudaArch StringToCudaArch(llvm::StringRef S);
+
+enum class CudaVirtualArch {
+  UNKNOWN,
+  COMPUTE_20,
+  COMPUTE_30,
+  COMPUTE_32,
+  COMPUTE_35,
+  COMPUTE_37,
+  COMPUTE_50,
+  COMPUTE_52,
+  COMPUTE_53,
+  COMPUTE_60,
+  COMPUTE_61,
+  COMPUTE_62,
+};
+const char *CudaVirtualArchToString(CudaVirtualArch A);
+
+// The input should have the form "compute_20".
+CudaVirtualArch StringToCudaVirtualArch(llvm::StringRef S);
+
+/// Get the compute_xx corresponding to an sm_yy.
+CudaVirtualArch VirtualArchForCudaArch(CudaArch A);
+
+/// Get the earliest CudaVersion that supports the given CudaArch.
+CudaVersion MinVersionForCudaArch(CudaArch A);
+
+} // namespace clang
+
+#endif
Index: cfe/trunk/lib/Driver/Action.cpp
===
--- cfe/trunk/lib/Driver/Action.cpp
+++ cfe/trunk/lib/Driver/Action.cpp
@@ -51,43 +51,11 @@
 BindArchAction::BindArchAction(Action *Input, const char *_ArchName)
 : Action(BindArchClass, Input), ArchName(_ArchName) {}
 
-// Converts CUDA GPU architecture, e.g. "sm_21", to its corresponding virtual
-// compute arch, e.g. "compute_20".  Returns null if the input arch is null or
-// doesn't match an existing arch.
-static const char* GpuArchToComputeName(const char *ArchName) {
-  if (!ArchName)
-return nullptr;
-  return llvm::StringSwitch(ArchName)
-  .Cases("sm_20", "sm_21", "compute_20")
-  .Case("sm_30", "compute_30")
-  .Case("sm_32", "compute_32")
-  .Case("sm_35", "comp

Re: [PATCH] D22048: [analyzer] Suppress false positives in std::shared_ptr

2016-07-06 Thread Devin Coughlin via cfe-commits
dcoughlin updated the summary for this revision.
dcoughlin updated this revision to Diff 62978.
dcoughlin added a comment.

Address Artem's comments: fix a copy-pasta mistake and separate out std stubs 
with deliberate divide-by-zero bugs into their own simulated header file. This 
required moving the suppression tests into their own separate test.


http://reviews.llvm.org/D22048

Files:
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  test/Analysis/Inputs/system-header-simulator-cxx-std-suppression.h
  test/Analysis/Inputs/system-header-simulator-cxx.h
  test/Analysis/diagnostics/implicit-cxx-std-suppression.cpp
  test/Analysis/inlining/stl.cpp

Index: test/Analysis/inlining/stl.cpp
===
--- test/Analysis/inlining/stl.cpp
+++ test/Analysis/inlining/stl.cpp
@@ -27,28 +27,3 @@
   // expected-warning@-4 {{UNKNOWN}}
 #endif
 }
-
-void testList_pop_front(std::list list) {
-  while(!list.empty())
-list.pop_front();  // no-warning
-}
-
-void testBasicStringSuppression() {
-  std::basic_string v;
-  v.push_back(1); // no-warning
-}
-
-void testBasicStringSuppression_append() {
-  std::basic_string v;
-  v += 'c'; // no-warning
-}
-
-void testBasicStringSuppression_assign(std::basic_string &v,
-   const std::basic_string &v2) {
-  v = v2;
-}
-
-class MyEngine;
-void testSupprerssion_independent_bits_engine(MyEngine& e) {
-  std::__independent_bits_engine x(e, 64); // no-warning
-}
Index: test/Analysis/diagnostics/implicit-cxx-std-suppression.cpp
===
--- /dev/null
+++ test/Analysis/diagnostics/implicit-cxx-std-suppression.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,debug.ExprInspection -analyzer-config c++-container-inlining=true -analyzer-config c++-stdlib-inlining=false -std=c++11 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,debug.ExprInspection -analyzer-config c++-container-inlining=true -analyzer-config c++-stdlib-inlining=true -std=c++11 -verify %s
+
+// expected-no-diagnostics
+
+#include "../Inputs/system-header-simulator-cxx-std-suppression.h"
+
+void testList_pop_front(std::list list) {
+  while(!list.empty())
+list.pop_front();  // no-warning
+}
+
+void testBasicStringSuppression() {
+  std::basic_string v;
+  v.push_back(1); // no-warning
+}
+
+void testBasicStringSuppression_append() {
+  std::basic_string v;
+  v += 'c'; // no-warning
+}
+
+void testBasicStringSuppression_assign(std::basic_string &v,
+   const std::basic_string &v2) {
+  v = v2; // no-warning
+}
+
+class MyEngine;
+void testSuppression_independent_bits_engine(MyEngine& e) {
+  std::__independent_bits_engine x(e, 64); // no-warning
+}
+
+void testSuppression_std_shared_pointer() {
+  std::shared_ptr p(new int(1));
+
+  p = nullptr; // no-warning
+}
Index: test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- test/Analysis/Inputs/system-header-simulator-cxx.h
+++ test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -229,106 +229,6 @@
   struct bidirectional_iterator_tag : public forward_iterator_tag { };
   struct random_access_iterator_tag : public bidirectional_iterator_tag { };
 
-  template 
-  class allocator {
-  public:
-void deallocate(void *p) {
-  ::delete p;
-}
-  };
-
-  template 
-  class allocator_traits {
-  public:
-static void deallocate(void *p) {
-  _Alloc().deallocate(p);
-}
-  };
-
-  template 
-  class __list_imp
-  {};
-
-  template  >
-  class list
-  : private __list_imp<_Tp, _Alloc>
-  {
-  public:
-void pop_front() {
-  // Fake use-after-free.
-  // No warning is expected as we are suppressing warning coming
-  // out of std::list.
-  int z = 0;
-  z = 5/z;
-}
-bool empty() const;
-  };
-
-  // basic_string
-  template >
-  class __attribute__ ((__type_visibility__("default"))) basic_string {
-bool isLong;
-union {
-  _CharT localStorage[4];
-  _CharT *externalStorage;
-
-  void assignExternal(_CharT *newExternal) {
-externalStorage = newExternal;
-  }
-} storage;
-
-typedef allocator_traits<_Alloc> __alloc_traits;
-
-  public:
-basic_string();
-
-void push_back(int c) {
-  // Fake error trigger.
-  // No warning is expected as we are suppressing warning coming
-  // out of std::basic_string.
-  int z = 0;
-  z = 5/z;
-}
-
-_CharT *getBuffer() {
-  return isLong ? storage.externalStorage : storage.localStorage;
-}
-
-basic_string &operator +=(int c) {
-  // Fake deallocate stack-based storage.
-  // No warning is expected as we are suppressing warnings within
-  // std::basic_string.
-  __alloc_traits::deallocate(getBuffer());
-}
-
-basic_string &operator =(con

r274689 - [CUDA] Add missing namespace qualification on CudaArch in Action.cpp.

2016-07-06 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Jul  6 16:45:44 2016
New Revision: 274689

URL: http://llvm.org/viewvc/llvm-project?rev=274689&view=rev
Log:
[CUDA] Add missing namespace qualification on CudaArch in Action.cpp.

Fix build breakage with MSVC.

Modified:
cfe/trunk/lib/Driver/Action.cpp

Modified: cfe/trunk/lib/Driver/Action.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Action.cpp?rev=274689&r1=274688&r2=274689&view=diff
==
--- cfe/trunk/lib/Driver/Action.cpp (original)
+++ cfe/trunk/lib/Driver/Action.cpp Wed Jul  6 16:45:44 2016
@@ -53,7 +53,7 @@ BindArchAction::BindArchAction(Action *I
 
 void CudaDeviceAction::anchor() {}
 
-CudaDeviceAction::CudaDeviceAction(Action *Input, CudaArch Arch,
+CudaDeviceAction::CudaDeviceAction(Action *Input, clang::CudaArch Arch,
bool AtTopLevel)
 : Action(CudaDeviceClass, Input), GpuArch(Arch), AtTopLevel(AtTopLevel) {}
 


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


r274691 - [analyzer] Suppress false positives in std::shared_ptr

2016-07-06 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Wed Jul  6 16:52:55 2016
New Revision: 274691

URL: http://llvm.org/viewvc/llvm-project?rev=274691&view=rev
Log:
[analyzer] Suppress false positives in std::shared_ptr

The analyzer does not model C++ temporary destructors completely and so
reports false alarms about leaks of memory allocated by the internals of
shared_ptr:

  std::shared_ptr p(new int(1));
  p = nullptr; // 'Potential leak of memory pointed to by field __cntrl_'

This patch suppresses all diagnostics where the end of the path is inside
a method in std::shared_ptr.

It also reorganizes the tests for suppressions in the C++ standard library
to use a separate simulated header for library functions with bugs
that were deliberately inserted to test suppression. This will prevent
other tests from using these as models.

rdar://problem/23652766

Added:
cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx-std-suppression.h
cfe/trunk/test/Analysis/diagnostics/implicit-cxx-std-suppression.cpp
  - copied, changed from r274682, cfe/trunk/test/Analysis/inlining/stl.cpp
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
cfe/trunk/test/Analysis/inlining/stl.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=274691&r1=274690&r2=274691&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Wed Jul  6 
16:52:55 2016
@@ -1596,12 +1596,6 @@ LikelyFalsePositiveSuppressionBRVisitor:
 }
   }
 
-  // The analyzer issues a false positive on
-  //   std::basic_string v; v.push_back(1);
-  // and
-  //   std::u16string s; s += u'a';
-  // because we cannot reason about the internal invariants of the
-  // datastructure.
   for (const LocationContext *LCtx = N->getLocationContext(); LCtx;
LCtx = LCtx->getParent()) {
 const CXXMethodDecl *MD = dyn_cast(LCtx->getDecl());
@@ -1609,10 +1603,24 @@ LikelyFalsePositiveSuppressionBRVisitor:
   continue;
 
 const CXXRecordDecl *CD = MD->getParent();
+// The analyzer issues a false positive on
+//   std::basic_string v; v.push_back(1);
+// and
+//   std::u16string s; s += u'a';
+// because we cannot reason about the internal invariants of the
+// datastructure.
 if (CD->getName() == "basic_string") {
   BR.markInvalid(getTag(), nullptr);
   return nullptr;
 }
+
+// The analyzer issues a false positive on
+//std::shared_ptr p(new int(1)); p = nullptr;
+// because it does not reason properly about temporary destructors.
+if (CD->getName() == "shared_ptr") {
+  BR.markInvalid(getTag(), nullptr);
+  return nullptr;
+}
   }
 }
   }

Added: 
cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx-std-suppression.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx-std-suppression.h?rev=274691&view=auto
==
--- 
cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx-std-suppression.h 
(added)
+++ 
cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx-std-suppression.h 
Wed Jul  6 16:52:55 2016
@@ -0,0 +1,146 @@
+// This is a fake system header with divide-by-zero bugs introduced in
+// c++ std library functions. We use these bugs to test hard-coded
+// suppression of diagnostics within standard library functions that are known
+// to produce false positives.
+
+#pragma clang system_header
+
+typedef unsigned char uint8_t;
+
+typedef __typeof__(sizeof(int)) size_t;
+void *memmove(void *s1, const void *s2, size_t n);
+
+namespace std {
+
+  template 
+  class allocator {
+  public:
+void deallocate(void *p) {
+  ::delete p;
+}
+  };
+
+  template 
+  class allocator_traits {
+  public:
+static void deallocate(void *p) {
+  _Alloc().deallocate(p);
+}
+  };
+
+  template 
+  class __list_imp
+  {};
+
+  template  >
+  class list
+  : private __list_imp<_Tp, _Alloc>
+  {
+  public:
+void pop_front() {
+  // Fake use-after-free.
+  // No warning is expected as we are suppressing warning coming
+  // out of std::list.
+  int z = 0;
+  z = 5/z;
+}
+bool empty() const;
+  };
+
+  // basic_string
+  template >
+  class __attribute__ ((__type_visibility__("default"))) basic_string {
+bool isLong;
+union {
+  _CharT localStorage[4];
+  _CharT *externalStorage;
+
+  void assignExternal(_CharT *newExternal) {
+externalStorage = newExternal;
+  }
+} storage;
+
+typedef allocator_t

r274695 - Ensuring the bit-fields have the same type; MSVC will place the fields in different allocation units otherwise.

2016-07-06 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Jul  6 17:06:19 2016
New Revision: 274695

URL: http://llvm.org/viewvc/llvm-project?rev=274695&view=rev
Log:
Ensuring the bit-fields have the same type; MSVC will place the fields in 
different allocation units otherwise.

Modified:
cfe/trunk/include/clang/Basic/Specifiers.h

Modified: cfe/trunk/include/clang/Basic/Specifiers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Specifiers.h?rev=274695&r1=274694&r2=274695&view=diff
==
--- cfe/trunk/include/clang/Basic/Specifiers.h (original)
+++ cfe/trunk/include/clang/Basic/Specifiers.h Wed Jul  6 17:06:19 2016
@@ -85,7 +85,7 @@ namespace clang {
 /*DeclSpec::TST*/ unsigned Type  : 5;
 /*DeclSpec::TSS*/ unsigned Sign  : 2;
 /*DeclSpec::TSW*/ unsigned Width : 2;
-bool ModeAttr : 1;
+unsigned ModeAttr : 1;
   };  
 
   /// \brief A C++ access specifier (public, private, protected), plus the


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


r274698 - Retry "Include debug info for nested structs and classes"

2016-07-06 Thread Adrian McCarthy via cfe-commits
Author: amccarth
Date: Wed Jul  6 17:39:15 2016
New Revision: 274698

URL: http://llvm.org/viewvc/llvm-project?rev=274698&view=rev
Log:
Retry "Include debug info for nested structs and classes"

This should work now that the LLVM-side of the change has landed successfully.

Original Differential Revision: http://reviews.llvm.org/D21705

This reverts commit a30322e861c387e1088f47065d0438c6bb019879.

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp
cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=274698&r1=274697&r2=274698&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Jul  6 17:39:15 2016
@@ -1095,6 +1095,13 @@ void CGDebugInfo::CollectRecordNormalFie
   elements.push_back(FieldType);
 }
 
+void CGDebugInfo::CollectRecordNestedRecord(
+const RecordDecl *RD, SmallVectorImpl &elements) {
+  QualType Ty = CGM.getContext().getTypeDeclType(RD);
+  llvm::DIType *nestedType = getOrCreateType(Ty, getOrCreateMainFile());
+  elements.push_back(nestedType);
+}
+
 void CGDebugInfo::CollectRecordFields(
 const RecordDecl *record, llvm::DIFile *tunit,
 SmallVectorImpl &elements,
@@ -1131,6 +1138,9 @@ void CGDebugInfo::CollectRecordFields(
 
 // Bump field number for next field.
 ++fieldNo;
+  } else if (const auto *nestedRec = dyn_cast(I)) {
+if (!nestedRec->isImplicit() && nestedRec->getDeclContext() == record)
+  CollectRecordNestedRecord(nestedRec, elements);
   }
   }
 }
@@ -3633,8 +3643,8 @@ void CGDebugInfo::EmitUsingDirective(con
   if (CGM.getCodeGenOpts().getDebugInfo() < codegenoptions::LimitedDebugInfo)
 return;
   const NamespaceDecl *NSDecl = UD.getNominatedNamespace();
-  if (!NSDecl->isAnonymousNamespace() || 
-  CGM.getCodeGenOpts().DebugExplicitImport) { 
+  if (!NSDecl->isAnonymousNamespace() ||
+  CGM.getCodeGenOpts().DebugExplicitImport) {
 DBuilder.createImportedModule(
 getCurrentContextDescriptor(cast(UD.getDeclContext())),
 getOrCreateNameSpace(NSDecl),

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=274698&r1=274697&r2=274698&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Wed Jul  6 17:39:15 2016
@@ -254,6 +254,8 @@ class CGDebugInfo {
 llvm::DIFile *F,
 SmallVectorImpl &E,
 llvm::DIType *RecordTy, const RecordDecl *RD);
+  void CollectRecordNestedRecord(const RecordDecl *RD,
+ SmallVectorImpl &E);
   void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile *F,
SmallVectorImpl &E,
llvm::DICompositeType *RecordTy);

Modified: cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp?rev=274698&r1=274697&r2=274698&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp Wed Jul  6 17:39:15 
2016
@@ -19,6 +19,6 @@ protected:
 
 Test t;
 
-// CHECK: !DIDerivedType(tag: DW_TAG_pointer_type
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "data"
+// CHECK: !DIDerivedType(tag: DW_TAG_pointer_type
 // CHECK-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "data"

Modified: cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp?rev=274698&r1=274697&r2=274698&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-indirect-field-decl.cpp Wed Jul  6 
17:39:15 2016
@@ -8,18 +8,18 @@ template  class Fo
 struct Bar {
   int i1;
   // CHECK: ![[INT:[0-9]+]] = !DIBasicType(name: "int"
-  // CHECK: !DIDerivedType(tag: DW_TAG_member, scope:
-  // CHECK-SAME:   line: [[@LINE+4]]
-  // CHECK-SAME:   baseType: ![[UNION:[0-9]+]]
-  // CHECK-SAME:   size: 32, align: 32, offset: 32
-  // CHECK: ![[UNION]] = distinct !DICompositeType(tag: 
DW_TAG_union_type,{{.*}} identifier: "_ZTSN3BarUt_E")
+  // CHECK: ![[UNION:[0-9]+]] = distinct !DICompositeType(tag: 
DW_TAG_un

  1   2   >