Re: [PATCH] D12128: Generating available_externally vtables bugfix

2015-08-18 Thread Piotr Padlewski via cfe-commits
Prazek updated this revision to Diff 32509.
Prazek added a comment.

Added tests, and changed the VTableComponent code which was wrong on so many 
levels. Sorry


http://reviews.llvm.org/D12128

Files:
  include/clang/AST/VTableBuilder.h
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/vtable-available-externally.cpp

Index: test/CodeGenCXX/vtable-available-externally.cpp
===
--- test/CodeGenCXX/vtable-available-externally.cpp
+++ test/CodeGenCXX/vtable-available-externally.cpp
@@ -7,6 +7,9 @@
 // RUN: FileCheck --check-prefix=CHECK-TEST9 %s < %t.opt
 // RUN: FileCheck --check-prefix=CHECK-TEST10 %s < %t.opt
 // RUN: FileCheck --check-prefix=CHECK-TEST11 %s < %t.opt
+// RUN: FileCheck --check-prefix=CHECK-TEST12 %s < %t.opt
+// RUN: FileCheck --check-prefix=CHECK-TEST13 %s < %t.opt
+// RUN: FileCheck --check-prefix=CHECK-TEST14 %s < %t.opt
 
 #include 
 
@@ -289,3 +292,56 @@
   g(d);
 }
 }  // Test 11
+
+namespace Test12 {
+
+// CHECK-TEST12: @_ZTVN6Test121AE = external unnamed_addr constant
+struct A {
+  virtual void foo();
+  virtual ~A() {}
+};
+// CHECK-TEST12: @_ZTVN6Test121BE = external unnamed_addr constant
+struct B : A {
+  void foo();
+};
+
+void g() {
+  A a;
+  a.foo();
+  B b;
+  b.foo();
+}
+}
+
+namespace Test13 {
+
+// CHECK-TEST13-DAG: @_ZTVN6Test131AE = available_externally unnamed_addr constant
+// CHECK-TEST13-DAG: @_ZTVN6Test131BE = external unnamed_addr constant
+struct A {
+  virtual ~A();
+};
+struct B : A {
+  virtual void f();
+  void operator delete(void *);
+  ~B() {}
+};
+
+void g() {
+  A *b = new B;
+}
+}
+
+namespace Test14 {
+
+// CHECK-TEST14: @_ZTVN6Test141AE = available_externally unnamed_addr constant
+struct A {
+  virtual void f();
+  void operator delete(void *);
+  ~A();
+};
+
+void g() {
+  A *b = new A;
+  delete b;
+}
+}
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -320,17 +320,15 @@
   void emitCXXStructor(const CXXMethodDecl *MD, StructorType Type) override;
 
  private:
-  /// Checks if function has any virtual inline function.
-  bool hasAnyVirtualInlineFunction(const CXXRecordDecl *RD) const {
+   bool hasAnyUsedVirtualInlineFunction(const CXXRecordDecl *RD) const {
 const auto &VtableLayout =
 CGM.getItaniumVTableContext().getVTableLayout(RD);
 
 for (const auto &VtableComponent : VtableLayout.vtable_components()) {
-  if (VtableComponent.getKind() !=
-  VTableComponent::Kind::CK_FunctionPointer)
+  if (!VtableComponent.isUsedFunctionPointerKind())
 continue;
 
-  const auto &Method = VtableComponent.getFunctionDecl();
+  const CXXMethodDecl *Method = VtableComponent.getFunctionDecl();
   if (Method->getCanonicalDecl()->isInlined())
 return true;
 }
@@ -1536,7 +1534,7 @@
   // then we are safe to emit available_externally copy of vtable.
   // FIXME we can still emit a copy of the vtable if we
   // can emit definition of the inline functions.
-  return !hasAnyVirtualInlineFunction(RD);
+  return !hasAnyUsedVirtualInlineFunction(RD);
 }
 static llvm::Value *performTypeAdjustment(CodeGenFunction &CGF,
   llvm::Value *Ptr,
Index: include/clang/AST/VTableBuilder.h
===
--- include/clang/AST/VTableBuilder.h
+++ include/clang/AST/VTableBuilder.h
@@ -123,30 +123,50 @@
 
   const CXXRecordDecl *getRTTIDecl() const {
 assert(getKind() == CK_RTTI && "Invalid component kind!");
-
 return reinterpret_cast(getPointer());
   }
 
   const CXXMethodDecl *getFunctionDecl() const {
-assert(getKind() == CK_FunctionPointer);
-
+assert(isFunctionPointerKind() && "Invalid component kind!");
+if (isDestructorKind())
+  return getDestructorDecl();
 return reinterpret_cast(getPointer());
   }
 
   const CXXDestructorDecl *getDestructorDecl() const {
-assert((getKind() == CK_CompleteDtorPointer ||
-getKind() == CK_DeletingDtorPointer) && "Invalid component kind!");
-
+assert(isDestructorKind() && "Invalid component kind!");
 return reinterpret_cast(getPointer());
   }
 
   const CXXMethodDecl *getUnusedFunctionDecl() const {
-assert(getKind() == CK_UnusedFunctionPointer);
-
+assert(getKind() == CK_UnusedFunctionPointer && "Invalid component kind!");
 return reinterpret_cast(getPointer());
   }
 
+  bool isDestructorKind() const { return isDestructorKind(getKind()); }
+
+  bool isUsedFunctionPointerKind() const {
+return isUsedFunctionPointerKind(getKind());
+  }
+
+  bool isFunctionPointerKind() const {
+return isFunctionPointerKind(getKind());
+  }
+
 private:
+  static bool isFunctionPointerKind(Kind ComponentKind) {
+return isUsedFunctionPointerKind(ComponentKind) ||
+   ComponentKind == CK_UnusedFunctionPointer;
+  }
+  static bool isUsed

[libcxx] r245421 - Fix warnings about pessimizing return moves for C++11 and higher

2015-08-18 Thread Dimitry Andric via cfe-commits
Author: dim
Date: Wed Aug 19 01:43:33 2015
New Revision: 245421

URL: http://llvm.org/viewvc/llvm-project?rev=245421&view=rev
Log:
Fix warnings about pessimizing return moves for C++11 and higher

Summary:
Throughout the libc++ headers, there are a few instances where
_VSTD::move() is used to return a local variable.  Howard commented in
r189039 that these were there "for non-obvious reasons such as to help
things limp along in C++03 language mode".

However, when compiling these headers with warnings on, and in C++11 or
higher mode (like we do in FreeBSD), they cause the following complaints
about pessimizing moves:

In file included from tests.cpp:26:
In file included from tests.hpp:29:
/usr/include/c++/v1/map:1368:12: error: moving a local object in a return 
statement prevents copy elision [-Werror,-Wpessimizing-move]
return _VSTD::move(__h);  // explicitly moved for C++03
   ^
/usr/include/c++/v1/__config:368:15: note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
  ^

Attempt to fix this by adding a _LIBCPP_EXPLICIT_MOVE() macro to
__config, which gets defined to _VSTD::move for pre-C++11, and to
nothing for C++11 and later.

I am not completely satisfied with the macro name (I also considered
_LIBCPP_COMPAT_MOVE and some other variants), so suggestions are
welcome. :)

Reviewers: mclow.lists, howard.hinnant, EricWF

Subscribers: arthur.j.odwyer, cfe-commits

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

Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/__hash_table
libcxx/trunk/include/__tree
libcxx/trunk/include/algorithm
libcxx/trunk/include/ext/hash_map
libcxx/trunk/include/map
libcxx/trunk/include/unordered_map

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=245421&r1=245420&r2=245421&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Aug 19 01:43:33 2015
@@ -716,6 +716,12 @@ template  struct __static_asse
 #define _LIBCPP_CONSTEXPR_AFTER_CXX11
 #endif
 
+#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#  define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x)
+#else
+#  define _LIBCPP_EXPLICIT_MOVE(x) (x)
+#endif
+
 #ifndef _LIBCPP_HAS_NO_ASAN
 extern "C" void __sanitizer_annotate_contiguous_container(
   const void *, const void *, const void *, const void *);

Modified: libcxx/trunk/include/__hash_table
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=245421&r1=245420&r2=245421&view=diff
==
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Wed Aug 19 01:43:33 2015
@@ -2108,7 +2108,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 __h.get_deleter().__value_constructed = true;
 __h->__hash_ = hash_function()(__h->__value_);
 __h->__next_ = nullptr;
-return _VSTD::move(__h);  // explicitly moved for C++03
+return _LIBCPP_EXPLICIT_MOVE(__h);  // explicitly moved for C++03
 }
 
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -2124,7 +2124,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 __h.get_deleter().__value_constructed = true;
 __h->__hash_ = __hash;
 __h->__next_ = nullptr;
-return _VSTD::move(__h);  // explicitly moved for C++03
+return _LIBCPP_EXPLICIT_MOVE(__h);  // explicitly moved for C++03
 }
 
 template 

Modified: libcxx/trunk/include/__tree
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tree?rev=245421&r1=245420&r2=245421&view=diff
==
--- libcxx/trunk/include/__tree (original)
+++ libcxx/trunk/include/__tree Wed Aug 19 01:43:33 2015
@@ -1843,7 +1843,7 @@ __tree<_Tp, _Compare, _Allocator>::__con
 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
 __node_traits::construct(__na, _VSTD::addressof(__h->__value_), __v);
 __h.get_deleter().__value_constructed = true;
-return _VSTD::move(__h);  // explicitly moved for C++03
+return _LIBCPP_EXPLICIT_MOVE(__h);  // explicitly moved for C++03
 }
 
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=245421&r1=245420&r2=245421&view=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Wed Aug 19 01:43:33 2015
@@ -851,7 +851,7 @@ for_each(_InputIterator __first, _InputI
 {
 for (; __first != __last; ++__first)
 __f(*__first);
-return _VSTD::move(__f);  // explicitly moved for (emulated) C++03
+return _LIBCPP_EXPLICIT_MOVE(__f);  // explicitly moved for (emulated) 
C++03
 }
 
 // find

Modified: libcxx/trunk/include/

Re: [PATCH] D11781: Refactored pthread usage in libcxx

2015-08-18 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Added more inline comments.



Comment at: include/__mutex_base:36
@@ -35,3 +37,3 @@
 #else
- mutex() _NOEXCEPT {__m_ = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;}
 #endif

Why was the cast insignificant?


Comment at: include/__mutex_base:275
@@ -274,3 +277,3 @@
 #else
-condition_variable() {__cv_ = (pthread_cond_t)PTHREAD_COND_INITIALIZER;}
 #endif

Why was the cast insignificant? 


Comment at: include/thread:412
@@ -411,3 +413,6 @@
 
-_LIBCPP_FUNC_VIS void sleep_for(const chrono::nanoseconds& ns);
 

I'm 99% this is an ABI break. Don't inline this function and make the change 
within the definition


Comment at: include/type_traits:222
@@ -221,3 +221,3 @@
 
-template 
-struct __identity { typedef _Tp type; };
+template 
+struct __identity { typedef T type; };

This change seems to have snuck in.


Comment at: src/algorithm.cpp:51
@@ -50,3 +50,3 @@
 #ifndef _LIBCPP_HAS_NO_THREADS
-static pthread_mutex_t __rs_mut = PTHREAD_MUTEX_INITIALIZER;
+static mutex __rs_mut;
 #endif

I think this prevents __rs_mut from being initialized during constant 
initialization. 
(http://en.cppreference.com/w/cpp/language/constant_initialization)


Comment at: src/memory.cpp:130
@@ -129,3 +129,1 @@
 static const std::size_t __sp_mut_count = 16;
-static pthread_mutex_t mut_back_imp[__sp_mut_count] =
-{

I have no idea what is going on here. Do you understand what this code was 
trying to do?


Repository:
  rL LLVM

http://reviews.llvm.org/D11781



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


Re: [PATCH] D11394: Fix warnings about pessimizing return moves for C++11 and higher

2015-08-18 Thread Dimitry Andric via cfe-commits
dim added a comment.

@ericwf, no, this just dropped off my radar, sorry.  I will commit it now. :)


http://reviews.llvm.org/D11394



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


[PATCH] D12137: Fix 4 typos in test/CodeGenCXX/

2015-08-18 Thread Kai Zhao via cfe-commits
loverszhaokai created this revision.
loverszhaokai added a reviewer: cfe-commits.

Fix 4 typos:
"targetted" -> "targeted"
"becuase" -> "because"
"staically" -> "statically"
"vitual" -> "virtual"

http://reviews.llvm.org/D12137

Files:
  test/CodeGenCXX/ctor-globalopt.cpp
  test/CodeGenCXX/homogeneous-aggregates.cpp
  test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance-vtordisps.cpp

Index: test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance-vtordisps.cpp
===
--- test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance-vtordisps.cpp
+++ test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance-vtordisps.cpp
@@ -33,7 +33,7 @@
 
 namespace simple {
 // In case of a single-layer virtual inheritance, the "this" adjustment for a
-// virtual method is done staically:
+// virtual method is done statically:
 //   struct A {
 // virtual void f();  // Expects "(A*)this" in ECX
 //   };
@@ -222,7 +222,7 @@
 
 namespace extended {
 // If a virtual function requires vtordisp adjustment and the final overrider
-// is defined in another vitual base of the most derived class,
+// is defined in another virtual base of the most derived class,
 // we need to know two vbase offsets.
 // In this case, we should use the extended form of vtordisp thunks, called
 // vtordispex thunks.
Index: test/CodeGenCXX/homogeneous-aggregates.cpp
===
--- test/CodeGenCXX/homogeneous-aggregates.cpp
+++ test/CodeGenCXX/homogeneous-aggregates.cpp
@@ -91,7 +91,7 @@
 // ARM32: define arm_aapcs_vfpcc void 
@_Z15with_empty_base16HVAWithEmptyBase(%struct.HVAWithEmptyBase %a.coerce)
 void CC with_empty_base(HVAWithEmptyBase a) {}
 
-// FIXME: MSVC doesn't consider this an HVA becuase of the empty base.
+// FIXME: MSVC doesn't consider this an HVA because of the empty base.
 // X64: define x86_vectorcallcc void 
@"\01_Z15with_empty_base16HVAWithEmptyBase@@16"(float %a.0, float %a.1, float 
%a.2)
 
 struct HVAWithEmptyBitField : Float1, Float2 {
Index: test/CodeGenCXX/ctor-globalopt.cpp
===
--- test/CodeGenCXX/ctor-globalopt.cpp
+++ test/CodeGenCXX/ctor-globalopt.cpp
@@ -4,7 +4,7 @@
 // RUN: %clang_cc1 -triple %ms_abi_triple -emit-llvm -o - %s -O1 | FileCheck 
%s --check-prefix=O1
 
 // Check that GlobalOpt can eliminate static constructors for simple implicit
-// constructors. This is a targetted integration test to make sure that LLVM's
+// constructors. This is a targeted integration test to make sure that LLVM's
 // optimizers are able to process Clang's IR. GlobalOpt in particular is
 // sensitive to the casts we emit.
 


Index: test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance-vtordisps.cpp
===
--- test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance-vtordisps.cpp
+++ test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance-vtordisps.cpp
@@ -33,7 +33,7 @@
 
 namespace simple {
 // In case of a single-layer virtual inheritance, the "this" adjustment for a
-// virtual method is done staically:
+// virtual method is done statically:
 //   struct A {
 // virtual void f();  // Expects "(A*)this" in ECX
 //   };
@@ -222,7 +222,7 @@
 
 namespace extended {
 // If a virtual function requires vtordisp adjustment and the final overrider
-// is defined in another vitual base of the most derived class,
+// is defined in another virtual base of the most derived class,
 // we need to know two vbase offsets.
 // In this case, we should use the extended form of vtordisp thunks, called
 // vtordispex thunks.
Index: test/CodeGenCXX/homogeneous-aggregates.cpp
===
--- test/CodeGenCXX/homogeneous-aggregates.cpp
+++ test/CodeGenCXX/homogeneous-aggregates.cpp
@@ -91,7 +91,7 @@
 // ARM32: define arm_aapcs_vfpcc void @_Z15with_empty_base16HVAWithEmptyBase(%struct.HVAWithEmptyBase %a.coerce)
 void CC with_empty_base(HVAWithEmptyBase a) {}
 
-// FIXME: MSVC doesn't consider this an HVA becuase of the empty base.
+// FIXME: MSVC doesn't consider this an HVA because of the empty base.
 // X64: define x86_vectorcallcc void @"\01_Z15with_empty_base16HVAWithEmptyBase@@16"(float %a.0, float %a.1, float %a.2)
 
 struct HVAWithEmptyBitField : Float1, Float2 {
Index: test/CodeGenCXX/ctor-globalopt.cpp
===
--- test/CodeGenCXX/ctor-globalopt.cpp
+++ test/CodeGenCXX/ctor-globalopt.cpp
@@ -4,7 +4,7 @@
 // RUN: %clang_cc1 -triple %ms_abi_triple -emit-llvm -o - %s -O1 | FileCheck %s --check-prefix=O1
 
 // Check that GlobalOpt can eliminate static constructors for simple implicit
-// constructors. This is a targetted integration test to make sure that LLVM's
+// constructors. This is a targeted integration test to make sure that LLVM's
 // optimizers are able to 

Re: [PATCH] D11781: Refactored pthread usage in libcxx

2015-08-18 Thread Eric Fiselier via cfe-commits
EricWF added a reviewer: EricWF.
EricWF added a comment.

This patch has a long way to go but it has also come a long way. Here are a 
couple of problems I see with it.

1. There are still plenty of ABI breaks. I'll try and point them all out.
2. This patch adds a lot of headers. libc++ has historically tried to keep the 
number of headers to a minimum for the reason that filesystem operations are 
expensive and its cheaper to include a few big headers as opposed to many small 
ones.
3. There where some subtle static initialization changes. However they may have 
been fixed.

I'll do a more through review soon.



Comment at: include/mutex:534
@@ -533,3 +516,3 @@
 
-_LIBCPP_FUNC_VIS void __call_once(volatile unsigned long&, void*, 
void(*)(void*));
 

This looks like an ABI break to me.


Repository:
  rL LLVM

http://reviews.llvm.org/D11781



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


Re: [PATCH] D11963: Create a __config_site file to capture configuration decisions.

2015-08-18 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

I also just realized that this change will currently likely play havoc with how 
libc++ and libc++abi build together. In order to build libc++ and libc++abi 
together we would need to

1. Configure libc++ pointing to the libc++abi headers in order to generate the 
__config_site file.
2. Configure libc++abi pointing it to the libc++ build directory for the 
headers.
3. build libc++abi
4. build libc++

I'm not quite sure how this would work for an in-tree build.

However if we do things as I suggested above we can keep the current two step 
build process.


http://reviews.llvm.org/D11963



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


Re: [PATCH] D10963: Implement LWG#2063: "Contradictory requirements for string move assignment"

2015-08-18 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

@mclow.lists: Do other containers need this update as well? If so it might be 
worth while writing noexcept traits that handle the `#ifdef` hell in one spot 
instead of repeating it throughout.


http://reviews.llvm.org/D10963



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


Re: [PATCH] D11963: Create a __config_site file to capture configuration decisions.

2015-08-18 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

I think we can avoid requiring the need to rebuild every time the headers 
change but it's not the cleanest. We could

1. Have an empty `__config_site` file in `libcxx/include`. This `__config_site` 
file does not get copied into the build directory.
2. Generate `__config_site.in` into `build-libcxx/include/c++/v1`.
3. Point LIT to `libcxx/include` (not `build-libcxx/include/c++/v1`) and add 
the flag `-include build-libcxx/include/c++/v1/__config_site` to pick up the 
generated `__config_site` file.

This way only changes that modify `__config_site` require rebuilding libc++ AND 
`libcxx/include` can be used as the libc++ include root for most configurations.

Another option would be to have `LIT` itself re-run the build and copy the 
headers but I don't think this is as good of an option.

Hopefully this all made sense.

@jroelofs What do you think of an approach like this?


http://reviews.llvm.org/D11963



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


Re: [PATCH] D11394: Fix warnings about pessimizing return moves for C++11 and higher

2015-08-18 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

@dim Has this been committed or is there something holding you back?


http://reviews.llvm.org/D11394



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


[libcxx] r245415 - Use TestAtomic instead of std::atomic so the test can run in C++03

2015-08-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Aug 19 00:00:36 2015
New Revision: 245415

URL: http://llvm.org/viewvc/llvm-project?rev=245415&view=rev
Log:
Use TestAtomic instead of std::atomic so the test can run in C++03

Modified:

libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp

Modified: 
libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp?rev=245415&r1=245414&r2=245415&view=diff
==
--- 
libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp
 Wed Aug 19 00:00:36 2015
@@ -16,10 +16,11 @@
 // void detach();
 
 #include 
-#include 
 #include 
 
-std::atomic_bool done = ATOMIC_VAR_INIT(false);
+#include "test_atomic.h"
+
+AtomicBool done(false);
 
 class G
 {


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


[PATCH] D12135: [libcxx] Mark most test/std/future tests as UNSUPPORTED in C++03

2015-08-18 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added a reviewer: mclow.lists.
EricWF added subscribers: cfe-commits, mclow.lists.

This patch marks *most* tests for `std::promise`, `std::future` and 
`std::shared_future` as unsupported in C++03. These tests fail in C++03 mode 
because they attempt to copy a `std::future` even though it is a `MoveOnly` 
type. AFAIK the missing move-semantics in `std::future` is the only reason 
these tests fail but without move semantics these classes are useless. For 
example even though `std::promise::set_value` and 
`std::promise::set_exception(...)` work in C++03 `std::promise` is still 
useless because we cannot call `std::promise::get_future(...)`.

It might be possible to hack `std::move(...)` like we do for `std::unique_ptr` 
to make the move semantics work but I don't think it is worth the effort. 
Instead I think we should leave the `` header as-is and mark the 
failing tests as `UNSUPPORTED`. I don't believe there are any users of 
`std::future` or `std::promise` in C++03 because they are so unusable. 
Therefore I am not concerned about losing test coverage and possibly breaking 
users. However because there are still parts of `` that work in C++03 
it would be wrong to `#ifdef` out the entire header.

@mclow.lists Should we take further steps to prevent the use of `std::promise`, 
`std::future` and `std::shared_future` in C++03?


Note: This patch also cleans up the tests and converts them to use 
`support/test_allocator.h` instead of a duplicate class in 
`test/std/futures/test_allocator.h`.

http://reviews.llvm.org/D12135

Files:
  test/libcxx/thread/futures/version.pass.cpp
  test/std/thread/futures/futures.promise/alloc_ctor.pass.cpp
  test/std/thread/futures/futures.promise/copy_assign.fail.cpp
  test/std/thread/futures/futures.promise/copy_ctor.fail.cpp
  test/std/thread/futures/futures.promise/default.pass.cpp
  test/std/thread/futures/futures.promise/dtor.pass.cpp
  test/std/thread/futures/futures.promise/get_future.pass.cpp
  test/std/thread/futures/futures.promise/move_assign.pass.cpp
  test/std/thread/futures/futures.promise/move_ctor.pass.cpp
  test/std/thread/futures/futures.promise/set_exception.pass.cpp
  test/std/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp
  test/std/thread/futures/futures.promise/set_lvalue.pass.cpp
  test/std/thread/futures/futures.promise/set_lvalue_at_thread_exit.pass.cpp
  
test/std/thread/futures/futures.promise/set_value_at_thread_exit_const.pass.cpp
  test/std/thread/futures/futures.promise/set_value_at_thread_exit_void.pass.cpp
  test/std/thread/futures/futures.promise/set_value_const.pass.cpp
  test/std/thread/futures/futures.promise/set_value_void.pass.cpp
  test/std/thread/futures/futures.promise/swap.pass.cpp
  test/std/thread/futures/futures.promise/uses_allocator.pass.cpp
  test/std/thread/futures/futures.shared_future/copy_assign.pass.cpp
  test/std/thread/futures/futures.shared_future/copy_ctor.pass.cpp
  test/std/thread/futures/futures.shared_future/ctor_future.pass.cpp
  test/std/thread/futures/futures.shared_future/dtor.pass.cpp
  test/std/thread/futures/futures.shared_future/get.pass.cpp
  test/std/thread/futures/futures.shared_future/move_assign.pass.cpp
  test/std/thread/futures/futures.shared_future/move_ctor.pass.cpp
  test/std/thread/futures/futures.shared_future/wait.pass.cpp
  test/std/thread/futures/futures.shared_future/wait_for.pass.cpp
  test/std/thread/futures/futures.shared_future/wait_until.pass.cpp
  test/std/thread/futures/futures.unique_future/copy_assign.fail.cpp
  test/std/thread/futures/futures.unique_future/copy_ctor.fail.cpp
  test/std/thread/futures/futures.unique_future/dtor.pass.cpp
  test/std/thread/futures/futures.unique_future/get.pass.cpp
  test/std/thread/futures/futures.unique_future/share.pass.cpp
  test/std/thread/futures/futures.unique_future/wait.pass.cpp
  test/std/thread/futures/futures.unique_future/wait_for.pass.cpp
  test/std/thread/futures/futures.unique_future/wait_until.pass.cpp
  test/std/thread/futures/test_allocator.h
  test/std/thread/futures/version.pass.cpp
  test/support/test_allocator.h

Index: test/support/test_allocator.h
===
--- test/support/test_allocator.h
+++ test/support/test_allocator.h
@@ -171,13 +171,13 @@
 
 template  struct rebind {typedef test_allocator other;};
 
-test_allocator() throw() : data_(-1) {}
+test_allocator() throw() : data_(0) {}
 explicit test_allocator(int i) throw() : data_(i) {}
 test_allocator(const test_allocator& a) throw()
 : data_(a.data_) {}
 template  test_allocator(const test_allocator& a) throw()
 : data_(a.data_) {}
-~test_allocator() throw() {data_ = 0;}
+~test_allocator() throw() {data_ = -1;}
 
 friend bool operator==(const test_allocator& x, const test_allocator& y)
 {return x.data_ == y.data_;}
Index: test/std/thread/futures/version.pass.cpp

Re: [PATCH] D11932: [OPENMP] Link libomp.lib on Windows

2015-08-18 Thread Alexey Bataev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL245414: [OPENMP] Link libomp.lib on Windows (authored by 
ABataev).

Changed prior to commit:
  http://reviews.llvm.org/D11932?vs=32275&id=32502#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11932

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/OpenMP/linking.c

Index: cfe/trunk/test/OpenMP/linking.c
===
--- cfe/trunk/test/OpenMP/linking.c
+++ cfe/trunk/test/OpenMP/linking.c
@@ -69,3 +69,21 @@
 // CHECK-LD-OVERRIDE-64: "-lgomp" "-lrt" "-lgcc"
 // CHECK-LD-OVERRIDE-64: "-lpthread" "-lc"
 //
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -fopenmp=libomp -target x86_64-msvc-win32 \
+// RUN:   | FileCheck --check-prefix=CHECK-MSVC-LINK-64 %s
+// CHECK-MSVC-LINK-64: link.exe
+// CHECK-MSVC-LINK-64-SAME: -nodefaultlib:vcomp.lib
+// CHECK-MSVC-LINK-64-SAME: -nodefaultlib:vcompd.lib
+// CHECK-MSVC-LINK-64-SAME: -libpath:{{.+}}/../lib
+// CHECK-MSVC-LINK-64-SAME: -defaultlib:libomp.lib
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -fopenmp=libiomp5 -target x86_64-msvc-win32 \
+// RUN:   | FileCheck --check-prefix=CHECK-MSVC-ILINK-64 %s
+// CHECK-MSVC-ILINK-64: link.exe
+// CHECK-MSVC-ILINK-64-SAME: -nodefaultlib:vcomp.lib
+// CHECK-MSVC-ILINK-64-SAME: -nodefaultlib:vcompd.lib
+// CHECK-MSVC-ILINK-64-SAME: -libpath:{{.+}}/../lib
+// CHECK-MSVC-ILINK-64-SAME: -defaultlib:libiomp5md.lib
+//
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -8885,6 +8885,27 @@
 
   Args.AddAllArgValues(CmdArgs, options::OPT__SLASH_link);
 
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false)) {
+CmdArgs.push_back("-nodefaultlib:vcomp.lib");
+CmdArgs.push_back("-nodefaultlib:vcompd.lib");
+CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:") +
+ TC.getDriver().Dir + "/../lib"));
+switch (getOpenMPRuntime(getToolChain(), Args)) {
+case OMPRT_OMP:
+  CmdArgs.push_back("-defaultlib:libomp.lib");
+  break;
+case OMPRT_IOMP5:
+  CmdArgs.push_back("-defaultlib:libiomp5md.lib");
+  break;
+case OMPRT_GOMP:
+  break;
+case OMPRT_Unknown:
+  // Already diagnosed.
+  break;
+}
+  }
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto &Input : Inputs) {
 if (Input.isFilename()) {


Index: cfe/trunk/test/OpenMP/linking.c
===
--- cfe/trunk/test/OpenMP/linking.c
+++ cfe/trunk/test/OpenMP/linking.c
@@ -69,3 +69,21 @@
 // CHECK-LD-OVERRIDE-64: "-lgomp" "-lrt" "-lgcc"
 // CHECK-LD-OVERRIDE-64: "-lpthread" "-lc"
 //
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -fopenmp=libomp -target x86_64-msvc-win32 \
+// RUN:   | FileCheck --check-prefix=CHECK-MSVC-LINK-64 %s
+// CHECK-MSVC-LINK-64: link.exe
+// CHECK-MSVC-LINK-64-SAME: -nodefaultlib:vcomp.lib
+// CHECK-MSVC-LINK-64-SAME: -nodefaultlib:vcompd.lib
+// CHECK-MSVC-LINK-64-SAME: -libpath:{{.+}}/../lib
+// CHECK-MSVC-LINK-64-SAME: -defaultlib:libomp.lib
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -fopenmp=libiomp5 -target x86_64-msvc-win32 \
+// RUN:   | FileCheck --check-prefix=CHECK-MSVC-ILINK-64 %s
+// CHECK-MSVC-ILINK-64: link.exe
+// CHECK-MSVC-ILINK-64-SAME: -nodefaultlib:vcomp.lib
+// CHECK-MSVC-ILINK-64-SAME: -nodefaultlib:vcompd.lib
+// CHECK-MSVC-ILINK-64-SAME: -libpath:{{.+}}/../lib
+// CHECK-MSVC-ILINK-64-SAME: -defaultlib:libiomp5md.lib
+//
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -8885,6 +8885,27 @@
 
   Args.AddAllArgValues(CmdArgs, options::OPT__SLASH_link);
 
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false)) {
+CmdArgs.push_back("-nodefaultlib:vcomp.lib");
+CmdArgs.push_back("-nodefaultlib:vcompd.lib");
+CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:") +
+ TC.getDriver().Dir + "/../lib"));
+switch (getOpenMPRuntime(getToolChain(), Args)) {
+case OMPRT_OMP:
+  CmdArgs.push_back("-defaultlib:libomp.lib");
+  break;
+case OMPRT_IOMP5:
+  CmdArgs.push_back("-defaultlib:libiomp5md.lib");
+  break;
+case OMPRT_GOMP:
+  break;
+case OMPRT_Unknown:
+  // Already diagnosed.
+  break;
+}
+  }
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto &Input : Inputs) {
 if (Input.isFilename()) {
___
cfe-commits mailing list
cfe

r245414 - [OPENMP] Link libomp.lib on Windows

2015-08-18 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Aug 18 23:49:01 2015
New Revision: 245414

URL: http://llvm.org/viewvc/llvm-project?rev=245414&view=rev
Log:
[OPENMP] Link libomp.lib on Windows

Adds libomp.lib for -fopenmp=libomp and libiomp5md.lib for -fopenmp=libiomp5 on 
Windows
Differential Revision: http://reviews.llvm.org/D11932

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/OpenMP/linking.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=245414&r1=245413&r2=245414&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Aug 18 23:49:01 2015
@@ -8885,6 +8885,27 @@ void visualstudio::Linker::ConstructJob(
 
   Args.AddAllArgValues(CmdArgs, options::OPT__SLASH_link);
 
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false)) {
+CmdArgs.push_back("-nodefaultlib:vcomp.lib");
+CmdArgs.push_back("-nodefaultlib:vcompd.lib");
+CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:") +
+ TC.getDriver().Dir + "/../lib"));
+switch (getOpenMPRuntime(getToolChain(), Args)) {
+case OMPRT_OMP:
+  CmdArgs.push_back("-defaultlib:libomp.lib");
+  break;
+case OMPRT_IOMP5:
+  CmdArgs.push_back("-defaultlib:libiomp5md.lib");
+  break;
+case OMPRT_GOMP:
+  break;
+case OMPRT_Unknown:
+  // Already diagnosed.
+  break;
+}
+  }
+
   // Add filenames, libraries, and other linker inputs.
   for (const auto &Input : Inputs) {
 if (Input.isFilename()) {

Modified: cfe/trunk/test/OpenMP/linking.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/linking.c?rev=245414&r1=245413&r2=245414&view=diff
==
--- cfe/trunk/test/OpenMP/linking.c (original)
+++ cfe/trunk/test/OpenMP/linking.c Tue Aug 18 23:49:01 2015
@@ -69,3 +69,21 @@
 // CHECK-LD-OVERRIDE-64: "-lgomp" "-lrt" "-lgcc"
 // CHECK-LD-OVERRIDE-64: "-lpthread" "-lc"
 //
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -fopenmp=libomp -target x86_64-msvc-win32 \
+// RUN:   | FileCheck --check-prefix=CHECK-MSVC-LINK-64 %s
+// CHECK-MSVC-LINK-64: link.exe
+// CHECK-MSVC-LINK-64-SAME: -nodefaultlib:vcomp.lib
+// CHECK-MSVC-LINK-64-SAME: -nodefaultlib:vcompd.lib
+// CHECK-MSVC-LINK-64-SAME: -libpath:{{.+}}/../lib
+// CHECK-MSVC-LINK-64-SAME: -defaultlib:libomp.lib
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -fopenmp=libiomp5 -target x86_64-msvc-win32 \
+// RUN:   | FileCheck --check-prefix=CHECK-MSVC-ILINK-64 %s
+// CHECK-MSVC-ILINK-64: link.exe
+// CHECK-MSVC-ILINK-64-SAME: -nodefaultlib:vcomp.lib
+// CHECK-MSVC-ILINK-64-SAME: -nodefaultlib:vcompd.lib
+// CHECK-MSVC-ILINK-64-SAME: -libpath:{{.+}}/../lib
+// CHECK-MSVC-ILINK-64-SAME: -defaultlib:libiomp5md.lib
+//


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


[libcxx] r245413 - Mark std::packaged_task tests as unsupported in C++03.

2015-08-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Aug 18 23:10:15 2015
New Revision: 245413

URL: http://llvm.org/viewvc/llvm-project?rev=245413&view=rev
Log:
Mark std::packaged_task tests as unsupported in C++03.

std::packaged_task requires variadic templates and is #ifdef out in C++03.
This patch silences the tests in C++03. This patch also rewrites the .fail.cpp 
tests so that they use clang verify.

Modified:

libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp

libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/assign_move.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp

libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp

libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/ctor_copy.fail.cpp

libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/ctor_default.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/ctor_move.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/dtor.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/get_future.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/make_ready_at_thread_exit.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/operator.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/reset.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/swap.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.nonmembers/swap.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.nonmembers/uses_allocator.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.tas/types.pass.cpp

Modified: 
libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp?rev=245413&r1=245412&r2=245413&view=diff
==
--- 
libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp
 (original)
+++ 
libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp
 Tue Aug 18 23:10:15 2015
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+// UNSUPPORTED: c++98, c++03
+
 // 
 
 // class packaged_task
@@ -14,35 +16,11 @@
 // packaged_task& operator=(packaged_task&) = delete;
 
 #include 
-#include 
-
-class A
-{
-long data_;
-
-public:
-explicit A(long i) : data_(i) {}
-
-long operator()(long i, long j) const {return data_ + i + j;}
-};
 
 int main()
 {
 {
-std::packaged_task p0(A(5));
-std::packaged_task p;
-p = p0;
-assert(!p0.valid());
-assert(p.valid());
-std::future f = p.get_future();
-p(3, 'a');
-assert(f.get() == 105.0);
-}
-{
-std::packaged_task p0;
-std::packaged_task p;
-p = p0;
-assert(!p0.valid());
-assert(!p.valid());
+std::packaged_task p0, p;
+p = p0; // expected-error {{overload resolution selected deleted 
operator '='}}
 }
 }

Modified: 
libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/assign_move.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/assign_move.pass.cpp?rev=245413&r1=245412&r2=245413&view=diff
==
--- 
libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/assign_move.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/assign_move.pass.cpp
 Tue Aug 18 23:10:15 2015
@@ -8,6 +8,7 @@
 
//===--===//
 //
 // UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++98, c++03
 
 // 
 

Modified: 
libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp?rev=245413&r1=245412&r2=245413&view=diff
==
--- 
libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp
 (original)
+++ 
libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp
 Tue Aug 18 23:10:15 2015
@@ -7,6 +7,8 @@
 //
 
//===-

[PATCH] D12134: Improve debug info for implicitly captured vars in lambdas

2015-08-18 Thread Alexey Bataev via cfe-commits
ABataev created this revision.
ABataev added reviewers: echristo, rjmccall, rsmith.
ABataev added a subscriber: cfe-commits.

When variables are implicitly captured in lambdas, debug info generated for 
captured variables points to location where they are used first.  This patch 
makes debug info to point to capture default location.

http://reviews.llvm.org/D12134

Files:
  lib/Sema/SemaLambda.cpp
  test/CodeGenCXX/debug-lambda-expressions.cpp

Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -1377,10 +1377,10 @@
 }
 
 static ExprResult performLambdaVarCaptureInitialization(
-Sema &S, LambdaScopeInfo::Capture &Capture,
-FieldDecl *Field,
+Sema &S, LambdaScopeInfo::Capture &Capture, FieldDecl *Field,
 SmallVectorImpl &ArrayIndexVars,
-SmallVectorImpl &ArrayIndexStarts) {
+SmallVectorImpl &ArrayIndexStarts, bool ImplicitCapture,
+SourceLocation CaptureDefaultLoc) {
   assert(Capture.isVariableCapture() && "not a variable capture");
 
   auto *Var = Capture.getVariable();
@@ -1399,7 +1399,10 @@
   //   An entity captured by a lambda-expression is odr-used (3.2) in
   //   the scope containing the lambda-expression.
   ExprResult RefResult = S.BuildDeclarationNameExpr(
-  CXXScopeSpec(), DeclarationNameInfo(Var->getDeclName(), Loc), Var);
+  CXXScopeSpec(),
+  DeclarationNameInfo(Var->getDeclName(),
+  ImplicitCapture ? CaptureDefaultLoc : Loc),
+  Var);
   if (RefResult.isInvalid())
 return ExprError();
   Expr *Ref = RefResult.get();
@@ -1561,7 +1564,8 @@
   Expr *Init = From.getInitExpr();
   if (!Init) {
 auto InitResult = performLambdaVarCaptureInitialization(
-*this, From, *CurField, ArrayIndexVars, ArrayIndexStarts);
+*this, From, *CurField, ArrayIndexVars, ArrayIndexStarts,
+CaptureDefault != LCD_None, CaptureDefaultLoc);
 if (InitResult.isInvalid())
   return ExprError();
 Init = InitResult.get();
Index: test/CodeGenCXX/debug-lambda-expressions.cpp
===
--- test/CodeGenCXX/debug-lambda-expressions.cpp
+++ test/CodeGenCXX/debug-lambda-expressions.cpp
@@ -14,6 +14,19 @@
 struct D { D(); D(const D&); int x; };
 int d(int x) { D y[10]; return [x,y] { return y[x].x; }(); }
 
+// CHECK-LABEL: foo
+int foo(int x) {
+// CHECK: [[X:%.+]] = alloca i32,
+// CHECK: call void @llvm.dbg.declare(
+// CHECK: [[X_REF:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* %{{.+}}, 
i32 0, i32 0, !dbg ![[DBG_FOO:[0-9]+]]
+// CHECK: [[X_VAL:%.+]] = load i32, i32* [[X]], align 4, !dbg ![[DBG_FOO]]
+// CHECK: store i32 [[X_VAL]], i32* [[X_REF]], align 4, !dbg ![[DBG_FOO]]
+// CHECK: call i32 @{{.+}}, !dbg ![[DBG_FOO]]
+  return [=] {
+return x;
+  }();
+}
+
 // Randomness for file. -- 6
 // CHECK: [[FILE:.*]] = !DIFile(filename: "{{.*}}debug-lambda-expressions.cpp",
 
@@ -100,3 +113,5 @@
 // CHECK-SAME:  line: [[VAR_LINE]],
 // CHECK-SAME:  elements: ![[VAR_ARGS:[0-9]+]]
 // CHECK: ![[VAR_ARGS]] = !{!{{[0-9]+}}}
+
+// CHECK: [[DBG_FOO:![0-9]+]] = !DILocation(line: 25,


Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -1377,10 +1377,10 @@
 }
 
 static ExprResult performLambdaVarCaptureInitialization(
-Sema &S, LambdaScopeInfo::Capture &Capture,
-FieldDecl *Field,
+Sema &S, LambdaScopeInfo::Capture &Capture, FieldDecl *Field,
 SmallVectorImpl &ArrayIndexVars,
-SmallVectorImpl &ArrayIndexStarts) {
+SmallVectorImpl &ArrayIndexStarts, bool ImplicitCapture,
+SourceLocation CaptureDefaultLoc) {
   assert(Capture.isVariableCapture() && "not a variable capture");
 
   auto *Var = Capture.getVariable();
@@ -1399,7 +1399,10 @@
   //   An entity captured by a lambda-expression is odr-used (3.2) in
   //   the scope containing the lambda-expression.
   ExprResult RefResult = S.BuildDeclarationNameExpr(
-  CXXScopeSpec(), DeclarationNameInfo(Var->getDeclName(), Loc), Var);
+  CXXScopeSpec(),
+  DeclarationNameInfo(Var->getDeclName(),
+  ImplicitCapture ? CaptureDefaultLoc : Loc),
+  Var);
   if (RefResult.isInvalid())
 return ExprError();
   Expr *Ref = RefResult.get();
@@ -1561,7 +1564,8 @@
   Expr *Init = From.getInitExpr();
   if (!Init) {
 auto InitResult = performLambdaVarCaptureInitialization(
-*this, From, *CurField, ArrayIndexVars, ArrayIndexStarts);
+*this, From, *CurField, ArrayIndexVars, ArrayIndexStarts,
+CaptureDefault != LCD_None, CaptureDefaultLoc);
 if (InitResult.isInvalid())
   return ExprError();
 Init = InitResult.get();
Index: test/CodeGenCXX/debug-lambda-expressions.cpp

[libcxx] r245411 - Remove commented out TODOs. They defined unneeded methods.

2015-08-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Aug 18 22:48:08 2015
New Revision: 245411

URL: http://llvm.org/viewvc/llvm-project?rev=245411&view=rev
Log:
Remove commented out TODOs. They defined unneeded methods.

Modified:
libcxx/trunk/include/experimental/any
libcxx/trunk/src/any.cpp

Modified: libcxx/trunk/include/experimental/any
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/any?rev=245411&r1=245410&r2=245411&view=diff
==
--- libcxx/trunk/include/experimental/any (original)
+++ libcxx/trunk/include/experimental/any Tue Aug 18 22:48:08 2015
@@ -93,9 +93,6 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
 class _LIBCPP_EXCEPTION_ABI bad_any_cast : public bad_cast
 {
 public:
- //TODO(EricWF) Enable or delete these.
-//bad_any_cast() _NOEXCEPT;
-//virtual ~bad_any_cast() _NOEXCEPT;
 virtual const char* what() const _NOEXCEPT;
 };
 

Modified: libcxx/trunk/src/any.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/any.cpp?rev=245411&r1=245410&r2=245411&view=diff
==
--- libcxx/trunk/src/any.cpp (original)
+++ libcxx/trunk/src/any.cpp Tue Aug 18 22:48:08 2015
@@ -11,10 +11,6 @@
 
 _LIBCPP_BEGIN_NAMESPACE_LFTS
 
-// TODO(EricWF) Enable or delete these
-//bad_any_cast::bad_any_cast() _NOEXCEPT {}
-//bad_any_cast::~bad_any_cast() _NOEXCEPT {}
-
 const char* bad_any_cast::what() const _NOEXCEPT {
 return "bad any cast";
 }


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


[libcxx] r245410 - Fix use of static_assert macro with nested commas

2015-08-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Aug 18 22:38:41 2015
New Revision: 245410

URL: http://llvm.org/viewvc/llvm-project?rev=245410&view=rev
Log:
Fix use of static_assert macro with nested commas

Modified:
libcxx/trunk/include/thread

Modified: libcxx/trunk/include/thread
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/thread?rev=245410&r1=245409&r2=245410&view=diff
==
--- libcxx/trunk/include/thread (original)
+++ libcxx/trunk/include/thread Tue Aug 18 22:38:41 2015
@@ -141,7 +141,7 @@ class __thread_specific_ptr
 
  // Only __thread_local_data() may construct a __thread_specific_ptr
  // and only with _Tp == __thread_struct.
-static_assert(is_same<_Tp, __thread_struct>::value, "");
+static_assert((is_same<_Tp, __thread_struct>::value), "");
 __thread_specific_ptr();
 friend _LIBCPP_FUNC_VIS __thread_specific_ptr<__thread_struct>& 
__thread_local_data();
 


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


Re: [PATCH] D12131: Make [Sema]DiagnosticBuilder move-only, instead of having a sneaky mutating copy ctor.

2015-08-18 Thread David Blaikie via cfe-commits
On Tue, Aug 18, 2015 at 8:28 PM, David Blaikie via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> dblaikie added inline comments.
>
> 
> Comment at: include/clang/Basic/Diagnostic.h:936-937
> @@ -935,3 +935,4 @@
>  public:
>/// Copy constructor.  When copied, this "takes" the diagnostic info
> from the
>/// input and neuters it.
> +  DiagnosticBuilder(DiagnosticBuilder &&D) {
> 
> rsmith wrote:
> > Comment is out of date.
> Updated the wording a bit - the scare quotes and somewhat-vague "neuter"
> seemed unhelpful. Hopefully my rephrasing is an improvement, but I can
> restore the old or alternate wording if you prefer.
>
> 
> Comment at: include/clang/Sema/Sema.h:1085-1092
> @@ -1084,10 +1084,10 @@
>
>  /// Teach operator<< to produce an object of the correct type.
>  template
>  friend const SemaDiagnosticBuilder &operator<<(
>  const SemaDiagnosticBuilder &Diag, const T &Value) {
>const DiagnosticBuilder &BaseDiag = Diag;
>BaseDiag << Value;
>return Diag;
>  }
>};
> 
> rsmith wrote:
> > If we only need to support value category preservation for
> `SemaDiagnosticBuilder`, can we duplicate this template for the
> `SemaDiagnosticBuilder &&operator<<(SemaDiagnosticBuilder &&Diag, const T
> &Value)` case?
> Ah, good idea - that seems to totally work and removes the need for all
> the mechanical changes. (the handful of non-Sema diag cleanups in a few
> places (including clang-tidy) remain)
>
> 
> Comment at: lib/Parse/Parser.cpp:163-170
> @@ -162,5 +162,10 @@
>
> -  DiagnosticBuilder DB =
> -  Spelling
> -  ? Diag(EndLoc, DiagID) << FixItHint::CreateInsertion(EndLoc,
> Spelling)
> -  : Diag(Tok, DiagID);
> +  DiagnosticBuilder DB = [&]() {
> +if (!Spelling)
> +  return Diag(Tok, DiagID);
> +
> +auto D = Diag(EndLoc, DiagID);
> +D << FixItHint::CreateInsertion(EndLoc, Spelling);
> +return D;
> +  }();
> +
> 
> rsmith wrote:
> > This one might be more readable as
> >
> >   DiagnosticBuilder DB = std::move(Spelling ? ... : ...);
> >
> > Thoughts?
> Tried a few things here (move inside or outside the conditional operator)
> and none of it works. op<< takes its first arg by const ref (so that it can
> successfully take a temporary) and then returns it by const ref too - so
> we'd have to cast away constness before we could move from it.
>

I suppose my original change could allow us to change the op<<'s to take by
non-const ref and return by non-const ref, thus making this code fixable
with std::move? Though that'd be even more invasive (but help remove the
oddity of << mutating const objects... might eventually be able to make
DiagnosticBuilder's members non-mutable... )


>
> Thoughts? Alternative approaches?
>
>
> http://reviews.llvm.org/D12131
>
>
>
> ___
> 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] D12131: Make [Sema]DiagnosticBuilder move-only, instead of having a sneaky mutating copy ctor.

2015-08-18 Thread David Blaikie via cfe-commits
dblaikie updated this revision to Diff 32495.
dblaikie marked 2 inline comments as done.
dblaikie added a comment.

Addressed Richard's code review feedback


http://reviews.llvm.org/D12131

Files:
  include/clang/Basic/Diagnostic.h
  include/clang/Sema/Sema.h
  lib/ARCMigrate/TransformActions.cpp
  lib/Lex/LiteralSupport.cpp
  lib/Parse/Parser.cpp

Index: lib/Parse/Parser.cpp
===
--- lib/Parse/Parser.cpp
+++ lib/Parse/Parser.cpp
@@ -160,10 +160,15 @@
   if (EndLoc.isValid())
 Spelling = tok::getPunctuatorSpelling(ExpectedTok);
 
-  DiagnosticBuilder DB =
-  Spelling
-  ? Diag(EndLoc, DiagID) << FixItHint::CreateInsertion(EndLoc, Spelling)
-  : Diag(Tok, DiagID);
+  DiagnosticBuilder DB = [&]() {
+if (!Spelling)
+  return Diag(Tok, DiagID);
+
+auto D = Diag(EndLoc, DiagID);
+D << FixItHint::CreateInsertion(EndLoc, Spelling);
+return D;
+  }();
+
   if (DiagID == diag::err_expected)
 DB << ExpectedTok;
   else if (DiagID == diag::err_expected_after)
Index: lib/Lex/LiteralSupport.cpp
===
--- lib/Lex/LiteralSupport.cpp
+++ lib/Lex/LiteralSupport.cpp
@@ -69,8 +69,10 @@
   SourceLocation Begin =
 Lexer::AdvanceToTokenCharacter(TokLoc, TokRangeBegin - TokBegin,
TokLoc.getManager(), Features);
-  return Diags->Report(Begin, DiagID) <<
-MakeCharSourceRange(Features, TokLoc, TokBegin, TokRangeBegin, TokRangeEnd);
+  auto D = Diags->Report(Begin, DiagID);
+  D << MakeCharSourceRange(Features, TokLoc, TokBegin, TokRangeBegin,
+   TokRangeEnd);
+  return D;
 }
 
 /// ProcessCharEscape - Parse a standard C escape sequence, which can occur in
Index: lib/ARCMigrate/TransformActions.cpp
===
--- lib/ARCMigrate/TransformActions.cpp
+++ lib/ARCMigrate/TransformActions.cpp
@@ -675,7 +675,9 @@
SourceRange range) {
   assert(!static_cast(Impl)->isInTransaction() &&
  "Errors should be emitted out of a transaction");
-  return Diags.Report(loc, diagId) << range;
+  auto D = Diags.Report(loc, diagId);
+  D << range;
+  return D;
 }
 
 void TransformActions::reportError(StringRef message, SourceLocation loc,
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -1051,16 +1051,13 @@
 unsigned DiagID;
 
   public:
-SemaDiagnosticBuilder(DiagnosticBuilder &DB, Sema &SemaRef, unsigned DiagID)
-  : DiagnosticBuilder(DB), SemaRef(SemaRef), DiagID(DiagID) { }
+SemaDiagnosticBuilder(DiagnosticBuilder DB, Sema &SemaRef, unsigned DiagID)
+: DiagnosticBuilder(std::move(DB)), SemaRef(SemaRef), DiagID(DiagID) {}
 
-// This is a cunning lie. DiagnosticBuilder actually performs move
-// construction in its copy constructor (but due to varied uses, it's not
-// possible to conveniently express this as actual move construction). So
-// the default copy ctor here is fine, because the base class disables the
-// source anyway, so the user-defined ~SemaDiagnosticBuilder is a safe no-op
-// in that case anwyay.
-SemaDiagnosticBuilder(const SemaDiagnosticBuilder&) = default;
+// DiagnosticBuilder's move ctor ensures that the source object becomes
+// inactive, so ~SemaDiagnosticBuilder will be a safe/correct no-op on
+// moved-from SemaDiagnosticBuilder instances.
+SemaDiagnosticBuilder(SemaDiagnosticBuilder &&) = default;
 
 ~SemaDiagnosticBuilder() {
   // If we aren't active, there is nothing to do.
@@ -1090,12 +1087,18 @@
   BaseDiag << Value;
   return Diag;
 }
+template 
+friend SemaDiagnosticBuilder operator<<(SemaDiagnosticBuilder &&Diag,
+const T &Value) {
+  const DiagnosticBuilder &BaseDiag = Diag;
+  BaseDiag << Value;
+  return std::move(Diag);
+}
   };
 
   /// \brief Emit a diagnostic.
   SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) {
-DiagnosticBuilder DB = Diags.Report(Loc, DiagID);
-return SemaDiagnosticBuilder(DB, *this, DiagID);
+return SemaDiagnosticBuilder(Diags.Report(Loc, DiagID), *this, DiagID);
   }
 
   /// \brief Emit a partial diagnostic.
Index: include/clang/Basic/Diagnostic.h
===
--- include/clang/Basic/Diagnostic.h
+++ include/clang/Basic/Diagnostic.h
@@ -933,14 +933,12 @@
   }
   
 public:
-  /// Copy constructor.  When copied, this "takes" the diagnostic info from the
-  /// input and neuters it.
-  DiagnosticBuilder(const DiagnosticBuilder &D) {
-DiagObj = D.DiagObj;
-IsActive = D.IsActive;
-IsForceEmit = D.IsForceEmit;
+  /// Move constructor. When moved, the source DiagnosticBuilder is made
+  ///

Re: [PATCH] D12131: Make [Sema]DiagnosticBuilder move-only, instead of having a sneaky mutating copy ctor.

2015-08-18 Thread David Blaikie via cfe-commits
dblaikie added inline comments.


Comment at: include/clang/Basic/Diagnostic.h:936-937
@@ -935,3 +935,4 @@
 public:
   /// Copy constructor.  When copied, this "takes" the diagnostic info from the
   /// input and neuters it.
+  DiagnosticBuilder(DiagnosticBuilder &&D) {

rsmith wrote:
> Comment is out of date.
Updated the wording a bit - the scare quotes and somewhat-vague "neuter" seemed 
unhelpful. Hopefully my rephrasing is an improvement, but I can restore the old 
or alternate wording if you prefer.


Comment at: include/clang/Sema/Sema.h:1085-1092
@@ -1084,10 +1084,10 @@
 
 /// Teach operator<< to produce an object of the correct type.
 template
 friend const SemaDiagnosticBuilder &operator<<(
 const SemaDiagnosticBuilder &Diag, const T &Value) {
   const DiagnosticBuilder &BaseDiag = Diag;
   BaseDiag << Value;
   return Diag;
 }
   };

rsmith wrote:
> If we only need to support value category preservation for 
> `SemaDiagnosticBuilder`, can we duplicate this template for the 
> `SemaDiagnosticBuilder &&operator<<(SemaDiagnosticBuilder &&Diag, const T 
> &Value)` case?
Ah, good idea - that seems to totally work and removes the need for all the 
mechanical changes. (the handful of non-Sema diag cleanups in a few places 
(including clang-tidy) remain)


Comment at: lib/Parse/Parser.cpp:163-170
@@ -162,5 +162,10 @@
 
-  DiagnosticBuilder DB =
-  Spelling
-  ? Diag(EndLoc, DiagID) << FixItHint::CreateInsertion(EndLoc, 
Spelling)
-  : Diag(Tok, DiagID);
+  DiagnosticBuilder DB = [&]() {
+if (!Spelling)
+  return Diag(Tok, DiagID);
+
+auto D = Diag(EndLoc, DiagID);
+D << FixItHint::CreateInsertion(EndLoc, Spelling);
+return D;
+  }();
+

rsmith wrote:
> This one might be more readable as
> 
>   DiagnosticBuilder DB = std::move(Spelling ? ... : ...);
> 
> Thoughts?
Tried a few things here (move inside or outside the conditional operator) and 
none of it works. op<< takes its first arg by const ref (so that it can 
successfully take a temporary) and then returns it by const ref too - so we'd 
have to cast away constness before we could move from it.

Thoughts? Alternative approaches?


http://reviews.llvm.org/D12131



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


Re: [PATCH] D12117: Replace __asan_set_error_exit_code() with __sanitizer_set_death_callback()

2015-08-18 Thread Eric Fiselier via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

Not really but I would add a `// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7` 
line to prevent the failures from appearing.


http://reviews.llvm.org/D12117



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


Re: [PATCH] D12117: Replace __asan_set_error_exit_code() with __sanitizer_set_death_callback()

2015-08-18 Thread Alexey Samsonov via cfe-commits
samsonov added a comment.

Yes. Is this is an issue?


http://reviews.llvm.org/D12117



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


[PATCH] Fix typo

2015-08-18 Thread Kai Zhao via cfe-commits
Hi,

This is my first patch for clang. It fixes 4 typos:

"targetted" -> "targeted"
"becuase" -> "because"
"staically" -> "statically"
"vitual" -> "virtual"

The svn diff file is attached. Thanks for your advice!


Author: Kai Zhao
Date: Wed Aug 19 10:10:08 2015
New Revision:

Log:
Fix 4 typos:
"targetted" -> "targeted"
"becuase" -> "because"
"staically" -> "statically"
"vitual" -> "virtual"

Modified:
test/CodeGenCXX/ctor-globalopt.cpp
test/CodeGenCXX/homogeneous-aggregates.cpp
test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance-vtordisps.cpp

Thanks,

Kai
Index: test/CodeGenCXX/ctor-globalopt.cpp
===
--- test/CodeGenCXX/ctor-globalopt.cpp  (revision 245406)
+++ test/CodeGenCXX/ctor-globalopt.cpp  (working copy)
@@ -4,7 +4,7 @@
 // RUN: %clang_cc1 -triple %ms_abi_triple -emit-llvm -o - %s -O1 | FileCheck 
%s --check-prefix=O1
 
 // Check that GlobalOpt can eliminate static constructors for simple implicit
-// constructors. This is a targetted integration test to make sure that LLVM's
+// constructors. This is a targeted integration test to make sure that LLVM's
 // optimizers are able to process Clang's IR. GlobalOpt in particular is
 // sensitive to the casts we emit.
 
Index: test/CodeGenCXX/homogeneous-aggregates.cpp
===
--- test/CodeGenCXX/homogeneous-aggregates.cpp  (revision 245406)
+++ test/CodeGenCXX/homogeneous-aggregates.cpp  (working copy)
@@ -91,7 +91,7 @@
 // ARM32: define arm_aapcs_vfpcc void 
@_Z15with_empty_base16HVAWithEmptyBase(%struct.HVAWithEmptyBase %a.coerce)
 void CC with_empty_base(HVAWithEmptyBase a) {}
 
-// FIXME: MSVC doesn't consider this an HVA becuase of the empty base.
+// FIXME: MSVC doesn't consider this an HVA because of the empty base.
 // X64: define x86_vectorcallcc void 
@"\01_Z15with_empty_base16HVAWithEmptyBase@@16"(float %a.0, float %a.1, float 
%a.2)
 
 struct HVAWithEmptyBitField : Float1, Float2 {
Index: test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance-vtordisps.cpp
===
--- test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance-vtordisps.cpp 
(revision 245406)
+++ test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance-vtordisps.cpp 
(working copy)
@@ -33,7 +33,7 @@
 
 namespace simple {
 // In case of a single-layer virtual inheritance, the "this" adjustment for a
-// virtual method is done staically:
+// virtual method is done statically:
 //   struct A {
 // virtual void f();  // Expects "(A*)this" in ECX
 //   };
@@ -222,7 +222,7 @@
 
 namespace extended {
 // If a virtual function requires vtordisp adjustment and the final overrider
-// is defined in another vitual base of the most derived class,
+// is defined in another virtual base of the most derived class,
 // we need to know two vbase offsets.
 // In this case, we should use the extended form of vtordisp thunks, called
 // vtordispex thunks.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r245406 - [modules] Don't eagerly deserialize so many ImportDecls. CodeGen basically ignores ImportDecls imported from modules, so only eagerly deserialize the ones from a PCH / preamble.

2015-08-18 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Aug 18 21:30:28 2015
New Revision: 245406

URL: http://llvm.org/viewvc/llvm-project?rev=245406&view=rev
Log:
[modules] Don't eagerly deserialize so many ImportDecls. CodeGen basically 
ignores ImportDecls imported from modules, so only eagerly deserialize the ones 
from a PCH / preamble.

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=245406&r1=245405&r2=245406&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Aug 18 21:30:28 2015
@@ -3363,11 +3363,8 @@ void CodeGenModule::EmitTopLevelDecl(Dec
 auto *Import = cast(D);
 
 // Ignore import declarations that come from imported modules.
-if (clang::Module *Owner = Import->getImportedOwningModule()) {
-  if (getLangOpts().CurrentModule.empty() ||
-  Owner->getTopLevelModule()->Name == getLangOpts().CurrentModule)
-break;
-}
+if (Import->getImportedOwningModule())
+  break;
 if (CGDebugInfo *DI = getModuleDebugInfo())
   DI->EmitImportDecl(*Import);
 

Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=245406&r1=245405&r2=245406&view=diff
==
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Tue Aug 18 21:30:28 2015
@@ -1994,14 +1994,19 @@ void ASTWriter::WriteDeclAbbrevs() {
 /// clients to use a separate API call to "realize" the decl. This should be
 /// relatively painless since they would presumably only do it for top-level
 /// decls.
-static bool isRequiredDecl(const Decl *D, ASTContext &Context) {
+static bool isRequiredDecl(const Decl *D, ASTContext &Context,
+   bool WritingModule) {
   // An ObjCMethodDecl is never considered as "required" because its
   // implementation container always is.
 
-  // File scoped assembly or obj-c implementation must be seen. ImportDecl is
-  // used by codegen to determine the set of imported modules to search for
-  // inputs for automatic linking.
-  if (isa(D) || isa(D) || isa(D))
+  // File scoped assembly or obj-c implementation must be seen.
+  if (isa(D) || isa(D))
+return true;
+
+  // ImportDecl is used by codegen to determine the set of imported modules to
+  // search for inputs for automatic linking; include it if it has a semantic
+  // effect.
+  if (isa(D) && !WritingModule)
 return true;
 
   return Context.DeclMustBeEmitted(D);
@@ -2090,7 +2095,7 @@ void ASTWriter::WriteDecl(ASTContext &Co
 
   // Note declarations that should be deserialized eagerly so that we can add
   // them to a record in the AST file later.
-  if (isRequiredDecl(D, Context))
+  if (isRequiredDecl(D, Context, WritingModule))
 EagerlyDeserializedDecls.push_back(ID);
 }
 


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


r245405 - Rename getDefaultFeatures -> initDefaultFeatures and update comment

2015-08-18 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Tue Aug 18 21:24:21 2015
New Revision: 245405

URL: http://llvm.org/viewvc/llvm-project?rev=245405&view=rev
Log:
Rename getDefaultFeatures -> initDefaultFeatures and update comment
with the current behavior as the name seems to match what's going on.

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=245405&r1=245404&r2=245405&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Tue Aug 18 21:24:21 2015
@@ -737,10 +737,11 @@ public:
   /// language options which change the target configuration.
   virtual void adjust(const LangOptions &Opts);
 
-  /// \brief Get the default set of target features for the CPU;
-  /// this should include all legal feature strings on the target.
-  virtual void getDefaultFeatures(llvm::StringMap &Features) const {
-  }
+  /// \brief Initialize the map with the default set of target features for the
+  /// CPU, ABI, and FPMath options - these should have already been set prior
+  /// to calling this function; this should include all legal feature strings 
on
+  /// the target.
+  virtual void initDefaultFeatures(llvm::StringMap &Features) const {}
 
   /// \brief Get the ABI currently in use.
   virtual StringRef getABI() const { return StringRef(); }

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=245405&r1=245404&r2=245405&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Aug 18 21:24:21 2015
@@ -863,7 +863,7 @@ public:
   void getTargetDefines(const LangOptions &Opts,
 MacroBuilder &Builder) const override;
 
-  void getDefaultFeatures(llvm::StringMap &Features) const override;
+  void initDefaultFeatures(llvm::StringMap &Features) const override;
 
   bool handleTargetFeatures(std::vector &Features,
 DiagnosticsEngine &Diags) override;
@@ -1262,7 +1262,7 @@ void PPCTargetInfo::getTargetDefines(con
   //   __NO_FPRS__
 }
 
-void PPCTargetInfo::getDefaultFeatures(llvm::StringMap &Features) const {
+void PPCTargetInfo::initDefaultFeatures(llvm::StringMap &Features) const 
{
   Features["altivec"] = llvm::StringSwitch(CPU)
 .Case("7400", true)
 .Case("g4", true)
@@ -1332,7 +1332,7 @@ bool PPCTargetInfo::hasFeature(StringRef
 -mcpu=pwr8 -mno-vsx (should disable vsx and everything that depends on it)
 -mcpu=pwr8 -mdirect-move -mno-vsx (should actually be diagnosed)
 
-NOTE: Do not call this from PPCTargetInfo::getDefaultFeatures
+NOTE: Do not call this from PPCTargetInfo::initDefaultFeatures
 */
 void PPCTargetInfo::setFeatureEnabled(llvm::StringMap &Features,
   StringRef Name, bool Enabled) const {
@@ -2308,10 +2308,10 @@ public:
 setFeatureEnabledImpl(Features, Name, Enabled);
   }
   // This exists purely to cut down on the number of virtual calls in
-  // getDefaultFeatures which calls this repeatedly.
+  // initDefaultFeatures which calls this repeatedly.
   static void setFeatureEnabledImpl(llvm::StringMap &Features,
 StringRef Name, bool Enabled);
-  void getDefaultFeatures(llvm::StringMap &Features) const override;
+  void initDefaultFeatures(llvm::StringMap &Features) const override;
   bool hasFeature(StringRef Feature) const override;
   bool handleTargetFeatures(std::vector &Features,
 DiagnosticsEngine &Diags) override;
@@ -2502,7 +2502,7 @@ bool X86TargetInfo::setFPMath(StringRef
   return false;
 }
 
-void X86TargetInfo::getDefaultFeatures(llvm::StringMap &Features) const {
+void X86TargetInfo::initDefaultFeatures(llvm::StringMap &Features) const 
{
   // FIXME: This *really* should not be here.
 
   // X86_64 always has SSE2.
@@ -4459,7 +4459,7 @@ public:
   }
 
   // FIXME: This should be based on Arch attributes, not CPU names.
-  void getDefaultFeatures(llvm::StringMap &Features) const override {
+  void initDefaultFeatures(llvm::StringMap &Features) const override {
 if (CPU == "arm1136jf-s" || CPU == "arm1176jzf-s" || CPU == "mpcore")
   Features["vfp2"] = true;
 else if (CPU == "cortex-a8" || CPU == "cortex-a9") {
@@ -5900,7 +5900,7 @@ public:
 
 return CPUKnown;
   }
-  void getDefaultFeatures(llvm::StringMap &Features) const override {
+  void initDefaultFeatures(llvm::StringMap &Features) const override {
 if (CPU == "zEC12")
   Features["transactional-execution"] = true;
 if (CPU == "z13") {
@@ -6267,7 +6267,7 @@ public:
 .Default(false);
   }
   const std::string& getCPU() const { return CPU; }
-  void getDef

r245404 - [SemaExpr] Re-enable missing assertion.

2015-08-18 Thread Davide Italiano via cfe-commits
Author: davide
Date: Tue Aug 18 21:21:12 2015
New Revision: 245404

URL: http://llvm.org/viewvc/llvm-project?rev=245404&view=rev
Log:
[SemaExpr] Re-enable missing assertion.

This has been disabled for a long time, but:
1) Initializers work (and apparently they're re reason why this was disabled).
2) various tests happen to hit this code path and the invariant seems to be
always verified.

Differential Revision:  http://reviews.llvm.org/D12110
Reviewed by:rsmith

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

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=245404&r1=245403&r2=245404&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Aug 18 21:21:12 2015
@@ -5085,8 +5085,7 @@ ExprResult
 Sema::ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty,
SourceLocation RParenLoc, Expr *InitExpr) {
   assert(Ty && "ActOnCompoundLiteral(): missing type");
-  // FIXME: put back this assert when initializers are worked out.
-  //assert((InitExpr != 0) && "ActOnCompoundLiteral(): missing expression");
+  assert(InitExpr && "ActOnCompoundLiteral(): missing expression");
 
   TypeSourceInfo *TInfo;
   QualType literalType = GetTypeFromParser(Ty, &TInfo);


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


r245403 - Make __builtin_object_size always answer correctly

2015-08-18 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Tue Aug 18 21:19:07 2015
New Revision: 245403

URL: http://llvm.org/viewvc/llvm-project?rev=245403&view=rev
Log:
Make __builtin_object_size always answer correctly

__builtin_object_size would return incorrect answers for many uses where
type=3. This fixes the inaccuracy by making us emit 0 instead of LLVM's
objectsize intrinsic.

Additionally, there are many cases where we would emit suboptimal (but
correct) answers, such as when arrays are involved. This patch fixes
some of these cases (please see new tests in test/CodeGen/object-size.c
for specifics on which cases are improved)

Resubmit of r245323 with PR24493 fixed.
Patch mostly by Richard Smith.
Differential Revision: http://reviews.llvm.org/D12000
This fixes PR15212.


Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/CodeGen/object-size.c
cfe/trunk/test/Sema/const-eval.c

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=245403&r1=245402&r2=245403&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Aug 18 21:19:07 2015
@@ -967,10 +967,6 @@ namespace {
 // Check this LValue refers to an object. If not, set the designator to be
 // invalid and emit a diagnostic.
 bool checkSubobject(EvalInfo &Info, const Expr *E, CheckSubobjectKind CSK) 
{
-  // Outside C++11, do not build a designator referring to a subobject of
-  // any object: we won't use such a designator for anything.
-  if (!Info.getLangOpts().CPlusPlus11)
-Designator.setInvalid();
   return (CSK == CSK_ArrayToPointer || checkNullPointer(Info, E, CSK)) &&
  Designator.checkSubobject(Info, E, CSK);
 }
@@ -2713,8 +2709,7 @@ static bool handleLValueToRValueConversi
 
   // Check for special cases where there is no existing APValue to look at.
   const Expr *Base = LVal.Base.dyn_cast();
-  if (!LVal.Designator.Invalid && Base && !LVal.CallIndex &&
-  !Type.isVolatileQualified()) {
+  if (Base && !LVal.CallIndex && !Type.isVolatileQualified()) {
 if (const CompoundLiteralExpr *CLE = dyn_cast(Base)) {
   // In C99, a CompoundLiteralExpr is an lvalue, and we defer evaluating 
the
   // initializer until now for such expressions. Such an expression can't 
be
@@ -5998,8 +5993,7 @@ public:
   bool VisitSizeOfPackExpr(const SizeOfPackExpr *E);
 
 private:
-  static QualType GetObjectType(APValue::LValueBase B);
-  bool TryEvaluateBuiltinObjectSize(const CallExpr *E);
+  bool TryEvaluateBuiltinObjectSize(const CallExpr *E, unsigned Type);
   // FIXME: Missing: array subscript of vector, member of vector
 };
 } // end anonymous namespace
@@ -6171,7 +6165,7 @@ static bool EvaluateBuiltinConstantP(AST
 
 /// Retrieves the "underlying object type" of the given expression,
 /// as used by __builtin_object_size.
-QualType IntExprEvaluator::GetObjectType(APValue::LValueBase B) {
+static QualType getObjectType(APValue::LValueBase B) {
   if (const ValueDecl *D = B.dyn_cast()) {
 if (const VarDecl *VD = dyn_cast(D))
   return VD->getType();
@@ -6183,49 +6177,94 @@ QualType IntExprEvaluator::GetObjectType
   return QualType();
 }
 
-bool IntExprEvaluator::TryEvaluateBuiltinObjectSize(const CallExpr *E) {
+bool IntExprEvaluator::TryEvaluateBuiltinObjectSize(const CallExpr *E,
+unsigned Type) {
+  // Determine the denoted object.
   LValue Base;
-
   {
 // The operand of __builtin_object_size is never evaluated for 
side-effects.
 // If there are any, but we can determine the pointed-to object anyway, 
then
 // ignore the side-effects.
 SpeculativeEvaluationRAII SpeculativeEval(Info);
+FoldConstant Fold(Info, true);
 if (!EvaluatePointer(E->getArg(0), Base, Info))
   return false;
   }
 
-  if (!Base.getLValueBase()) {
-// It is not possible to determine which objects ptr points to at compile 
time,
-// __builtin_object_size should return (size_t) -1 for type 0 or 1
-// and (size_t) 0 for type 2 or 3.
-llvm::APSInt TypeIntVaue;
-const Expr *ExprType = E->getArg(1);
-if (!ExprType->EvaluateAsInt(TypeIntVaue, Info.Ctx))
-  return false;
-if (TypeIntVaue == 0 || TypeIntVaue == 1)
-  return Success(-1, E);
-if (TypeIntVaue == 2 || TypeIntVaue == 3)
-  return Success(0, E);
+  CharUnits BaseOffset = Base.getLValueOffset();
+
+  // If we point to before the start of the object, there are no
+  // accessible bytes.
+  if (BaseOffset < CharUnits::Zero())
+return Success(0, E);
+
+  // MostDerivedType is null if we're dealing with a literal such as nullptr or
+  // (char*)0x10. Lower it to LLVM in either case so it can figure out what
+  // to do with it.
+  // FIXME(gbiv): Try to do a better job with this in clang.
+  if (Base.Designator.MostDerivedType.isNull())
 return Er

Re: [PATCH] D9286: Insert override at the same line as the end of the function declaration

2015-08-18 Thread Ehsan Akhgari via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL245401: Insert override at the same line as the end of the 
function declaration (authored by ehsan).

Changed prior to commit:
  http://reviews.llvm.org/D9286?vs=24449&id=32492#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D9286

Files:
  clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
@@ -32,6 +32,12 @@
   virtual void m();
   virtual void m2();
   virtual void o() __attribute__((unused));
+
+  virtual void r() &;
+  virtual void rr() &&;
+
+  virtual void cv() const volatile;
+  virtual void cv2() const volatile;
 };
 
 struct SimpleCases : public Base {
@@ -157,25 +163,47 @@
   // CHECK-MESSAGES-NOT: warning:
   // CHECK-FIXES: {{^}}  void b() override {}
 
-  virtual void c() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void c() override {}
+  virtual void c()
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void c() override
 
   virtual void d() override {}
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant
   // CHECK-FIXES: {{^}}  void d() override {}
 
-  virtual void j() const {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void j() const override {}
+  virtual void j() const
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void j() const override
 
   virtual MustUseResultObject k() {}  // Has an implicit attribute.
   // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: prefer using
   // CHECK-FIXES: {{^}}  MustUseResultObject k() override {}
 
   virtual bool l() MUST_USE_RESULT UNUSED {}
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
   // CHECK-FIXES: {{^}}  bool l() override MUST_USE_RESULT UNUSED {}
+
+  virtual void r() &
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void r() & override
+
+  virtual void rr() &&
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void rr() && override
+
+  virtual void cv() const volatile
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void cv() const volatile override
+
+  virtual void cv2() const volatile // some comment
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void cv2() const volatile override // some comment
 };
 
 struct Macros : public Base {
Index: clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
@@ -140,8 +140,20 @@
 }
 
 if (InsertLoc.isInvalid() && Method->doesThisDeclarationHaveABody() &&
-Method->getBody() && !Method->isDefaulted())
-  InsertLoc = Method->getBody()->getLocStart();
+Method->getBody() && !Method->isDefaulted()) {
+  // For methods with inline definition, add the override keyword at the
+  // end of the declaration of the function, but prefer to put it on the
+  // same line as the declaration if the beginning brace for the start of
+  // the body falls on the next line.
+  Token LastNonCommentToken;
+  for (Token T : Tokens) {
+if (!T.is(tok::comment)) {
+  LastNonCommentToken = T;
+}
+  }
+  InsertLoc = LastNonCommentToken.getEndLoc();
+  ReplacementText = " override";
+}
 
 if (!InsertLoc.isValid()) {
   // For declarations marked with "= 0" or "= [default|delete]", the end


Index: clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
@@ -32,6 +32,12 @@
   virtual void m();
   virtual void m2();
   virtual void o() __attribute__((unused));
+
+  virtual void r() &;
+  virtual void rr() &&;
+
+  virtual void cv() const volatile;
+  virtual void cv2() const volatile;
 };
 
 struct SimpleCases : public Base {
@@ -157,25 +163,47 @@
   // CHECK-MESSAGES-NOT: warning:
   // CHECK-FIXES: {{^}}  void b() override {}
 
-  virtual void c() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void c() override {}
+  virtual void c()
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void c() override
 
   virtual void d() override {}

[clang-tools-extra] r245401 - Insert override at the same line as the end of the function declaration

2015-08-18 Thread Ehsan Akhgari via cfe-commits
Author: ehsan
Date: Tue Aug 18 21:05:37 2015
New Revision: 245401

URL: http://llvm.org/viewvc/llvm-project?rev=245401&view=rev
Log:
Insert override at the same line as the end of the function declaration

Summary:
The existing check converts the code pattern below:

  void f()
  {
  }

to:

  void f()
  override {
  }

which is fairly sub-optimal.  This patch fixes this by inserting the
override keyword on the same line as the function declaration if
possible, so that we instead get:

  void f() override
  {
  }

We do this by looking for the last token before the start of the body
and inserting the override keyword at the end of its location.  Note
that we handle const, volatile and ref-qualifiers correctly.

Test Plan: Includes an automated test.

Reviewers: alexfh

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp?rev=245401&r1=245400&r2=245401&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp Tue Aug 18 
21:05:37 2015
@@ -140,8 +140,20 @@ void UseOverrideCheck::check(const Match
 }
 
 if (InsertLoc.isInvalid() && Method->doesThisDeclarationHaveABody() &&
-Method->getBody() && !Method->isDefaulted())
-  InsertLoc = Method->getBody()->getLocStart();
+Method->getBody() && !Method->isDefaulted()) {
+  // For methods with inline definition, add the override keyword at the
+  // end of the declaration of the function, but prefer to put it on the
+  // same line as the declaration if the beginning brace for the start of
+  // the body falls on the next line.
+  Token LastNonCommentToken;
+  for (Token T : Tokens) {
+if (!T.is(tok::comment)) {
+  LastNonCommentToken = T;
+}
+  }
+  InsertLoc = LastNonCommentToken.getEndLoc();
+  ReplacementText = " override";
+}
 
 if (!InsertLoc.isValid()) {
   // For declarations marked with "= 0" or "= [default|delete]", the end

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp?rev=245401&r1=245400&r2=245401&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp Tue Aug 18 
21:05:37 2015
@@ -32,6 +32,12 @@ struct Base {
   virtual void m();
   virtual void m2();
   virtual void o() __attribute__((unused));
+
+  virtual void r() &;
+  virtual void rr() &&;
+
+  virtual void cv() const volatile;
+  virtual void cv2() const volatile;
 };
 
 struct SimpleCases : public Base {
@@ -157,17 +163,19 @@ public:
   // CHECK-MESSAGES-NOT: warning:
   // CHECK-FIXES: {{^}}  void b() override {}
 
-  virtual void c() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void c() override {}
+  virtual void c()
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void c() override
 
   virtual void d() override {}
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant
   // CHECK-FIXES: {{^}}  void d() override {}
 
-  virtual void j() const {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void j() const override {}
+  virtual void j() const
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void j() const override
 
   virtual MustUseResultObject k() {}  // Has an implicit attribute.
   // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: prefer using
@@ -176,6 +184,26 @@ public:
   virtual bool l() MUST_USE_RESULT UNUSED {}
   // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
   // CHECK-FIXES: {{^}}  bool l() override MUST_USE_RESULT UNUSED {}
+
+  virtual void r() &
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void r() & override
+
+  virtual void rr() &&
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void rr() && override
+
+  virtual void cv() const volatile
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void cv() const volatile override
+
+  virtual void cv2() const volatile // some comment
+  {}
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
+  // CHECK-FIXES: {{^}}  void cv2() const volatile override // some comment
 };
 
 struct Macros : publi

Re: [PATCH] D11740: ABI versioning macros for libc++

2015-08-18 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

I don't think the tricky part of this patch is actually implementing the ABI 
macros. The tricky part is defining how libc++ should use the macros.  Some 
questions I would like to see answered:

1. How long is a major and minor ABI version supported?
2. When is the major and minor ABI version bumped?
3. How will maintaining multiple ABI versions affect code complexity and 
maintainability?

I would want to see documentation accompany this patch that anwsers some of 
these questions. It could we written in reStructured text after 
http://reviews.llvm.org/D12129 lands.


Repository:
  rL LLVM

http://reviews.llvm.org/D11740



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


Re: [PATCH] D12117: Replace __asan_set_error_exit_code() with __sanitizer_set_death_callback()

2015-08-18 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Is this going to break this test with older versions of compiler-rt?


http://reviews.llvm.org/D12117



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


Re: [PATCH] D12129: [libcxx] Add new Sphinx documentation

2015-08-18 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

I've uploaded a version of the docs built with the "haiku" theme to 
http://efcs.ca/libcxx-haiku-docs. I would like other's input on which style 
they prefer (Note: The LLVM themed docs are here http://efcs.ca/libcxx-docs).


http://reviews.llvm.org/D12129



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


Re: [PATCH] D12129: [libcxx] Add new Sphinx documentation

2015-08-18 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

In http://reviews.llvm.org/D12129#227320, @silvas wrote:

> From a Sphinx perspective, this looks fine to me. You may want to consider 
> using `html_theme = 'haiku'` for consistency with clang, but reusing LLVM's 
> is fine. (the reason I had clang use 'haiku' is that it is a bit better put 
> together since it ships with sphinx (llvm's theme also has a notorious 
> problem distinguishing different header levels); 'haiku' also doesn't require 
> any static theme-related assets to be checked in since sphinx has them 
> already as part of its own installation)


I'll take a look at using clang's theme and see what comes out. Ironically I 
think I chose LLVM's theme because I preferred the way it distinguished between 
headers levels (although I have noticed some issues distinguishing nested 
levels). It would be nice to remove some assets from the repository.


http://reviews.llvm.org/D12129



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


Re: [PATCH] D12129: [libcxx] Add new Sphinx documentation

2015-08-18 Thread Sean Silva via cfe-commits
silvas added a subscriber: silvas.
silvas added a comment.

From a Sphinx perspective, this looks fine to me. You may want to consider 
using `html_theme = 'haiku'` for consistency with clang, but reusing LLVM's is 
fine. (the reason I had clang use 'haiku' is that it is a bit better put 
together since it ships with sphinx (llvm's theme also has a notorious problem 
distinguishing different header levels); 'haiku' also doesn't require any 
static theme-related assets to be checked in since sphinx has them already as 
part of its own installation)


http://reviews.llvm.org/D12129



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


Re: [PATCH] D12131: Make [Sema]DiagnosticBuilder move-only, instead of having a sneaky mutating copy ctor.

2015-08-18 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/Basic/Diagnostic.h:936-937
@@ -935,3 +935,4 @@
 public:
   /// Copy constructor.  When copied, this "takes" the diagnostic info from the
   /// input and neuters it.
+  DiagnosticBuilder(DiagnosticBuilder &&D) {

Comment is out of date.


Comment at: include/clang/Sema/Sema.h:1085-1092
@@ -1084,10 +1084,10 @@
 
 /// Teach operator<< to produce an object of the correct type.
 template
 friend const SemaDiagnosticBuilder &operator<<(
 const SemaDiagnosticBuilder &Diag, const T &Value) {
   const DiagnosticBuilder &BaseDiag = Diag;
   BaseDiag << Value;
   return Diag;
 }
   };

If we only need to support value category preservation for 
`SemaDiagnosticBuilder`, can we duplicate this template for the 
`SemaDiagnosticBuilder &&operator<<(SemaDiagnosticBuilder &&Diag, const T 
&Value)` case?


Comment at: lib/Parse/Parser.cpp:163-170
@@ -162,5 +162,10 @@
 
-  DiagnosticBuilder DB =
-  Spelling
-  ? Diag(EndLoc, DiagID) << FixItHint::CreateInsertion(EndLoc, 
Spelling)
-  : Diag(Tok, DiagID);
+  DiagnosticBuilder DB = [&]() {
+if (!Spelling)
+  return Diag(Tok, DiagID);
+
+auto D = Diag(EndLoc, DiagID);
+D << FixItHint::CreateInsertion(EndLoc, Spelling);
+return D;
+  }();
+

This one might be more readable as

  DiagnosticBuilder DB = std::move(Spelling ? ... : ...);

Thoughts?


http://reviews.llvm.org/D12131



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


Re: r245352 - Workaround -Wdeprecated on SemDiagnosticConsumer's tricksy copy ctor.

2015-08-18 Thread David Blaikie via cfe-commits
On Tue, Aug 18, 2015 at 4:46 PM, Richard Smith 
wrote:

> On Tue, Aug 18, 2015 at 2:03 PM, David Blaikie  wrote:
>
>> Richard, do you think there's anything we could do better here?
>>
>> It seems difficult to support proper move semantic behavior for
>> [Sema]DiagnosticBuilder across the two common use cases:
>>
>>   DiagnosticBuilder D;
>>   D << x;
>>   D << y;
>>   return D;
>>
>> and
>>
>>   return DiagnosticBuilder() << x << y;
>>
>
> Do we actually use this form to return a DiagnosticBuilder, or just to
> construct an ActionResult? Can we eliminate uses of this form?
>

We don't use it very often outside of "return S.Diag(...) << x << y" - 3
cases (each in disparate parts of the codebase) in Clang, 5 in Clang-Tidy.

For the Sema case, there seemed to be enough uses that I've experimented
with making Sema::Diag variadic and taking the extra parameters: "return
S.Diag(..., x, y);" which seems to work pretty well. Sent for review in
http://reviews.llvm.org/D12131


>
>
>> The only thing I can imagine is if every one of those op<< were function
>> templates using universal references (I forget, is that the right name for
>> them?) and matching their return value (so in the first case, passed a
>> non-const lvalue ref, they return by non-const lvalue ref, and in the
>> second case, passed an rvalue, they return the same). But that seems
>> painful.
>>
>
> It seems tricky to form an unambiguous overload set for this that
> preserves the value category, without duplicating all the operator<

Yep :/


>
>
>> On Tue, Aug 18, 2015 at 1:54 PM, David Blaikie via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: dblaikie
>>> Date: Tue Aug 18 15:54:26 2015
>>> New Revision: 245352
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=245352&view=rev
>>> Log:
>>> Workaround -Wdeprecated on SemDiagnosticConsumer's tricksy copy ctor.
>>>
>>> Modified:
>>> cfe/trunk/include/clang/Sema/Sema.h
>>>
>>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=245352&r1=245351&r2=245352&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>>> +++ cfe/trunk/include/clang/Sema/Sema.h Tue Aug 18 15:54:26 2015
>>> @@ -1054,6 +1054,14 @@ public:
>>>  SemaDiagnosticBuilder(DiagnosticBuilder &DB, Sema &SemaRef,
>>> unsigned DiagID)
>>>: DiagnosticBuilder(DB), SemaRef(SemaRef), DiagID(DiagID) { }
>>>
>>> +// This is a cunning lie. DiagnosticBuilder actually performs move
>>> +// construction in its copy constructor (but due to varied uses,
>>> it's not
>>> +// possible to conveniently express this as actual move
>>> construction). So
>>> +// the default copy ctor here is fine, because the base class
>>> disables the
>>> +// source anyway, so the user-defined ~SemaDiagnosticBuilder is a
>>> safe no-op
>>> +// in that case anwyay.
>>> +SemaDiagnosticBuilder(const SemaDiagnosticBuilder&) = default;
>>> +
>>>  ~SemaDiagnosticBuilder() {
>>>// If we aren't active, there is nothing to do.
>>>if (!isActive()) return;
>>>
>>>
>>> ___
>>> 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


[PATCH] D12131: Make [Sema]DiagnosticBuilder move-only, instead of having a sneaky mutating copy ctor.

2015-08-18 Thread David Blaikie via cfe-commits
dblaikie created this revision.
dblaikie added a reviewer: rsmith.
dblaikie added a subscriber: cfe-commits.

While there wasn't much use of "return Diag(...) << x" outside Sema (one
each in ARCMigrate, Lex, Parse, and 5 in ClangTidy - which were all just
changed to use named local variables, then stream, then return), in Sema
there were quite a few uses. So this extends Sema::Diag to be a variadic
template allowing the extra parameters to be passed directly rather than
via streaming on the resulting temporary expression.

http://reviews.llvm.org/D12131

Files:
  include/clang/Basic/Diagnostic.h
  include/clang/Sema/Sema.h
  lib/ARCMigrate/TransformActions.cpp
  lib/Lex/LiteralSupport.cpp
  lib/Parse/Parser.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaExprObjC.cpp
  lib/Sema/SemaObjCProperty.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/SemaStmt.cpp
  lib/Sema/SemaStmtAsm.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp

Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -5611,12 +5611,11 @@
 : chunk.Kind == DeclaratorChunk::BlockPointer ? PK_BlockPointer
 : inFunction? PK_MemberFunctionPointer : PK_MemberPointer;
 
-auto diag = state.getSema().Diag(attr.getLoc(),
- diag::warn_nullability_declspec)
-  << DiagNullabilityKind(mapNullabilityAttrKind(attr.getKind()),
- attr.isContextSensitiveKeywordAttribute())
-  << type
-  << static_cast(pointerKind);
+auto diag = state.getSema().Diag(
+attr.getLoc(), diag::warn_nullability_declspec,
+DiagNullabilityKind(mapNullabilityAttrKind(attr.getKind()),
+attr.isContextSensitiveKeywordAttribute()),
+type, static_cast(pointerKind));
 
 // FIXME: MemberPointer chunks don't carry the location of the *.
 if (chunk.Kind != DeclaratorChunk::MemberPointer) {
Index: lib/Sema/SemaTemplateVariadic.cpp
===
--- lib/Sema/SemaTemplateVariadic.cpp
+++ lib/Sema/SemaTemplateVariadic.cpp
@@ -251,8 +251,8 @@
   Locations.push_back(Unexpanded[I].second);
   }
 
-  DiagnosticBuilder DB = Diag(Loc, diag::err_unexpanded_parameter_pack)
- << (int)UPPC << (int)Names.size();
+  DiagnosticBuilder DB = Diag(Loc, diag::err_unexpanded_parameter_pack,
+  (int)UPPC, (int)Names.size());
   for (size_t I = 0, E = std::min(Names.size(), (size_t)2); I != E; ++I)
 DB << Names[I];
 
Index: lib/Sema/SemaStmtAsm.cpp
===
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -393,9 +393,9 @@
diag::warn_asm_mismatched_size_modifier);
 
   if (!SuggestedModifier.empty()) {
-auto B = Diag(Piece.getRange().getBegin(),
-  diag::note_asm_missing_constraint_modifier)
- << SuggestedModifier;
+auto B =
+Diag(Piece.getRange().getBegin(),
+ diag::note_asm_missing_constraint_modifier, SuggestedModifier);
 SuggestedModifier = "%" + SuggestedModifier + Piece.getString();
 B.AddFixItHint(FixItHint::CreateReplacement(Piece.getRange(),
 SuggestedModifier));
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -604,35 +604,35 @@
 
 SemaDiagnosticBuilder diagnoseNotInt(Sema &S, SourceLocation Loc,
  QualType T) override {
-  return S.Diag(Loc, diag::err_typecheck_statement_requires_integer) << T;
+  return S.Diag(Loc, diag::err_typecheck_statement_requires_integer, T);
 }
 
 SemaDiagnosticBuilder diagnoseIncomplete(
 Sema &S, SourceLocation Loc, QualType T) override {
-  return S.Diag(Loc, diag::err_switch_incomplete_class_type)
-   << T << Cond->getSourceRange();
+  return S.Diag(Loc, diag::err_switch_incomplete_class_type, T,
+Cond->getSourceRange());
 }
 
 SemaDiagnosticBuilder diagnoseExplicitConv(
 Sema &S, SourceLocation Loc, QualType T, QualType ConvTy) override {
-  return S.Diag(Loc, diag::err_switch_explicit_conversion) << T << ConvTy;
+  return S.Diag(Loc, diag::err_switch_explicit_conversion , T , ConvTy);
 }
 
 SemaDiagnosticBuilder noteExplicitConv(
 Sema &S, CXXConversionDecl *Conv, QualType ConvTy) override {
-  return S.Diag(Conv->getLocation(), diag::note_switch_conversion)
-<< ConvTy->isEnumeralType() << ConvTy;
+  return S.Diag(Conv->getLocation(), diag::note_switch_conversion,
+ConvTy->isEnumeralType(), ConvTy);
 }
 
 SemaDiagnosticBuilder diagnoseAmbig

Re: [PATCH] D11194: Instantiate function declarations in instantiated functions.

2015-08-18 Thread Richard Smith via cfe-commits
On Tue, Aug 18, 2015 at 10:05 AM, Serge Pavlov  wrote:

> sepavloff added inline comments.
>
> 
> Comment at: lib/AST/DeclBase.cpp:273
> @@ +272,3 @@
> +return true;
> +  if (const CXXRecordDecl *ClassD = dyn_cast(LDC))
> +return ClassD->isLocalClass() && !ClassD->isLambda();;
> 
> rsmith wrote:
> > It's not necessary for this change, but to match its documentation this
> function should handle other kinds of `TagDecl` too (enums, C structs).
> Something like:
> >
> >   do {
> > if (LDC->isFunctionOrMethod())
> >   return true;
> > if (!isa(LDC))
> >   return false;
> > LDC = LDC->getLexicalParent();
> >   } while (LDC);
> >   return false;
> >
> > ... maybe?
> The proposed code recognizes lambda as lexically contained within a
> function. As a result, the following test starts to fail (obtained from
> CXX\expr\expr.prim\expr.prim.lambda\default-arguments.cpp):
> ```
> struct NoDefaultCtor {
>   NoDefaultCtor(const NoDefaultCtor&); // expected-note{{candidate
> constructor}}
>   ~NoDefaultCtor();
> };
>
> template
> void defargs_in_template_unused(T t) {
>   auto l1 = [](const T& value = T()) { };
>   l1(t);
> }
>
> template void defargs_in_template_unused(NoDefaultCtor);
> ```
> because default value for lambda argument cannot be instantiated. It is
> not clear whether instantiation of the lambda default argument must always
> occur similar to DR1484. I couldn't find appropriate place in the standard.
> According to spirit it shouldn't as lambda is not a separate declaration
> but a part of instantiated content.


I agree. The default argument must be instantiated as part of instantiating
the surrounding function.


> If so  14.6.4.1p2 is more likely to be applied and the above test must
> pass.
>

The call operator of the lambda is neither a function template nor a member
function of a class template. The relevant rule is 14.7.1/1: "Within a
template declaration, a local class or enumeration and the members
of a local class are never considered to be entities that can be separately
instantiated (this includes their
default arguments, exception-specifications, and non-static data member
initializers, if any)." The lambda expression defines a local class, so its
members' default arguments are instantiated with the surrounding function.


> Maybe we need to rename `isLexicallyWithinFunctionOrMethod` to
> `shouldBeAlwaysInstantiated` or something like that to avoid
> misunderstanding?
>
>
>
> http://reviews.llvm.org/D11194
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12002: Initial WebAssembly support in clang

2015-08-18 Thread Dan Gohman via cfe-commits
sunfish updated this revision to Diff 32485.
sunfish marked an inline comment as done.
sunfish added a comment.

The patch evolved enough to prompt posting one more new version; major changes:

- make constructors and destructors return this
- enable -fuse-init-array
- enable -fno-common
- disable -mdisable-fp-elim
- put static init code in ".text.__startup"
- define a "+simd128" feature, -msimd128 option, __wasm_simd128__ macro
- ignore empty struct arguments and return values
- more tests


Repository:
  rL LLVM

http://reviews.llvm.org/D12002

Files:
  include/clang/Basic/BuiltinsWebAssembly.def
  include/clang/Basic/TargetBuiltins.h
  include/clang/Basic/TargetCXXABI.h
  include/clang/Driver/Options.td
  include/clang/module.modulemap
  lib/AST/ASTContext.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  test/CodeGen/align-wasm.c
  test/CodeGen/builtins-wasm.c
  test/CodeGen/target-data.c
  test/CodeGen/wasm-arguments.c
  test/CodeGen/wasm-regparm.c
  test/CodeGenCXX/constructor-destructor-return-this.cpp
  test/CodeGenCXX/member-alignment.cpp
  test/CodeGenCXX/member-function-pointers.cpp
  test/CodeGenCXX/static-init-wasm.cpp
  test/CodeGenCXX/wasm-args-returns.cpp
  test/Driver/wasm32-unknown-unknown.cpp
  test/Driver/wasm64-unknown-unknown.cpp
  test/Preprocessor/init.c
  test/Preprocessor/wasm-target-features.c

Index: test/Preprocessor/wasm-target-features.c
===
--- test/Preprocessor/wasm-target-features.c
+++ test/Preprocessor/wasm-target-features.c
@@ -0,0 +1,35 @@
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm32-unknown-unknown -msimd128 \
+// RUN:   | FileCheck %s -check-prefix=SIMD128
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm64-unknown-unknown -msimd128 \
+// RUN:   | FileCheck %s -check-prefix=SIMD128
+//
+// SIMD128:#define __wasm_simd128__ 1{{$}}
+//
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm32-unknown-unknown -mcpu=mvp \
+// RUN:   | FileCheck %s -check-prefix=MVP
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm64-unknown-unknown -mcpu=mvp \
+// RUN:   | FileCheck %s -check-prefix=MVP
+//
+// MVP-NOT:#define __wasm_simd128__
+//
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm32-unknown-unknown -mcpu=bleeding-edge \
+// RUN:   | FileCheck %s -check-prefix=BLEEDING_EDGE
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm64-unknown-unknown -mcpu=bleeding-edge \
+// RUN:   | FileCheck %s -check-prefix=BLEEDING_EDGE
+//
+// BLEEDING_EDGE:#define __wasm_simd128__ 1{{$}}
+//
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm32-unknown-unknown -mcpu=bleeding-edge -mno-simd128 \
+// RUN:   | FileCheck %s -check-prefix=BLEEDING_EDGE_NO_SIMD128
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm64-unknown-unknown -mcpu=bleeding-edge -mno-simd128 \
+// RUN:   | FileCheck %s -check-prefix=BLEEDING_EDGE_NO_SIMD128
+//
+// BLEEDING_EDGE_NO_SIMD128-NOT:#define __wasm_simd128__
Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8419,3 +8419,623 @@
 // XCORE:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
 // XCORE:#define __LITTLE_ENDIAN__ 1
 // XCORE:#define __XS1B__ 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=wasm32-unknown-unknown \
+// RUN:   < /dev/null \
+// RUN:   | FileCheck -check-prefix=WEBASSEMBLY32 %s
+//
+// WEBASSEMBLY32:#define _ILP32 1{{$}}
+// WEBASSEMBLY32-NOT:#define _LP64
+// WEBASSEMBLY32-NEXT:#define __ATOMIC_ACQUIRE 2{{$}}
+// WEBASSEMBLY32-NEXT:#define __ATOMIC_ACQ_REL 4{{$}}
+// WEBASSEMBLY32-NEXT:#define __ATOMIC_CONSUME 1{{$}}
+// WEBASSEMBLY32-NEXT:#define __ATOMIC_RELAXED 0{{$}}
+// WEBASSEMBLY32-NEXT:#define __ATOMIC_RELEASE 3{{$}}
+// WEBASSEMBLY32-NEXT:#define __ATOMIC_SEQ_CST 5{{$}}
+// WEBASSEMBLY32-NEXT:#define __BIGGEST_ALIGNMENT__ 16{{$}}
+// WEBASSEMBLY32-NEXT:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__{{$}}
+// WEBASSEMBLY32-NEXT:#define __CHAR16_TYPE__ unsigned short{{$}}
+// WEBASSEMBLY32-NEXT:#define __CHAR32_TYPE__ unsigned int{{$}}
+// WEBASSEMBLY32-NEXT:#define __CHAR_BIT__ 8{{$}}
+// WEBASSEMBLY32-NEXT:#define __CONSTANT_CFSTRINGS__ 1{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_DECIMAL_DIG__ 17{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_DIG__ 15{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_EPSILON__ 2.2204460492503131e-16{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_HAS_DENORM__ 1{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_HAS_INFINITY__ 1{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_HAS_QUIET_NAN__ 1{{$}}
+// WEBASSEMBLY32-NEXT:#define __DBL_MANT_DIG__ 

Re: r245084 - WindowsX86: long double is x87DoubleExtended on mingw

2015-08-18 Thread Richard Smith via cfe-commits
On Tue, Aug 18, 2015 at 3:01 PM, Hans Wennborg  wrote:

> Richard, I tried to ping you on the review thread but I'm not sure it
> got through. Martell requested this be merged to 3.7. What do you
> think?


LGTM


> On Fri, Aug 14, 2015 at 12:05 PM, Martell Malone via cfe-commits
>  wrote:
> > Author: martell
> > Date: Fri Aug 14 14:05:56 2015
> > New Revision: 245084
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=245084&view=rev
> > Log:
> > WindowsX86: long double is x87DoubleExtended on mingw
> >
> > Summary:
> > long double on x86 mingw is 80bits and is aligned to 16bytes
> >
> > Fixes:
> > https://llvm.org/bugs/show_bug.cgi?id=24398
> >
> > Reviewers: rnk
> >
> > Subscribers: cfe-commits
> >
> > Differential Revision: http://reviews.llvm.org/D12037
> >
> > Modified:
> > cfe/trunk/lib/Basic/Targets.cpp
> >
> > Modified: cfe/trunk/lib/Basic/Targets.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=245084&r1=245083&r2=245084&view=diff
> >
> ==
> > --- cfe/trunk/lib/Basic/Targets.cpp (original)
> > +++ cfe/trunk/lib/Basic/Targets.cpp Fri Aug 14 14:05:56 2015
> > @@ -3784,7 +3784,10 @@ namespace {
> >  class MinGWX86_32TargetInfo : public WindowsX86_32TargetInfo {
> >  public:
> >MinGWX86_32TargetInfo(const llvm::Triple &Triple)
> > -  : WindowsX86_32TargetInfo(Triple) {}
> > +  : WindowsX86_32TargetInfo(Triple) {
> > +LongDoubleWidth = LongDoubleAlign = 128;
> > +LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
> > +  }
> >void getTargetDefines(const LangOptions &Opts,
> >  MacroBuilder &Builder) const override {
> >  WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder);
> > @@ -4014,7 +4017,10 @@ public:
> >  class MinGWX86_64TargetInfo : public WindowsX86_64TargetInfo {
> >  public:
> >MinGWX86_64TargetInfo(const llvm::Triple &Triple)
> > -  : WindowsX86_64TargetInfo(Triple) {}
> > +  : WindowsX86_64TargetInfo(Triple) {
> > +LongDoubleWidth = LongDoubleAlign = 128;
> > +LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
> > +  }
> >void getTargetDefines(const LangOptions &Opts,
> >  MacroBuilder &Builder) const override {
> >  WindowsX86_64TargetInfo::getTargetDefines(Opts, Builder);
> >
> >
> > ___
> > 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


[PATCH] D12129: [libcxx] Add new Sphinx documentation

2015-08-18 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added reviewers: jroelofs, chandlerc, danalbert, mclow.lists.
EricWF added a subscriber: cfe-commits.

This patch adds Sphinx based documentation to libc++. The goal is to make it 
easier to write documentation for libc++ since writing new documentation in 
HTML is cumbersome. This patch rewrites the main page for libc++ along with the 
instructions for using, building and testing libc++. 

The built documentation can be found and reviewed here: 
http://efcs.ca/libcxx-docs

In order to build the sphinx documentation you need to specify the cmake 
options `-DLLVM_ENABLE_SPHINX=ON -DLIBCXX_INCLUDE_DOCS=ON`. This will add the 
makefile rule `docs-libcxx-html`. 


http://reviews.llvm.org/D12129

Files:
  CMakeLists.txt
  cmake/Modules/HandleOutOfTreeLLVM.cmake
  cmake/config-ix.cmake
  docs/BuildingLibcxx.rst
  docs/CMakeLists.txt
  docs/README.txt
  docs/TestingLibcxx.rst
  docs/UsingLibcxx.rst
  docs/_static/favicon.ico
  docs/_static/lines.gif
  docs/_static/llvm.css
  docs/_templates/indexsidebar.html
  docs/_templates/layout.html
  docs/_themes/llvm-theme/layout.html
  docs/_themes/llvm-theme/static/contents.png
  docs/_themes/llvm-theme/static/llvm-theme.css
  docs/_themes/llvm-theme/static/logo.png
  docs/_themes/llvm-theme/static/navigation.png
  docs/_themes/llvm-theme/theme.conf
  docs/conf.py
  docs/index.rst

Index: docs/index.rst
===
--- /dev/null
+++ docs/index.rst
@@ -0,0 +1,171 @@
+.. _index:
+
+=
+"libc++" C++ Standard Library
+=
+
+Overview
+
+
+libc++ is a new implementation of the C++ standard library, targeting C++11.
+
+* Features and Goals
+
+  * Correctness as defined by the C++11 standard.
+  * Fast execution.
+  * Minimal memory use.
+  * Fast compile times.
+  * ABI compatibility with gcc's libstdc++ for some low-level features
+such as exception objects, rtti and memory allocation.
+  * Extensive unit tests.
+
+* Design and Implementation:
+
+  * Extensive unit tests
+  * Internal linker model can be dumped/read to textual format
+  * Additional linking features can be plugged in as "passes"
+  * OS specific and CPU specific code factored out
+
+
+Getting Started with libc++
+---
+
+.. toctree::
+   :maxdepth: 2
+
+   UsingLibcxx
+   BuildingLibcxx
+   TestingLibcxx
+
+Current Status
+--
+
+After its initial introduction, many people have asked "why start a new
+library instead of contributing to an existing library?" (like Apache's
+libstdcxx, GNU's libstdc++, STLport, etc).  There are many contributing
+reasons, but some of the major ones are:
+
+From years of experience (including having implemented the standard
+library before), we've learned many things about implementing
+the standard containers which require ABI breakage and fundamental changes
+to how they are implemented.  For example, it is generally accepted that
+building std::string using the "short string optimization" instead of
+using Copy On Write (COW) is a superior approach for multicore
+machines (particularly in C++11, which has rvalue references).  Breaking
+ABI compatibility with old versions of the library was
+determined to be critical to achieving the performance goals of
+libc++.
+
+Mainline libstdc++ has switched to GPL3, a license which the developers
+of libc++ cannot use.  libstdc++ 4.2 (the last GPL2 version) could be
+independently extended to support C++11, but this would be a fork of the
+codebase (which is often seen as worse for a project than starting a new
+independent one).  Another problem with libstdc++ is that it is tightly
+integrated with G++ development, tending to be tied fairly closely to the
+matching version of G++.
+
+STLport and the Apache libstdcxx library are two other popular
+candidates, but both lack C++11 support.  Our experience (and the
+experience of libstdc++ developers) is that adding support for C++11 (in
+particular rvalue references and move-only types) requires changes to
+almost every class and function, essentially amounting to a rewrite.
+Faced with a rewrite, we decided to start from scratch and evaluate every
+design decision from first principles based on experience.
+
+Further, both projects are apparently abandoned: STLport 5.2.1 was
+released in Oct'08, and STDCXX 4.2.1 in May'08.
+
+Platform and Compiler Support
+-
+
+libc++ is known to work on the following platforms, using gcc-4.2 and
+clang  (lack of C++11 language support disables some functionality).
+Note that functionality provided by  is only functional with clang
+and GCC.
+
+   
+OS   Arch CompilersABI Library
+   
+Mac OS X i386, x86_64 Clang, GCC   libc++abi
+FreeBSD 10+  i386, x86_64, ARM 

Re: [PATCH] D12128: Generating available_externally vtables bugfix

2015-08-18 Thread Richard Smith via cfe-commits
rsmith added a comment.

This looks fine; can you add a testcase?


http://reviews.llvm.org/D12128



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


Re: [PATCH] D11682: [libcxxabi] Add "install-libcxxabi" target.

2015-08-18 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

@beanz I tested installing both libc++abi.so and libc++abi.a at the same time 
with different destinations. They both installed into the correct destinations.


http://reviews.llvm.org/D11682



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


Re: r244902 - Driver: Fix include directories when not using libgcc under mingw

2015-08-18 Thread Hans Wennborg via cfe-commits
On Tue, Aug 18, 2015 at 4:52 PM, Richard Smith  wrote:
> On Tue, Aug 18, 2015 at 3:00 PM, Hans Wennborg via cfe-commits
>  wrote:
>>
>> Richard, I tried to ping you on the review thread but I'm not sure it
>> got through. Martell requested this be merged to 3.7. What do you
>> think?
>
>
> Sure, this looks fine for branch.

Thanks! r245393.


>> On Thu, Aug 13, 2015 at 8:41 AM, Martell Malone via cfe-commits
>>  wrote:
>> > Author: martell
>> > Date: Thu Aug 13 10:41:04 2015
>> > New Revision: 244902
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=244902&view=rev
>> > Log:
>> > Driver: Fix include directories when not using libgcc under mingw
>> >
>> > Summary:
>> > When we want to use mingw-w64 and clang with compiler-rt we should not
>> > need to have libgcc installed. This fixes finding includes when libgcc
>> > is not installed
>> >
>> > Reviewers: yaron.keren
>> >
>> > Subscribers: cfe-commits
>> >
>> > Differential Revision: http://reviews.llvm.org/D11808
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11682: [libcxxabi] Add "install-libcxxabi" target.

2015-08-18 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

What about the extra `[` at the beginning of `ARCHIVE` that spans all the way 
down to the last line. It seems to me that `DESTINATION` can be supplied for 
each library type. There is also an example in the docs that shows using two 
library types in one install command.

However if your still not confident it will work correctly I will make the 
change.


http://reviews.llvm.org/D11682



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


Re: [PATCH] D12122: [CUDA] Add appropriate host/device attribute to target-specific builtins.

2015-08-18 Thread Artem Belevich via cfe-commits
tra marked an inline comment as done.


Comment at: lib/Sema/SemaDecl.cpp:11166
@@ +11165,3 @@
+!FD->hasAttr() && !FD->hasAttr()) {
+  if (getLangOpts().CUDAIsDevice)
+FD->addAttr(CUDADeviceAttr::CreateImplicit(Context, 
FD->getLocation()));

eliben wrote:
> It is not immediately clear why you would mark target-specific builtins as 
> __host__ in host compilation mode. So for example __builtin_ptx_read_tid_x 
> would be callable from a host function when compiling in host mode? Can you 
> clarify this with a comment here, and also add a relevant test?
Target triple used for particular compilation pass is assumed to be valid for 
this particular compilation mode. Builtins provided by the target are therefore 
assumed to be intended to be used in that compilation mode. builtins.cu already 
includes test cases for using target-specific builtins from different targets 
and and non-target-specific builtins in host and device functions in host and 
device compilation.

Your example scenario (__builtin_ptx_read_tid_x getting host attribute) is 
possible only if you compile in host mode *and* use --triple 
nvptx-unknown-cuda. IMO, __host__ would be an appropriate attribute to assign 
to builtins in this scenario, even though I don't think we can currently do 
anything useful with NVPTX as the host at the moment. If you attempt to use 
__builtin_ptx_read_tid_x() during host compilation using non-NVPTX target 
(which is a typical scenario), then compilation will fail because that 
particular builtin would not be available at all.

That said, another corner case would be compiling CUDA for device with the same 
architecture as host. Again, it's not a practical scenario at the moment. 
If/when we get to the point when we may want to do that, it should be easy to 
check for it and treat builtins as __host__ __device__ which would reflect 
their intended use domain.


http://reviews.llvm.org/D12122



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


Re: [PATCH] D12122: [CUDA] Add appropriate host/device attribute to target-specific builtins.

2015-08-18 Thread Artem Belevich via cfe-commits
tra updated this revision to Diff 32481.
tra added a comment.

Added a comment explaining reasoning behind attribute choice for 
target-specific builtins.


http://reviews.llvm.org/D12122

Files:
  include/clang/Basic/Builtins.h
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDecl.cpp
  test/SemaCUDA/builtins.cu
  test/SemaCUDA/implicit-intrinsic.cu

Index: test/SemaCUDA/implicit-intrinsic.cu
===
--- test/SemaCUDA/implicit-intrinsic.cu
+++ test/SemaCUDA/implicit-intrinsic.cu
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -std=gnu++11 -triple nvptx64-unknown-unknown -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -fcuda-is-device -fsyntax-only -verify %s
 
 #include "Inputs/cuda.h"
 
 // expected-no-diagnostics
 __device__ void __threadfence_system() {
-  // This shouldn't produce an error, since __nvvm_membar_sys is inferred to
-  // be __host__ __device__ and thus callable from device code.
+  // This shouldn't produce an error, since __nvvm_membar_sys should be
+  // __device__ and thus callable from device code.
   __nvvm_membar_sys();
 }
Index: test/SemaCUDA/builtins.cu
===
--- /dev/null
+++ test/SemaCUDA/builtins.cu
@@ -0,0 +1,35 @@
+// Tests that target-specific builtins have appropriate host/device
+// attributes and that CUDA call restrictions are enforced. Also
+// verify that non-target builtins can be used from both host and
+// device functions.
+//
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple nvptx64-unknown-cuda -fcuda-is-device \
+// RUN:   -fsyntax-only -verify %s
+
+
+#ifdef __CUDA_ARCH__
+// Device-side builtins are not allowed to be called from host functions.
+void hf() {
+  int x = __builtin_ptx_read_tid_x(); // expected-note  {{'__builtin_ptx_read_tid_x' declared here}}
+  // expected-error@-1 {{reference to __device__ function '__builtin_ptx_read_tid_x' in __host__ function}}
+  x = __builtin_abs(1);
+}
+__attribute__((device)) void df() {
+  int x = __builtin_ptx_read_tid_x();
+  x = __builtin_abs(1);
+}
+#else
+// Host-side builtins are not allowed to be called from device functions.
+__attribute__((device)) void df() {
+  int x = __builtin_ia32_rdtsc();   // expected-note {{'__builtin_ia32_rdtsc' declared here}}
+  // expected-error@-1 {{reference to __host__ function '__builtin_ia32_rdtsc' in __device__ function}}
+  x = __builtin_abs(1);
+}
+void hf() {
+  int x = __builtin_ia32_rdtsc();
+  x = __builtin_abs(1);
+}
+#endif
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -11161,6 +11161,17 @@
   FD->addAttr(NoThrowAttr::CreateImplicit(Context, FD->getLocation()));
 if (Context.BuiltinInfo.isConst(BuiltinID) && !FD->hasAttr())
   FD->addAttr(ConstAttr::CreateImplicit(Context, FD->getLocation()));
+if (getLangOpts().CUDA && Context.BuiltinInfo.isTSBuiltin(BuiltinID) &&
+!FD->hasAttr() && !FD->hasAttr()) {
+  // Target-specific builtins are assumed to be intended for use
+  // in this particular CUDA compilation mode and should have
+  // appropriate attribute set so we can enforce CUDA function
+  // call restrictions.
+  if (getLangOpts().CUDAIsDevice)
+FD->addAttr(CUDADeviceAttr::CreateImplicit(Context, FD->getLocation()));
+  else
+FD->addAttr(CUDAHostAttr::CreateImplicit(Context, FD->getLocation()));
+}
   }
 
   IdentifierInfo *Name = FD->getIdentifier();
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -525,7 +525,7 @@
 
   // Since the target specific builtins for each arch overlap, only check those
   // of the arch we are compiling for.
-  if (BuiltinID >= Builtin::FirstTSBuiltin) {
+  if (Context.BuiltinInfo.isTSBuiltin(BuiltinID)) {
 switch (Context.getTargetInfo().getTriple().getArch()) {
   case llvm::Triple::arm:
   case llvm::Triple::armeb:
Index: include/clang/Basic/Builtins.h
===
--- include/clang/Basic/Builtins.h
+++ include/clang/Basic/Builtins.h
@@ -81,6 +81,11 @@
 return getRecord(ID).Type;
   }
 
+  /// \brief Return true if this function is a target-specific builtin
+  bool isTSBuiltin(unsigned ID) const {
+return ID >= Builtin::FirstTSBuiltin;
+  }
+
   /// \brief Return true if this function has no side effects and doesn't
   /// read memory.
   bool isConst(unsigned ID) const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D12128: Generating available_externally vtables bugfix

2015-08-18 Thread Piotr Padlewski via cfe-commits
Prazek created this revision.
Prazek added reviewers: rsmith, majnemer, rjmccall.
Prazek added a subscriber: cfe-commits.

Bugfix revealed in r245264.

http://reviews.llvm.org/D12128

Files:
  include/clang/AST/VTableBuilder.h
  lib/CodeGen/ItaniumCXXABI.cpp

Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -320,17 +320,15 @@
   void emitCXXStructor(const CXXMethodDecl *MD, StructorType Type) override;
 
  private:
-  /// Checks if function has any virtual inline function.
-  bool hasAnyVirtualInlineFunction(const CXXRecordDecl *RD) const {
+   bool hasAnyUsedVirtualInlineFunction(const CXXRecordDecl *RD) const {
 const auto &VtableLayout =
 CGM.getItaniumVTableContext().getVTableLayout(RD);
 
 for (const auto &VtableComponent : VtableLayout.vtable_components()) {
-  if (VtableComponent.getKind() !=
-  VTableComponent::Kind::CK_FunctionPointer)
+  if (!VtableComponent.isUsedFunctionPointerKind())
 continue;
 
-  const auto &Method = VtableComponent.getFunctionDecl();
+  const CXXMethodDecl *Method = VtableComponent.getFunctionDecl();
   if (Method->getCanonicalDecl()->isInlined())
 return true;
 }
@@ -1536,7 +1534,7 @@
   // then we are safe to emit available_externally copy of vtable.
   // FIXME we can still emit a copy of the vtable if we
   // can emit definition of the inline functions.
-  return !hasAnyVirtualInlineFunction(RD);
+  return !hasAnyUsedVirtualInlineFunction(RD);
 }
 static llvm::Value *performTypeAdjustment(CodeGenFunction &CGF,
   llvm::Value *Ptr,
Index: include/clang/AST/VTableBuilder.h
===
--- include/clang/AST/VTableBuilder.h
+++ include/clang/AST/VTableBuilder.h
@@ -123,29 +123,39 @@
 
   const CXXRecordDecl *getRTTIDecl() const {
 assert(getKind() == CK_RTTI && "Invalid component kind!");
-
 return reinterpret_cast(getPointer());
   }
 
   const CXXMethodDecl *getFunctionDecl() const {
-assert(getKind() == CK_FunctionPointer);
-
+assert(isFunctionPointerKind() && "Invalid component kind!");
+if (isDestructorKind())
+  return getDestructorDecl();
 return reinterpret_cast(getPointer());
   }
 
   const CXXDestructorDecl *getDestructorDecl() const {
-assert((getKind() == CK_CompleteDtorPointer ||
-getKind() == CK_DeletingDtorPointer) && "Invalid component kind!");
-
+assert(isDestructorKind() && "Invalid component kind!");
 return reinterpret_cast(getPointer());
   }
 
   const CXXMethodDecl *getUnusedFunctionDecl() const {
-assert(getKind() == CK_UnusedFunctionPointer);
-
+assert(getKind() == CK_UnusedFunctionPointer && "Invalid component kind!");
 return reinterpret_cast(getPointer());
   }
 
+  bool isDestructorKind() const {
+return getKind() == CK_CompleteDtorPointer ||
+   getKind() == CK_DeletingDtorPointer;
+  }
+
+  bool isUsedFunctionPointerKind() const {
+return getKind() == CK_FunctionPointer || isDestructorKind();
+  }
+
+  bool isFunctionPointerKind() const {
+return isUsedFunctionPointerKind() || getKind() == CK_UnusedFunctionPointer;
+  }
+
 private:
   VTableComponent(Kind ComponentKind, CharUnits Offset) {
 assert((ComponentKind == CK_VCallOffset ||
@@ -158,12 +168,8 @@
   }
 
   VTableComponent(Kind ComponentKind, uintptr_t Ptr) {
-assert((ComponentKind == CK_RTTI ||
-ComponentKind == CK_FunctionPointer ||
-ComponentKind == CK_CompleteDtorPointer ||
-ComponentKind == CK_DeletingDtorPointer ||
-ComponentKind == CK_UnusedFunctionPointer) &&
-"Invalid component kind!");
+assert((ComponentKind == CK_RTTI || isFunctionPointerKind()) &&
+   "Invalid component kind!");
 
 assert((Ptr & 7) == 0 && "Pointer not sufficiently aligned!");
 
@@ -178,11 +184,7 @@
   }
 
   uintptr_t getPointer() const {
-assert((getKind() == CK_RTTI ||
-getKind() == CK_FunctionPointer ||
-getKind() == CK_CompleteDtorPointer ||
-getKind() == CK_DeletingDtorPointer ||
-getKind() == CK_UnusedFunctionPointer) &&
+assert((getKind() == CK_RTTI || isFunctionPointerKind()) &&
"Invalid component kind!");
 
 return static_cast(Value & ~7ULL);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r245392 - unique_ptrify CXXBasePaths::DeclsFound & remove the then-unnecessary user-defined dtor

2015-08-18 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Tue Aug 18 18:56:00 2015
New Revision: 245392

URL: http://llvm.org/viewvc/llvm-project?rev=245392&view=rev
Log:
unique_ptrify CXXBasePaths::DeclsFound & remove the then-unnecessary 
user-defined dtor

Maybe this and the NumDeclsFound member should just be a std::vector
instead. (it could be a std::dynarray, but that missed standardization)

Modified:
cfe/trunk/include/clang/AST/CXXInheritance.h
cfe/trunk/lib/AST/CXXInheritance.cpp

Modified: cfe/trunk/include/clang/AST/CXXInheritance.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CXXInheritance.h?rev=245392&r1=245391&r2=245392&view=diff
==
--- cfe/trunk/include/clang/AST/CXXInheritance.h (original)
+++ cfe/trunk/include/clang/AST/CXXInheritance.h Tue Aug 18 18:56:00 2015
@@ -155,7 +155,7 @@ class CXXBasePaths {
   /// \brief Array of the declarations that have been found. This
   /// array is constructed only if needed, e.g., to iterate over the
   /// results within LookupResult.
-  NamedDecl **DeclsFound;
+  std::unique_ptr DeclsFound;
   unsigned NumDeclsFound;
   
   friend class CXXRecordDecl;
@@ -172,15 +172,12 @@ public:
   
   /// BasePaths - Construct a new BasePaths structure to record the
   /// paths for a derived-to-base search.
-  explicit CXXBasePaths(bool FindAmbiguities = true,
-bool RecordPaths = true,
+  explicit CXXBasePaths(bool FindAmbiguities = true, bool RecordPaths = true,
 bool DetectVirtual = true)
-: FindAmbiguities(FindAmbiguities), RecordPaths(RecordPaths),
-  DetectVirtual(DetectVirtual), DetectedVirtual(nullptr),
-  DeclsFound(nullptr), NumDeclsFound(0) { }
-  
-  ~CXXBasePaths() { delete [] DeclsFound; }
-  
+  : FindAmbiguities(FindAmbiguities), RecordPaths(RecordPaths),
+DetectVirtual(DetectVirtual), DetectedVirtual(nullptr),
+NumDeclsFound(0) {}
+
   paths_iterator begin() { return Paths.begin(); }
   paths_iterator end()   { return Paths.end(); }
   const_paths_iterator begin() const { return Paths.begin(); }

Modified: cfe/trunk/lib/AST/CXXInheritance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CXXInheritance.cpp?rev=245392&r1=245391&r2=245392&view=diff
==
--- cfe/trunk/lib/AST/CXXInheritance.cpp (original)
+++ cfe/trunk/lib/AST/CXXInheritance.cpp Tue Aug 18 18:56:00 2015
@@ -31,16 +31,16 @@ void CXXBasePaths::ComputeDeclsFound() {
 Decls.insert(Path->Decls.front());
 
   NumDeclsFound = Decls.size();
-  DeclsFound = new NamedDecl * [NumDeclsFound];
-  std::copy(Decls.begin(), Decls.end(), DeclsFound);
+  DeclsFound = llvm::make_unique(NumDeclsFound);
+  std::copy(Decls.begin(), Decls.end(), DeclsFound.get());
 }
 
 CXXBasePaths::decl_range CXXBasePaths::found_decls() {
   if (NumDeclsFound == 0)
 ComputeDeclsFound();
 
-  return decl_range(decl_iterator(DeclsFound),
-decl_iterator(DeclsFound + NumDeclsFound));
+  return decl_range(decl_iterator(DeclsFound.get()),
+decl_iterator(DeclsFound.get() + NumDeclsFound));
 }
 
 /// isAmbiguous - Determines whether the set of paths provided is


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


Re: [PATCH] D11682: [libcxxabi] Add "install-libcxxabi" target.

2015-08-18 Thread Chris Bieneman via cfe-commits
beanz added a comment.

The signature is:

  install(TARGETS targets... [EXPORT ]
  [[ARCHIVE|LIBRARY|RUNTIME|FRAMEWORK|BUNDLE|
PRIVATE_HEADER|PUBLIC_HEADER|RESOURCE]
   [DESTINATION ]
   [INCLUDES DESTINATION [ ...]]
   [PERMISSIONS permissions...]
   [CONFIGURATIONS [Debug|Release|...]]
   [COMPONENT ]
   [OPTIONAL] [NAMELINK_ONLY|NAMELINK_SKIP]
  ] [...])

The `|` markers between the argument values mean `OR`.

You may also note that `DESTINATION` only shows up once because only one 
occurrence of it is parsed, and it only accepts one value.

I know that the code you wrote follows a pattern that exists elsewhere in our 
CMake, I'm just saying it doesn't work, so we shouldn't introduce more 
occurrences.


http://reviews.llvm.org/D11682



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


Re: r244902 - Driver: Fix include directories when not using libgcc under mingw

2015-08-18 Thread Richard Smith via cfe-commits
On Tue, Aug 18, 2015 at 3:00 PM, Hans Wennborg via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Richard, I tried to ping you on the review thread but I'm not sure it
> got through. Martell requested this be merged to 3.7. What do you
> think?


Sure, this looks fine for branch.


> On Thu, Aug 13, 2015 at 8:41 AM, Martell Malone via cfe-commits
>  wrote:
> > Author: martell
> > Date: Thu Aug 13 10:41:04 2015
> > New Revision: 244902
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=244902&view=rev
> > Log:
> > Driver: Fix include directories when not using libgcc under mingw
> >
> > Summary:
> > When we want to use mingw-w64 and clang with compiler-rt we should not
> > need to have libgcc installed. This fixes finding includes when libgcc
> > is not installed
> >
> > Reviewers: yaron.keren
> >
> > Subscribers: cfe-commits
> >
> > Differential Revision: http://reviews.llvm.org/D11808
> >
> > Added:
> > cfe/trunk/test/Driver/Inputs/mingw_clang_tree/
> > cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/
> >
>  cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/i686-w64-mingw32/
> >
>  
> cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/i686-w64-mingw32/include/
> >
>  
> cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/i686-w64-mingw32/include/.keep
> > cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/include/
> > cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/include/.keep
> > Modified:
> > cfe/trunk/lib/Driver/MinGWToolChain.cpp
> > cfe/trunk/test/Driver/mingw.cpp
> >
> > Modified: cfe/trunk/lib/Driver/MinGWToolChain.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MinGWToolChain.cpp?rev=244902&r1=244901&r2=244902&view=diff
> >
> ==
> > --- cfe/trunk/lib/Driver/MinGWToolChain.cpp (original)
> > +++ cfe/trunk/lib/Driver/MinGWToolChain.cpp Thu Aug 13 10:41:04 2015
> > @@ -47,7 +47,7 @@ void MinGW::findGccLibDir() {
> >Archs.emplace_back(getTriple().getArchName());
> >Archs[0] += "-w64-mingw32";
> >Archs.emplace_back("mingw32");
> > -  Arch = "unknown";
> > +  Arch = Archs[0].str();
> >// lib: Arch Linux, Ubuntu, Windows
> >// lib64: openSUSE Linux
> >for (StringRef CandidateLib : {"lib", "lib64"}) {
> >
> > Added:
> cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/i686-w64-mingw32/include/.keep
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/i686-w64-mingw32/include/.keep?rev=244902&view=auto
> >
> ==
> > (empty)
> >
> > Added:
> cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/include/.keep
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/include/.keep?rev=244902&view=auto
> >
> ==
> > (empty)
> >
> > Modified: cfe/trunk/test/Driver/mingw.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mingw.cpp?rev=244902&r1=244901&r2=244902&view=diff
> >
> ==
> > --- cfe/trunk/test/Driver/mingw.cpp (original)
> > +++ cfe/trunk/test/Driver/mingw.cpp Thu Aug 13 10:41:04 2015
> > @@ -1,3 +1,8 @@
> > +// RUN: %clang -target i686-windows-gnu -c -###
> --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck
> -check-prefix=CHECK_MINGW_CLANG_TREE %s
> > +// CHECK_MINGW_CLANG_TREE:
> "{{.*}}/Inputs/mingw_clang_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include"
> > +// CHECK_MINGW_CLANG_TREE:
> "{{.*}}/Inputs/mingw_clang_tree/mingw32{{/|}}include"
> > +
> > +
> >  // RUN: %clang -target i686-pc-windows-gnu -stdlib=libstdc++ -c -###
> --sysroot=%S/Inputs/mingw_mingw_org_tree/mingw %s 2>&1 | FileCheck
> -check-prefix=CHECK_MINGW_ORG_TREE %s
> >  // CHECK_MINGW_ORG_TREE:
> "{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++"
> >  // CHECK_MINGW_ORG_TREE:
> "{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++{{/|}}mingw32"
> >
> >
> > ___
> > 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


Re: [PATCH] D12122: [CUDA] Add appropriate host/device attribute to target-specific builtins.

2015-08-18 Thread Artem Belevich via cfe-commits
tra updated this revision to Diff 32478.
tra marked an inline comment as done.
tra added a comment.

used isTSBuiltin in SemaChecking.cpp


http://reviews.llvm.org/D12122

Files:
  include/clang/Basic/Builtins.h
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDecl.cpp
  test/SemaCUDA/builtins.cu
  test/SemaCUDA/implicit-intrinsic.cu

Index: test/SemaCUDA/implicit-intrinsic.cu
===
--- test/SemaCUDA/implicit-intrinsic.cu
+++ test/SemaCUDA/implicit-intrinsic.cu
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -std=gnu++11 -triple nvptx64-unknown-unknown -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -fcuda-is-device -fsyntax-only -verify %s
 
 #include "Inputs/cuda.h"
 
 // expected-no-diagnostics
 __device__ void __threadfence_system() {
-  // This shouldn't produce an error, since __nvvm_membar_sys is inferred to
-  // be __host__ __device__ and thus callable from device code.
+  // This shouldn't produce an error, since __nvvm_membar_sys should be
+  // __device__ and thus callable from device code.
   __nvvm_membar_sys();
 }
Index: test/SemaCUDA/builtins.cu
===
--- /dev/null
+++ test/SemaCUDA/builtins.cu
@@ -0,0 +1,35 @@
+// Tests that target-specific builtins have appropriate host/device
+// attributes and that CUDA call restrictions are enforced. Also
+// verify that non-target builtins can be used from both host and
+// device functions.
+//
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple nvptx64-unknown-cuda -fcuda-is-device \
+// RUN:   -fsyntax-only -verify %s
+
+
+#ifdef __CUDA_ARCH__
+// Device-side builtins are not allowed to be called from host functions.
+void hf() {
+  int x = __builtin_ptx_read_tid_x(); // expected-note  {{'__builtin_ptx_read_tid_x' declared here}}
+  // expected-error@-1 {{reference to __device__ function '__builtin_ptx_read_tid_x' in __host__ function}}
+  x = __builtin_abs(1);
+}
+__attribute__((device)) void df() {
+  int x = __builtin_ptx_read_tid_x();
+  x = __builtin_abs(1);
+}
+#else
+// Host-side builtins are not allowed to be called from device functions.
+__attribute__((device)) void df() {
+  int x = __builtin_ia32_rdtsc();   // expected-note {{'__builtin_ia32_rdtsc' declared here}}
+  // expected-error@-1 {{reference to __host__ function '__builtin_ia32_rdtsc' in __device__ function}}
+  x = __builtin_abs(1);
+}
+void hf() {
+  int x = __builtin_ia32_rdtsc();
+  x = __builtin_abs(1);
+}
+#endif
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -11161,6 +11161,13 @@
   FD->addAttr(NoThrowAttr::CreateImplicit(Context, FD->getLocation()));
 if (Context.BuiltinInfo.isConst(BuiltinID) && !FD->hasAttr())
   FD->addAttr(ConstAttr::CreateImplicit(Context, FD->getLocation()));
+if (getLangOpts().CUDA && Context.BuiltinInfo.isTSBuiltin(BuiltinID) &&
+!FD->hasAttr() && !FD->hasAttr()) {
+  if (getLangOpts().CUDAIsDevice)
+FD->addAttr(CUDADeviceAttr::CreateImplicit(Context, FD->getLocation()));
+  else
+FD->addAttr(CUDAHostAttr::CreateImplicit(Context, FD->getLocation()));
+}
   }
 
   IdentifierInfo *Name = FD->getIdentifier();
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -525,7 +525,7 @@
 
   // Since the target specific builtins for each arch overlap, only check those
   // of the arch we are compiling for.
-  if (BuiltinID >= Builtin::FirstTSBuiltin) {
+  if (Context.BuiltinInfo.isTSBuiltin(BuiltinID)) {
 switch (Context.getTargetInfo().getTriple().getArch()) {
   case llvm::Triple::arm:
   case llvm::Triple::armeb:
Index: include/clang/Basic/Builtins.h
===
--- include/clang/Basic/Builtins.h
+++ include/clang/Basic/Builtins.h
@@ -81,6 +81,11 @@
 return getRecord(ID).Type;
   }
 
+  /// \brief Return true if this function is a target-specific builtin
+  bool isTSBuiltin(unsigned ID) const {
+return ID >= Builtin::FirstTSBuiltin;
+  }
+
   /// \brief Return true if this function has no side effects and doesn't
   /// read memory.
   bool isConst(unsigned ID) const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12110: [SemaExpr] Re-enable missing assertion

2015-08-18 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.
rsmith added a comment.

LGTM


http://reviews.llvm.org/D12110



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


Re: r245352 - Workaround -Wdeprecated on SemDiagnosticConsumer's tricksy copy ctor.

2015-08-18 Thread Richard Smith via cfe-commits
On Tue, Aug 18, 2015 at 2:03 PM, David Blaikie  wrote:

> Richard, do you think there's anything we could do better here?
>
> It seems difficult to support proper move semantic behavior for
> [Sema]DiagnosticBuilder across the two common use cases:
>
>   DiagnosticBuilder D;
>   D << x;
>   D << y;
>   return D;
>
> and
>
>   return DiagnosticBuilder() << x << y;
>

Do we actually use this form to return a DiagnosticBuilder, or just to
construct an ActionResult? Can we eliminate uses of this form?


> The only thing I can imagine is if every one of those op<< were function
> templates using universal references (I forget, is that the right name for
> them?) and matching their return value (so in the first case, passed a
> non-const lvalue ref, they return by non-const lvalue ref, and in the
> second case, passed an rvalue, they return the same). But that seems
> painful.
>

It seems tricky to form an unambiguous overload set for this that preserves
the value category, without duplicating all the operator< On Tue, Aug 18, 2015 at 1:54 PM, David Blaikie via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: dblaikie
>> Date: Tue Aug 18 15:54:26 2015
>> New Revision: 245352
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=245352&view=rev
>> Log:
>> Workaround -Wdeprecated on SemDiagnosticConsumer's tricksy copy ctor.
>>
>> Modified:
>> cfe/trunk/include/clang/Sema/Sema.h
>>
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=245352&r1=245351&r2=245352&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>> +++ cfe/trunk/include/clang/Sema/Sema.h Tue Aug 18 15:54:26 2015
>> @@ -1054,6 +1054,14 @@ public:
>>  SemaDiagnosticBuilder(DiagnosticBuilder &DB, Sema &SemaRef, unsigned
>> DiagID)
>>: DiagnosticBuilder(DB), SemaRef(SemaRef), DiagID(DiagID) { }
>>
>> +// This is a cunning lie. DiagnosticBuilder actually performs move
>> +// construction in its copy constructor (but due to varied uses,
>> it's not
>> +// possible to conveniently express this as actual move
>> construction). So
>> +// the default copy ctor here is fine, because the base class
>> disables the
>> +// source anyway, so the user-defined ~SemaDiagnosticBuilder is a
>> safe no-op
>> +// in that case anwyay.
>> +SemaDiagnosticBuilder(const SemaDiagnosticBuilder&) = default;
>> +
>>  ~SemaDiagnosticBuilder() {
>>// If we aren't active, there is nothing to do.
>>if (!isActive()) return;
>>
>>
>> ___
>> 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


r245390 - [modules] Fix HeaderFileInfo serialization to store all the known owning modules for a header, not just the current favourite.

2015-08-18 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Aug 18 18:42:23 2015
New Revision: 245390

URL: http://llvm.org/viewvc/llvm-project?rev=245390&view=rev
Log:
[modules] Fix HeaderFileInfo serialization to store all the known owning 
modules for a header, not just the current favourite.

Modified:
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=245390&r1=245389&r2=245390&view=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Tue Aug 18 18:42:23 2015
@@ -49,7 +49,8 @@ struct HeaderFileInfo {
   /// SrcMgr::CharacteristicKind.
   unsigned DirInfo : 2;
 
-  /// \brief Whether this header file info was supplied by an external source.
+  /// \brief Whether this header file info was supplied by an external source,
+  /// and has not changed since.
   unsigned External : 1;
 
   /// \brief Whether this header is part of a module.
@@ -58,10 +59,6 @@ struct HeaderFileInfo {
   /// \brief Whether this header is part of the module that we are building.
   unsigned isCompilingModuleHeader : 1;
 
-  /// \brief Whether this header is part of the module that we are building.
-  /// This is an instance of ModuleMap::ModuleHeaderRole.
-  unsigned HeaderRole : 2;
-  
   /// \brief Whether this structure is considered to already have been
   /// "resolved", meaning that it was loaded from the external source.
   unsigned Resolved : 1;
@@ -75,7 +72,7 @@ struct HeaderFileInfo {
   /// those framework headers.
   unsigned IndexHeaderMapHeader : 1;
 
-  /// \brief Whether this file had been looked up as a header.
+  /// \brief Whether this file has been looked up as a header.
   unsigned IsValid : 1;
   
   /// \brief The number of times the file has been included already.
@@ -105,7 +102,6 @@ struct HeaderFileInfo {
   HeaderFileInfo()
 : isImport(false), isPragmaOnce(false), DirInfo(SrcMgr::C_User), 
   External(false), isModuleHeader(false), isCompilingModuleHeader(false),
-  HeaderRole(ModuleMap::NormalHeader),
   Resolved(false), IndexHeaderMapHeader(false), IsValid(0),
   NumIncludes(0), ControllingMacroID(0), ControllingMacro(nullptr)  {}
 
@@ -120,16 +116,6 @@ struct HeaderFileInfo {
 return isImport || isPragmaOnce || NumIncludes || ControllingMacro || 
   ControllingMacroID;
   }
-
-  /// \brief Get the HeaderRole properly typed.
-  ModuleMap::ModuleHeaderRole getHeaderRole() const {
-return static_cast(HeaderRole);
-  }
-
-  /// \brief Set the HeaderRole properly typed.
-  void setHeaderRole(ModuleMap::ModuleHeaderRole Role) {
-HeaderRole = Role;
-  }
 };
 
 /// \brief An external source of header file information, which may supply
@@ -189,7 +175,7 @@ class HeaderSearch {
   
   /// \brief All of the preprocessor-specific data about files that are
   /// included, indexed by the FileEntry's UID.
-  std::vector FileInfo;
+  mutable std::vector FileInfo;
 
   /// Keeps track of each lookup performed by LookupFile.
   struct LookupFileCacheInfo {
@@ -575,20 +561,20 @@ private:
   /// of the given search directory.
   void loadSubdirectoryModuleMaps(DirectoryLookup &SearchDir);
 
-  /// \brief Return the HeaderFileInfo structure for the specified FileEntry.
-  const HeaderFileInfo &getFileInfo(const FileEntry *FE) const {
-return const_cast(this)->getFileInfo(FE);
-  }
-
 public:
   /// \brief Retrieve the module map.
   ModuleMap &getModuleMap() { return ModMap; }
   
+  /// \brief Retrieve the module map.
+  const ModuleMap &getModuleMap() const { return ModMap; }
+  
   unsigned header_file_size() const { return FileInfo.size(); }
 
-  /// \brief Get a \c HeaderFileInfo structure for the specified \c FileEntry,
-  /// if one exists.
-  bool tryGetFileInfo(const FileEntry *FE, HeaderFileInfo &Result) const;
+  /// \brief Return the HeaderFileInfo structure for the specified FileEntry.
+  HeaderFileInfo &getFileInfo(const FileEntry *FE);
+
+  /// \brief Return the HeaderFileInfo structure for the specified FileEntry.
+  const HeaderFileInfo *getExistingFileInfo(const FileEntry *FE) const;
 
   // Used by external tools
   typedef std::vector::const_iterator search_dir_iterator;
@@ -665,9 +651,6 @@ private:
   /// named directory.
   LoadModuleMapResult loadModuleMapFile(const DirectoryEntry *Dir,
 bool IsSystem, bool IsFramework);
-
-  /// \brief Return the HeaderFileInfo structure for the specified FileEntry.
-  HeaderFileInfo &getFileInfo(const FileEntry *FE);
 };
 
 }  // end namespace clang

Modified: cfe/trunk/include/clang/Lex/

r245391 - [modules] Tests for r245390.

2015-08-18 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Aug 18 18:42:50 2015
New Revision: 245391

URL: http://llvm.org/viewvc/llvm-project?rev=245391&view=rev
Log:
[modules] Tests for r245390.

Added:
cfe/trunk/test/Modules/Inputs/explicit-build-overlap/
cfe/trunk/test/Modules/Inputs/explicit-build-overlap/a.h
cfe/trunk/test/Modules/Inputs/explicit-build-overlap/b.h
cfe/trunk/test/Modules/Inputs/explicit-build-overlap/def.map
cfe/trunk/test/Modules/Inputs/explicit-build-overlap/use.map
cfe/trunk/test/Modules/explicit-build-overlap.cpp

Added: cfe/trunk/test/Modules/Inputs/explicit-build-overlap/a.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/explicit-build-overlap/a.h?rev=245391&view=auto
==
--- cfe/trunk/test/Modules/Inputs/explicit-build-overlap/a.h (added)
+++ cfe/trunk/test/Modules/Inputs/explicit-build-overlap/a.h Tue Aug 18 
18:42:50 2015
@@ -0,0 +1 @@
+struct A {};

Added: cfe/trunk/test/Modules/Inputs/explicit-build-overlap/b.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/explicit-build-overlap/b.h?rev=245391&view=auto
==
--- cfe/trunk/test/Modules/Inputs/explicit-build-overlap/b.h (added)
+++ cfe/trunk/test/Modules/Inputs/explicit-build-overlap/b.h Tue Aug 18 
18:42:50 2015
@@ -0,0 +1 @@
+struct B {};

Added: cfe/trunk/test/Modules/Inputs/explicit-build-overlap/def.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/explicit-build-overlap/def.map?rev=245391&view=auto
==
--- cfe/trunk/test/Modules/Inputs/explicit-build-overlap/def.map (added)
+++ cfe/trunk/test/Modules/Inputs/explicit-build-overlap/def.map Tue Aug 18 
18:42:50 2015
@@ -0,0 +1,2 @@
+module a { textual header "a.h" }
+module b { header "a.h" header "b.h" }

Added: cfe/trunk/test/Modules/Inputs/explicit-build-overlap/use.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/explicit-build-overlap/use.map?rev=245391&view=auto
==
--- cfe/trunk/test/Modules/Inputs/explicit-build-overlap/use.map (added)
+++ cfe/trunk/test/Modules/Inputs/explicit-build-overlap/use.map Tue Aug 18 
18:42:50 2015
@@ -0,0 +1,3 @@
+module "use" {
+  use a
+}

Added: cfe/trunk/test/Modules/explicit-build-overlap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/explicit-build-overlap.cpp?rev=245391&view=auto
==
--- cfe/trunk/test/Modules/explicit-build-overlap.cpp (added)
+++ cfe/trunk/test/Modules/explicit-build-overlap.cpp Tue Aug 18 18:42:50 2015
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x c++ -fmodules   
%S/Inputs/explicit-build-overlap/def.map -fmodule-name=a -emit-module -o 
%t/a.pcm
+// RUN: %clang_cc1 -x c++ -fmodules   
%S/Inputs/explicit-build-overlap/def.map -fmodule-name=b -emit-module -o 
%t/ba.pcm -fmodule-file=%t/a.pcm
+// RUN: %clang_cc1 -x c++ -fmodules 
-fmodule-map-file=%S/Inputs/explicit-build-overlap/use.map -fmodule-name=use 
-fmodule-file=%t/ba.pcm %s -verify -I%S/Inputs/explicit-build-overlap 
-fmodules-decluse
+//
+// RUN: %clang_cc1 -x c++ -fmodules   
%S/Inputs/explicit-build-overlap/def.map -fmodule-name=b -emit-module -o 
%t/b.pcm
+// RUN: %clang_cc1 -x c++ -fmodules   
%S/Inputs/explicit-build-overlap/def.map -fmodule-name=a -emit-module -o 
%t/ab.pcm -fmodule-file=%t/b.pcm
+// RUN: %clang_cc1 -x c++ -fmodules 
-fmodule-map-file=%S/Inputs/explicit-build-overlap/use.map -fmodule-name=use 
-fmodule-file=%t/ab.pcm %s -verify -I%S/Inputs/explicit-build-overlap 
-fmodules-decluse
+
+// expected-no-diagnostics
+#include "a.h"
+
+A a;
+B b;


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


Re: [PATCH] D12123: [analyzer] Skip Pre/Post handlers for ObjC calls when receiver is nil.

2015-08-18 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

Looks good to me. There are some minor nits inline.



Comment at: include/clang/StaticAnalyzer/Core/CheckerManager.h:96
@@ -95,1 +95,3 @@
 
+enum class ObjCCheckerKind {
+  PreVisit,

I do not really like the name ObjCCheckerKind, because it is not kind of an 
Obj-C related checker. It is the kind of the visit of the message expression. 
Maybe ObjCMessageVisitKind? Or just MessageVisitKind to be a bit shorter?


Comment at: lib/StaticAnalyzer/Core/ExprEngineObjC.cpp:153
@@ +152,3 @@
+  ProgramStateRef notNilState, nilState;
+  std::tie(notNilState, nilState) = State->assume(receiverVal);
+  if (nilState && !notNilState) {

The old code had a comment about merging two cases and a reference to a rdar. 
Is that rdar already fixed? Maybe it would be good to preserve the at least the 
first part of the commend?


http://reviews.llvm.org/D12123



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


Re: [PATCH] D11682: [libcxxabi] Add "install-libcxxabi" target.

2015-08-18 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Followup on @beanz comments.



Comment at: src/CMakeLists.txt:123
@@ -124,1 +122,3 @@
+  LIBRARY DESTINATION lib${LIBCXXABI_LIBDIR_SUFFIX} COMPONENT libcxxabi
+  ARCHIVE DESTINATION lib${LIBCXXABI_LIBDIR_SUFFIX} COMPONENT libcxxabi
   )

beanz wrote:
> You should not specify both ARCHIVE and LIBRARY in the same install command. 
> One of the two will be ignored. As per the documentation 
> (http://www.cmake.org/cmake/help/v3.0/command/install.html).
> 
> You will need to do something similar to what is done in 
> AddLLVM.cmake:507-520.
I don't see where in the documentation that it says you can't use ARCHIVE and 
LIBRARY in the same install command. Could you be more explicit?


http://reviews.llvm.org/D11682



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


[libcxx] r245389 - [libcxx] Add Atomic test helper and fix TSAN failures.

2015-08-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Aug 18 18:29:59 2015
New Revision: 245389

URL: http://llvm.org/viewvc/llvm-project?rev=245389&view=rev
Log:
[libcxx] Add Atomic test helper and fix TSAN failures.

Summary:
This patch attempts to fix the last 3 TSAN failures on the libc++ bot 
(http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-tsan/builds/143).
 This patch also adds a `Atomic` test type that can be used where `` 
cannot.

`wait.exception.pass.cpp` and `wait_for.exception.pass.cpp` were failing 
because the test replaced `std::terminate` with `std::exit`. `std::exit` would 
asynchronously run the TLS and static destructors and this would cause a race 
condition. See PR22606 and D8802 for more details. 

This is fixed by using `_Exit` to prevent cleanup.

`notify_all_at_thread_exit.pass.cpp` exercises the same race condition but for 
different reasons. I fixed this test by manually joining the thread before 
beginning program termination.

Reviewers: EricWF, mclow.lists

Subscribers: cfe-commits

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

Added:

libcxx/trunk/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp
libcxx/trunk/test/support/test_atomic.h
Removed:

libcxx/trunk/test/std/thread/thread.condition/thread.condition.condvarany/wait.exception.pass.cpp

libcxx/trunk/test/std/thread/thread.condition/thread.condition.condvarany/wait_for.exception.pass.cpp
Modified:

libcxx/trunk/test/std/thread/thread.condition/notify_all_at_thread_exit.pass.cpp

libcxx/trunk/test/std/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp

libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp

libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp

Modified: 
libcxx/trunk/test/std/thread/thread.condition/notify_all_at_thread_exit.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.condition/notify_all_at_thread_exit.pass.cpp?rev=245389&r1=245388&r2=245389&view=diff
==
--- 
libcxx/trunk/test/std/thread/thread.condition/notify_all_at_thread_exit.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/thread/thread.condition/notify_all_at_thread_exit.pass.cpp
 Tue Aug 18 18:29:59 2015
@@ -36,9 +36,10 @@ void func()
 int main()
 {
 std::unique_lock lk(mut);
-std::thread(func).detach();
+std::thread t(func);
 Clock::time_point t0 = Clock::now();
 cv.wait(lk);
 Clock::time_point t1 = Clock::now();
 assert(t1-t0 > ms(250));
+t.join();
 }

Modified: 
libcxx/trunk/test/std/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp?rev=245389&r1=245388&r2=245389&view=diff
==
--- 
libcxx/trunk/test/std/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp
 Tue Aug 18 18:29:59 2015
@@ -20,12 +20,13 @@
 #include 
 #include 
 
+#include "test_atomic.h"
+
 std::condition_variable cv;
 std::mutex mut;
 
-int test0 = 0;
-int test1 = 0;
-int test2 = 0;
+AtomicInt test1(0);
+AtomicInt test2(0);
 
 void f1()
 {
@@ -64,11 +65,13 @@ int main()
 }
 if (test1 == 2)
 {
+assert(test2 == 1);
 t1.join();
 test1 = 0;
 }
 else if (test2 == 2)
 {
+assert(test1 == 1);
 t2.join();
 test2 = 0;
 }
@@ -81,11 +84,13 @@ int main()
 }
 if (test1 == 2)
 {
+assert(test2 == 0);
 t1.join();
 test1 = 0;
 }
 else if (test2 == 2)
 {
+assert(test1 == 0);
 t2.join();
 test2 = 0;
 }

Removed: 
libcxx/trunk/test/std/thread/thread.condition/thread.condition.condvarany/wait.exception.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.condition/thread.condition.condvarany/wait.exception.pass.cpp?rev=245388&view=auto
==
--- 
libcxx/trunk/test/std/thread/thread.condition/thread.condition.condvarany/wait.exception.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/thread/thread.condition/thread.condition.condvarany/wait.exception.pass.cpp
 (removed)
@@ -1,63 +0,0 @@
-//===--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
-
-#i

Re: r244488 - [dllimport] A non-imported class with an imported key can't have a key

2015-08-18 Thread Hans Wennborg via cfe-commits
Awesome, thanks!

On Tue, Aug 18, 2015 at 4:27 PM, Reid Kleckner  wrote:
> I merged both of them and tweaked the test case to make it work.
>
> On Tue, Aug 18, 2015 at 2:55 PM, Hans Wennborg  wrote:
>>
>> On Tue, Aug 11, 2015 at 9:40 AM, Hans Wennborg  wrote:
>> > On Mon, Aug 10, 2015 at 12:39 PM, Reid Kleckner via cfe-commits
>> >  wrote:
>> >> Author: rnk
>> >> Date: Mon Aug 10 14:39:01 2015
>> >> New Revision: 244488
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=244488&view=rev
>> >> Log:
>> >> [dllimport] A non-imported class with an imported key can't have a key
>> >>
>> >> Summary:
>> >> The vtable takes its DLL storage class from the class, not the key
>> >> function. When they disagree, the vtable won't be exported by the DLL
>> >> that defines the key function. The easiest way to ensure that importers
>> >> of the class emit their own vtable is to say that the class has no key
>> >> function.
>> >>
>> >> Reviewers: hans, majnemer
>> >>
>> >> Subscribers: cfe-commits
>> >>
>> >> Differential Revision: http://reviews.llvm.org/D11913
>> >
>> > Should we merge this and r244266 to 3.7?
>>
>> As pointed out on the r244266 thread, these patches are still not
>> merged as the tests don't pass on 3.7. I was hoping someone more
>> familiar with the patches could take a look.
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r244488 - [dllimport] A non-imported class with an imported key can't have a key

2015-08-18 Thread Reid Kleckner via cfe-commits
I merged both of them and tweaked the test case to make it work.

On Tue, Aug 18, 2015 at 2:55 PM, Hans Wennborg  wrote:

> On Tue, Aug 11, 2015 at 9:40 AM, Hans Wennborg  wrote:
> > On Mon, Aug 10, 2015 at 12:39 PM, Reid Kleckner via cfe-commits
> >  wrote:
> >> Author: rnk
> >> Date: Mon Aug 10 14:39:01 2015
> >> New Revision: 244488
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=244488&view=rev
> >> Log:
> >> [dllimport] A non-imported class with an imported key can't have a key
> >>
> >> Summary:
> >> The vtable takes its DLL storage class from the class, not the key
> >> function. When they disagree, the vtable won't be exported by the DLL
> >> that defines the key function. The easiest way to ensure that importers
> >> of the class emit their own vtable is to say that the class has no key
> >> function.
> >>
> >> Reviewers: hans, majnemer
> >>
> >> Subscribers: cfe-commits
> >>
> >> Differential Revision: http://reviews.llvm.org/D11913
> >
> > Should we merge this and r244266 to 3.7?
>
> As pointed out on the r244266 thread, these patches are still not
> merged as the tests don't pass on 3.7. I was hoping someone more
> familiar with the patches could take a look.
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11046: [libcxx] Add Atomic test helper and fix TSAN failures.

2015-08-18 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 32473.
EricWF added a comment.

Fix more failing TSAN tests.


http://reviews.llvm.org/D11046

Files:
  test/std/thread/thread.condition/notify_all_at_thread_exit.pass.cpp
  test/std/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp
  
test/std/thread/thread.condition/thread.condition.condvarany/wait.exception.pass.cpp
  
test/std/thread/thread.condition/thread.condition.condvarany/wait_for.exception.pass.cpp
  
test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp
  
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
  
test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp
  test/support/test_atomic.h

Index: test/support/test_atomic.h
===
--- /dev/null
+++ test/support/test_atomic.h
@@ -0,0 +1,109 @@
+#ifndef SUPPORT_TEST_ATOMIC_H
+#define SUPPORT_TEST_ATOMIC_H
+
+// If the atomic memory order macros are defined then assume
+// the compiler supports the required atomic builtins.
+#if !defined(__ATOMIC_SEQ_CST)
+#define TEST_HAS_NO_ATOMICS
+#endif
+
+template 
+class Atomic {
+   ValType value;
+   Atomic(Atomic const&);
+   Atomic& operator=(Atomic const&);
+   Atomic& operator=(Atomic const&) volatile;
+private:
+  enum {
+#if !defined(TEST_HAS_NO_ATOMICS)
+AO_Relaxed = __ATOMIC_RELAXED,
+AO_Seq = __ATOMIC_SEQ_CST
+#else
+AO_Relaxed,
+AO_Seq
+#endif
+  };
+  template 
+  static inline void atomic_store_imp(Tp* dest, FromType from, int order = AO_Seq) {
+#if !defined(TEST_HAS_NO_ATOMICS)
+  __atomic_store_n(dest, from, order);
+#else
+*dest = from;
+#endif
+  }
+
+  template 
+  static inline Tp atomic_load_imp(Tp* from, int order = AO_Seq) {
+#if !defined(TEST_HAS_NO_ATOMICS)
+return __atomic_load_n(from, order);
+#else
+return *from;
+#endif
+  }
+
+  template 
+  static inline Tp atomic_add_imp(Tp* val, AddType add, int order = AO_Seq) {
+#if !defined(TEST_HAS_NO_ATOMICS)
+  return __atomic_add_fetch(val, add, order);
+#else
+return *val += add;
+#endif
+  }
+
+  template 
+  static inline Tp atomic_exchange_imp(Tp* val, Tp other, int order = AO_Seq) {
+#if !defined(TEST_HAS_NO_ATOMICS)
+  return __atomic_exchange_n(val, other, order);
+#else
+  Tp old = *val;
+  *val = other;
+  return old;
+#endif
+  }
+public:
+Atomic() : value(0) {}
+Atomic(ValType x) : value(x) {}
+
+ValType operator=(ValType val) {
+   atomic_store_imp(&value, val);
+   return val;
+}
+
+ValType operator=(ValType val) volatile {
+atomic_store_imp(&value, val);
+return val;
+}
+
+ValType load() const volatile { return atomic_load_imp(&value); }
+voidstore(ValType val) volatile { atomic_store_imp(&value, val); }
+
+ValType relaxedLoad() const volatile { return atomic_load_imp(&value, AO_Relaxed); }
+voidrelaxedStore(ValType val) volatile { atomic_store_imp(&value, val, AO_Relaxed); }
+
+ValType exchange(ValType other) volatile { return atomic_exchange_imp(&value, other); }
+booltestAndSet() volatile { return atomic_exchange_imp(&value, 1); }
+voidclear() volatile { atomic_store_imp(&value, 0); }
+
+operator ValType() const { return atomic_load_imp(&value); }
+operator ValType() const volatile { return atomic_load_imp(&value); }
+
+ValType operator+=(ValType val)  { return atomic_add_imp(&value, val); }
+ValType operator-=(ValType val)  { return atomic_add_imp(&value, -val); }
+ValType operator+=(ValType val) volatile { return atomic_add_imp(&value, val); }
+ValType operator-=(ValType val) volatile { return atomic_add_imp(&value, -val); }
+
+ValType operator++()  { return *this += 1; }
+ValType operator++(int) { return (*this += 1) - 1;  }
+ValType operator++() volatile { return *this += 1; }
+ValType operator++(int) volatile { return (*this += 1) - 1;  }
+
+ValType operator--() { return *this -= 1; }
+ValType operator--(int) { return (*this -= 1) + 1; }
+ValType operator--() volatile { return *this -= 1; }
+ValType operator--(int) volatile { return (*this -= 1) + 1; }
+};
+
+typedef Atomic AtomicInt;
+typedef Atomic AtomicBool;
+
+#endif // SUPPORT_TEST_ATOMIC_H
Index: test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp
===
--- test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp
+++ test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp
@@ -9,8 +9,6 @@
 //
 // UNSUPPORTED: libcpp-has-no-threads
 
-// NOTE: TSAN will report this test as leaking a thread.
-// XFAIL: tsan
 
 // 
 
@@ -47,7 +45,7 @@
 
 void f1()
 {
-std::exit(0);
+std::_Exit(0);
 }
 
 int main()
Index: test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
==

Re: [PATCH] D12122: [CUDA] Add appropriate host/device attribute to target-specific builtins.

2015-08-18 Thread Eli Bendersky via cfe-commits
eliben added inline comments.


Comment at: include/clang/Basic/Builtins.h:85
@@ +84,3 @@
+  /// \brief Return true if this function is a target-specific builtin
+  bool isTSBuiltin(unsigned ID) const {
+return ID >= Builtin::FirstTSBuiltin;

You can also use it in SemaChecking now


Comment at: lib/Sema/SemaDecl.cpp:11166
@@ +11165,3 @@
+!FD->hasAttr() && !FD->hasAttr()) {
+  if (getLangOpts().CUDAIsDevice)
+FD->addAttr(CUDADeviceAttr::CreateImplicit(Context, 
FD->getLocation()));

It is not immediately clear why you would mark target-specific builtins as 
__host__ in host compilation mode. So for example __builtin_ptx_read_tid_x 
would be callable from a host function when compiling in host mode? Can you 
clarify this with a comment here, and also add a relevant test?


http://reviews.llvm.org/D12122



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


Re: r244266 - [ItaniumCXXABI] Don't import RTTI data for classes with key functions

2015-08-18 Thread Reid Kleckner via cfe-commits
On Tue, Aug 18, 2015 at 3:00 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Fri, Aug 14, 2015 at 11:27 AM, Hans Wennborg via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> On Tue, Aug 11, 2015 at 1:41 PM, Hans Wennborg  wrote:
>> > On Thu, Aug 6, 2015 at 1:56 PM, David Majnemer via cfe-commits
>> >  wrote:
>> >> Author: majnemer
>> >> Date: Thu Aug  6 15:56:55 2015
>> >> New Revision: 244266
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=244266&view=rev
>> >> Log:
>> >> [ItaniumCXXABI] Don't import RTTI data for classes with key functions
>> >>
>> >> MinGW has some pretty strange behvaior around RTTI and
>> >> dllimport/dllexport:
>> >> - RTTI data is never imported
>> >> - RTTI data is only exported if the class has no key function.
>> >>
>> >> Modified:
>> >> cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
>> >> cfe/trunk/test/CodeGenCXX/dllimport-rtti.cpp
>> >
>> > I tried to merge this to 3.7 (as discussed on the commit thread for
>> > r244488), but the test doesn't pass:
>> >
>> > --
>> >
>> /usr/local/google/work/llvm-3.7/cfe.src/test/CodeGenCXX/dllimport-rtti.cpp:22:13:
>> > error: expected string not found in input
>> > // GNU-DAG: @_ZTV1V = available_externally dllimport
>> > ^
>> > :1:1: note: scanning from here
>> > ; ModuleID =
>> '/usr/local/google/work/llvm-3.7/cfe.src/test/CodeGenCXX/dllimport-rtti.cpp'
>> > ^
>> > :15:1: note: possible intended match here
>> > @_ZTV1S = available_externally dllimport unnamed_addr constant [3 x
>> > i8*] [i8* null, i8* bitcast (i8** @_ZTI1S to i8*), i8* bitcast (void
>> > (%struct.S*)* @_ZN1S1fEv to i8*)], align 4
>> > ^
>> > --
>> >
>> > I assume there's some other commit this depends on, but I haven't been
>> > able to figure out which. Can you take a look?
>>
>> Ping?
>>
>
> Looks like the test depends on r243090, which shouldn't go to the branch.
> I'd guess we could fix the test by changing that check line to "// GNU-DAG:
> @_ZTV1V = external" or similar. David?
>

external linkage works as long as it's still dllimport. I was just about to
give this a shot myself.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12123: [analyzer] Skip Pre/Post handlers for ObjC calls when receiver is nil.

2015-08-18 Thread Ted Kremenek via cfe-commits
krememek added a subscriber: krememek.
krememek added a comment.

I think this is a great refinement overall, with a few minor nits.  It also 
isn't clear what the test does.



Comment at: include/clang/StaticAnalyzer/Core/CheckerManager.h:577
@@ -559,1 +576,3 @@
 
+  const std::vector &
+  getObjCMessageCheckers(ObjCCheckerKind Kind);

Can we break with tradition here and add a documentation comment?


Comment at: lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp:64
@@ -62,2 +63,3 @@
   void checkPreObjCMessage(const ObjCMethodCall &msg, CheckerContext &C) const;
+  void checkObjCMessageNil(const ObjCMethodCall &msg, CheckerContext &C) const;
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;

Can we break with tradition here and actually add a small documentation comment?


Comment at: test/Analysis/NSContainers.m:297
@@ -294,1 +296,3 @@
 
+@interface MyView : NSObject
+-(NSArray *)subviews;

Can we add a comment above this test that makes it clear what this test is 
doing?  It is not obvious at all from basic inspection.

There's also no matching 'no-warning' or 'expected-warning', so it is not clear 
at all what it is testing.  Having the comment clearly say what the test is 
testing will make it more resilient to somebody accidentally deleting it.


http://reviews.llvm.org/D12123



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


r245378 - Devirtualize EHScopeStack::Cleanup's dtor because it's never destroyed polymorphically

2015-08-18 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Tue Aug 18 17:40:54 2015
New Revision: 245378

URL: http://llvm.org/viewvc/llvm-project?rev=245378&view=rev
Log:
Devirtualize EHScopeStack::Cleanup's dtor because it's never destroyed 
polymorphically

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/EHScopeStack.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=245378&r1=245377&r2=245378&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Tue Aug 18 17:40:54 2015
@@ -2239,7 +2239,7 @@ void CodeGenFunction::BuildBlockRelease(
 }
 
 namespace {
-  struct CallBlockRelease : EHScopeStack::Cleanup {
+  struct CallBlockRelease final : EHScopeStack::Cleanup {
 llvm::Value *Addr;
 CallBlockRelease(llvm::Value *Addr) : Addr(Addr) {}
 

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=245378&r1=245377&r2=245378&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Aug 18 17:40:54 2015
@@ -2851,7 +2851,7 @@ void CodeGenFunction::EmitCallArgs(
 
 namespace {
 
-struct DestroyUnpassedArg : EHScopeStack::Cleanup {
+struct DestroyUnpassedArg final : EHScopeStack::Cleanup {
   DestroyUnpassedArg(llvm::Value *Addr, QualType Ty)
   : Addr(Addr), Ty(Ty) {}
 

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=245378&r1=245377&r2=245378&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Tue Aug 18 17:40:54 2015
@@ -345,7 +345,7 @@ llvm::Value *CodeGenFunction::GetVTTPara
 
 namespace {
   /// Call the destructor for a direct base class.
-  struct CallBaseDtor : EHScopeStack::Cleanup {
+  struct CallBaseDtor final : EHScopeStack::Cleanup {
 const CXXRecordDecl *BaseClass;
 bool BaseIsVirtual;
 CallBaseDtor(const CXXRecordDecl *Base, bool BaseIsVirtual)
@@ -1526,7 +1526,7 @@ void CodeGenFunction::emitImplicitAssign
 
 namespace {
   /// Call the operator delete associated with the current destructor.
-  struct CallDtorDelete : EHScopeStack::Cleanup {
+  struct CallDtorDelete final : EHScopeStack::Cleanup {
 CallDtorDelete() {}
 
 void Emit(CodeGenFunction &CGF, Flags flags) override {
@@ -1537,7 +1537,7 @@ namespace {
 }
   };
 
-  struct CallDtorDeleteConditional : EHScopeStack::Cleanup {
+  struct CallDtorDeleteConditional final : EHScopeStack::Cleanup {
 llvm::Value *ShouldDeleteCondition;
   public:
 CallDtorDeleteConditional(llvm::Value *ShouldDeleteCondition)
@@ -1563,7 +1563,7 @@ namespace {
 }
   };
 
-  class DestroyField  : public EHScopeStack::Cleanup {
+  class DestroyField  final : public EHScopeStack::Cleanup {
 const FieldDecl *field;
 CodeGenFunction::Destroyer *destroyer;
 bool useEHCleanupForArray;
@@ -1933,7 +1933,7 @@ CodeGenFunction::EmitDelegateCXXConstruc
 }
 
 namespace {
-  struct CallDelegatingCtorDtor : EHScopeStack::Cleanup {
+  struct CallDelegatingCtorDtor final : EHScopeStack::Cleanup {
 const CXXDestructorDecl *Dtor;
 llvm::Value *Addr;
 CXXDtorType Type;
@@ -1987,7 +1987,7 @@ void CodeGenFunction::EmitCXXDestructorC
 }
 
 namespace {
-  struct CallLocalDtor : EHScopeStack::Cleanup {
+  struct CallLocalDtor final : EHScopeStack::Cleanup {
 const CXXDestructorDecl *Dtor;
 llvm::Value *Addr;
 

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=245378&r1=245377&r2=245378&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Tue Aug 18 17:40:54 2015
@@ -400,7 +400,7 @@ void CodeGenFunction::EmitStaticVarDecl(
 }
 
 namespace {
-  struct DestroyObject : EHScopeStack::Cleanup {
+  struct DestroyObject final : EHScopeStack::Cleanup {
 DestroyObject(llvm::Value *addr, QualType type,
   CodeGenFunction::Destroyer *destroyer,
   bool useEHCleanupForArray)
@@ -421,7 +421,7 @@ namespace {
 }
   };
 
-  struct DestroyNRVOVariable : EHScopeStack::Cleanup {
+  struct DestroyN

[PATCH] D12123: [analyzer] Skip Pre/Post handlers for ObjC calls when receiver is nil.

2015-08-18 Thread Devin Coughlin via cfe-commits
dcoughlin created this revision.
dcoughlin added reviewers: zaks.anna, jordan_rose, xazax.hun.
dcoughlin added a subscriber: cfe-commits.
Herald added a subscriber: aemerson.

In Objective-C, method calls with nil receivers are essentially no-ops. They
do not fault (although the returned value may be garbage depending on the
declared return type and architecture). Programmers are aware of this
behavior and will complain about a false alarm when the analyzer
diagnoses API violations for method calls when the receiver is known to
be nil.

Rather than require each individual checker to be aware of this behavior
and suppress a warning when the receiver is nil, this patch
changes ExprEngineObjC so that VisitObjCMessage skips calling checker
pre/post handlers when the receiver is nil definitely nil. Instead, it adds a
new event, ObjCMessageNil, that is only called in that case.

The CallAndMessageChecker explicitly cares about this case, so I've changed it
to add a callback for ObjCMessageNil and moved the logic that handles nil 
receivers
in its PreObjCMessage callback to the new callback.

rdar://problem/18092611

http://reviews.llvm.org/D12123

Files:
  include/clang/StaticAnalyzer/Core/Checker.h
  include/clang/StaticAnalyzer/Core/CheckerManager.h
  lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
  lib/StaticAnalyzer/Core/CheckerManager.cpp
  lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
  test/Analysis/NSContainers.m

Index: test/Analysis/NSContainers.m
===
--- test/Analysis/NSContainers.m
+++ test/Analysis/NSContainers.m
@@ -24,6 +24,8 @@
 @interface NSObject  {}
 - (id)init;
 + (id)alloc;
+
+- (id)mutableCopy;
 @end
 
 typedef struct {
@@ -292,3 +294,16 @@
   [arr addObject:0 safe:1]; // no-warning
 }
 
+@interface MyView : NSObject
+-(NSArray *)subviews;
+@end
+
+void testNoReportWhenReceiverNil(NSMutableArray *array, int b) {
+  if (array == 0) {
+[array addObject:0];
+  }
+
+  MyView *view = b ? [[MyView alloc] init] : 0;
+  NSMutableArray *subviews = [[view subviews] mutableCopy];
+  [subviews addObject:view];
+}
Index: lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
@@ -139,6 +139,31 @@
   CallEventRef Msg =
 CEMgr.getObjCMethodCall(ME, Pred->getState(), Pred->getLocationContext());
 
+  // If the receiver is definitely nil, skip the pre/post callbacks and instead
+  // call the ObjCMessageNil callbacks and return.
+  if (Msg->isInstanceMessage()) {
+SVal recVal = Msg->getReceiverSVal();
+if (!recVal.isUndef()) {
+  // Bifurcate the state into nil and non-nil ones.
+  DefinedOrUnknownSVal receiverVal =
+  recVal.castAs();
+  ProgramStateRef State = Pred->getState();
+
+  ProgramStateRef notNilState, nilState;
+  std::tie(notNilState, nilState) = State->assume(receiverVal);
+  if (nilState && !notNilState) {
+ExplodedNodeSet dstNil;
+StmtNodeBuilder Bldr(Pred, dstNil, *currBldrCtx);
+
+Pred = Bldr.generateNode(ME, Pred, nilState);
+assert(Pred && "Should have cached out already!");
+getCheckerManager().runCheckersForObjCMessageNil(Dst, dstNil,
+ *Msg, *this);
+return;
+  }
+}
+  }
+
   // Handle the previsits checks.
   ExplodedNodeSet dstPrevisit;
   getCheckerManager().runCheckersForPreObjCMessage(dstPrevisit, Pred,
@@ -160,35 +185,12 @@
 if (UpdatedMsg->isInstanceMessage()) {
   SVal recVal = UpdatedMsg->getReceiverSVal();
   if (!recVal.isUndef()) {
-// Bifurcate the state into nil and non-nil ones.
-DefinedOrUnknownSVal receiverVal =
-recVal.castAs();
-
-ProgramStateRef notNilState, nilState;
-std::tie(notNilState, nilState) = State->assume(receiverVal);
-
-// There are three cases: can be nil or non-nil, must be nil, must be
-// non-nil. We ignore must be nil, and merge the rest two into non-nil.
-// FIXME: This ignores many potential bugs ().
-// Revisit once we have lazier constraints.
-if (nilState && !notNilState) {
-  continue;
-}
-
-// Check if the "raise" message was sent.
-assert(notNilState);
 if (ObjCNoRet.isImplicitNoReturn(ME)) {
   // If we raise an exception, for now treat it as a sink.
   // Eventually we will want to handle exceptions properly.
   Bldr.generateSink(ME, Pred, State);
   continue;
 }
-
-// Generate a transition to non-Nil state.
-if (notNilState != State) {
-  Pred = Bldr.generateNode(ME, Pred, notNilState);
-  assert(Pred && "Should have cached out already!");
-}
   }
 } else {
   // Check for special class methods that are known to not ret

[PATCH] D12122: [CUDA] Add appropriate host/device attribute to target-specific builtins.

2015-08-18 Thread Artem Belevich via cfe-commits
tra created this revision.
tra added reviewers: eliben, echristo.
tra added a subscriber: cfe-commits.

The patch adds appropriate __host__ or __device__ attributes to target-specific 
builtins 
so we can properly check whether they may or may not be called from particular 
context.


http://reviews.llvm.org/D12122

Files:
  include/clang/Basic/Builtins.h
  lib/Sema/SemaDecl.cpp
  test/SemaCUDA/builtins.cu
  test/SemaCUDA/implicit-intrinsic.cu

Index: test/SemaCUDA/implicit-intrinsic.cu
===
--- test/SemaCUDA/implicit-intrinsic.cu
+++ test/SemaCUDA/implicit-intrinsic.cu
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -std=gnu++11 -triple nvptx64-unknown-unknown -fsyntax-only 
-verify %s
+// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -fcuda-is-device 
-fsyntax-only -verify %s
 
 #include "Inputs/cuda.h"
 
 // expected-no-diagnostics
 __device__ void __threadfence_system() {
-  // This shouldn't produce an error, since __nvvm_membar_sys is inferred to
-  // be __host__ __device__ and thus callable from device code.
+  // This shouldn't produce an error, since __nvvm_membar_sys should be
+  // __device__ and thus callable from device code.
   __nvvm_membar_sys();
 }
Index: test/SemaCUDA/builtins.cu
===
--- /dev/null
+++ test/SemaCUDA/builtins.cu
@@ -0,0 +1,35 @@
+// Tests that target-specific builtins have appropriate host/device
+// attributes and that CUDA call restrictions are enforced. Also
+// verify that non-target builtins can be used from both host and
+// device functions.
+//
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple nvptx64-unknown-cuda -fcuda-is-device \
+// RUN:   -fsyntax-only -verify %s
+
+
+#ifdef __CUDA_ARCH__
+// Device-side builtins are not allowed to be called from host functions.
+void hf() {
+  int x = __builtin_ptx_read_tid_x(); // expected-note  
{{'__builtin_ptx_read_tid_x' declared here}}
+  // expected-error@-1 {{reference to __device__ function 
'__builtin_ptx_read_tid_x' in __host__ function}}
+  x = __builtin_abs(1);
+}
+__attribute__((device)) void df() {
+  int x = __builtin_ptx_read_tid_x();
+  x = __builtin_abs(1);
+}
+#else
+// Host-side builtins are not allowed to be called from device functions.
+__attribute__((device)) void df() {
+  int x = __builtin_ia32_rdtsc();   // expected-note {{'__builtin_ia32_rdtsc' 
declared here}}
+  // expected-error@-1 {{reference to __host__ function '__builtin_ia32_rdtsc' 
in __device__ function}}
+  x = __builtin_abs(1);
+}
+void hf() {
+  int x = __builtin_ia32_rdtsc();
+  x = __builtin_abs(1);
+}
+#endif
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -11161,6 +11161,13 @@
   FD->addAttr(NoThrowAttr::CreateImplicit(Context, FD->getLocation()));
 if (Context.BuiltinInfo.isConst(BuiltinID) && !FD->hasAttr())
   FD->addAttr(ConstAttr::CreateImplicit(Context, FD->getLocation()));
+if (getLangOpts().CUDA && Context.BuiltinInfo.isTSBuiltin(BuiltinID) &&
+!FD->hasAttr() && !FD->hasAttr()) {
+  if (getLangOpts().CUDAIsDevice)
+FD->addAttr(CUDADeviceAttr::CreateImplicit(Context, 
FD->getLocation()));
+  else
+FD->addAttr(CUDAHostAttr::CreateImplicit(Context, FD->getLocation()));
+}
   }
 
   IdentifierInfo *Name = FD->getIdentifier();
Index: include/clang/Basic/Builtins.h
===
--- include/clang/Basic/Builtins.h
+++ include/clang/Basic/Builtins.h
@@ -81,6 +81,11 @@
 return getRecord(ID).Type;
   }
 
+  /// \brief Return true if this function is a target-specific builtin
+  bool isTSBuiltin(unsigned ID) const {
+return ID >= Builtin::FirstTSBuiltin;
+  }
+
   /// \brief Return true if this function has no side effects and doesn't
   /// read memory.
   bool isConst(unsigned ID) const {


Index: test/SemaCUDA/implicit-intrinsic.cu
===
--- test/SemaCUDA/implicit-intrinsic.cu
+++ test/SemaCUDA/implicit-intrinsic.cu
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -std=gnu++11 -triple nvptx64-unknown-unknown -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -fcuda-is-device -fsyntax-only -verify %s
 
 #include "Inputs/cuda.h"
 
 // expected-no-diagnostics
 __device__ void __threadfence_system() {
-  // This shouldn't produce an error, since __nvvm_membar_sys is inferred to
-  // be __host__ __device__ and thus callable from device code.
+  // This shouldn't produce an error, since __nvvm_membar_sys should be
+  // __device__ and thus callable from device code.
   __nvvm_membar_sys();
 }
Index: test/SemaCUDA/builtins.cu
===
--- /dev/nul

Re: [PATCH] D12119: Analyzer: Fix a crasher in UbigraphViz

2015-08-18 Thread Ted Kremenek via cfe-commits
krememek added inline comments.


Comment at: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:749
@@ -748,3 +748,3 @@
 
   assert (Src != Dst && "Self-edges are not allowed.");
 

ismailp wrote:
> Is Ubigraph generator actively maintained? If I run tests with 
> '-analyzer-viz-egraph-ubigraph', this assertion gets triggered. According to 
> static analyzer documentation, cycles are allowed in ExplodedGraph. I am 
> unsure whether self-cycles are allowed, however.
There was a time where a self-cycle indicated a bug in the analyzer.  Much has 
changed since destructor support was added, but the Ubigraph support hasn't 
bitrotted.  It could be the case that this assertion needs to be removed 
because an invariant in the analyzer has changed, but I would be willing to 
also say it is possible that the tests are failing because an invariant is 
getting violated.


http://reviews.llvm.org/D12119



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


Re: [PATCH] D12119: Analyzer: Fix a crasher in UbigraphViz

2015-08-18 Thread Ted Kremenek via cfe-commits
krememek added inline comments.


Comment at: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:784
@@ -783,3 +783,3 @@
 
-  *Out << "('vertex_style_attribute', 0, ('shape', 'icosahedron'))\n";
-  *Out << "('vertex_style', 1, 0, ('shape', 'sphere'), ('color', '#ffcc66'),"
+  *this->Out << "('vertex_style_attribute', 0, ('shape', 'icosahedron'))\n";
+  *this->Out << "('vertex_style', 1, 0, ('shape', 'sphere'), ('color', 
'#ffcc66'),"

This seems really brittle.

Can we just rename the parameter 'Out' to something else, and then just use 
'Out'?  Seems more reasonable to rename the parameter than to change every 
single functional line of code that uses 'Out'.


http://reviews.llvm.org/D12119



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


r245368 - Fix for MSVC

2015-08-18 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Tue Aug 18 17:10:49 2015
New Revision: 245368

URL: http://llvm.org/viewvc/llvm-project?rev=245368&view=rev
Log:
Fix for MSVC

Modified:
cfe/trunk/lib/CodeGen/EHScopeStack.h

Modified: cfe/trunk/lib/CodeGen/EHScopeStack.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/EHScopeStack.h?rev=245368&r1=245367&r2=245368&view=diff
==
--- cfe/trunk/lib/CodeGen/EHScopeStack.h (original)
+++ cfe/trunk/lib/CodeGen/EHScopeStack.h Tue Aug 18 17:10:49 2015
@@ -147,7 +147,7 @@ public:
 
   public:
 Cleanup(const Cleanup &) = default;
-Cleanup(Cleanup &&) = default;
+Cleanup(Cleanup &&) {}
 Cleanup() = default;
 
 /// Generation flags.


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


r245367 - Wdeprecated: Support movability of EHScopeStack::Cleanup objects as they are move constructed in ConditionalCleanup::restore

2015-08-18 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Tue Aug 18 17:09:28 2015
New Revision: 245367

URL: http://llvm.org/viewvc/llvm-project?rev=245367&view=rev
Log:
Wdeprecated: Support movability of EHScopeStack::Cleanup objects as they are 
move constructed in ConditionalCleanup::restore

Modified:
cfe/trunk/lib/CodeGen/EHScopeStack.h

Modified: cfe/trunk/lib/CodeGen/EHScopeStack.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/EHScopeStack.h?rev=245367&r1=245366&r2=245367&view=diff
==
--- cfe/trunk/lib/CodeGen/EHScopeStack.h (original)
+++ cfe/trunk/lib/CodeGen/EHScopeStack.h Tue Aug 18 17:09:28 2015
@@ -144,7 +144,12 @@ public:
   class Cleanup {
 // Anchor the construction vtable.
 virtual void anchor();
+
   public:
+Cleanup(const Cleanup &) = default;
+Cleanup(Cleanup &&) = default;
+Cleanup() = default;
+
 /// Generation flags.
 class Flags {
   enum {


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


Re: r244416 - [modules] PR22534: Load files specified by -fmodule-file= eagerly. In particular, this avoids the need to re-parse module map files when using such a module.

2015-08-18 Thread Gábor Horváth via cfe-commits
On 18 August 2015 at 14:46, Richard Smith  wrote:

> On Tue, Aug 18, 2015 at 1:52 PM, Gábor Horváth 
> wrote:
>
>> On 18 August 2015 at 13:41, Richard Smith  wrote:
>>
>>> On Tue, Aug 18, 2015 at 12:59 PM, Gábor Horváth 
>>> wrote:
>>>
 Hi!

 In r244416 you made createModuleManager to call the Initialize method
 of the ASTConsumer.
 Because of this change the ASTConsumer::Initialize might be called
 twice in some scenarios.

 This change makes the Static Analyzer crash (use after free) in those
 scenarios. I think most of the ASTConsumers was not written with that in
 mind Initialize might be called twice for the object. This fact is also not
 covered by the documentation.

 In my opinion we should either guarantee that the Initialize method
 will be called only once during the lifetime of an ASTConsumer, or document
 the fact that, it might be called multiple times and notify the authors of
 the different consumers to update their classes accordingly (announcement
 on the mailing list?).

 What do you think?

>>>
>>> Fixed in r245346.
>>>
>>> It seems like an indicator of poor design that we have the initialize
>>> function at all. I don't think there is any situation where we need or want
>>> to create an ASTConsumer before we have enough information to create the
>>> ASTContext, so perhaps we can just get rid of this function.
>>>
>>
>> Thank you for fixing this!
>>
>> I agree that it would be awesome to get rid of that function.
>>
>
> CCing the right list again :)
>
> Are you interested in looking into this? (If not, it's going to near the
> bottom of a long list of TODO items for me...)
>

Hope to CC the right list this time :)

Well, it would end up on the bottom of my TODO list as well, so maybe we
should both add it, and the one who gets there earlier should do this.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12119: Analyzer: Fix a crasher in UbigraphViz

2015-08-18 Thread Ismail Pazarbasi via cfe-commits
ismailp added inline comments.


Comment at: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:749
@@ -748,3 +748,3 @@
 
   assert (Src != Dst && "Self-edges are not allowed.");
 

Is Ubigraph generator actively maintained? If I run tests with 
'-analyzer-viz-egraph-ubigraph', this assertion gets triggered. According to 
static analyzer documentation, cycles are allowed in ExplodedGraph. I am unsure 
whether self-cycles are allowed, however.


http://reviews.llvm.org/D12119



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


Re: r245084 - WindowsX86: long double is x87DoubleExtended on mingw

2015-08-18 Thread Hans Wennborg via cfe-commits
Richard, I tried to ping you on the review thread but I'm not sure it
got through. Martell requested this be merged to 3.7. What do you
think?

On Fri, Aug 14, 2015 at 12:05 PM, Martell Malone via cfe-commits
 wrote:
> Author: martell
> Date: Fri Aug 14 14:05:56 2015
> New Revision: 245084
>
> URL: http://llvm.org/viewvc/llvm-project?rev=245084&view=rev
> Log:
> WindowsX86: long double is x87DoubleExtended on mingw
>
> Summary:
> long double on x86 mingw is 80bits and is aligned to 16bytes
>
> Fixes:
> https://llvm.org/bugs/show_bug.cgi?id=24398
>
> Reviewers: rnk
>
> Subscribers: cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D12037
>
> Modified:
> cfe/trunk/lib/Basic/Targets.cpp
>
> Modified: cfe/trunk/lib/Basic/Targets.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=245084&r1=245083&r2=245084&view=diff
> ==
> --- cfe/trunk/lib/Basic/Targets.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets.cpp Fri Aug 14 14:05:56 2015
> @@ -3784,7 +3784,10 @@ namespace {
>  class MinGWX86_32TargetInfo : public WindowsX86_32TargetInfo {
>  public:
>MinGWX86_32TargetInfo(const llvm::Triple &Triple)
> -  : WindowsX86_32TargetInfo(Triple) {}
> +  : WindowsX86_32TargetInfo(Triple) {
> +LongDoubleWidth = LongDoubleAlign = 128;
> +LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
> +  }
>void getTargetDefines(const LangOptions &Opts,
>  MacroBuilder &Builder) const override {
>  WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder);
> @@ -4014,7 +4017,10 @@ public:
>  class MinGWX86_64TargetInfo : public WindowsX86_64TargetInfo {
>  public:
>MinGWX86_64TargetInfo(const llvm::Triple &Triple)
> -  : WindowsX86_64TargetInfo(Triple) {}
> +  : WindowsX86_64TargetInfo(Triple) {
> +LongDoubleWidth = LongDoubleAlign = 128;
> +LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
> +  }
>void getTargetDefines(const LangOptions &Opts,
>  MacroBuilder &Builder) const override {
>  WindowsX86_64TargetInfo::getTargetDefines(Opts, Builder);
>
>
> ___
> 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


[PATCH] D12119: Analyzer: Fix a crasher in UbigraphViz

2015-08-18 Thread Ismail Pazarbasi via cfe-commits
ismailp created this revision.
ismailp added reviewers: zaks.anna, krememek.
ismailp added a subscriber: cfe-commits.

Name `Out` refers to the parameter. It is moved into the member `Out`
in ctor-init. Dereferencing null pointer will crash clang, if user
passes '-analyzer-viz-egraph-ubigraph' argument.

http://reviews.llvm.org/D12119

Files:
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -781,8 +781,8 @@
 UbigraphViz::UbigraphViz(std::unique_ptr Out, StringRef Filename)
 : Out(std::move(Out)), Filename(Filename), Cntr(0) {
 
-  *Out << "('vertex_style_attribute', 0, ('shape', 'icosahedron'))\n";
-  *Out << "('vertex_style', 1, 0, ('shape', 'sphere'), ('color', '#ffcc66'),"
+  *this->Out << "('vertex_style_attribute', 0, ('shape', 'icosahedron'))\n";
+  *this->Out << "('vertex_style', 1, 0, ('shape', 'sphere'), ('color', 
'#ffcc66'),"
   " ('size', '1.5'))\n";
 }
 


Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -781,8 +781,8 @@
 UbigraphViz::UbigraphViz(std::unique_ptr Out, StringRef Filename)
 : Out(std::move(Out)), Filename(Filename), Cntr(0) {
 
-  *Out << "('vertex_style_attribute', 0, ('shape', 'icosahedron'))\n";
-  *Out << "('vertex_style', 1, 0, ('shape', 'sphere'), ('color', '#ffcc66'),"
+  *this->Out << "('vertex_style_attribute', 0, ('shape', 'icosahedron'))\n";
+  *this->Out << "('vertex_style', 1, 0, ('shape', 'sphere'), ('color', '#ffcc66'),"
   " ('size', '1.5'))\n";
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r244266 - [ItaniumCXXABI] Don't import RTTI data for classes with key functions

2015-08-18 Thread Richard Smith via cfe-commits
On Fri, Aug 14, 2015 at 11:27 AM, Hans Wennborg via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Tue, Aug 11, 2015 at 1:41 PM, Hans Wennborg  wrote:
> > On Thu, Aug 6, 2015 at 1:56 PM, David Majnemer via cfe-commits
> >  wrote:
> >> Author: majnemer
> >> Date: Thu Aug  6 15:56:55 2015
> >> New Revision: 244266
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=244266&view=rev
> >> Log:
> >> [ItaniumCXXABI] Don't import RTTI data for classes with key functions
> >>
> >> MinGW has some pretty strange behvaior around RTTI and
> >> dllimport/dllexport:
> >> - RTTI data is never imported
> >> - RTTI data is only exported if the class has no key function.
> >>
> >> Modified:
> >> cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> >> cfe/trunk/test/CodeGenCXX/dllimport-rtti.cpp
> >
> > I tried to merge this to 3.7 (as discussed on the commit thread for
> > r244488), but the test doesn't pass:
> >
> > --
> >
> /usr/local/google/work/llvm-3.7/cfe.src/test/CodeGenCXX/dllimport-rtti.cpp:22:13:
> > error: expected string not found in input
> > // GNU-DAG: @_ZTV1V = available_externally dllimport
> > ^
> > :1:1: note: scanning from here
> > ; ModuleID =
> '/usr/local/google/work/llvm-3.7/cfe.src/test/CodeGenCXX/dllimport-rtti.cpp'
> > ^
> > :15:1: note: possible intended match here
> > @_ZTV1S = available_externally dllimport unnamed_addr constant [3 x
> > i8*] [i8* null, i8* bitcast (i8** @_ZTI1S to i8*), i8* bitcast (void
> > (%struct.S*)* @_ZN1S1fEv to i8*)], align 4
> > ^
> > --
> >
> > I assume there's some other commit this depends on, but I haven't been
> > able to figure out which. Can you take a look?
>
> Ping?
>

Looks like the test depends on r243090, which shouldn't go to the branch.
I'd guess we could fix the test by changing that check line to "// GNU-DAG:
@_ZTV1V = external" or similar. David?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r244902 - Driver: Fix include directories when not using libgcc under mingw

2015-08-18 Thread Hans Wennborg via cfe-commits
Richard, I tried to ping you on the review thread but I'm not sure it
got through. Martell requested this be merged to 3.7. What do you
think?

On Thu, Aug 13, 2015 at 8:41 AM, Martell Malone via cfe-commits
 wrote:
> Author: martell
> Date: Thu Aug 13 10:41:04 2015
> New Revision: 244902
>
> URL: http://llvm.org/viewvc/llvm-project?rev=244902&view=rev
> Log:
> Driver: Fix include directories when not using libgcc under mingw
>
> Summary:
> When we want to use mingw-w64 and clang with compiler-rt we should not
> need to have libgcc installed. This fixes finding includes when libgcc
> is not installed
>
> Reviewers: yaron.keren
>
> Subscribers: cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D11808
>
> Added:
> cfe/trunk/test/Driver/Inputs/mingw_clang_tree/
> cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/
> cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/i686-w64-mingw32/
> 
> cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/i686-w64-mingw32/include/
> 
> cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/i686-w64-mingw32/include/.keep
> cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/include/
> cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/include/.keep
> Modified:
> cfe/trunk/lib/Driver/MinGWToolChain.cpp
> cfe/trunk/test/Driver/mingw.cpp
>
> Modified: cfe/trunk/lib/Driver/MinGWToolChain.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MinGWToolChain.cpp?rev=244902&r1=244901&r2=244902&view=diff
> ==
> --- cfe/trunk/lib/Driver/MinGWToolChain.cpp (original)
> +++ cfe/trunk/lib/Driver/MinGWToolChain.cpp Thu Aug 13 10:41:04 2015
> @@ -47,7 +47,7 @@ void MinGW::findGccLibDir() {
>Archs.emplace_back(getTriple().getArchName());
>Archs[0] += "-w64-mingw32";
>Archs.emplace_back("mingw32");
> -  Arch = "unknown";
> +  Arch = Archs[0].str();
>// lib: Arch Linux, Ubuntu, Windows
>// lib64: openSUSE Linux
>for (StringRef CandidateLib : {"lib", "lib64"}) {
>
> Added: 
> cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/i686-w64-mingw32/include/.keep
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/i686-w64-mingw32/include/.keep?rev=244902&view=auto
> ==
> (empty)
>
> Added: cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/include/.keep
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/include/.keep?rev=244902&view=auto
> ==
> (empty)
>
> Modified: cfe/trunk/test/Driver/mingw.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mingw.cpp?rev=244902&r1=244901&r2=244902&view=diff
> ==
> --- cfe/trunk/test/Driver/mingw.cpp (original)
> +++ cfe/trunk/test/Driver/mingw.cpp Thu Aug 13 10:41:04 2015
> @@ -1,3 +1,8 @@
> +// RUN: %clang -target i686-windows-gnu -c -### 
> --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck 
> -check-prefix=CHECK_MINGW_CLANG_TREE %s
> +// CHECK_MINGW_CLANG_TREE: 
> "{{.*}}/Inputs/mingw_clang_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include"
> +// CHECK_MINGW_CLANG_TREE: 
> "{{.*}}/Inputs/mingw_clang_tree/mingw32{{/|}}include"
> +
> +
>  // RUN: %clang -target i686-pc-windows-gnu -stdlib=libstdc++ -c -### 
> --sysroot=%S/Inputs/mingw_mingw_org_tree/mingw %s 2>&1 | FileCheck 
> -check-prefix=CHECK_MINGW_ORG_TREE %s
>  // CHECK_MINGW_ORG_TREE: 
> "{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++"
>  // CHECK_MINGW_ORG_TREE: 
> "{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++{{/|}}mingw32"
>
>
> ___
> 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: r244488 - [dllimport] A non-imported class with an imported key can't have a key

2015-08-18 Thread Hans Wennborg via cfe-commits
On Tue, Aug 11, 2015 at 9:40 AM, Hans Wennborg  wrote:
> On Mon, Aug 10, 2015 at 12:39 PM, Reid Kleckner via cfe-commits
>  wrote:
>> Author: rnk
>> Date: Mon Aug 10 14:39:01 2015
>> New Revision: 244488
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=244488&view=rev
>> Log:
>> [dllimport] A non-imported class with an imported key can't have a key
>>
>> Summary:
>> The vtable takes its DLL storage class from the class, not the key
>> function. When they disagree, the vtable won't be exported by the DLL
>> that defines the key function. The easiest way to ensure that importers
>> of the class emit their own vtable is to say that the class has no key
>> function.
>>
>> Reviewers: hans, majnemer
>>
>> Subscribers: cfe-commits
>>
>> Differential Revision: http://reviews.llvm.org/D11913
>
> Should we merge this and r244266 to 3.7?

As pointed out on the r244266 thread, these patches are still not
merged as the tests don't pass on 3.7. I was hoping someone more
familiar with the patches could take a look.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r245361 - Range-based-for-convert some loops in ASTWriter. No functionality change intended.

2015-08-18 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Aug 18 16:53:42 2015
New Revision: 245361

URL: http://llvm.org/viewvc/llvm-project?rev=245361&view=rev
Log:
Range-based-for-convert some loops in ASTWriter. No functionality change 
intended.

Modified:
cfe/trunk/include/clang/Basic/Module.h
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Basic/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=245361&r1=245360&r2=245361&view=diff
==
--- cfe/trunk/include/clang/Basic/Module.h (original)
+++ cfe/trunk/include/clang/Basic/Module.h Tue Aug 18 16:53:42 2015
@@ -475,6 +475,13 @@ public:
   submodule_iterator submodule_end()   { return SubModules.end(); }
   submodule_const_iterator submodule_end() const { return SubModules.end(); }
 
+  llvm::iterator_range submodules() {
+return llvm::make_range(submodule_begin(), submodule_end());
+  }
+  llvm::iterator_range submodules() const {
+return llvm::make_range(submodule_begin(), submodule_end());
+  }
+
   /// \brief Appends this module's list of exported modules to \p Exported.
   ///
   /// This provides a subset of immediately imported modules (the ones that are

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=245361&r1=245360&r2=245361&view=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Tue Aug 18 16:53:42 2015
@@ -2284,6 +2284,9 @@ void ASTWriter::WritePreprocessorDetail(
 }
 
 unsigned ASTWriter::getSubmoduleID(Module *Mod) {
+  if (!Mod)
+return 0;
+
   llvm::DenseMap::iterator Known = SubmoduleIDs.find(Mod);
   if (Known != SubmoduleIDs.end())
 return Known->second;
@@ -2434,12 +2437,11 @@ void ASTWriter::WriteSubmodules(Module *
 Stream.EmitRecordWithBlob(DefinitionAbbrev, Record, Mod->Name);
 
 // Emit the requirements.
-for (unsigned I = 0, N = Mod->Requirements.size(); I != N; ++I) {
+for (const auto &R : Mod->Requirements) {
   Record.clear();
   Record.push_back(SUBMODULE_REQUIRES);
-  Record.push_back(Mod->Requirements[I].second);
-  Stream.EmitRecordWithBlob(RequiresAbbrev, Record,
-Mod->Requirements[I].first);
+  Record.push_back(R.second);
+  Stream.EmitRecordWithBlob(RequiresAbbrev, Record, R.first);
 }
 
 // Emit the umbrella header, if there is one.
@@ -2487,26 +2489,19 @@ void ASTWriter::WriteSubmodules(Module *
 // Emit the imports. 
 if (!Mod->Imports.empty()) {
   Record.clear();
-  for (unsigned I = 0, N = Mod->Imports.size(); I != N; ++I) {
-unsigned ImportedID = getSubmoduleID(Mod->Imports[I]);
-assert(ImportedID && "Unknown submodule!");
-Record.push_back(ImportedID);
-  }
+  for (auto *I : Mod->Imports)
+Record.push_back(getSubmoduleID(I));
   Stream.EmitRecord(SUBMODULE_IMPORTS, Record);
 }
 
 // Emit the exports. 
 if (!Mod->Exports.empty()) {
   Record.clear();
-  for (unsigned I = 0, N = Mod->Exports.size(); I != N; ++I) {
-if (Module *Exported = Mod->Exports[I].getPointer()) {
-  unsigned ExportedID = getSubmoduleID(Exported);
-  Record.push_back(ExportedID);
-} else {
-  Record.push_back(0);
-}
-
-Record.push_back(Mod->Exports[I].getInt());
+  for (const auto &E : Mod->Exports) {
+// FIXME: This may fail; we don't require that all exported modules
+// are local or imported.
+Record.push_back(getSubmoduleID(E.getPointer()));
+Record.push_back(E.getInt());
   }
   Stream.EmitRecord(SUBMODULE_EXPORTS, Record);
 }
@@ -2516,38 +2511,33 @@ void ASTWriter::WriteSubmodules(Module *
 // module itself.
 
 // Emit the link libraries.
-for (unsigned I = 0, N = Mod->LinkLibraries.size(); I != N; ++I) {
+for (const auto &LL : Mod->LinkLibraries) {
   Record.clear();
   Record.push_back(SUBMODULE_LINK_LIBRARY);
-  Record.push_back(Mod->LinkLibraries[I].IsFramework);
-  Stream.EmitRecordWithBlob(LinkLibraryAbbrev, Record,
-Mod->LinkLibraries[I].Library);
+  Record.push_back(LL.IsFramework);
+  Stream.EmitRecordWithBlob(LinkLibraryAbbrev, Record, LL.Library);
 }
 
 // Emit the conflicts.
-for (unsigned I = 0, N = Mod->Conflicts.size(); I != N; ++I) {
+for (const auto &C : Mod->Conflicts) {
   Record.clear();
   Record.push_back(SUBMODULE_CONFLICT);
-  unsigned OtherID = getSubmoduleID(Mod->Conflicts[I].Other);
-  assert(OtherID && "Unknown submodule!");
-  Record.push_back(OtherID);
-  Stream.EmitRecordWithBlob(ConflictAbbrev, Record,
-Mod->Conflicts[I].Message);

Re: r244416 - [modules] PR22534: Load files specified by -fmodule-file= eagerly. In particular, this avoids the need to re-parse module map files when using such a module.

2015-08-18 Thread Richard Smith via cfe-commits
On Tue, Aug 18, 2015 at 1:52 PM, Gábor Horváth  wrote:

> On 18 August 2015 at 13:41, Richard Smith  wrote:
>
>> On Tue, Aug 18, 2015 at 12:59 PM, Gábor Horváth 
>> wrote:
>>
>>> Hi!
>>>
>>> In r244416 you made createModuleManager to call the Initialize method
>>> of the ASTConsumer.
>>> Because of this change the ASTConsumer::Initialize might be called twice
>>> in some scenarios.
>>>
>>> This change makes the Static Analyzer crash (use after free) in those
>>> scenarios. I think most of the ASTConsumers was not written with that in
>>> mind Initialize might be called twice for the object. This fact is also not
>>> covered by the documentation.
>>>
>>> In my opinion we should either guarantee that the Initialize method will
>>> be called only once during the lifetime of an ASTConsumer, or document the
>>> fact that, it might be called multiple times and notify the authors of the
>>> different consumers to update their classes accordingly (announcement on
>>> the mailing list?).
>>>
>>> What do you think?
>>>
>>
>> Fixed in r245346.
>>
>> It seems like an indicator of poor design that we have the initialize
>> function at all. I don't think there is any situation where we need or want
>> to create an ASTConsumer before we have enough information to create the
>> ASTContext, so perhaps we can just get rid of this function.
>>
>
> Thank you for fixing this!
>
> I agree that it would be awesome to get rid of that function.
>

CCing the right list again :)

Are you interested in looking into this? (If not, it's going to near the
bottom of a long list of TODO items for me...)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D12117: Replace __asan_set_error_exit_code() with __sanitizer_set_death_callback()

2015-08-18 Thread Alexey Samsonov via cfe-commits
samsonov created this revision.
samsonov added a reviewer: EricWF.
samsonov added a subscriber: cfe-commits.

We are going to remove the former soon.

http://reviews.llvm.org/D12117

Files:
  test/libcxx/containers/sequences/vector/asan.pass.cpp

Index: test/libcxx/containers/sequences/vector/asan.pass.cpp
===
--- test/libcxx/containers/sequences/vector/asan.pass.cpp
+++ test/libcxx/containers/sequences/vector/asan.pass.cpp
@@ -21,8 +21,11 @@
 #include "test_macros.h"
 
 #ifndef _LIBCPP_HAS_NO_ASAN
-extern "C" void __asan_set_error_exit_code(int);
+extern "C" void __sanitizer_set_death_callback(void (*callback)(void));
 
+void do_exit() {
+  exit(0);
+}
 
 int main()
 {
@@ -48,7 +51,7 @@
 assert(is_contiguous_container_asan_correct(v));
 }
 
-__asan_set_error_exit_code(0);
+__sanitizer_set_death_callback(do_exit);
 {
 typedef int T;
 typedef std::vector C;


Index: test/libcxx/containers/sequences/vector/asan.pass.cpp
===
--- test/libcxx/containers/sequences/vector/asan.pass.cpp
+++ test/libcxx/containers/sequences/vector/asan.pass.cpp
@@ -21,8 +21,11 @@
 #include "test_macros.h"
 
 #ifndef _LIBCPP_HAS_NO_ASAN
-extern "C" void __asan_set_error_exit_code(int);
+extern "C" void __sanitizer_set_death_callback(void (*callback)(void));
 
+void do_exit() {
+  exit(0);
+}
 
 int main()
 {
@@ -48,7 +51,7 @@
 assert(is_contiguous_container_asan_correct(v));
 }
 
-__asan_set_error_exit_code(0);
+__sanitizer_set_death_callback(do_exit);
 {
 typedef int T;
 typedef std::vector C;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11046: [libcxx] Add Atomic test helper and fix TSAN failures.

2015-08-18 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 32454.
EricWF added a comment.

Add more explanation to the wait tests.


http://reviews.llvm.org/D11046

Files:
  test/std/thread/thread.condition/notify_all_at_thread_exit.pass.cpp
  
test/std/thread/thread.condition/thread.condition.condvarany/wait.exception.pass.cpp
  
test/std/thread/thread.condition/thread.condition.condvarany/wait_for.exception.pass.cpp
  
test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp
  test/support/test_atomic.h

Index: test/support/test_atomic.h
===
--- /dev/null
+++ test/support/test_atomic.h
@@ -0,0 +1,109 @@
+#ifndef SUPPORT_TEST_ATOMIC_H
+#define SUPPORT_TEST_ATOMIC_H
+
+// If the atomic memory order macros are defined then assume
+// the compiler supports the required atomic builtins.
+#if !defined(__ATOMIC_SEQ_CST)
+#define TEST_HAS_NO_ATOMICS
+#endif
+
+template 
+class Atomic {
+   ValType value;
+   Atomic(Atomic const&);
+   Atomic& operator=(Atomic const&);
+   Atomic& operator=(Atomic const&) volatile;
+private:
+  enum {
+#if !defined(TEST_HAS_NO_ATOMICS)
+AO_Relaxed = __ATOMIC_RELAXED,
+AO_Seq = __ATOMIC_SEQ_CST
+#else
+AO_Relaxed,
+AO_Seq
+#endif
+  };
+  template 
+  static inline void atomic_store_imp(Tp* dest, FromType from, int order = AO_Seq) {
+#if !defined(TEST_HAS_NO_ATOMICS)
+  __atomic_store_n(dest, from, order);
+#else
+*dest = from;
+#endif
+  }
+
+  template 
+  static inline Tp atomic_load_imp(Tp* from, int order = AO_Seq) {
+#if !defined(TEST_HAS_NO_ATOMICS)
+return __atomic_load_n(from, order);
+#else
+return *from;
+#endif
+  }
+
+  template 
+  static inline Tp atomic_add_imp(Tp* val, AddType add, int order = AO_Seq) {
+#if !defined(TEST_HAS_NO_ATOMICS)
+  return __atomic_add_fetch(val, add, order);
+#else
+return *val += add;
+#endif
+  }
+
+  template 
+  static inline Tp atomic_exchange_imp(Tp* val, Tp other, int order = AO_Seq) {
+#if !defined(TEST_HAS_NO_ATOMICS)
+  return __atomic_exchange_n(val, other, order);
+#else
+  Tp old = *val;
+  *val = other;
+  return old;
+#endif
+  }
+public:
+Atomic() : value(0) {}
+Atomic(ValType x) : value(x) {}
+
+ValType operator=(ValType val) {
+   atomic_store_imp(&value, val);
+   return val;
+}
+
+ValType operator=(ValType val) volatile {
+atomic_store_imp(&value, val);
+return val;
+}
+
+ValType load() const volatile { return atomic_load_imp(&value); }
+voidstore(ValType val) volatile { atomic_store_imp(&value, val); }
+
+ValType relaxedLoad() const volatile { return atomic_load_imp(&value, AO_Relaxed); }
+voidrelaxedStore(ValType val) volatile { atomic_store_imp(&value, val, AO_Relaxed); }
+
+ValType exchange(ValType other) volatile { return atomic_exchange_imp(&value, other); }
+booltestAndSet() volatile { return atomic_exchange_imp(&value, 1); }
+voidclear() volatile { atomic_store_imp(&value, 0); }
+
+operator ValType() const { return atomic_load_imp(&value); }
+operator ValType() const volatile { return atomic_load_imp(&value); }
+
+ValType operator+=(ValType val)  { return atomic_add_imp(&value, val); }
+ValType operator-=(ValType val)  { return atomic_add_imp(&value, -val); }
+ValType operator+=(ValType val) volatile { return atomic_add_imp(&value, val); }
+ValType operator-=(ValType val) volatile { return atomic_add_imp(&value, -val); }
+
+ValType operator++()  { return *this += 1; }
+ValType operator++(int) { return (*this += 1) - 1;  }
+ValType operator++() volatile { return *this += 1; }
+ValType operator++(int) volatile { return (*this += 1) - 1;  }
+
+ValType operator--() { return *this -= 1; }
+ValType operator--(int) { return (*this -= 1) + 1; }
+ValType operator--() volatile { return *this -= 1; }
+ValType operator--(int) volatile { return (*this -= 1) + 1; }
+};
+
+typedef Atomic AtomicInt;
+typedef Atomic AtomicBool;
+
+#endif // SUPPORT_TEST_ATOMIC_H
Index: test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp
===
--- /dev/null
+++ test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp
@@ -0,0 +1,132 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// UNSUPPORTED: libcpp-has-no-threads
+
+// 
+
+// class condition_variable_any;
+
+// RUN: %build
+// RUN: %run 1
+// RUN: %run 2
+// RUN: %run 3
+// RUN: %run 4
+// RUN: %run 5
+// RUN: %run 6
+
+// 

Re: r245304 - We shouldn't need to pass -fno-strict-aliasing when building clang with clang.

2015-08-18 Thread Chris Bieneman via cfe-commits
Wow! Thank you for catching that!

Fixed in r245359.

-Chris

> On Aug 18, 2015, at 2:15 PM, Hal Finkel  wrote:
> 
> - Original Message -
>> From: "Chris Bieneman via cfe-commits" 
>> To: cfe-commits@lists.llvm.org
>> Sent: Tuesday, August 18, 2015 11:15:44 AM
>> Subject: r245304 - We shouldn't need to pass -fno-strict-aliasing when 
>> building clang with clang.
>> 
>> Author: cbieneman
>> Date: Tue Aug 18 11:15:44 2015
>> New Revision: 245304
>> 
>> URL: 
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D245304-26view-3Drev&d=BQICaQ&c=eEvniauFctOgLOKGJOplqw&r=Hfcbhu5JC70tzQtVGDgDJg&m=LZ6mOKBg2jvfMXj1e1AeP3UD23LAMeWnUDGoS7OAfRo&s=OwUS_r30_fyatqpHGo8Mfbpay2m_WXuAZbUe6yr-m5A&e=
>>  
>> Log:
>> We shouldn't need to pass -fno-strict-aliasing when building clang
>> with clang.
>> 
>> Summary: The code comments in the Makefile indicate this was put in
>> place to support issues when building clang with GCC. Today clang's
>> strict aliasing works, so we shouldn't pass -fno-strict-aliasing
>> when building with clang.
>> 
>> Reviewers: bogner, echristo
>> 
>> Subscribers: cfe-commits
>> 
>> Differential Revision: 
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D12036&d=BQICaQ&c=eEvniauFctOgLOKGJOplqw&r=Hfcbhu5JC70tzQtVGDgDJg&m=LZ6mOKBg2jvfMXj1e1AeP3UD23LAMeWnUDGoS7OAfRo&s=61uO56iUYJqbrrPmpu3s3IC4BqPskB4xQ1IhffBJM5g&e=
>>  
>> 
>> Modified:
>>cfe/trunk/CMakeLists.txt
>>cfe/trunk/Makefile
>> 
>> Modified: cfe/trunk/CMakeLists.txt
>> URL:
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_CMakeLists.txt-3Frev-3D245304-26r1-3D245303-26r2-3D245304-26view-3Ddiff&d=BQICaQ&c=eEvniauFctOgLOKGJOplqw&r=Hfcbhu5JC70tzQtVGDgDJg&m=LZ6mOKBg2jvfMXj1e1AeP3UD23LAMeWnUDGoS7OAfRo&s=kMBsIYcu-mqcpUPKstn6a3qKi1tZ8ZipfNj7-n5zJTE&e=
>>  
>> ==
>> --- cfe/trunk/CMakeLists.txt (original)
>> +++ cfe/trunk/CMakeLists.txt Tue Aug 18 11:15:44 2015
>> @@ -253,7 +253,10 @@ configure_file(
>> 
>> # Add appropriate flags for GCC
>> if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
>> -  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common
>> -Woverloaded-virtual -fno-strict-aliasing")
>> +  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common
>> -Woverloaded-virtual")
>> +  if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
>> +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
>> +  endif ()
>> 
>>   # Enable -pedantic for Clang even if it's not enabled for LLVM.
>>   if (NOT LLVM_ENABLE_PEDANTIC)
>> 
>> Modified: cfe/trunk/Makefile
>> URL:
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_Makefile-3Frev-3D245304-26r1-3D245303-26r2-3D245304-26view-3Ddiff&d=BQICaQ&c=eEvniauFctOgLOKGJOplqw&r=Hfcbhu5JC70tzQtVGDgDJg&m=LZ6mOKBg2jvfMXj1e1AeP3UD23LAMeWnUDGoS7OAfRo&s=oVWnGjjONssWGC7tIuD3ftvoidZBhow7jIBK3jGNPzY&e=
>>  
>> ==
>> --- cfe/trunk/Makefile (original)
>> +++ cfe/trunk/Makefile Tue Aug 18 11:15:44 2015
>> @@ -67,8 +67,11 @@ endif
>> #   
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__gcc.gnu.org_PR41874&d=BQICaQ&c=eEvniauFctOgLOKGJOplqw&r=Hfcbhu5JC70tzQtVGDgDJg&m=LZ6mOKBg2jvfMXj1e1AeP3UD23LAMeWnUDGoS7OAfRo&s=LjF6Tc2RbfHB6IGj5VcgnpQp0V7Ag_ptcayUefS3k0k&e=
>>  
>> #   
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__gcc.gnu.org_PR41838&d=BQICaQ&c=eEvniauFctOgLOKGJOplqw&r=Hfcbhu5JC70tzQtVGDgDJg&m=LZ6mOKBg2jvfMXj1e1AeP3UD23LAMeWnUDGoS7OAfRo&s=Wg9_cRbtgqczt08wykO8rWLJYEmUWSxVMeZmPVOxo_Y&e=
>>  
>> #
>> -# We can revisit this when LLVM/Clang support it.
>> +# We don't need to do this if the host compiler is clang.
>> +ifeq ($(CXX_COMPILER), "clang")
>> CXX.Flags += -fno-strict-aliasing
>> +endif
> 
> This logic is backwards, it disables strict aliasing when the compiler is 
> clang, and leaves it enabled otherwise. Perhaps you want to ifeq -> ifneq?
> 
> -Hal
> 
>> +
>> 
>> # Set up Clang's tblgen.
>> ifndef CLANG_TBLGEN
>> 
>> 
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Dcommits&d=BQICaQ&c=eEvniauFctOgLOKGJOplqw&r=Hfcbhu5JC70tzQtVGDgDJg&m=LZ6mOKBg2jvfMXj1e1AeP3UD23LAMeWnUDGoS7OAfRo&s=WPkNdzCUCk9mc2t5-AjiEWBOb63rfTn7cniall2Powc&e=
>>  
>> 
> 
> -- 
> Hal Finkel
> Assistant Computational Scientist
> Leadership Computing Facility
> Argonne National Laboratory

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


r245359 - [autoconf] Fixing reversed logic introduced r245304.

2015-08-18 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue Aug 18 16:23:44 2015
New Revision: 245359

URL: http://llvm.org/viewvc/llvm-project?rev=245359&view=rev
Log:
[autoconf] Fixing reversed logic introduced r245304.

Thanks for the catch Hal!

Modified:
cfe/trunk/Makefile

Modified: cfe/trunk/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/Makefile?rev=245359&r1=245358&r2=245359&view=diff
==
--- cfe/trunk/Makefile (original)
+++ cfe/trunk/Makefile Tue Aug 18 16:23:44 2015
@@ -68,7 +68,7 @@ endif
 #   http://gcc.gnu.org/PR41838
 #
 # We don't need to do this if the host compiler is clang.
-ifeq ($(CXX_COMPILER), "clang")
+ifneq ($(CXX_COMPILER), "clang")
 CXX.Flags += -fno-strict-aliasing
 endif
 


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


Re: r245304 - We shouldn't need to pass -fno-strict-aliasing when building clang with clang.

2015-08-18 Thread Hal Finkel via cfe-commits
- Original Message -
> From: "Chris Bieneman via cfe-commits" 
> To: cfe-commits@lists.llvm.org
> Sent: Tuesday, August 18, 2015 11:15:44 AM
> Subject: r245304 - We shouldn't need to pass -fno-strict-aliasing when 
> building clang with clang.
> 
> Author: cbieneman
> Date: Tue Aug 18 11:15:44 2015
> New Revision: 245304
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=245304&view=rev
> Log:
> We shouldn't need to pass -fno-strict-aliasing when building clang
> with clang.
> 
> Summary: The code comments in the Makefile indicate this was put in
> place to support issues when building clang with GCC. Today clang's
> strict aliasing works, so we shouldn't pass -fno-strict-aliasing
> when building with clang.
> 
> Reviewers: bogner, echristo
> 
> Subscribers: cfe-commits
> 
> Differential Revision: http://reviews.llvm.org/D12036
> 
> Modified:
> cfe/trunk/CMakeLists.txt
> cfe/trunk/Makefile
> 
> Modified: cfe/trunk/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=245304&r1=245303&r2=245304&view=diff
> ==
> --- cfe/trunk/CMakeLists.txt (original)
> +++ cfe/trunk/CMakeLists.txt Tue Aug 18 11:15:44 2015
> @@ -253,7 +253,10 @@ configure_file(
>  
>  # Add appropriate flags for GCC
>  if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
> -  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common
> -Woverloaded-virtual -fno-strict-aliasing")
> +  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common
> -Woverloaded-virtual")
> +  if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
> +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
> +  endif ()
>  
># Enable -pedantic for Clang even if it's not enabled for LLVM.
>if (NOT LLVM_ENABLE_PEDANTIC)
> 
> Modified: cfe/trunk/Makefile
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/Makefile?rev=245304&r1=245303&r2=245304&view=diff
> ==
> --- cfe/trunk/Makefile (original)
> +++ cfe/trunk/Makefile Tue Aug 18 11:15:44 2015
> @@ -67,8 +67,11 @@ endif
>  #   http://gcc.gnu.org/PR41874
>  #   http://gcc.gnu.org/PR41838
>  #
> -# We can revisit this when LLVM/Clang support it.
> +# We don't need to do this if the host compiler is clang.
> +ifeq ($(CXX_COMPILER), "clang")
>  CXX.Flags += -fno-strict-aliasing
> +endif

This logic is backwards, it disables strict aliasing when the compiler is 
clang, and leaves it enabled otherwise. Perhaps you want to ifeq -> ifneq?

 -Hal

> +
>  
>  # Set up Clang's tblgen.
>  ifndef CLANG_TBLGEN
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r245354 - Move atomic_support.h and config_elast.h into src/include

2015-08-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Aug 18 16:08:54 2015
New Revision: 245354

URL: http://llvm.org/viewvc/llvm-project?rev=245354&view=rev
Log:
Move atomic_support.h and config_elast.h into src/include

Added:
libcxx/trunk/src/include/
libcxx/trunk/src/include/atomic_support.h
libcxx/trunk/src/include/config_elast.h
Removed:
libcxx/trunk/src/config_elast.h
libcxx/trunk/src/support/atomic_support.h
Modified:
libcxx/trunk/src/ios.cpp
libcxx/trunk/src/memory.cpp
libcxx/trunk/src/mutex.cpp
libcxx/trunk/src/system_error.cpp

Removed: libcxx/trunk/src/config_elast.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/config_elast.h?rev=245353&view=auto
==
--- libcxx/trunk/src/config_elast.h (original)
+++ libcxx/trunk/src/config_elast.h (removed)
@@ -1,36 +0,0 @@
-//===--- config_elast.h 
---===//
-//
-// 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 _LIBCPP_CONFIG_ELAST
-#define _LIBCPP_CONFIG_ELAST
-
-#if defined(_WIN32)
-#include 
-#else
-#include 
-#endif
-
-#if defined(ELAST)
-#define _LIBCPP_ELAST ELAST
-#elif defined(_NEWLIB_VERSION)
-#define _LIBCPP_ELAST __ELASTERROR
-#elif defined(__linux__)
-#define _LIBCPP_ELAST 4095
-#elif defined(__APPLE__)
-// No _LIBCPP_ELAST needed on Apple
-#elif defined(__sun__)
-#define _LIBCPP_ELAST ESTALE
-#elif defined(_WIN32)
-#define _LIBCPP_ELAST _sys_nerr
-#else
-// Warn here so that the person doing the libcxx port has an easier time:
-#warning ELAST for this platform not yet implemented
-#endif
-
-#endif // _LIBCPP_CONFIG_ELAST

Added: libcxx/trunk/src/include/atomic_support.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/include/atomic_support.h?rev=245354&view=auto
==
--- libcxx/trunk/src/include/atomic_support.h (added)
+++ libcxx/trunk/src/include/atomic_support.h Tue Aug 18 16:08:54 2015
@@ -0,0 +1,142 @@
+#ifndef ATOMIC_SUPPORT_H
+#define ATOMIC_SUPPORT_H
+
+#include "__config"
+#include "memory" // for __libcpp_relaxed_load
+
+#if defined(__clang__) && __has_builtin(__atomic_load_n) \
+   && __has_builtin(__atomic_store_n)\
+   && __has_builtin(__atomic_add_fetch)  \
+   && __has_builtin(__atomic_compare_exchange_n) \
+   && defined(__ATOMIC_RELAXED)  \
+   && defined(__ATOMIC_CONSUME)  \
+   && defined(__ATOMIC_ACQUIRE)  \
+   && defined(__ATOMIC_RELEASE)  \
+   && defined(__ATOMIC_ACQ_REL)  \
+   && defined(__ATOMIC_SEQ_CST)
+#   define _LIBCPP_HAS_ATOMIC_BUILTINS
+#elif !defined(__clang__) && defined(_GNUC_VER) && _GNUC_VER >= 407
+#   define _LIBCPP_HAS_ATOMIC_BUILTINS
+#endif
+
+#if !defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)
+# if defined(_MSC_VER) && !defined(__clang__)
+_LIBCPP_WARNING("Building libc++ without __atomic builtins is unsupported")
+# else
+#   warning Building libc++ without __atomic builtins is unsupported
+# endif
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace {
+
+#if defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)
+
+enum __libcpp_atomic_order {
+_AO_Relaxed = __ATOMIC_RELAXED,
+_AO_Consume = __ATOMIC_CONSUME,
+_AO_Aquire  = __ATOMIC_ACQUIRE,
+_AO_Release = __ATOMIC_RELEASE,
+_AO_Acq_Rel = __ATOMIC_ACQ_REL,
+_AO_Seq = __ATOMIC_SEQ_CST
+};
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+void __libcpp_atomic_store(_ValueType* __dest, _FromType __val,
+   int __order = _AO_Seq)
+{
+__atomic_store_n(__dest, __val, __order);
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+void __libcpp_relaxed_store(_ValueType* __dest, _FromType __val)
+{
+__atomic_store_n(__dest, __val, _AO_Relaxed);
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+_ValueType __libcpp_atomic_load(_ValueType const* __val,
+int __order = _AO_Seq)
+{
+return __atomic_load_n(__val, __order);
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+_ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a,
+   int __order = _AO_Seq)
+{
+return __atomic_add_fetch(__val, __a, __order);
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+bool __libcpp_atomic_compare_exchange(_ValueType* __val,
+_ValueType* __expected, _ValueType __after,
+int __success_order = _AO_Seq,
+int __fail_order = _AO_Seq)
+{
+return __

Re: r245352 - Workaround -Wdeprecated on SemDiagnosticConsumer's tricksy copy ctor.

2015-08-18 Thread David Blaikie via cfe-commits
Richard, do you think there's anything we could do better here?

It seems difficult to support proper move semantic behavior for
[Sema]DiagnosticBuilder across the two common use cases:

  DiagnosticBuilder D;
  D << x;
  D << y;
  return D;

and

  return DiagnosticBuilder() << x << y;

The only thing I can imagine is if every one of those op<< were function
templates using universal references (I forget, is that the right name for
them?) and matching their return value (so in the first case, passed a
non-const lvalue ref, they return by non-const lvalue ref, and in the
second case, passed an rvalue, they return the same). But that seems
painful.


On Tue, Aug 18, 2015 at 1:54 PM, David Blaikie via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: dblaikie
> Date: Tue Aug 18 15:54:26 2015
> New Revision: 245352
>
> URL: http://llvm.org/viewvc/llvm-project?rev=245352&view=rev
> Log:
> Workaround -Wdeprecated on SemDiagnosticConsumer's tricksy copy ctor.
>
> Modified:
> cfe/trunk/include/clang/Sema/Sema.h
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=245352&r1=245351&r2=245352&view=diff
>
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Tue Aug 18 15:54:26 2015
> @@ -1054,6 +1054,14 @@ public:
>  SemaDiagnosticBuilder(DiagnosticBuilder &DB, Sema &SemaRef, unsigned
> DiagID)
>: DiagnosticBuilder(DB), SemaRef(SemaRef), DiagID(DiagID) { }
>
> +// This is a cunning lie. DiagnosticBuilder actually performs move
> +// construction in its copy constructor (but due to varied uses, it's
> not
> +// possible to conveniently express this as actual move
> construction). So
> +// the default copy ctor here is fine, because the base class
> disables the
> +// source anyway, so the user-defined ~SemaDiagnosticBuilder is a
> safe no-op
> +// in that case anwyay.
> +SemaDiagnosticBuilder(const SemaDiagnosticBuilder&) = default;
> +
>  ~SemaDiagnosticBuilder() {
>// If we aren't active, there is nothing to do.
>if (!isActive()) return;
>
>
> ___
> 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


r245352 - Workaround -Wdeprecated on SemDiagnosticConsumer's tricksy copy ctor.

2015-08-18 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Tue Aug 18 15:54:26 2015
New Revision: 245352

URL: http://llvm.org/viewvc/llvm-project?rev=245352&view=rev
Log:
Workaround -Wdeprecated on SemDiagnosticConsumer's tricksy copy ctor.

Modified:
cfe/trunk/include/clang/Sema/Sema.h

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=245352&r1=245351&r2=245352&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Aug 18 15:54:26 2015
@@ -1054,6 +1054,14 @@ public:
 SemaDiagnosticBuilder(DiagnosticBuilder &DB, Sema &SemaRef, unsigned 
DiagID)
   : DiagnosticBuilder(DB), SemaRef(SemaRef), DiagID(DiagID) { }
 
+// This is a cunning lie. DiagnosticBuilder actually performs move
+// construction in its copy constructor (but due to varied uses, it's not
+// possible to conveniently express this as actual move construction). So
+// the default copy ctor here is fine, because the base class disables the
+// source anyway, so the user-defined ~SemaDiagnosticBuilder is a safe 
no-op
+// in that case anwyay.
+SemaDiagnosticBuilder(const SemaDiagnosticBuilder&) = default;
+
 ~SemaDiagnosticBuilder() {
   // If we aren't active, there is nothing to do.
   if (!isActive()) return;


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


r245346 - Initialize the AST consumer as soon as we have both an ASTConsumer and an

2015-08-18 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Aug 18 15:39:29 2015
New Revision: 245346

URL: http://llvm.org/viewvc/llvm-project?rev=245346&view=rev
Log:
Initialize the AST consumer as soon as we have both an ASTConsumer and an
ASTContext. Fixes some cases where we could previously initialize the AST
consumer more than once.

Modified:
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/lib/Frontend/ASTMerge.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/test/Index/index-pch-with-module.m
cfe/trunk/test/Index/skip-parsed-bodies/compile_commands.json

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=245346&r1=245345&r2=245346&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Tue Aug 18 15:39:29 2015
@@ -82,11 +82,8 @@ namespace clang {
 }
 
 void Initialize(ASTContext &Ctx) override {
-  if (Context) {
-assert(Context == &Ctx);
-return;
-  }
-
+  assert(!Context && "initialized multiple times");
+
   Context = &Ctx;
 
   if (llvm::TimePassesIsEnabled)

Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=245346&r1=245345&r2=245346&view=diff
==
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Tue Aug 18 
15:39:29 2015
@@ -71,10 +71,7 @@ public:
   virtual ~PCHContainerGenerator() {}
 
   void Initialize(ASTContext &Context) override {
-if (Ctx) {
-  assert(Ctx == &Context);
-  return;
-}
+assert(!Ctx && "initialized multiple times");
 
 Ctx = &Context;
 VMContext.reset(new llvm::LLVMContext());

Modified: cfe/trunk/lib/Frontend/ASTMerge.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTMerge.cpp?rev=245346&r1=245345&r2=245346&view=diff
==
--- cfe/trunk/lib/Frontend/ASTMerge.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTMerge.cpp Tue Aug 18 15:39:29 2015
@@ -59,7 +59,6 @@ void ASTMergeAction::ExecuteAction() {
  /*MinimalImport=*/false);
 
 TranslationUnitDecl *TU = Unit->getASTContext().getTranslationUnitDecl();
-CI.getASTConsumer().Initialize(CI.getASTContext());
 for (auto *D : TU->decls()) {
   // Don't re-import __va_list_tag, __builtin_va_list.
   if (const auto *ND = dyn_cast(D))

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=245346&r1=245345&r2=245346&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Tue Aug 18 15:39:29 2015
@@ -96,7 +96,12 @@ void CompilerInstance::setSourceManager(
 
 void CompilerInstance::setPreprocessor(Preprocessor *Value) { PP = Value; }
 
-void CompilerInstance::setASTContext(ASTContext *Value) { Context = Value; }
+void CompilerInstance::setASTContext(ASTContext *Value) {
+  Context = Value;
+
+  if (Context && Consumer)
+getASTConsumer().Initialize(getASTContext());
+}
 
 void CompilerInstance::setSema(Sema *S) {
   TheSema.reset(S);
@@ -104,6 +109,9 @@ void CompilerInstance::setSema(Sema *S)
 
 void CompilerInstance::setASTConsumer(std::unique_ptr Value) {
   Consumer = std::move(Value);
+
+  if (Context && Consumer)
+getASTConsumer().Initialize(getASTContext());
 }
 
 void CompilerInstance::setCodeCompletionConsumer(CodeCompleteConsumer *Value) {
@@ -385,10 +393,11 @@ std::string CompilerInstance::getSpecifi
 
 void CompilerInstance::createASTContext() {
   Preprocessor &PP = getPreprocessor();
-  Context = new ASTContext(getLangOpts(), PP.getSourceManager(),
-   PP.getIdentifierTable(), PP.getSelectorTable(),
-   PP.getBuiltinInfo());
+  auto *Context = new ASTContext(getLangOpts(), PP.getSourceManager(),
+ PP.getIdentifierTable(), 
PP.getSelectorTable(),
+ PP.getBuiltinInfo());
   Context->InitBuiltinTypes(getTarget());
+  setASTContext(Context);
 }
 
 // ExternalASTSource
@@ -1249,7 +1258,7 @@ void CompilerInstance::createModuleManag
   ReadTimer = llvm::make_unique("Reading modules",
  *FrontendTimerGroup);
 ModuleManager = new ASTReader(
-getPreprocessor(), *Context, getPCHContainerReader(),
+getPreprocessor(), getASTCont

r245344 - [sanitizer] Add -lutil to static runtime link flags.

2015-08-18 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Tue Aug 18 15:36:11 2015
New Revision: 245344

URL: http://llvm.org/viewvc/llvm-project?rev=245344&view=rev
Log:
[sanitizer] Add -lutil to static runtime link flags.

This is needed to prevent breakage of -Wl,-as-needed link when
interceptors for functions in libutil are added. See PR15823.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/sanitizer-ld.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=245344&r1=245343&r2=245344&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Aug 18 15:36:11 2015
@@ -2498,6 +2498,7 @@ static void linkSanitizerRuntimeDeps(con
   CmdArgs.push_back("--no-as-needed");
   CmdArgs.push_back("-lpthread");
   CmdArgs.push_back("-lrt");
+  CmdArgs.push_back("-lutil");
   CmdArgs.push_back("-lm");
   // There's no libdl on FreeBSD.
   if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)

Modified: cfe/trunk/test/Driver/sanitizer-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/sanitizer-ld.c?rev=245344&r1=245343&r2=245344&view=diff
==
--- cfe/trunk/test/Driver/sanitizer-ld.c (original)
+++ cfe/trunk/test/Driver/sanitizer-ld.c Tue Aug 18 15:36:11 2015
@@ -14,6 +14,7 @@
 // CHECK-ASAN-LINUX-NOT: "-export-dynamic"
 // CHECK-ASAN-LINUX: "-lpthread"
 // CHECK-ASAN-LINUX: "-lrt"
+// CHECK-ASAN-LINUX: "-lutil"
 // CHECK-ASAN-LINUX: "-ldl"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -29,6 +30,7 @@
 // CHECK-SHARED-ASAN-LINUX: "-whole-archive" 
"{{.*}}libclang_rt.asan-preinit-i386.a" "-no-whole-archive"
 // CHECK-SHARED-ASAN-LINUX-NOT: "-lpthread"
 // CHECK-SHARED-ASAN-LINUX-NOT: "-lrt"
+// CHECK-SHARED-ASAN-LINUX-NOT: "-lutil"
 // CHECK-SHARED-ASAN-LINUX-NOT: "-ldl"
 // CHECK-SHARED-ASAN-LINUX-NOT: "-export-dynamic"
 // CHECK-SHARED-ASAN-LINUX-NOT: "--dynamic-list"
@@ -46,6 +48,7 @@
 // CHECK-DSO-SHARED-ASAN-LINUX: libclang_rt.asan-i386.so"
 // CHECK-DSO-SHARED-ASAN-LINUX-NOT: "-lpthread"
 // CHECK-DSO-SHARED-ASAN-LINUX-NOT: "-lrt"
+// CHECK-DSO-SHARED-ASAN-LINUX-NOT: "-lutil"
 // CHECK-DSO-SHARED-ASAN-LINUX-NOT: "-ldl"
 // CHECK-DSO-SHARED-ASAN-LINUX-NOT: "-export-dynamic"
 // CHECK-DSO-SHARED-ASAN-LINUX-NOT: "--dynamic-list"
@@ -65,6 +68,7 @@
 // CHECK-ASAN-FREEBSD: "-export-dynamic"
 // CHECK-ASAN-FREEBSD: "-lpthread"
 // CHECK-ASAN-FREEBSD: "-lrt"
+// CHECK-ASAN-FREEBSD: "-lutil"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-freebsd -fsanitize=address \
@@ -90,6 +94,7 @@
 // CHECK-ASAN-LINUX-CXX: stdc++
 // CHECK-ASAN-LINUX-CXX: "-lpthread"
 // CHECK-ASAN-LINUX-CXX: "-lrt"
+// CHECK-ASAN-LINUX-CXX: "-lutil"
 // CHECK-ASAN-LINUX-CXX: "-ldl"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o /dev/null -fsanitize=address \
@@ -167,6 +172,7 @@
 // CHECK-TSAN-LINUX-CXX: stdc++
 // CHECK-TSAN-LINUX-CXX: "-lpthread"
 // CHECK-TSAN-LINUX-CXX: "-lrt"
+// CHECK-TSAN-LINUX-CXX: "-lutil"
 // CHECK-TSAN-LINUX-CXX: "-ldl"
 
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -185,6 +191,7 @@
 // CHECK-MSAN-LINUX-CXX: stdc++
 // CHECK-MSAN-LINUX-CXX: "-lpthread"
 // CHECK-MSAN-LINUX-CXX: "-lrt"
+// CHECK-MSAN-LINUX-CXX: "-lutil"
 // CHECK-MSAN-LINUX-CXX: "-ldl"
 
 // RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \


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


[libcxx] r245343 - GC empty directory.

2015-08-18 Thread Joerg Sonnenberger via cfe-commits
Author: joerg
Date: Tue Aug 18 15:34:33 2015
New Revision: 245343

URL: http://llvm.org/viewvc/llvm-project?rev=245343&view=rev
Log:
GC empty directory.

Removed:
libcxx/trunk/src/support/newlib/

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


r245342 - Revert r245323, it caused PR24493.

2015-08-18 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Aug 18 15:32:55 2015
New Revision: 245342

URL: http://llvm.org/viewvc/llvm-project?rev=245342&view=rev
Log:
Revert r245323, it caused PR24493.

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/CodeGen/object-size.c
cfe/trunk/test/Sema/const-eval.c

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=245342&r1=245341&r2=245342&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Aug 18 15:32:55 2015
@@ -967,6 +967,10 @@ namespace {
 // Check this LValue refers to an object. If not, set the designator to be
 // invalid and emit a diagnostic.
 bool checkSubobject(EvalInfo &Info, const Expr *E, CheckSubobjectKind CSK) 
{
+  // Outside C++11, do not build a designator referring to a subobject of
+  // any object: we won't use such a designator for anything.
+  if (!Info.getLangOpts().CPlusPlus11)
+Designator.setInvalid();
   return (CSK == CSK_ArrayToPointer || checkNullPointer(Info, E, CSK)) &&
  Designator.checkSubobject(Info, E, CSK);
 }
@@ -2709,7 +2713,8 @@ static bool handleLValueToRValueConversi
 
   // Check for special cases where there is no existing APValue to look at.
   const Expr *Base = LVal.Base.dyn_cast();
-  if (Base && !LVal.CallIndex && !Type.isVolatileQualified()) {
+  if (!LVal.Designator.Invalid && Base && !LVal.CallIndex &&
+  !Type.isVolatileQualified()) {
 if (const CompoundLiteralExpr *CLE = dyn_cast(Base)) {
   // In C99, a CompoundLiteralExpr is an lvalue, and we defer evaluating 
the
   // initializer until now for such expressions. Such an expression can't 
be
@@ -5993,7 +5998,8 @@ public:
   bool VisitSizeOfPackExpr(const SizeOfPackExpr *E);
 
 private:
-  bool TryEvaluateBuiltinObjectSize(const CallExpr *E, unsigned Type);
+  static QualType GetObjectType(APValue::LValueBase B);
+  bool TryEvaluateBuiltinObjectSize(const CallExpr *E);
   // FIXME: Missing: array subscript of vector, member of vector
 };
 } // end anonymous namespace
@@ -6165,7 +6171,7 @@ static bool EvaluateBuiltinConstantP(AST
 
 /// Retrieves the "underlying object type" of the given expression,
 /// as used by __builtin_object_size.
-static QualType getObjectType(APValue::LValueBase B) {
+QualType IntExprEvaluator::GetObjectType(APValue::LValueBase B) {
   if (const ValueDecl *D = B.dyn_cast()) {
 if (const VarDecl *VD = dyn_cast(D))
   return VD->getType();
@@ -6177,87 +6183,49 @@ static QualType getObjectType(APValue::L
   return QualType();
 }
 
-bool IntExprEvaluator::TryEvaluateBuiltinObjectSize(const CallExpr *E,
-unsigned Type) {
-  // Determine the denoted object.
+bool IntExprEvaluator::TryEvaluateBuiltinObjectSize(const CallExpr *E) {
   LValue Base;
+
   {
 // The operand of __builtin_object_size is never evaluated for 
side-effects.
 // If there are any, but we can determine the pointed-to object anyway, 
then
 // ignore the side-effects.
 SpeculativeEvaluationRAII SpeculativeEval(Info);
-FoldConstant Fold(Info, true);
 if (!EvaluatePointer(E->getArg(0), Base, Info))
   return false;
   }
 
-  CharUnits BaseOffset = Base.getLValueOffset();
-
-  // If we point to before the start of the object, there are no
-  // accessible bytes.
-  if (BaseOffset < CharUnits::Zero())
-return Success(0, E);
-
-  // If Type & 1 is 0, the object in question is the complete object; reset to
-  // a complete object designator in that case.
-  //
-  // If Type is 1 and we've lost track of the subobject, just find the complete
-  // object instead. (If Type is 3, that's not correct behavior and we should
-  // return 0 instead.)
-  LValue End = Base;
-  if (((Type & 1) == 0) || (End.Designator.Invalid && Type == 1)) {
-QualType T = getObjectType(End.getLValueBase());
-if (T.isNull())
-  End.Designator.setInvalid();
-else {
-  End.Designator = SubobjectDesignator(T);
-  End.Offset = CharUnits::Zero();
-}
-  }
-
-  // FIXME: We should produce a valid object size for an unknown object with a
-  // known designator, if Type & 1 is 1. For instance:
-  //
-  //   extern struct X { char buff[32]; int a, b, c; } *p;
-  //   int a = __builtin_object_size(p->buff + 4, 3); // returns 28
-  //   int b = __builtin_object_size(p->buff + 4, 2); // returns 0, not 40
-  //
-  // This is GCC's behavior. We currently don't do this, but (hopefully) will 
in
-  // the near future.
-
-  // If it is not possible to determine which objects ptr points to at compile
-  // time, __builtin_object_size should return (size_t) -1 for type 0 or 1
-  // and (size_t) 0 for type 2 or 3.
-  if (End.Designator.Invalid)
-return false;
-
-  // According to the GCC documentation, we want the size of the subobject
-  // denote

[clang-tools-extra] r245340 - We no longer need a custom matcher for this; use the builtin AST matcher instead. NFC, and existing tests should cover this change.

2015-08-18 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Aug 18 15:27:44 2015
New Revision: 245340

URL: http://llvm.org/viewvc/llvm-project?rev=245340&view=rev
Log:
We no longer need a custom matcher for this; use the builtin AST matcher 
instead. NFC, and existing tests should cover this change.

Modified:
clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp?rev=245340&r1=245339&r2=245340&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp 
Tue Aug 18 15:27:44 2015
@@ -15,20 +15,14 @@
 using namespace clang::ast_matchers;
 
 namespace clang {
-namespace {
-AST_MATCHER(NamespaceDecl, isAnonymousNamespace) {
-  return Node.isAnonymousNamespace();
-}
-} // namespace
-
 namespace tidy {
 namespace google {
 namespace build {
 
 void UnnamedNamespaceInHeaderCheck::registerMatchers(
 ast_matchers::MatchFinder *Finder) {
-  Finder->addMatcher(
-  namespaceDecl(isAnonymousNamespace()).bind("anonymousNamespace"), this);
+  Finder->addMatcher(namespaceDecl(isAnonymous()).bind("anonymousNamespace"),
+ this);
 }
 
 void


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


r245339 - Simplify Diagnostic's ctors a bit by using in-class initializers for its members

2015-08-18 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Tue Aug 18 15:24:06 2015
New Revision: 245339

URL: http://llvm.org/viewvc/llvm-project?rev=245339&view=rev
Log:
Simplify Diagnostic's ctors a bit by using in-class initializers for its members

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

Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=245339&r1=245338&r2=245339&view=diff
==
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Tue Aug 18 15:24:06 2015
@@ -864,28 +864,27 @@ public:
 /// the common fields to registers, eliminating increments of the NumArgs 
field,
 /// for example.
 class DiagnosticBuilder {
-  mutable DiagnosticsEngine *DiagObj;
-  mutable unsigned NumArgs;
+  mutable DiagnosticsEngine *DiagObj = nullptr;
+  mutable unsigned NumArgs = 0;
 
   /// \brief Status variable indicating if this diagnostic is still active.
   ///
   // NOTE: This field is redundant with DiagObj (IsActive iff (DiagObj == 0)),
   // but LLVM is not currently smart enough to eliminate the null check that
   // Emit() would end up with if we used that as our status variable.
-  mutable bool IsActive;
+  mutable bool IsActive = false;
 
   /// \brief Flag indicating that this diagnostic is being emitted via a
   /// call to ForceEmit.
-  mutable bool IsForceEmit;
+  mutable bool IsForceEmit = false;
 
   void operator=(const DiagnosticBuilder &) = delete;
   friend class DiagnosticsEngine;
 
-  DiagnosticBuilder()
-  : DiagObj(nullptr), NumArgs(0), IsActive(false), IsForceEmit(false) {}
+  DiagnosticBuilder() = default;
 
   explicit DiagnosticBuilder(DiagnosticsEngine *diagObj)
-  : DiagObj(diagObj), NumArgs(0), IsActive(true), IsForceEmit(false) {
+  : DiagObj(diagObj), IsActive(true) {
 assert(diagObj && "DiagnosticBuilder requires a valid DiagnosticsEngine!");
 diagObj->DiagRanges.clear();
 diagObj->DiagFixItHints.clear();


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


Re: r244416 - [modules] PR22534: Load files specified by -fmodule-file= eagerly. In particular, this avoids the need to re-parse module map files when using such a module.

2015-08-18 Thread Gábor Horváth via cfe-commits
Sorry, I sent the original message to the wrong list.

-- Forwarded message --
From: Gábor Horváth 
Date: 18 August 2015 at 12:59
Subject: Re: r244416 - [modules] PR22534: Load files specified by
-fmodule-file= eagerly. In particular, this avoids the need to re-parse
module map files when using such a module.
To: Richard Smith 
Cc: "cfe-comm...@cs.uiuc.edu" 


Hi!

In r244416 you made createModuleManager to call the Initialize method of
the ASTConsumer.
Because of this change the ASTConsumer::Initialize might be called twice in
some scenarios.

This change makes the Static Analyzer crash (use after free) in those
scenarios. I think most of the ASTConsumers was not written with that in
mind Initialize might be called twice for the object. This fact is also not
covered by the documentation.

In my opinion we should either guarantee that the Initialize method will be
called only once during the lifetime of an ASTConsumer, or document the
fact that, it might be called multiple times and notify the authors of the
different consumers to update their classes accordingly (announcement on
the mailing list?).

What do you think?

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


Re: [PATCH] D12110: [SemaExpr] Re-enable missing assertion

2015-08-18 Thread Davide Italiano via cfe-commits
While at it, maybe the assertion can be modernized removing the != 0 part.

On Tue, Aug 18, 2015 at 3:09 PM, Davide Italiano  wrote:
> davide created this revision.
> davide added a reviewer: rsmith.
> davide added a subscriber: cfe-commits.
>
> This has been disabled for a long time, but:
> 1) Initializers work (and apparently they're re reason why this was disabled).
> 2) various tests happen to hit this code path and the invariant seems to be 
> always verified.
>
> I propose to add this back, it may be useful to catch mistakes.
>
> http://reviews.llvm.org/D12110
>
> Files:
>   lib/Sema/SemaExpr.cpp
>
> Index: lib/Sema/SemaExpr.cpp
> ===
> --- lib/Sema/SemaExpr.cpp
> +++ lib/Sema/SemaExpr.cpp
> @@ -5085,8 +5085,7 @@
>  Sema::ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty,
> SourceLocation RParenLoc, Expr *InitExpr) {
>assert(Ty && "ActOnCompoundLiteral(): missing type");
> -  // FIXME: put back this assert when initializers are worked out.
> -  //assert((InitExpr != 0) && "ActOnCompoundLiteral(): missing expression");
> +  assert((InitExpr != 0) && "ActOnCompoundLiteral(): missing expression");
>
>TypeSourceInfo *TInfo;
>QualType literalType = GetTypeFromParser(Ty, &TInfo);
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r245336 - Broke C++03 compatibility in 245330. Fix that.

2015-08-18 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Aug 18 14:51:37 2015
New Revision: 245336

URL: http://llvm.org/viewvc/llvm-project?rev=245336&view=rev
Log:
Broke C++03 compatibility in 245330. Fix that.

Modified:
libcxx/trunk/include/memory

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=245336&r1=245335&r2=245336&view=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Tue Aug 18 14:51:37 2015
@@ -5574,7 +5574,7 @@ template 
 _LIBCPP_INLINE_VISIBILITY
 void __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {}
 
-template >
+template  >
 struct __noexcept_move_assign_container : public integral_constant 14


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


[libcxx] r245335 - [libcxx] Fix PR23589: std::function doesn't recognize null pointer to varargs function.

2015-08-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Aug 18 14:41:51 2015
New Revision: 245335

URL: http://llvm.org/viewvc/llvm-project?rev=245335&view=rev
Log:
[libcxx] Fix PR23589: std::function doesn't recognize null pointer to varargs 
function.

Summary:
This patch fixes __not_null's detection of nullptr by breaking it down into 4 
cases.

1. `__not_null(Tp const&)`: Default case. Tp is not null.
2. `__not_null(Tp* __ptr);` Case for pointers to functions.
3. `__not_null(_Ret _Class::* __ptr);` Case for pointers to members.
4. `__not_null(function const&);`: Cases for other std::functions.

Reviewers: mclow.lists

Subscribers: cfe-commits

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

Added:

libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp
Modified:
libcxx/trunk/include/__functional_03
libcxx/trunk/include/functional

Modified: libcxx/trunk/include/__functional_03
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__functional_03?rev=245335&r1=245334&r2=245335&view=diff
==
--- libcxx/trunk/include/__functional_03 (original)
+++ libcxx/trunk/include/__functional_03 Tue Aug 18 14:41:51 2015
@@ -451,15 +451,6 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp
 aligned_storage<3*sizeof(void*)>::type __buf_;
 __base* __f_;
 
-template 
-_LIBCPP_INLINE_VISIBILITY
-static bool __not_null(const _Fp&) {return true;}
-template 
-_LIBCPP_INLINE_VISIBILITY
-static bool __not_null(_R2 (*__p)()) {return __p;}
-template 
-_LIBCPP_INLINE_VISIBILITY
-static bool __not_null(const function<_R2()>& __p) {return __p;}
 public:
 typedef _Rp result_type;
 
@@ -558,7 +549,7 @@ function<_Rp()>::function(_Fp __f,
  typename 
enable_if::value>::type*)
 : __f_(0)
 {
-if (__not_null(__f))
+if (__function::__not_null(__f))
 {
 typedef __function::__func<_Fp, allocator<_Fp>, _Rp()> _FF;
 if (sizeof(_FF) <= sizeof(__buf_))
@@ -585,7 +576,7 @@ function<_Rp()>::function(allocator_arg_
 : __f_(0)
 {
 typedef allocator_traits<_Alloc> __alloc_traits;
-if (__not_null(__f))
+if (__function::__not_null(__f))
 {
 typedef __function::__func<_Fp, _Alloc, _Rp()> _FF;
 if (sizeof(_FF) <= sizeof(__buf_))
@@ -736,27 +727,6 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp
 aligned_storage<3*sizeof(void*)>::type __buf_;
 __base* __f_;
 
-template 
-_LIBCPP_INLINE_VISIBILITY
-static bool __not_null(const _Fp&) {return true;}
-template 
-_LIBCPP_INLINE_VISIBILITY
-static bool __not_null(_R2 (*__p)(_B0)) {return __p;}
-template 
-_LIBCPP_INLINE_VISIBILITY
-static bool __not_null(_R2 (_Cp::*__p)()) {return __p;}
-template 
-_LIBCPP_INLINE_VISIBILITY
-static bool __not_null(_R2 (_Cp::*__p)() const) {return __p;}
-template 
-_LIBCPP_INLINE_VISIBILITY
-static bool __not_null(_R2 (_Cp::*__p)() volatile) {return __p;}
-template 
-_LIBCPP_INLINE_VISIBILITY
-static bool __not_null(_R2 (_Cp::*__p)() const volatile) {return __p;}
-template 
-_LIBCPP_INLINE_VISIBILITY
-static bool __not_null(const function<_R2(_B0)>& __p) {return __p;}
 public:
 typedef _Rp result_type;
 
@@ -855,7 +825,7 @@ function<_Rp(_A0)>::function(_Fp __f,
  typename 
enable_if::value>::type*)
 : __f_(0)
 {
-if (__not_null(__f))
+if (__function::__not_null(__f))
 {
 typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0)> _FF;
 if (sizeof(_FF) <= sizeof(__buf_))
@@ -882,7 +852,7 @@ function<_Rp(_A0)>::function(allocator_a
 : __f_(0)
 {
 typedef allocator_traits<_Alloc> __alloc_traits;
-if (__not_null(__f))
+if (__function::__not_null(__f))
 {
 typedef __function::__func<_Fp, _Alloc, _Rp(_A0)> _FF;
 if (sizeof(_FF) <= sizeof(__buf_))
@@ -1033,27 +1003,6 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp
 aligned_storage<3*sizeof(void*)>::type __buf_;
 __base* __f_;
 
-template 
-_LIBCPP_INLINE_VISIBILITY
-static bool __not_null(const _Fp&) {return true;}
-template 
-_LIBCPP_INLINE_VISIBILITY
-static bool __not_null(_R2 (*__p)(_B0, _B1)) {return __p;}
-template 
-_LIBCPP_INLINE_VISIBILITY
-static bool __not_null(_R2 (_Cp::*__p)(_B1)) {return __p;}
-template 
-_LIBCPP_INLINE_VISIBILITY
-static bool __not_null(_R2 (_Cp::*__p)(_B1) const) {return __p;}
-template 
-_LIBCPP_INLINE_VISIBILITY
-static bool __not_null(_R2 (_Cp::*__p)(_B1) volatile) {return __p;}
-template 
-_LIBCPP_INLINE_VISIBILITY
-static bool __not_null(_R2 (_Cp::*__p)(_B1) const volatile) {return 
__p;}
-template 
-_LIBCPP_INLINE_VISIBILITY
-  

  1   2   >