Re: [PATCH] D17815: [libc++abi] Use fallback_malloc to allocate __cxa_eh_globals in case of dynamic memory exhaustion.

2016-04-18 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

It's almost there.

Please move "fallback_malloc.ipp" into "fallback_malloc.cpp"  and then delete 
it all together. We can't have other files trying to include it.



Comment at: src/fallback_malloc.cpp:23
@@ +22,3 @@
+namespace __cxxabiv1 {
+
+void * __cxa_malloc_with_fallback(size_t size) {

I think we should have the `pragma GCC visibility push(hidden)` in this file as 
well, but I'm not 100% sure.


Comment at: test/test_exception_storage_nodynmem.pass.cpp:13
@@ +12,3 @@
+// Override calloc to simulate exhaustion of dynamic memory
+void *calloc(size_t, size_t) { return 0; }
+

Let's check that we actually replace `calloc` here and assert that our 
replacement has been called at the end of main.


Comment at: test/test_exception_storage_nodynmem.pass.cpp:16
@@ +15,3 @@
+int main(int argc, char *argv[]) {
+  try {
+throw 42;

Let's perform this test a couple of times so we're testing
* The memory get's returned properly
* The returned memory can be reused.


http://reviews.llvm.org/D17815



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


Re: [PATCH] D19248: [CUDA] Add --cuda-compile-host-device, which overrides --cuda-host-only and --cuda-device-only.

2016-04-18 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266707: [CUDA] Add --cuda-compile-host-device, which 
overrides --cuda-host-only and… (authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D19248?vs=54148=54152#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19248

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Driver/cuda-options.cu
  cfe/trunk/test/Driver/cuda-unused-arg-warning.cu

Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -375,11 +375,15 @@
 def c : Flag<["-"], "c">, Flags<[DriverOption]>,
   HelpText<"Only run preprocess, compile, and assemble steps">;
 def cuda_device_only : Flag<["--"], "cuda-device-only">,
-  HelpText<"Do device-side CUDA compilation only">;
+  HelpText<"Compile CUDA code for device only">;
+def cuda_host_only : Flag<["--"], "cuda-host-only">,
+  HelpText<"Compile CUDA code for host only.  Has no effect on non-CUDA "
+   "compilations.">;
+def cuda_compile_host_device : Flag<["--"], "cuda-compile-host-device">,
+  HelpText<"Compile CUDA code for both host and device (default).  Has no "
+   "effect on non-CUDA compilations.">;
 def cuda_gpu_arch_EQ : Joined<["--"], "cuda-gpu-arch=">, Flags<[DriverOption]>,
   HelpText<"CUDA GPU architecture (e.g. sm_35).  May be specified more than once.">;
-def cuda_host_only : Flag<["--"], "cuda-host-only">,
-  HelpText<"Do host-side CUDA compilation only">;
 def cuda_noopt_device_debug : Flag<["--"], "cuda-noopt-device-debug">,
   HelpText<"Enable device-side debug info generation. Disables ptxas optimizations.">;
 def cuda_path_EQ : Joined<["--"], "cuda-path=">, Group,
Index: cfe/trunk/test/Driver/cuda-unused-arg-warning.cu
===
--- cfe/trunk/test/Driver/cuda-unused-arg-warning.cu
+++ cfe/trunk/test/Driver/cuda-unused-arg-warning.cu
@@ -4,11 +4,16 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 
-// --cuda-host-only should never trigger unused arg warning.
+// --cuda-host-only and --cuda-compile-host-device should never trigger an
+// unused arg warning.
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -c %s 2>&1 | \
 // RUN:FileCheck %s
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -x c -c %s 2>&1 | \
 // RUN:FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-compile-host-device -c %s 2>&1 | \
+// RUN:FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-compile-host-device -x c -c %s 2>&1 | \
+// RUN:FileCheck %s
 
 // --cuda-device-only should warn during non-CUDA compilation.
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -x c -c %s 2>&1 | \
@@ -19,5 +24,6 @@
 // RUN:FileCheck -check-prefix NO-UNUSED-WARNING %s
 
 // CHECK-NOT: warning: argument unused during compilation: '--cuda-host-only'
+// CHECK-NOT: warning: argument unused during compilation: '--cuda-compile-host-device'
 // UNUSED-WARNING: warning: argument unused during compilation: '--cuda-device-only'
 // NO-UNUSED-WARNING-NOT: warning: argument unused during compilation: '--cuda-device-only'
Index: cfe/trunk/test/Driver/cuda-options.cu
===
--- cfe/trunk/test/Driver/cuda-options.cu
+++ cfe/trunk/test/Driver/cuda-options.cu
@@ -22,23 +22,46 @@
 // RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \
 // RUN:-check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s
 
-// Same test as above, but with preceeding --cuda-device-only to make sure only
-// the last option has an effect.
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only --cuda-host-only %s 2>&1 \
+// Verify that --cuda-device-only disables host-side compilation and linking.
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only %s 2>&1 \
+// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
+// RUN:-check-prefix NOHOST -check-prefix NOLINK %s
+
+// Check that the last of --cuda-compile-host-device, --cuda-host-only, and
+// --cuda-device-only wins.
+
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:--cuda-host-only %s 2>&1 \
 // RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \
 // RUN:-check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s
 
-// Verify that --cuda-device-only disables host-side compilation and linking.
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only %s 2>&1 \
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-compile-host-device \
+// RUN:--cuda-host-only %s 2>&1 \
+// RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \
+// RUN:-check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s
+
+// RUN: %clang -### -target 

r266706 - Add a test case to check a member's default constructor is also run.

2016-04-18 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon Apr 18 21:21:47 2016
New Revision: 266706

URL: http://llvm.org/viewvc/llvm-project?rev=266706=rev
Log:
Add a test case to check a member's default constructor is also run.

This is a follow-up to r266645.

Modified:
cfe/trunk/test/Parser/objc-default-ctor-init.mm

Modified: cfe/trunk/test/Parser/objc-default-ctor-init.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-default-ctor-init.mm?rev=266706=266705=266706=diff
==
--- cfe/trunk/test/Parser/objc-default-ctor-init.mm (original)
+++ cfe/trunk/test/Parser/objc-default-ctor-init.mm Mon Apr 18 21:21:47 2016
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.10 -std=c++11 -ast-dump %s | 
FileCheck %s
 // CHECK: CXXCtorInitializer Field {{.*}} 'ptr' 'void *'
+// CHECK: CXXCtorInitializer Field {{.*}} 'q' 'struct Q'
 
 @interface NSObject
 @end
@@ -7,9 +8,12 @@
 @interface I : NSObject
 @end
 
+struct Q { Q(); };
+
 struct S {
   S();
   void *ptr = nullptr;
+  Q q;
 };
 
 @implementation I


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


Re: [PATCH] D17815: [libc++abi] Use fallback_malloc to allocate __cxa_eh_globals in case of dynamic memory exhaustion.

2016-04-18 Thread Igor Kudrin via cfe-commits
ikudrin updated this revision to Diff 54151.
ikudrin added a comment.

Regenerated the patch against project's root.


http://reviews.llvm.org/D17815

Files:
  src/CMakeLists.txt
  src/cxa_exception.cpp
  src/cxa_exception_storage.cpp
  src/fallback_malloc.cpp
  src/fallback_malloc.h
  test/test_exception_storage_nodynmem.pass.cpp

Index: test/test_exception_storage_nodynmem.pass.cpp
===
--- /dev/null
+++ test/test_exception_storage_nodynmem.pass.cpp
@@ -0,0 +1,21 @@
+//===--- test_exception_storage_nodynmem.cpp --===//
+//
+// 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.
+//
+//===--===//
+
+#include 
+
+// Override calloc to simulate exhaustion of dynamic memory
+void *calloc(size_t, size_t) { return 0; }
+
+int main(int argc, char *argv[]) {
+  try {
+throw 42;
+  } catch (...) {
+  }
+  return 0;
+}
Index: src/fallback_malloc.h
===
--- /dev/null
+++ src/fallback_malloc.h
@@ -0,0 +1,29 @@
+//===- fallback_malloc.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 _FALLBACK_MALLOC_H
+#define _FALLBACK_MALLOC_H
+
+namespace __cxxabiv1 {
+
+#pragma GCC visibility push(hidden)
+
+// Allocate some memory from _somewhere_
+void * __cxa_malloc_with_fallback(size_t size);
+
+// Allocate and zero-initialize memory from _somewhere_
+void * __cxa_calloc_with_fallback(size_t count, size_t size);
+
+void __cxa_free_with_fallback(void *ptr);
+
+#pragma GCC visibility pop
+
+} // namespace __cxxabiv1
+
+#endif
Index: src/fallback_malloc.cpp
===
--- /dev/null
+++ src/fallback_malloc.cpp
@@ -0,0 +1,49 @@
+//=== fallback_malloc.ipp -===//
+//
+// 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.
+//
+//===--===//
+
+#include "config.h"
+
+#include  // for malloc, calloc, free
+#include  // for memset
+
+#if !LIBCXXABI_HAS_NO_THREADS
+#include  // for fallback_malloc.ipp's mutexes
+#endif
+
+#include "fallback_malloc.h"
+#include "fallback_malloc.ipp"
+
+namespace __cxxabiv1 {
+
+void * __cxa_malloc_with_fallback(size_t size) {
+void *ptr = std::malloc(size);
+if (NULL == ptr) // if malloc fails, fall back to emergency stash
+ptr = fallback_malloc(size);
+return ptr;
+}
+
+void * __cxa_calloc_with_fallback(size_t count, size_t size) {
+void *ptr = std::calloc(count, size);
+if (NULL != ptr)
+return ptr;
+// if calloc fails, fall back to emergency stash
+ptr = fallback_malloc(size * count);
+if (NULL != ptr)
+std::memset(ptr, 0, size * count);
+return ptr;
+}
+
+void __cxa_free_with_fallback(void *ptr) {
+if (is_fallback_ptr(ptr))
+fallback_free(ptr);
+else
+std::free(ptr);
+}
+
+} // namespace __cxxabiv1
Index: src/cxa_exception_storage.cpp
===
--- src/cxa_exception_storage.cpp
+++ src/cxa_exception_storage.cpp
@@ -45,8 +45,8 @@
 #else
 
 #include 
-#include   // for calloc, free
 #include "abort_message.h"
+#include "fallback_malloc.h"
 
 //  In general, we treat all pthread errors as fatal.
 //  We cannot call std::terminate() because that will in turn
@@ -58,7 +58,7 @@
 pthread_once_t flag_ = PTHREAD_ONCE_INIT;
 
 void destruct_ (void *p) {
-std::free ( p );
+__cxa_free_with_fallback ( p );
 if ( 0 != ::pthread_setspecific ( key_, NULL ) ) 
 abort_message("cannot zero out thread value for __cxa_get_globals()");
 }
@@ -77,7 +77,7 @@
 //  If this is the first time we've been asked for these globals, create them
 if ( NULL == retVal ) {
 retVal = static_cast<__cxa_eh_globals*>
-(std::calloc (1, sizeof (__cxa_eh_globals)));
+(__cxa_calloc_with_fallback (1, sizeof (__cxa_eh_globals)));
 if ( NULL == retVal )
 abort_message("cannot allocate __cxa_eh_globals");
 if ( 0 != pthread_setspecific ( key_, retVal ) )
Index: src/cxa_exception.cpp
===
--- src/cxa_exception.cpp
+++ 

[PATCH] D19254: Implement P0033R1 - Re-enabling shared_from_this

2016-04-18 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added a reviewer: mclow.lists.
EricWF added a subscriber: cfe-commits.

See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0033r1.html

http://reviews.llvm.org/D19254

Files:
  include/memory
  
test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
  www/cxx1z_status.html

Index: www/cxx1z_status.html
===
--- www/cxx1z_status.html
+++ www/cxx1z_status.html
@@ -82,7 +82,7 @@
 	http://wg21.link/P0226R1;>P0226R1LWGMathematical Special Functions for C++17Jacksonville
 	http://wg21.link/P0220R1;>P0220R1LWGAdopt Library Fundamentals V1 TS Components for C++17Jacksonville
 	http://wg21.link/P0218R1;>P0218R1LWGAdopt the File System TS for C++17Jacksonville	
-	http://wg21.link/P0033R1;>P0033R1LWGRe-enabling shared_from_thisJacksonville
+	http://wg21.link/P0033R1;>P0033R1LWGRe-enabling shared_from_thisJacksonvilleComplete3.9
 	http://wg21.link/P0005R4;>P0005R4LWGAdopt not_fn from Library Fundamentals 2 for C++17Jacksonville
 	http://wg21.link/P0152R1;>P0152R1LWGconstexpr atomic::is_always_lock_freeJacksonvilleComplete3.9
 	http://wg21.link/P0185R1;>P0185R1LWGAdding [nothrow-]swappable traitsJacksonville
Index: test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
===
--- test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
+++ test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
@@ -18,11 +18,15 @@
 // public:
 // shared_ptr shared_from_this();
 // shared_ptr shared_from_this() const;
+// weak_ptr weak_from_this() noexcept; // C++17
+// weak_ptr weak_from_this() const noexecpt; // C++17
 // };
 
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct T
 : public std::enable_shared_from_this
 {
@@ -32,6 +36,8 @@
 
 struct Z : Y {};
 
+void nullDeleter(void*) {}
+
 int main()
 {
 {  // https://llvm.org/bugs/show_bug.cgi?id=18843
@@ -50,4 +56,40 @@
 assert(p == q);
 assert(!p.owner_before(q) && !q.owner_before(p)); // p and q share ownership
 }
+// Test weak_from_this_methods
+{
+T* ptr = new T;
+const T* cptr = ptr;
+
+#if TEST_STD_VER >= 11
+static_assert(noexcept(ptr->weak_from_this()), "Operation must be noexcept");
+static_assert(noexcept(cptr->weak_from_this()), "Operation must be noexcept");
+#endif
+std::weak_ptr my_weak = ptr->weak_from_this();
+assert(my_weak.expired());
+
+std::weak_ptr my_const_weak = cptr->weak_from_this();
+assert(my_const_weak.expired());
+
+// Enable shared_from_this with ptr.
+std::shared_ptr sptr(ptr);
+my_weak = ptr->weak_from_this();
+assert(!my_weak.expired());
+assert(my_weak.lock().get() == ptr);
+}
+// Test LWG issue 2529. Only reset '__weak_ptr_' when it's already expired.
+// http://cplusplus.github.io/LWG/lwg-active.html#2529
+{
+T* ptr = new T;
+std::shared_ptr s(ptr);
+{
+// Don't re-initialize the "enabled_shared_from_this" base
+// because it already references a non-expired shared_ptr.
+std::shared_ptr s2(ptr, );
+}
+// The enabled_shared_from_this base should still be referencing
+// the original shared_ptr.
+assert(!ptr->weak_from_this().expired());
+
+}
 }
Index: include/memory
===
--- include/memory
+++ include/memory
@@ -4124,7 +4124,7 @@
 void
 __enable_weak_this(const enable_shared_from_this<_Yp>* __e) _NOEXCEPT
 {
-if (__e)
+if (__e && __e->__weak_this_.expired())
 {
 __e->__weak_this_.__ptr_ = const_cast<_Yp*>(static_cast(__e));
 __e->__weak_this_.__cntrl_ = __cntrl_;
@@ -5436,6 +5436,14 @@
 shared_ptr<_Tp const> shared_from_this() const
 {return shared_ptr(__weak_this_);}
 
+_LIBCPP_INLINE_VISIBILITY
+weak_ptr<_Tp> weak_from_this() _NOEXCEPT
+   { return __weak_this_; }
+
+_LIBCPP_INLINE_VISIBILITY
+weak_ptr weak_from_this() const _NOEXCEPT
+{ return __weak_this_; }
+
 template  friend class shared_ptr;
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r266703 - Make tuples constructors conditionally EXPLICIT. See N4387

2016-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Apr 18 20:19:25 2016
New Revision: 266703

URL: http://llvm.org/viewvc/llvm-project?rev=266703=rev
Log:
Make tuples constructors conditionally EXPLICIT. See N4387

Added:

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_Types.fail.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.fail.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_move.fail.cpp
Modified:
libcxx/trunk/include/tuple

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_Types.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_move.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.fail.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp

Modified: libcxx/trunk/include/tuple
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=266703=266702=266703=diff
==
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Mon Apr 18 20:19:25 2016
@@ -449,7 +449,7 @@ struct __tuple_impl<__tuple_indices<_Ind
 template  >::value
+ __tuple_constructible<_Tuple, tuple<_Tp...> >::value
   >::type
  >
 _LIBCPP_INLINE_VISIBILITY
@@ -673,8 +673,17 @@ public:
 typename __make_tuple_indices::type(),
 __tuple_types<_Tp...>()) {}
 
+template ::template __enable_implicit<_Tp...>(),
+ bool
+  >::type = false
+>
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-explicit tuple(const _Tp& ... __t) 
_NOEXCEPT_((__all::value...>::value)) 
+tuple(const _Tp& ... __t) 
_NOEXCEPT_((__all::value...>::value))
 : base_(typename __make_tuple_indices::type(),
 typename __make_tuple_types::type(),
 typename __make_tuple_indices<0>::type(),
@@ -682,8 +691,54 @@ public:
 __t...
) {}
 
-template 
+template ::template __enable_explicit<_Tp...>(),
+ bool
+  >::type = false
+>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+explicit tuple(const _Tp& ... __t) 
_NOEXCEPT_((__all::value...>::value))
+: base_(typename __make_tuple_indices::type(),
+typename __make_tuple_types::type(),
+typename __make_tuple_indices<0>::type(),
+typename __make_tuple_types::type(),
+__t...
+   ) {}
+
+template ::template __enable_implicit<_Tp...>(),
+ bool
+  >::type = false
+>
+  _LIBCPP_INLINE_VISIBILITY
+  tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
+: base_(allocator_arg_t(), __a,
+typename __make_tuple_indices::type(),
+typename __make_tuple_types::type(),
+typename __make_tuple_indices<0>::type(),
+typename __make_tuple_types::type(),
+__t...
+   ) {}
+
+template ::template __enable_explicit<_Tp...>(),
+ bool
+  >::type = false
+>
   _LIBCPP_INLINE_VISIBILITY
+  explicit
   tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
 : base_(allocator_arg_t(), __a,
 typename __make_tuple_indices::type(),
@@ -749,15 +804,36 @@ public:
 _VSTD::forward<_Up>(__u)...) {}
 
 template ::value
- >::template __enable_implicit<_Up...>()
-  >::type
+ >::template __enable_implicit<_Up...>(),
+ bool
+  >::type = false
+ >
+_LIBCPP_INLINE_VISIBILITY
+tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
+: base_(allocator_arg_t(), __a,
+typename __make_tuple_indices::type(),
+typename __make_tuple_types::type(),
+typename 

Re: [PATCH] D19248: [CUDA] Add --cuda-compile-host-device, which overrides --cuda-host-only and --cuda-device-only.

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

Wow, oops.  Thank you.


http://reviews.llvm.org/D19248



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


Re: [PATCH] D19248: [CUDA] Add --cuda-compile-host-device, which overrides --cuda-host-only and --cuda-device-only.

2016-04-18 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 54148.
jlebar marked 2 inline comments as done.
jlebar added a comment.

Fix help text.


http://reviews.llvm.org/D19248

Files:
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp
  test/Driver/cuda-options.cu
  test/Driver/cuda-unused-arg-warning.cu

Index: test/Driver/cuda-unused-arg-warning.cu
===
--- test/Driver/cuda-unused-arg-warning.cu
+++ test/Driver/cuda-unused-arg-warning.cu
@@ -4,11 +4,16 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 
-// --cuda-host-only should never trigger unused arg warning.
+// --cuda-host-only and --cuda-compile-host-device should never trigger an
+// unused arg warning.
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -c %s 2>&1 | \
 // RUN:FileCheck %s
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -x c -c %s 2>&1 | \
 // RUN:FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-compile-host-device -c %s 2>&1 | \
+// RUN:FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-compile-host-device -x c -c %s 2>&1 | \
+// RUN:FileCheck %s
 
 // --cuda-device-only should warn during non-CUDA compilation.
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -x c -c %s 2>&1 | \
@@ -19,5 +24,6 @@
 // RUN:FileCheck -check-prefix NO-UNUSED-WARNING %s
 
 // CHECK-NOT: warning: argument unused during compilation: '--cuda-host-only'
+// CHECK-NOT: warning: argument unused during compilation: '--cuda-compile-host-device'
 // UNUSED-WARNING: warning: argument unused during compilation: '--cuda-device-only'
 // NO-UNUSED-WARNING-NOT: warning: argument unused during compilation: '--cuda-device-only'
Index: test/Driver/cuda-options.cu
===
--- test/Driver/cuda-options.cu
+++ test/Driver/cuda-options.cu
@@ -22,23 +22,46 @@
 // RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \
 // RUN:-check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s
 
-// Same test as above, but with preceeding --cuda-device-only to make sure only
-// the last option has an effect.
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only --cuda-host-only %s 2>&1 \
-// RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \
-// RUN:-check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s
-
 // Verify that --cuda-device-only disables host-side compilation and linking.
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only %s 2>&1 \
 // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
 // RUN:-check-prefix NOHOST -check-prefix NOLINK %s
 
-// Same test as above, but with preceeding --cuda-host-only to make sure only
-// the last option has an effect.
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only --cuda-device-only %s 2>&1 \
+// Check that the last of --cuda-compile-host-device, --cuda-host-only, and
+// --cuda-device-only wins.
+
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:--cuda-host-only %s 2>&1 \
+// RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \
+// RUN:-check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s
+
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-compile-host-device \
+// RUN:--cuda-host-only %s 2>&1 \
+// RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \
+// RUN:-check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s
+
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only \
+// RUN:--cuda-device-only %s 2>&1 \
 // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
 // RUN:-check-prefix NOHOST -check-prefix NOLINK %s
 
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-compile-host-device \
+// RUN:--cuda-device-only %s 2>&1 \
+// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
+// RUN:-check-prefix NOHOST -check-prefix NOLINK %s
+
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only \
+// RUN:   --cuda-compile-host-device %s 2>&1 \
+// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
+// RUN:-check-prefix HOST -check-prefix INCLUDES-DEVICE \
+// RUN:-check-prefix LINK %s
+
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --cuda-compile-host-device %s 2>&1 \
+// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
+// RUN:-check-prefix HOST -check-prefix INCLUDES-DEVICE \
+// RUN:-check-prefix LINK %s
+
 // Verify that --cuda-gpu-arch option passes the correct GPU archtecture to
 // device compilation.
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1316,11 +1316,17 @@
 static Action *buildCudaActions(Compilation , DerivedArgList ,
   

Re: [PATCH] D19248: [CUDA] Add --cuda-compile-host-device, which overrides --cuda-host-only and --cuda-device-only.

2016-04-18 Thread Artem Belevich via cfe-commits
tra added a comment.

Help strings seem to be backwards.
LGTM otherwise.



Comment at: include/clang/Driver/Options.td:378
@@ -377,2 +377,3 @@
 def cuda_device_only : Flag<["--"], "cuda-device-only">,
-  HelpText<"Do device-side CUDA compilation only">;
+  HelpText<"Compile CUDA code for host only.  Has no effect on non-CUDA "
+   "compilations.">;

for *device* 


Comment at: include/clang/Driver/Options.td:381
@@ +380,3 @@
+def cuda_host_only : Flag<["--"], "cuda-host-only">,
+  HelpText<"Compile CUDA code for device only">;
+def cuda_compile_host_device : Flag<["--"], "cuda-compile-host-device">,

for *host*


http://reviews.llvm.org/D19248



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


[PATCH] D19251: [CUDA] Add --no-cuda-noopt-debug, which disables --cuda-noopt-debug.

2016-04-18 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added subscribers: jhen, cfe-commits.

http://reviews.llvm.org/D19251

Files:
  include/clang/Driver/Options.td
  lib/Driver/Tools.cpp
  test/Driver/cuda-external-tools.cu

Index: test/Driver/cuda-external-tools.cu
===
--- test/Driver/cuda-external-tools.cu
+++ test/Driver/cuda-external-tools.cu
@@ -22,6 +22,11 @@
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-noopt-device-debug -O2 -c 
%s 2>&1 \
 // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix DBG 
%s
 
+// --no-cuda-noopt-device-debug overrides --cuda-noopt-device-debug.
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-noopt-debug \
+// RUN:   --no-cuda-noopt-debug -O2 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT2 
%s
+
 // Regular compile without -O.  This should result in us passing -O0 to ptxas.
 // RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT0 
%s
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -10956,7 +10956,8 @@
 
   ArgStringList CmdArgs;
   CmdArgs.push_back(TC.getTriple().isArch64Bit() ? "-m64" : "-m32");
-  if (Args.getLastArg(options::OPT_cuda_noopt_device_debug)) {
+  if (Args.hasFlag(options::OPT_cuda_noopt_device_debug,
+   options::OPT_no_cuda_noopt_device_debug, false)) {
 // ptxas does not accept -g option if optimization is enabled, so
 // we ignore the compiler's -O* options if we want debug info.
 CmdArgs.push_back("-g");
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -386,6 +386,7 @@
   HelpText<"CUDA GPU architecture (e.g. sm_35).  May be specified more than 
once.">;
 def cuda_noopt_device_debug : Flag<["--"], "cuda-noopt-device-debug">,
   HelpText<"Enable device-side debug info generation. Disables ptxas 
optimizations.">;
+def no_cuda_noopt_device_debug : Flag<["--"], "no-cuda-noopt-device-debug">;
 def cuda_path_EQ : Joined<["--"], "cuda-path=">, Group,
   HelpText<"CUDA installation path">;
 def fcuda_flush_denormals_to_zero : Flag<["-"], 
"fcuda-flush-denormals-to-zero">,


Index: test/Driver/cuda-external-tools.cu
===
--- test/Driver/cuda-external-tools.cu
+++ test/Driver/cuda-external-tools.cu
@@ -22,6 +22,11 @@
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-noopt-device-debug -O2 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix DBG %s
 
+// --no-cuda-noopt-device-debug overrides --cuda-noopt-device-debug.
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-noopt-debug \
+// RUN:   --no-cuda-noopt-debug -O2 -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT2 %s
+
 // Regular compile without -O.  This should result in us passing -O0 to ptxas.
 // RUN: %clang -### -target x86_64-linux-gnu -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix ARCH64 -check-prefix SM20 -check-prefix OPT0 %s
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -10956,7 +10956,8 @@
 
   ArgStringList CmdArgs;
   CmdArgs.push_back(TC.getTriple().isArch64Bit() ? "-m64" : "-m32");
-  if (Args.getLastArg(options::OPT_cuda_noopt_device_debug)) {
+  if (Args.hasFlag(options::OPT_cuda_noopt_device_debug,
+   options::OPT_no_cuda_noopt_device_debug, false)) {
 // ptxas does not accept -g option if optimization is enabled, so
 // we ignore the compiler's -O* options if we want debug info.
 CmdArgs.push_back("-g");
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -386,6 +386,7 @@
   HelpText<"CUDA GPU architecture (e.g. sm_35).  May be specified more than once.">;
 def cuda_noopt_device_debug : Flag<["--"], "cuda-noopt-device-debug">,
   HelpText<"Enable device-side debug info generation. Disables ptxas optimizations.">;
+def no_cuda_noopt_device_debug : Flag<["--"], "no-cuda-noopt-device-debug">;
 def cuda_path_EQ : Joined<["--"], "cuda-path=">, Group,
   HelpText<"CUDA installation path">;
 def fcuda_flush_denormals_to_zero : Flag<["-"], "fcuda-flush-denormals-to-zero">,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19249: Fix include path in ClangTidy.cpp.

2016-04-18 Thread Chih-Hung Hsieh via cfe-commits
chh created this revision.
chh added reviewers: srhines, alexfh.
chh added a subscriber: cfe-commits.
Herald added subscribers: danalbert, tberghammer.

https://llvm.org/bugs/show_bug.cgi?id=27355
To compile with other binary output directory structures in build systems like 
Android.



http://reviews.llvm.org/D19249

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/ClangTidy.cpp

Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -58,7 +58,7 @@
 #define GET_CHECKERS
 #define CHECKER(FULLNAME, CLASS, DESCFILE, HELPTEXT, GROUPINDEX, HIDDEN)   
\
   FULLNAME,
-#include "../../../lib/StaticAnalyzer/Checkers/Checkers.inc"
+#include "Checkers.inc"
 #undef CHECKER
 #undef GET_CHECKERS
 };
Index: clang-tidy/CMakeLists.txt
===
--- clang-tidy/CMakeLists.txt
+++ clang-tidy/CMakeLists.txt
@@ -2,6 +2,10 @@
   Support
   )
 
+include_directories(
+  "${CMAKE_CURRENT_BINARY_DIR}/../../../lib/StaticAnalyzer/Checkers"
+  )
+
 add_clang_library(clangTidy
   ClangTidy.cpp
   ClangTidyModule.cpp


Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -58,7 +58,7 @@
 #define GET_CHECKERS
 #define CHECKER(FULLNAME, CLASS, DESCFILE, HELPTEXT, GROUPINDEX, HIDDEN)   \
   FULLNAME,
-#include "../../../lib/StaticAnalyzer/Checkers/Checkers.inc"
+#include "Checkers.inc"
 #undef CHECKER
 #undef GET_CHECKERS
 };
Index: clang-tidy/CMakeLists.txt
===
--- clang-tidy/CMakeLists.txt
+++ clang-tidy/CMakeLists.txt
@@ -2,6 +2,10 @@
   Support
   )
 
+include_directories(
+  "${CMAKE_CURRENT_BINARY_DIR}/../../../lib/StaticAnalyzer/Checkers"
+  )
+
 add_clang_library(clangTidy
   ClangTidy.cpp
   ClangTidyModule.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18584: Complete support for C++ Core Guidelines Type.6: Always initialize a member variable.

2016-04-18 Thread Alexander Kornienko via cfe-commits
alexfh added a subscriber: alexfh.
alexfh added a comment.

Would be nice, if you could write a patch. I don't yet have a reduced test
case (it crashes without delayed template parsing), since my creduce is
still running after many hours ;)


Repository:
  rL LLVM

http://reviews.llvm.org/D18584



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


Re: [PATCH] D18584: Complete support for C++ Core Guidelines Type.6: Always initialize a member variable.

2016-04-18 Thread Alexander Kornienko via cfe-commits
Would be nice, if you could write a patch. I don't yet have a reduced test
case (it crashes without delayed template parsing), since my creduce is
still running after many hours ;)
On Apr 18, 2016 8:45 PM, "Michael Miller"  wrote:

> michael_miller added a comment.
>
> In http://reviews.llvm.org/D18584#403872, @alexfh wrote:
>
> > FYI, the check has started crashing after this patch. I'll try to
> provide a minimal test case soon. The relevant part of the stack trace is:
> >
> >   @ 0x7fc9c255efa0  8  clang::Stmt::getLocStart()
> >   @ 0x7fc9c48fdac1 64
> clang::tidy::cppcoreguidelines::(anonymous
> namespace)::IntializerInsertion::getLocation()
> >   @ 0x7fc9c49026d5   1696
> clang::tidy::cppcoreguidelines::ProTypeMemberInitCheck::checkMissingBaseClassInitializer()
> >   @ 0x7fc9c490424f 96
> clang::tidy::cppcoreguidelines::ProTypeMemberInitCheck::check()
>
>
> Hmm... I can get this to crash in that location but only if I run with
> -fdelayed-template-parsing. I've got an easy fix and test case if that's
> the same issue you're running into. We should move the check at line 307
> into ProTypeMemberInitCheck::check before both checks. I've got a test case
> I can add to cppcoreguidelines-pro-type-member-init-delayed.cpp that
> reproduces it. Let me know if I should write up a patch for this.
>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D18584
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19248: [CUDA] Add --cuda-compile-host-device, which overrides --cuda-host-only and --cuda-device-only.

2016-04-18 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added subscribers: jhen, cfe-commits.

This completes the flag's tristate, letting you override it at will on
the command line.

http://reviews.llvm.org/D19248

Files:
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp
  test/Driver/cuda-options.cu
  test/Driver/cuda-unused-arg-warning.cu

Index: test/Driver/cuda-unused-arg-warning.cu
===
--- test/Driver/cuda-unused-arg-warning.cu
+++ test/Driver/cuda-unused-arg-warning.cu
@@ -4,11 +4,16 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 
-// --cuda-host-only should never trigger unused arg warning.
+// --cuda-host-only and --cuda-compile-host-device should never trigger an
+// unused arg warning.
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -c %s 2>&1 | \
 // RUN:FileCheck %s
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -x c -c %s 2>&1 | \
 // RUN:FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-compile-host-device -c %s 2>&1 | \
+// RUN:FileCheck %s
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-compile-host-device -x c -c %s 2>&1 | \
+// RUN:FileCheck %s
 
 // --cuda-device-only should warn during non-CUDA compilation.
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -x c -c %s 2>&1 | \
@@ -19,5 +24,6 @@
 // RUN:FileCheck -check-prefix NO-UNUSED-WARNING %s
 
 // CHECK-NOT: warning: argument unused during compilation: '--cuda-host-only'
+// CHECK-NOT: warning: argument unused during compilation: '--cuda-compile-host-device'
 // UNUSED-WARNING: warning: argument unused during compilation: '--cuda-device-only'
 // NO-UNUSED-WARNING-NOT: warning: argument unused during compilation: '--cuda-device-only'
Index: test/Driver/cuda-options.cu
===
--- test/Driver/cuda-options.cu
+++ test/Driver/cuda-options.cu
@@ -22,23 +22,46 @@
 // RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \
 // RUN:-check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s
 
-// Same test as above, but with preceeding --cuda-device-only to make sure only
-// the last option has an effect.
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only --cuda-host-only %s 2>&1 \
-// RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \
-// RUN:-check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s
-
 // Verify that --cuda-device-only disables host-side compilation and linking.
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only %s 2>&1 \
 // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
 // RUN:-check-prefix NOHOST -check-prefix NOLINK %s
 
-// Same test as above, but with preceeding --cuda-host-only to make sure only
-// the last option has an effect.
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only --cuda-device-only %s 2>&1 \
+// Check that the last of --cuda-compile-host-device, --cuda-host-only, and
+// --cuda-device-only wins.
+
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:--cuda-host-only %s 2>&1 \
+// RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \
+// RUN:-check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s
+
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-compile-host-device \
+// RUN:--cuda-host-only %s 2>&1 \
+// RUN: | FileCheck -check-prefix NODEVICE -check-prefix HOST \
+// RUN:-check-prefix NOINCLUDES-DEVICE -check-prefix LINK %s
+
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only \
+// RUN:--cuda-device-only %s 2>&1 \
 // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
 // RUN:-check-prefix NOHOST -check-prefix NOLINK %s
 
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-compile-host-device \
+// RUN:--cuda-device-only %s 2>&1 \
+// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
+// RUN:-check-prefix NOHOST -check-prefix NOLINK %s
+
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only \
+// RUN:   --cuda-compile-host-device %s 2>&1 \
+// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
+// RUN:-check-prefix HOST -check-prefix INCLUDES-DEVICE \
+// RUN:-check-prefix LINK %s
+
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --cuda-compile-host-device %s 2>&1 \
+// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
+// RUN:-check-prefix HOST -check-prefix INCLUDES-DEVICE \
+// RUN:-check-prefix LINK %s
+
 // Verify that --cuda-gpu-arch option passes the correct GPU archtecture to
 // device compilation.
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1316,11 +1316,17 @@
 

Re: [PATCH] D16544: [libcxx] Framework to allow testing of static libc++abi

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

LGTM. It's up to you if you want to address the inline comments before 
committing.

Thanks for updating the Doc. I really need to kill one version of it.



Comment at: test/libcxx/test/config.py:454
@@ -464,1 +453,3 @@
+else:
+self.cxx.link_flags += ['-lc++']
 

In this fallback case do we want to explicitly ask for static linkage using 
`-Wl,-Bstatic -lc++ -Wl,-Bdynamic`? I think that will cause the linker to 
diagnose that your not actually getting a static library.


Comment at: test/libcxx/test/config.py:473
@@ -474,1 +472,3 @@
+else:
+self.cxx.link_flags += ['-lc++abi']
 elif cxx_abi == 'libcxxrt':

In this fallback case do we want to explicitly ask for static linkage using 
`-Wl,-Bstatic -lc++abi -Wl,-Bdynamic`? 


http://reviews.llvm.org/D16544



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


Re: [PATCH] D19244: Extend checking of va_start builtin

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


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7417-7421
@@ -7416,4 +7416,7 @@
   InGroup;
-def warn_va_start_of_reference_type_is_undefined : Warning<
-  "'va_start' has undefined behavior with reference types">, InGroup;
+def warn_va_start_type_is_undefined : Warning<
+  "'va_start' has undefined behavior with "
+  "%select{types that undergo default argument promotion|reference types|"
+  "an object declared with the register storage class}0">,
+  InGroup;
 def err_first_argument_to_va_arg_not_of_type_va_list : Error<

rsmith wrote:
> I'm not sure that
> 
> 'va_start' has undefined behavior with an object declared with the 
> register storage class
> 
> is clear enough about what object it's talking about. Can you explicitly 
> state that the problem is with the type of the parameter name passed to 
> `va_start` here, somehow?
How about: "'va_start' has undefined behavior with a parameter declared with 
the 'register' keyword"?

Then again, we could reword the entire diagnostic and I wouldn't be sad. I 
notice that it's using the plural "types" already instead of the singular form, 
for instance. How about:

"Passing %select{an object of reference type|an object that undergoes default 
argument promotion|a parameter declared with the 'register' keyword}0 to 
'va_start' is undefined behavior"


Comment at: lib/Sema/SemaChecking.cpp:2722
@@ -2720,2 +2721,3 @@
   ParamLoc = PV->getLocation();
+  IsRegister = PV->getStorageClass() == SC_Register;
 }

rsmith wrote:
> Where is this restriction specified? Does this only apply to C?
7.16.1.4p3:

If the parameter parmN is declared with the register storage class ...  the 
behavior is undefined.

I think this may only apply in C, actually, because [support.runtime]p3 does 
not mention it in its description (even as far back as C++03). Whether that's 
an explicit omission (to make va_start() more powerful than in C) or an 
oversight is kind of moot since register was removed in C++17. Thoughts?


http://reviews.llvm.org/D19244



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


[PATCH] D19247: Deprecate C++03 Extensions: std::function, std::mem_fn and more

2016-04-18 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added a reviewer: mclow.lists.
EricWF added a subscriber: cfe-commits.

This patch deprecates almost all C++03 extensions offered by . 
These extensions started as fallback implementations for compilers without 
variadic template support.
Since compiler support is no longer an issue I would like to remove these 
features. The end goal is to remove both `<__functional_03>` and 
`<__functional_base_03>` entirely. 

The features this patch deprecates are:

* `std::function`
* `std::mem_fn`
* `std::reference_wrapper::operator()`

Although `reference_wrapper` is C++11 only I chose to only deprecate the 
variadic call operator. The rest of the class will remain as an extension.

Killing these features allows us to kill the C++03 implementation of INVOKE and 
it's related traits, which have a poor QoI with a large maintenance burden. 


http://reviews.llvm.org/D19247

Files:
  include/__config
  include/__functional_03
  include/__functional_base
  include/functional

Index: include/functional
===
--- include/functional
+++ include/functional
@@ -1363,6 +1363,7 @@
 
 template
 inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_DEPRECATED_CXX03_EXTENSION("std::mem_fn requires C++11 or newer")
 __mem_fn<_Rp _Tp::*>
 mem_fn(_Rp _Tp::* __pm) _NOEXCEPT
 {
Index: include/__functional_base
===
--- include/__functional_base
+++ include/__functional_base
@@ -462,7 +462,8 @@
 };
 
 template 
-class _LIBCPP_TYPE_VIS_ONLY reference_wrapper
+class _LIBCPP_TYPE_VIS_ONLY
+  reference_wrapper
 : public __weak_result_type<_Tp>
 {
 public:
@@ -492,8 +493,8 @@
 return __invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);
 }
 #else
-
 _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
 typename __invoke_return::type
 operator() () const {
 return __invoke(get());
@@ -501,6 +502,7 @@
 
 template 
 _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
 typename __invoke_return0::type
 operator() (_A0& __a0) const {
 return __invoke(get(), __a0);
@@ -508,6 +510,7 @@
 
 template 
 _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
 typename __invoke_return0::type
 operator() (_A0 const& __a0) const {
 return __invoke(get(), __a0);
@@ -515,6 +518,7 @@
 
 template 
 _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
 typename __invoke_return1::type
 operator() (_A0& __a0, _A1& __a1) const {
 return __invoke(get(), __a0, __a1);
@@ -522,6 +526,7 @@
 
 template 
 _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
 typename __invoke_return1::type
 operator() (_A0 const& __a0, _A1& __a1) const {
 return __invoke(get(), __a0, __a1);
@@ -529,6 +534,7 @@
 
 template 
 _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
 typename __invoke_return1::type
 operator() (_A0& __a0, _A1 const& __a1) const {
 return __invoke(get(), __a0, __a1);
@@ -536,6 +542,7 @@
 
 template 
 _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
 typename __invoke_return1::type
 operator() (_A0 const& __a0, _A1 const& __a1) const {
 return __invoke(get(), __a0, __a1);
@@ -543,6 +550,7 @@
 
 template 
 _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
 typename __invoke_return2::type
 operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
 return __invoke(get(), __a0, __a1, __a2);
@@ -550,6 +558,7 @@
 
 template 
 _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
 typename __invoke_return2::type
 operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const {
 return __invoke(get(), __a0, __a1, __a2);
@@ -557,6 +566,7 @@
 
 template 
 _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_DEPRECATED_CXX03_EXTENSION("invoking reference_wrapper requires C++11 or newer")
 typename __invoke_return2::type
 operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const {
 return __invoke(get(), __a0, __a1, __a2);
@@ -564,6 +574,7 @@
 
 template 
 _LIBCPP_INLINE_VISIBILITY
+

r266698 - [ObjC++] Fix crash when emitting debug info for a block member capturing this.

2016-04-18 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Apr 18 18:48:16 2016
New Revision: 266698

URL: http://llvm.org/viewvc/llvm-project?rev=266698=rev
Log:
[ObjC++] Fix crash when emitting debug info for a block member capturing this.

rdar://problem/23871824

Added:
cfe/trunk/test/CodeGenObjCXX/debug-info-block-capture-this.mm
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=266698=266697=266698=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Apr 18 18:48:16 2016
@@ -3262,9 +3262,14 @@ void CGDebugInfo::EmitDeclareOfBlockLite
 
 // If we have a null capture, this must be the C++ 'this' capture.
 if (!capture) {
-  const CXXMethodDecl *method =
-  cast(blockDecl->getNonClosureContext());
-  QualType type = method->getThisType(C);
+  QualType type;
+  if (auto *Method =
+  cast_or_null(blockDecl->getNonClosureContext()))
+type = Method->getThisType(C);
+  else if (auto *RDecl = dyn_cast(blockDecl->getParent()))
+type = QualType(RDecl->getTypeForDecl(), 0);
+  else
+llvm_unreachable("unexpected block declcontext");
 
   fields.push_back(createFieldType("this", type, 0, loc, AS_public,
offsetInBits, tunit, tunit));

Added: cfe/trunk/test/CodeGenObjCXX/debug-info-block-capture-this.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/debug-info-block-capture-this.mm?rev=266698=auto
==
--- cfe/trunk/test/CodeGenObjCXX/debug-info-block-capture-this.mm (added)
+++ cfe/trunk/test/CodeGenObjCXX/debug-info-block-capture-this.mm Mon Apr 18 
18:48:16 2016
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++14 -fblocks 
-debug-info-kind=standalone -emit-llvm %s -o - | FileCheck %s
+struct test
+{
+int func() { return 1; }
+int (^block)() = ^{ return func(); };
+};
+
+int main(int argc, const char * argv[]) {
+test t;
+return t.block();
+}
+
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: 
"__block_literal_1",
+// CHECK-SAME: elements: ![[ELEMS:.*]])
+// CHECK: ![[ELEMS]] = !{{{.*}}, ![[THIS:[0-9]+]]}
+// CHECK: ![[THIS]] = !DIDerivedType(tag: DW_TAG_member, name: "this",
+// CHECK-SAME:   baseType: !"_ZTS4test",
+
+


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


LLVM buildmaster will be updated and restarted tonight

2016-04-18 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted after 6 PM Pacific time
today.

Thanks

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


Re: [PATCH] D19144: Handle TemplateArgument in DynTypedNode comparison operations.

2016-04-18 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D19144#404234, @sbenza wrote:

> Sent http://reviews.llvm.org/D19231 to fix the underlying bug in 
> `hasAncestor`.
>  We can proceed with this change if you want, but it is not required anymore. 
> I don't know whether we need the extra complexity of `TemplateArgumentLess`.


If this patch is not going to help with performance, I'm happy to abandon it.


http://reviews.llvm.org/D19144



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


Re: [PATCH] D19231: [ASTMatchers] Do not try to memoize nodes we can't compare.

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

Looks good. Thanks!


http://reviews.llvm.org/D19231



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


Re: [PATCH] D19244: Extend checking of va_start builtin

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


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7417-7421
@@ -7416,4 +7416,7 @@
   InGroup;
-def warn_va_start_of_reference_type_is_undefined : Warning<
-  "'va_start' has undefined behavior with reference types">, InGroup;
+def warn_va_start_type_is_undefined : Warning<
+  "'va_start' has undefined behavior with "
+  "%select{types that undergo default argument promotion|reference types|"
+  "an object declared with the register storage class}0">,
+  InGroup;
 def err_first_argument_to_va_arg_not_of_type_va_list : Error<

I'm not sure that

'va_start' has undefined behavior with an object declared with the register 
storage class

is clear enough about what object it's talking about. Can you explicitly state 
that the problem is with the type of the parameter name passed to `va_start` 
here, somehow?


Comment at: lib/Sema/SemaChecking.cpp:2722
@@ -2720,2 +2721,3 @@
   ParamLoc = PV->getLocation();
+  IsRegister = PV->getStorageClass() == SC_Register;
 }

Where is this restriction specified? Does this only apply to C?


http://reviews.llvm.org/D19244



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


r266695 - Mark -Xclang as being a compilation-only option so that the clang driver

2016-04-18 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Apr 18 18:12:59 2016
New Revision: 266695

URL: http://llvm.org/viewvc/llvm-project?rev=266695=rev
Log:
Mark -Xclang as being a compilation-only option so that the clang driver
doesn't warn if it's passed to a link action. This matches the behavior for
most other compilation-only options (including things like -f flags), and is
necessary to suppress warnings on systems like cmake that always pass all
compile flags to the linker.

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/test/Driver/linker-opts.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=266695=266694=266695=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Apr 18 18:12:59 2016
@@ -337,7 +337,7 @@ def Xassembler : Separate<["-"], "Xassem
   HelpText<"Pass  to the assembler">, MetaVarName<"">;
 def Xclang : Separate<["-"], "Xclang">,
   HelpText<"Pass  to the clang compiler">, MetaVarName<"">,
-  Flags<[DriverOption, CoreOption]>;
+  Flags<[DriverOption, CoreOption]>, Group;
 def Xcuda_fatbinary : Separate<["-"], "Xcuda-fatbinary">,
   HelpText<"Pass  to fatbinary invocation">, MetaVarName<"">;
 def Xcuda_ptxas : Separate<["-"], "Xcuda-ptxas">,

Modified: cfe/trunk/test/Driver/linker-opts.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linker-opts.c?rev=266695=266694=266695=diff
==
--- cfe/trunk/test/Driver/linker-opts.c (original)
+++ cfe/trunk/test/Driver/linker-opts.c Mon Apr 18 18:12:59 2016
@@ -1,3 +1,6 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
 // RUN: env LIBRARY_PATH=%T/test1 %clang -x c %s -### 2>&1 | FileCheck %s
 // CHECK: "-L{{.*}}/test1"
 
@@ -9,3 +12,12 @@
 // Make sure that LIBRARY_PATH works for both i386 and x86_64 on Darwin.
 // RUN: env LIBRARY_PATH=%T/test1 %clang -target x86_64-apple-darwin %s -### 
2>&1 | FileCheck %s
 // RUN: env LIBRARY_PATH=%T/test1 %clang -target i386-apple-darwin  %s -### 
2>&1 | FileCheck %s
+//
+// Make sure that we don't warn on unused compiler arguments.
+// RUN: %clang -Xclang -I. -x c %s -c -o %t/tmp.o
+// RUN: %clang -Xclang -I. %t/tmp.o -o %t/tmp -### 2>&1 | FileCheck %s 
--check-prefix=NO-UNUSED
+// NO-UNUSED-NOT: warning:{{.*}}unused
+//
+// Make sure that we do warn in other cases.
+// RUN: %clang %s -lfoo -c -o %t/tmp2.o -### 2>&1 | FileCheck %s 
--check-prefix=UNUSED
+// UNUSED: warning:{{.*}}unused


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


[PATCH] D19244: Extend checking of va_start builtin

2016-04-18 Thread Aaron Ballman via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, dblaikie.
aaron.ballman added a subscriber: cfe-commits.
Herald added a subscriber: aemerson.

The va_start macro currently diagnoses passing a reference as the second 
argument (the one representing the parameter before the ellipsis) because this 
is undefined behavior in C++. This patch extends the checking to cover 
additional cases of undefined behavior in both C and C++. The C11 Standard, 
7.16.1.4p4 states, in part:

If the parameter parmN is declared with the register storage class, with a 
function or array type, or with a type that is not compatible with the type 
that results after application of the default argument promotions, the behavior 
is undefined.

(This is picked up by reference in C++ under [support.runtime]p3.)

This patch adds a check for default argument promotions as well as parameters 
declared with the register storage class. This helps cover some more of the 
CERT secure coding rule EXP58-CPP. Pass an object of the correct type to 
va_start 
(https://www.securecoding.cert.org/confluence/display/cplusplus/EXP58-CPP.+Pass+an+object+of+the+correct+type+to+va_start).

http://reviews.llvm.org/D19244

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/Sema/varargs-x86-64.c
  test/Sema/varargs.c

Index: test/Sema/varargs.c
===
--- test/Sema/varargs.c
+++ test/Sema/varargs.c
@@ -18,12 +18,11 @@
 __builtin_va_start(ap, b);
 }
 
-void f3(float a, ...)
-{
+void f3(float a, ...) { // expected-note 2{{parameter of type 'float' is declared here}}
 __builtin_va_list ap;
 
-__builtin_va_start(ap, a);
-__builtin_va_start(ap, (a));
+__builtin_va_start(ap, a); // expected-warning {{'va_start' has undefined behavior with types that undergo default argument promotion}}
+__builtin_va_start(ap, (a)); // expected-warning {{'va_start' has undefined behavior with types that undergo default argument promotion}}
 }
 
 
@@ -83,3 +82,21 @@
   i = __builtin_va_start(ap, a); // expected-error {{assigning to 'int' from incompatible type 'void'}}
   __builtin_va_end(ap);
 }
+
+void f11(float f, ...) {  // expected-note {{parameter of type 'float' is declared here}}
+  __builtin_va_list ap;
+  __builtin_va_start(ap, f); // expected-warning {{'va_start' has undefined behavior with types that undergo default argument promotion}}
+  __builtin_va_end(ap);
+}
+
+void f12(short s, ...) {  // expected-note {{parameter of type 'short' is declared here}}
+  __builtin_va_list ap;
+  __builtin_va_start(ap, s); // expected-warning {{'va_start' has undefined behavior with types that undergo default argument promotion}}
+  __builtin_va_end(ap);
+}
+
+void f13(register int i, ...) {  // expected-note {{parameter of type 'int' is declared here}}
+  __builtin_va_list ap;
+  __builtin_va_start(ap, i); // expected-warning {{'va_start' has undefined behavior with an object declared with the register storage class}}
+  __builtin_va_end(ap);
+}
Index: test/Sema/varargs-x86-64.c
===
--- test/Sema/varargs-x86-64.c
+++ test/Sema/varargs-x86-64.c
@@ -26,11 +26,11 @@
   __builtin_ms_va_start(ap, b);
 }
 
-void __attribute__((ms_abi)) g3(float a, ...) {
+void __attribute__((ms_abi)) g3(float a, ...) { // expected-note 2{{parameter of type 'float' is declared here}}
   __builtin_ms_va_list ap;
 
-  __builtin_ms_va_start(ap, a);
-  __builtin_ms_va_start(ap, (a));
+  __builtin_ms_va_start(ap, a); // expected-warning {{'va_start' has undefined behavior with types that undergo default argument promotion}}
+  __builtin_ms_va_start(ap, (a)); // expected-warning {{'va_start' has undefined behavior with types that undergo default argument promotion}}
 }
 
 void __attribute__((ms_abi)) g5() {
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -2702,6 +2702,7 @@
   // block.
   QualType Type;
   SourceLocation ParamLoc;
+  bool IsRegister = false;
 
   if (const DeclRefExpr *DR = dyn_cast(Arg)) {
 if (const ParmVarDecl *PV = dyn_cast(DR->getDecl())) {
@@ -2718,6 +2719,7 @@
 
   Type = PV->getType();
   ParamLoc = PV->getLocation();
+  IsRegister = PV->getStorageClass() == SC_Register;
 }
   }
 
@@ -2724,9 +2726,13 @@
   if (!SecondArgIsLastNamedArgument)
 Diag(TheCall->getArg(1)->getLocStart(),
  diag::warn_second_arg_of_va_start_not_last_named_param);
-  else if (Type->isReferenceType()) {
-Diag(Arg->getLocStart(),
- diag::warn_va_start_of_reference_type_is_undefined);
+  else if (IsRegister || Type->isReferenceType() ||
+   Type->isPromotableIntegerType() ||
+   Type->isSpecificBuiltinType(BuiltinType::Float)) {
+unsigned Reason = 0;
+if (Type->isReferenceType())  Reason = 1;
+else if (IsRegister)  

Re: [PATCH] D19243: [CodeGen] Move some CodeGenPGO stuff out of CodeGenFunction.h

2016-04-18 Thread Vedant Kumar via cfe-commits
vsk updated the summary for this revision.
vsk updated this revision to Diff 54128.
vsk added a comment.

- Remove extraneous whitespace changes.


http://reviews.llvm.org/D19243

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenPGO.cpp

Index: lib/CodeGen/CodeGenPGO.cpp
===
--- lib/CodeGen/CodeGenPGO.cpp
+++ lib/CodeGen/CodeGenPGO.cpp
@@ -878,12 +878,33 @@
 
 llvm::MDNode *CodeGenFunction::createProfileWeightsForLoop(const Stmt *Cond,
uint64_t LoopCount) {
-  if (!PGO.haveRegionCounts())
+  if (!PGO->haveRegionCounts())
 return nullptr;
-  Optional CondCount = PGO.getStmtCount(Cond);
+  Optional CondCount = PGO->getStmtCount(Cond);
   assert(CondCount.hasValue() && "missing expected loop condition count");
   if (*CondCount == 0)
 return nullptr;
   return createProfileWeights(LoopCount,
   std::max(*CondCount, LoopCount) - LoopCount);
 }
+
+void CodeGenFunction::incrementProfileCounter(const Stmt *S) {
+  if (CGM.getCodeGenOpts().hasProfileClangInstr())
+PGO->emitCounterIncrement(Builder, S);
+  PGO->setCurrentStmt(S);
+}
+
+uint64_t CodeGenFunction::getProfileCount(const Stmt *S) {
+  Optional Count = PGO->getStmtCount(S);
+  if (!Count.hasValue())
+return 0;
+  return *Count;
+}
+
+void CodeGenFunction::setCurrentProfileCount(uint64_t Count) {
+  PGO->setCurrentRegionCount(Count);
+}
+
+uint64_t CodeGenFunction::getCurrentProfileCount() {
+  return PGO->getCurrentRegionCount();
+}
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -19,7 +19,6 @@
 #include "CGLoopInfo.h"
 #include "CGValue.h"
 #include "CodeGenModule.h"
-#include "CodeGenPGO.h"
 #include "EHScopeStack.h"
 #include "clang/AST/CharUnits.h"
 #include "clang/AST/ExprCXX.h"
@@ -76,6 +75,7 @@
 class ObjCAutoreleasePoolStmt;
 
 namespace CodeGen {
+class CodeGenPGO;
 class CodeGenTypes;
 class CGFunctionInfo;
 class CGRecordLayout;
@@ -943,7 +943,7 @@
   };
   SmallVector BreakContinueStack;
 
-  CodeGenPGO PGO;
+  CodeGenPGO *PGO;
 
   /// Calculate branch weights appropriate for PGO data
   llvm::MDNode *createProfileWeights(uint64_t TrueCount, uint64_t FalseCount);
@@ -953,30 +953,17 @@
 
 public:
   /// Increment the profiler's counter for the given statement.
-  void incrementProfileCounter(const Stmt *S) {
-if (CGM.getCodeGenOpts().hasProfileClangInstr())
-  PGO.emitCounterIncrement(Builder, S);
-PGO.setCurrentStmt(S);
-  }
+  void incrementProfileCounter(const Stmt *S);
 
   /// Get the profiler's count for the given statement.
-  uint64_t getProfileCount(const Stmt *S) {
-Optional Count = PGO.getStmtCount(S);
-if (!Count.hasValue())
-  return 0;
-return *Count;
-  }
+  uint64_t getProfileCount(const Stmt *S);
 
   /// Set the profiler's current count.
-  void setCurrentProfileCount(uint64_t Count) {
-PGO.setCurrentRegionCount(Count);
-  }
+  void setCurrentProfileCount(uint64_t Count);
 
   /// Get the profiler's current count. This is generally the count for the most
   /// recently incremented counter.
-  uint64_t getCurrentProfileCount() {
-return PGO.getCurrentRegionCount();
-  }
+  uint64_t getCurrentProfileCount();
 
 private:
 
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -52,7 +52,7 @@
   ExceptionSlot(nullptr), EHSelectorSlot(nullptr),
   DebugInfo(CGM.getModuleDebugInfo()),
   DisableDebugInfo(false), DidCallStackSave(false), IndirectBranch(nullptr),
-  PGO(cgm), SwitchInsn(nullptr), SwitchWeights(nullptr),
+  PGO(new CodeGenPGO(cgm)), SwitchInsn(nullptr), SwitchWeights(nullptr),
   CaseRangeBlock(nullptr), UnreachableBlock(nullptr), NumReturnExprs(0),
   NumSimpleReturnExprs(0), CXXABIThisDecl(nullptr),
   CXXABIThisValue(nullptr), CXXThisValue(nullptr),
@@ -94,6 +94,8 @@
   if (getLangOpts().OpenMP) {
 CGM.getOpenMPRuntime().functionFinished(*this);
   }
+
+  delete PGO;
 }
 
 CharUnits CodeGenFunction::getNaturalPointeeTypeAlignment(QualType T,
@@ -988,7 +990,7 @@
   StartFunction(GD, ResTy, Fn, FnInfo, Args, Loc, BodyRange.getBegin());
 
   // Generate the body of the function.
-  PGO.assignRegionCounters(GD, CurFn);
+  PGO->assignRegionCounters(GD, CurFn);
   if (isa(FD))
 EmitDestructorBody(Args);
   else if (isa(FD))
Index: lib/CodeGen/CGStmtOpenMP.cpp
===
--- lib/CodeGen/CGStmtOpenMP.cpp
+++ lib/CodeGen/CGStmtOpenMP.cpp
@@ -15,6 +15,7 @@
 

[PATCH] D19243: [CodeGen] Move some CodeGenPGO stuff out of CodeGenFunction.h

2016-04-18 Thread Vedant Kumar via cfe-commits
vsk created this revision.
vsk added a reviewer: bogner.
vsk added a subscriber: cfe-commits.

Cons: 1 extra malloc per CodeGenFunction instantiation.

Pros: This makes incremental builds noticeably faster, especially on my laptop. 
E.g with this patch there's no need to re-compile 
clang/lib/CodeGen/CGCUDARuntime.cpp InstrProfReader.h changes.

http://reviews.llvm.org/D19243

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenPGO.cpp

Index: lib/CodeGen/CodeGenPGO.cpp
===
--- lib/CodeGen/CodeGenPGO.cpp
+++ lib/CodeGen/CodeGenPGO.cpp
@@ -878,12 +878,33 @@
 
 llvm::MDNode *CodeGenFunction::createProfileWeightsForLoop(const Stmt *Cond,
uint64_t LoopCount) {
-  if (!PGO.haveRegionCounts())
+  if (!PGO->haveRegionCounts())
 return nullptr;
-  Optional CondCount = PGO.getStmtCount(Cond);
+  Optional CondCount = PGO->getStmtCount(Cond);
   assert(CondCount.hasValue() && "missing expected loop condition count");
   if (*CondCount == 0)
 return nullptr;
   return createProfileWeights(LoopCount,
   std::max(*CondCount, LoopCount) - LoopCount);
 }
+
+void CodeGenFunction::incrementProfileCounter(const Stmt *S) {
+  if (CGM.getCodeGenOpts().hasProfileClangInstr())
+PGO->emitCounterIncrement(Builder, S);
+  PGO->setCurrentStmt(S);
+}
+
+uint64_t CodeGenFunction::getProfileCount(const Stmt *S) {
+  Optional Count = PGO->getStmtCount(S);
+  if (!Count.hasValue())
+return 0;
+  return *Count;
+}
+
+void CodeGenFunction::setCurrentProfileCount(uint64_t Count) {
+  PGO->setCurrentRegionCount(Count);
+}
+
+uint64_t CodeGenFunction::getCurrentProfileCount() {
+  return PGO->getCurrentRegionCount();
+}
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -19,7 +19,6 @@
 #include "CGLoopInfo.h"
 #include "CGValue.h"
 #include "CodeGenModule.h"
-#include "CodeGenPGO.h"
 #include "EHScopeStack.h"
 #include "clang/AST/CharUnits.h"
 #include "clang/AST/ExprCXX.h"
@@ -76,6 +75,7 @@
 class ObjCAutoreleasePoolStmt;
 
 namespace CodeGen {
+class CodeGenPGO;
 class CodeGenTypes;
 class CGFunctionInfo;
 class CGRecordLayout;
@@ -692,7 +692,7 @@
   /// block through the normal cleanup handling code (if any) and then
   /// on to \arg Dest.
   void EmitBranchThroughCleanup(JumpDest Dest);
-  
+
   /// isObviouslyBranchWithoutCleanups - Return true if a branch to the
   /// specified destination obviously has no cleanups to run.  'false' is always
   /// a conservatively correct answer for this method.
@@ -900,7 +900,7 @@
   if (Data.isValid()) Data.unbind(CGF);
 }
   };
-  
+
 private:
   CGDebugInfo *DebugInfo;
   bool DisableDebugInfo;
@@ -943,7 +943,7 @@
   };
   SmallVector BreakContinueStack;
 
-  CodeGenPGO PGO;
+  CodeGenPGO *PGO;
 
   /// Calculate branch weights appropriate for PGO data
   llvm::MDNode *createProfileWeights(uint64_t TrueCount, uint64_t FalseCount);
@@ -953,30 +953,17 @@
 
 public:
   /// Increment the profiler's counter for the given statement.
-  void incrementProfileCounter(const Stmt *S) {
-if (CGM.getCodeGenOpts().hasProfileClangInstr())
-  PGO.emitCounterIncrement(Builder, S);
-PGO.setCurrentStmt(S);
-  }
+  void incrementProfileCounter(const Stmt *S);
 
   /// Get the profiler's count for the given statement.
-  uint64_t getProfileCount(const Stmt *S) {
-Optional Count = PGO.getStmtCount(S);
-if (!Count.hasValue())
-  return 0;
-return *Count;
-  }
+  uint64_t getProfileCount(const Stmt *S);
 
   /// Set the profiler's current count.
-  void setCurrentProfileCount(uint64_t Count) {
-PGO.setCurrentRegionCount(Count);
-  }
+  void setCurrentProfileCount(uint64_t Count);
 
   /// Get the profiler's current count. This is generally the count for the most
   /// recently incremented counter.
-  uint64_t getCurrentProfileCount() {
-return PGO.getCurrentRegionCount();
-  }
+  uint64_t getCurrentProfileCount();
 
 private:
 
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -52,7 +52,7 @@
   ExceptionSlot(nullptr), EHSelectorSlot(nullptr),
   DebugInfo(CGM.getModuleDebugInfo()),
   DisableDebugInfo(false), DidCallStackSave(false), IndirectBranch(nullptr),
-  PGO(cgm), SwitchInsn(nullptr), SwitchWeights(nullptr),
+  PGO(new CodeGenPGO(cgm)), SwitchInsn(nullptr), SwitchWeights(nullptr),
   CaseRangeBlock(nullptr), UnreachableBlock(nullptr), NumReturnExprs(0),
   NumSimpleReturnExprs(0), CXXABIThisDecl(nullptr),
 

r266687 - [modules] Remove some more unnecessary forwarding functions.

2016-04-18 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Apr 18 16:54:58 2016
New Revision: 266687

URL: http://llvm.org/viewvc/llvm-project?rev=266687=rev
Log:
[modules] Remove some more unnecessary forwarding functions.

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

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=266687=266686=266687=diff
==
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Mon Apr 18 16:54:58 2016
@@ -538,12 +538,6 @@ public:
   /// \brief Emit a reference to an identifier.
   void AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl );
 
-  /// \brief Emit a Selector (which is a smart pointer reference).
-  void AddSelectorRef(Selector, RecordDataImpl );
-
-  /// \brief Emit a CXXTemporary.
-  void AddCXXTemporary(const CXXTemporary *Temp, RecordDataImpl );
-
   /// \brief Get the unique number used to refer to the given selector.
   serialization::SelectorID getSelectorRef(Selector Sel);
 
@@ -582,21 +576,8 @@ public:
   /// declaration.
   serialization::DeclID getDeclID(const Decl *D);
 
-  /// \brief Emit a declaration name.
-  void AddDeclarationName(DeclarationName Name, RecordDataImpl );
-
   unsigned getAnonymousDeclarationNumber(const NamedDecl *D);
 
-  /// \brief Emit a nested name specifier.
-  void AddNestedNameSpecifier(NestedNameSpecifier *NNS, RecordDataImpl 
);
-
-  /// \brief Emit a template parameter list.
-  void AddTemplateParameterList(const TemplateParameterList *TemplateParams,
-RecordDataImpl );
-
-  /// \brief Emit a UnresolvedSet structure.
-  void AddUnresolvedSet(const ASTUnresolvedSet , RecordDataImpl );
-
   /// \brief Add a string to the given record.
   void AddString(StringRef Str, RecordDataImpl );
 
@@ -663,6 +644,7 @@ public:
   bool hasChain() const { return Chain; }
   ASTReader *getChain() const { return Chain; }
 
+private:
   // ASTDeserializationListener implementation
   void ReaderInitialized(ASTReader *Reader) override;
   void IdentifierRead(serialization::IdentID ID, IdentifierInfo *II) override;
@@ -820,14 +802,10 @@ public:
   }
 
   /// \brief Emit a Selector (which is a smart pointer reference).
-  void AddSelectorRef(Selector S) {
-return Writer->AddSelectorRef(S, *Record);
-  }
+  void AddSelectorRef(Selector S);
 
   /// \brief Emit a CXXTemporary.
-  void AddCXXTemporary(const CXXTemporary *Temp) {
-return Writer->AddCXXTemporary(Temp, *Record);
-  }
+  void AddCXXTemporary(const CXXTemporary *Temp);
 
   /// \brief Emit a C++ base specifier.
   void AddCXXBaseSpecifier(const CXXBaseSpecifier );
@@ -862,9 +840,8 @@ public:
 return Writer->AddDeclRef(D, *Record);
   }
 
-  void AddDeclarationName(DeclarationName Name) {
-return Writer->AddDeclarationName(Name, *Record);
-  }
+  /// \brief Emit a declaration name.
+  void AddDeclarationName(DeclarationName Name);
 
   void AddDeclarationNameLoc(const DeclarationNameLoc ,
  DeclarationName Name);
@@ -873,9 +850,7 @@ public:
   void AddQualifierInfo(const QualifierInfo );
 
   /// \brief Emit a nested name specifier.
-  void AddNestedNameSpecifier(NestedNameSpecifier *NNS) {
-return Writer->AddNestedNameSpecifier(NNS, *Record);
-  }
+  void AddNestedNameSpecifier(NestedNameSpecifier *NNS);
 
   /// \brief Emit a nested name specifier with source-location information.
   void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS);
@@ -887,17 +862,13 @@ public:
   void AddTemplateArgument(const TemplateArgument );
 
   /// \brief Emit a template parameter list.
-  void AddTemplateParameterList(const TemplateParameterList *TemplateParams) {
-return Writer->AddTemplateParameterList(TemplateParams, *Record);
-  }
+  void AddTemplateParameterList(const TemplateParameterList *TemplateParams);
 
   /// \brief Emit a template argument list.
   void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs);
 
   /// \brief Emit a UnresolvedSet structure.
-  void AddUnresolvedSet(const ASTUnresolvedSet ) {
-return Writer->AddUnresolvedSet(Set, *Record);
-  }
+  void AddUnresolvedSet(const ASTUnresolvedSet );
 
   /// \brief Emit a CXXCtorInitializer array.
   void AddCXXCtorInitializers(ArrayRef CtorInits);

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=266687=266686=266687=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Mon Apr 18 16:54:58 2016
@@ -3076,6 +3076,7 @@ void ASTWriter::WriteReferencedSelectors
 return;
 
   RecordData Record;
+  ASTRecordWriter 

[PATCH] D19240: clang-format: [JS] support `interface` as a free standing identifier.

2016-04-18 Thread Martin Probst via cfe-commits
mprobst created this revision.
mprobst added a reviewer: djasper.
mprobst added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

`interface` can be used as a fee standing identifier in JavaScript/TypeScript.
This change uses the heuristic of whether it's followed by another identifier
as an indication.

http://reviews.llvm.org/D19240

Files:
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -136,6 +136,9 @@
"};");
   verifyFormat("var struct = 2;");
   verifyFormat("var union = 2;");
+  verifyFormat("var interface = 2;");
+  verifyFormat("interface = 2;");
+  verifyFormat("x = interface instanceof y;");
 }
 
 TEST_F(FormatTestJS, CppKeywords) {
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1007,6 +1007,21 @@
   if ((Style.Language == FormatStyle::LK_JavaScript ||
Style.Language == FormatStyle::LK_Java) &&
   FormatTok->is(Keywords.kw_interface)) {
+if (Style.Language == FormatStyle::LK_JavaScript) {
+  // In JavaScript/TypeScript, "interface" can be used as a standalone
+  // identifier, e.g. in `var interface = 1;`. If "interface" is
+  // followed by another identifier, it is very like to be an actual
+  // interface declaration.
+  unsigned StoredPosition = Tokens->getPosition();
+  FormatToken *Next = Tokens->getNextToken();
+  FormatTok = Tokens->setPosition(StoredPosition);
+  if (Next && (Next->isNot(tok::identifier) ||
+   Next->isOneOf(Keywords.kw_instanceof, Keywords.kw_of,
+ Keywords.kw_in))) {
+nextToken();
+break;
+  }
+}
 parseRecord();
 addUnwrappedLine();
 return;


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -136,6 +136,9 @@
"};");
   verifyFormat("var struct = 2;");
   verifyFormat("var union = 2;");
+  verifyFormat("var interface = 2;");
+  verifyFormat("interface = 2;");
+  verifyFormat("x = interface instanceof y;");
 }
 
 TEST_F(FormatTestJS, CppKeywords) {
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1007,6 +1007,21 @@
   if ((Style.Language == FormatStyle::LK_JavaScript ||
Style.Language == FormatStyle::LK_Java) &&
   FormatTok->is(Keywords.kw_interface)) {
+if (Style.Language == FormatStyle::LK_JavaScript) {
+  // In JavaScript/TypeScript, "interface" can be used as a standalone
+  // identifier, e.g. in `var interface = 1;`. If "interface" is
+  // followed by another identifier, it is very like to be an actual
+  // interface declaration.
+  unsigned StoredPosition = Tokens->getPosition();
+  FormatToken *Next = Tokens->getNextToken();
+  FormatTok = Tokens->setPosition(StoredPosition);
+  if (Next && (Next->isNot(tok::identifier) ||
+   Next->isOneOf(Keywords.kw_instanceof, Keywords.kw_of,
+ Keywords.kw_in))) {
+nextToken();
+break;
+  }
+}
 parseRecord();
 addUnwrappedLine();
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r266673 - [sanitizer-coverage] make sure coverage flags are not passed to clang if the driver thinks they are unused

2016-04-18 Thread Kostya Serebryany via cfe-commits
Author: kcc
Date: Mon Apr 18 16:30:17 2016
New Revision: 266673

URL: http://llvm.org/viewvc/llvm-project?rev=266673=rev
Log:
[sanitizer-coverage] make sure coverage flags are not passed to clang if the 
driver thinks they are unused

Modified:
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/test/Driver/fsanitize-coverage.c

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=266673=266672=266673=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Mon Apr 18 16:30:17 2016
@@ -482,6 +482,8 @@ SanitizerArgs::SanitizerArgs(const ToolC
   if ((CoverageFeatures & CoverageTracePC) ||
   (AllAddedKinds & SupportsCoverage)) {
 Arg->claim();
+  } else {
+CoverageFeatures = 0;
   }
 } else if (Arg->getOption().matches(options::OPT_fno_sanitize_coverage)) {
   Arg->claim();

Modified: cfe/trunk/test/Driver/fsanitize-coverage.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize-coverage.c?rev=266673=266672=266673=diff
==
--- cfe/trunk/test/Driver/fsanitize-coverage.c (original)
+++ cfe/trunk/test/Driver/fsanitize-coverage.c Mon Apr 18 16:30:17 2016
@@ -35,6 +35,7 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=thread   
-fsanitize-coverage=func %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-UNUSED
 // RUN: %clang -target x86_64-linux-gnu 
-fsanitize-coverage=func %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-UNUSED
 // CHECK-SANITIZE-COVERAGE-UNUSED: argument unused during compilation: 
'-fsanitize-coverage=func'
+// CHECK-SANITIZE-COVERAGE-UNUSED-NOT: -fsanitize-coverage-type=1
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-coverage=func -fno-sanitize=address %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-SAN-DISABLED
 // CHECK-SANITIZE-COVERAGE-SAN-DISABLED-NOT: argument unused


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


r266672 - [sanitizer-coverage] better docs for -fsanitize-coverage=trace-bb

2016-04-18 Thread Kostya Serebryany via cfe-commits
Author: kcc
Date: Mon Apr 18 16:28:37 2016
New Revision: 266672

URL: http://llvm.org/viewvc/llvm-project?rev=266672=rev
Log:
[sanitizer-coverage] better docs for -fsanitize-coverage=trace-bb

Modified:
cfe/trunk/docs/SanitizerCoverage.rst

Modified: cfe/trunk/docs/SanitizerCoverage.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/SanitizerCoverage.rst?rev=266672=266671=266672=diff
==
--- cfe/trunk/docs/SanitizerCoverage.rst (original)
+++ cfe/trunk/docs/SanitizerCoverage.rst Mon Apr 18 16:28:37 2016
@@ -286,10 +286,26 @@ These counters may also be used for in-p
 
 Tracing basic blocks
 
-An *experimental* feature to support basic block (or edge) tracing.
+Experimental support for basic block (or edge) tracing.
 With ``-fsanitize-coverage=trace-bb`` the compiler will insert
 ``__sanitizer_cov_trace_basic_block(s32 *id)`` before every function, basic 
block, or edge
 (depending on the value of ``-fsanitize-coverage=[func,bb,edge]``).
+Example:
+
+.. code-block:: console
+
+% clang -g -fsanitize=address -fsanitize-coverage=edge,trace-bb foo.cc
+% ASAN_OPTIONS=coverage=1 ./a.out
+
+This will produce two files after the process exit:
+`trace-points.PID.sancov` and `trace-events.PID.sancov`.
+The first file will contain a textual description of all the instrumented 
points in the program
+in the form that you can feed into llvm-symbolizer (e.g. `a.out 0x4dca89`), 
one per line.
+The second file will contain the actual execution trace as a sequence of 
4-byte integers
+-- these integers are the indices into the array of instrumented points (the 
first file).
+
+Basic block tracing is currently supported only for single-threaded 
applications.
+
 
 Tracing PCs
 ===


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


Re: [PATCH] D19072: [CodeGen] Split CGDebugInfo into CGDebugInfo and CGDebugDwarf

2016-04-18 Thread Eric Christopher via cfe-commits
echristo requested changes to this revision.
echristo added a comment.
This revision now requires changes to proceed.

As a note I'm going to want to review this before it goes in.


http://reviews.llvm.org/D19072



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


Re: [PATCH] D19072: [CodeGen] Split CGDebugInfo into CGDebugInfo and CGDebugDwarf

2016-04-18 Thread Reid Kleckner via cfe-commits
rnk marked an inline comment as done.


Comment at: lib/CodeGen/CGDebugInfo.h:97
@@ -273,3 +96,3 @@
   /// Set the main CU's DwoId field to \p Signature.
-  void setDwoId(uint64_t Signature);
+  virtual void setDwoId(uint64_t Signature) = 0;
 

aprantl wrote:
> Why does this need to be virtual?
I guess it adjusts the CU, which is shared. OK, I'll move it back to 
CGDebugInfo. It just felt fairly dwarf-specific.


Comment at: lib/CodeGen/CGDebugInfo.h:298
@@ +297,3 @@
+  virtual llvm::DISubroutineType *
+  getOrCreateFunctionType(const Decl *D, QualType FnType, llvm::DIFile *F) = 0;
+

aprantl wrote:
> As you said, this isn't very clean. Can you outline how this can be improved 
> later? Will CodeView still need some form of DISubroutineTypes?
I think the parameters are right for CodeView and DWARF, but the return type 
will have to be DITypeRef so that I can get a DITypeIndex out of here. My next 
patch changes this and a few other return types.


Comment at: lib/CodeGen/CGDebugInfo.h:348
@@ -493,1 +347,3 @@
+  virtual llvm::DIType *EmitTypeForVarWithBlocksAttr(const VarDecl *VD,
+ uint64_t *OffSet) = 0;
 

aprantl wrote:
> Should this be part of CGDebugInfoDwarf?
The implementation directly uses DIBuilder to make a DICompositeType. If we 
wanted to make this logic common, we would have to first build a synthetic 
clang AST RecordDecl and then send that through getOrCreateType.


Comment at: lib/CodeGen/CGDebugInfo.h:350
@@ -493,4 +349,3 @@
 
-  /// Get the vtable name for the given class.
-  StringRef getVTableName(const CXXRecordDecl *Decl);
+  virtual void retainType(void *OpaqueDecl) {};
 

aprantl wrote:
> 1. Why does retainType need to be virtual?
> 2. I assume that the list of retained types is meaningless for CodeView? 
> Could this be moved to CGDebugInfoDwarf instead?
1. Yes, I intend to keep retainType as a no-op for CodeView. If a type makes it 
to the stream, it's up to the linker to decide whether it keeps it or not.
2. Are you asking if I can sink all the callers of this method down into 
CGDebugDwarf? Possibly, but EmitGlobalVariable directly references it, and I 
would expect that to be part of CGDebugInfo. We could come up with a different 
level of indirection, such as getOrCreateGlobalVariableType, similar to 
getOrCreateFunctionType and sink that logic to DWARF.


http://reviews.llvm.org/D19072



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


Re: [PATCH] D16544: [libcxx] Framework to allow testing of static libc++abi

2016-04-18 Thread Ben Craig via cfe-commits
bcraig marked 2 inline comments as done.
bcraig added a comment.

http://reviews.llvm.org/D16544



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


Re: [PATCH] D16544: [libcxx] Framework to allow testing of static libc++abi

2016-04-18 Thread Ben Craig via cfe-commits
bcraig updated the summary for this revision.
bcraig updated this revision to Diff 54112.
bcraig added a comment.

EricWF's feedback.  Removed libcxx_library option.  I plan on submitting this 
tomorrow morning.


http://reviews.llvm.org/D16544

Files:
  docs/TestingLibcxx.rst
  test/CMakeLists.txt
  test/libcxx/test/config.py
  test/libcxx/test/target_info.py
  test/lit.site.cfg.in
  www/lit_usage.html

Index: www/lit_usage.html
===
--- www/lit_usage.html
+++ www/lit_usage.html
@@ -114,15 +114,6 @@
 
 
 
-libcxx_library=path/to/libc++.so
-
-Specify the libc++ library that is tested. By default the library in the build
-directory is used. This option cannot be used when use_system_lib
-is provided.
-
-
-
-
 use_system_lib=bool
 
 Default: False
Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -21,6 +21,7 @@
 config.executor = "@LIBCXX_EXECUTOR@"
 config.llvm_unwinder= "@LIBCXXABI_USE_LLVM_UNWINDER@"
 config.use_libatomic= "@LIBCXX_HAS_ATOMIC_LIB@"
+config.libcxxabi_shared = "@LIBCXXABI_ENABLE_SHARED@"
 
 # Let the main config do the real work.
 lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg")
Index: test/libcxx/test/target_info.py
===
--- test/libcxx/test/target_info.py
+++ test/libcxx/test/target_info.py
@@ -90,11 +90,8 @@
 def configure_env(self, env):
 library_paths = []
 # Configure the library path for libc++
-libcxx_library = self.full_config.get_lit_conf('libcxx_library')
 if self.full_config.use_system_cxx_lib:
 pass
-elif libcxx_library:
-library_paths += [os.path.dirname(libcxx_library)]
 elif self.full_config.cxx_library_root:
 library_paths += [self.full_config.cxx_library_root]
 # Configure the abi library path
@@ -104,6 +101,15 @@
 env['DYLD_LIBRARY_PATH'] = ':'.join(library_paths)
 
 def allow_cxxabi_link(self):
+# FIXME: PR27405
+# libc++ *should* export all of the symbols found in libc++abi on OS X.
+# For this reason LibcxxConfiguration will not link libc++abi in OS X.
+# However __cxa_throw_bad_new_array_length doesn't get exported into
+# libc++ yet so we still need to explicitly link libc++abi when testing
+# libc++abi
+# See PR22654.
+if(self.full_config.get_lit_conf('name', '') == 'libc++abi'):
+return True
 # Don't link libc++abi explicitly on OS X because the symbols
 # should be available in libc++ directly.
 return False
@@ -162,11 +168,14 @@
 enable_threads = ('libcpp-has-no-threads' not in
   self.full_config.config.available_features)
 llvm_unwinder = self.full_config.get_lit_bool('llvm_unwinder', False)
+shared_libcxx = self.full_config.get_lit_bool('enable_shared', True)
 flags += ['-lm']
 if not llvm_unwinder:
 flags += ['-lgcc_s', '-lgcc']
 if enable_threads:
 flags += ['-lpthread']
+if not shared_libcxx:
+  flags += ['-lrt']
 flags += ['-lc']
 if llvm_unwinder:
 flags += ['-lunwind', '-ldl']
Index: test/libcxx/test/config.py
===
--- test/libcxx/test/config.py
+++ test/libcxx/test/config.py
@@ -430,21 +430,7 @@
 self.cxx.link_flags += shlex.split(link_flags_str)
 
 def configure_link_flags_cxx_library_path(self):
-libcxx_library = self.get_lit_conf('libcxx_library')
-# Configure libc++ library paths.
-if libcxx_library is not None:
-# Check that the given value for libcxx_library is valid.
-if not os.path.isfile(libcxx_library):
-self.lit_config.fatal(
-"libcxx_library='%s' is not a valid file." %
-libcxx_library)
-if self.use_system_cxx_lib:
-self.lit_config.fatal(
-"Conflicting options: 'libcxx_library' cannot be used "
-"with 'use_system_cxx_lib=true'")
-self.cxx.link_flags += ['-Wl,-rpath,' +
-os.path.dirname(libcxx_library)]
-elif not self.use_system_cxx_lib and self.cxx_library_root:
+if not self.use_system_cxx_lib and self.cxx_library_root:
 self.cxx.link_flags += ['-L' + self.cxx_library_root,
 '-Wl,-rpath,' + self.cxx_library_root]
 
@@ -456,11 +442,16 @@
 '-Wl,-rpath,' + self.abi_library_root]
 
 def configure_link_flags_cxx_library(self):
-libcxx_library = self.get_lit_conf('libcxx_library')
-if libcxx_library:

Re: [PATCH] D16545: [libcxxabi] Enable testing for static libc++abi

2016-04-18 Thread Ben Craig via cfe-commits
bcraig updated this revision to Diff 54110.
bcraig marked an inline comment as done.
bcraig added a comment.

EricWF's feedback.  I plan on submitting this tomorrow morning.


http://reviews.llvm.org/D16545

Files:
  CMakeLists.txt
  test/CMakeLists.txt
  test/libcxxabi/test/config.py
  test/lit.site.cfg.in

Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -14,6 +14,8 @@
 config.target_info  = "@LIBCXXABI_TARGET_INFO@"
 config.executor = "@LIBCXXABI_EXECUTOR@"
 config.thread_atexit= "@LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL@"
+config.libcxxabi_shared = "@LIBCXXABI_ENABLE_SHARED@"
+config.enable_shared= "@LIBCXX_ENABLE_SHARED@"
 
 # Let the main config do the real work.
 lit_config.load_config(config, "@LIBCXXABI_SOURCE_DIR@/test/lit.cfg")
Index: test/libcxxabi/test/config.py
===
--- test/libcxxabi/test/config.py
+++ test/libcxxabi/test/config.py
@@ -68,13 +68,3 @@
 
 def configure_compile_flags_rtti(self):
 pass
-
-# TODO(ericwf): Remove this. This is a hack for OS X.
-# libc++ *should* export all of the symbols found in libc++abi on OS X.
-# For this reason LibcxxConfiguration will not link libc++abi in OS X.
-# However __cxa_throw_bad_new_array_length doesn't get exported into libc++
-# yet so we still need to explicitly link libc++abi.
-# See PR22654.
-def configure_link_flags_abi_library(self):
-self.cxx.link_flags += ['-lc++abi']
-
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -6,7 +6,12 @@
   endif()
 endmacro()
 
+if (NOT DEFINED LIBCXX_ENABLE_SHARED)
+  set(LIBCXX_ENABLE_SHARED ON)
+endif()
+
 pythonize_bool(LLVM_BUILD_32_BITS)
+pythonize_bool(LIBCXX_ENABLE_SHARED)
 pythonize_bool(LIBCXXABI_ENABLE_SHARED)
 pythonize_bool(LIBCXXABI_ENABLE_THREADS)
 pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
@@ -22,7 +27,12 @@
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
   @ONLY)
 
-set(LIBCXXABI_TEST_DEPS cxxabi_shared)
+if (LIBCXXABI_ENABLE_SHARED)
+  set(LIBCXXABI_TEST_DEPS cxxabi_shared)
+else()
+  set(LIBCXXABI_TEST_DEPS cxxabi_static)
+endif()
+
 if (NOT LIBCXXABI_BUILT_STANDALONE)
   list(APPEND LIBCXXABI_TEST_DEPS cxx)
 endif()
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -116,9 +116,9 @@
 option(LIBCXXABI_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
 option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF)
 option(LIBCXXABI_ENABLE_THREADS "Build with threads enabled" ON)
-set(LIBCXXABI_GCC_TOOLCHAIN "" CACHE STRING "GCC toolchain for cross compiling.")
-set(LIBCXXABI_SYSROOT "" CACHE STRING "Sysroot for cross compiling.")
-set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE STRING "The path to libc++ library.")
+set(LIBCXXABI_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
+set(LIBCXXABI_SYSROOT "" CACHE PATH "Sysroot for cross compiling.")
+set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE PATH "The path to libc++ library.")
 
 # Default to building a shared library so that the default options still test
 # the libc++abi that is being built. There are two problems with testing a
@@ -182,6 +182,13 @@
 set(LIBCXXABI_BINARY_DIR  ${CMAKE_CURRENT_BINARY_DIR})
 set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
 
+# By default, for non-standalone builds, libcxx and libcxxabi share a library
+# directory.
+if (NOT LIBCXXABI_LIBCXX_LIBRARY_PATH)
+  set(LIBCXXABI_LIBCXX_LIBRARY_PATH "${LIBCXXABI_LIBRARY_DIR}" CACHE PATH
+  "The path to libc++ library.")
+endif ()
+
 #===
 # Setup Compiler Flags
 #===
@@ -338,14 +345,16 @@
 # soname, etc...
 add_subdirectory(src)
 
-if(NOT LIBCXXABI_ENABLE_SHARED)
-  # TODO: Fix the libc++ cmake files so that libc++abi can be statically linked.
-  # As it is now, libc++ will prefer linking against a dynamic libc++abi in the
-  # system library paths over a static libc++abi in the out directory. This
-  # would test the system library rather than the one we just built, which isn't
-  # very helpful.
-  message(WARNING "The libc++abi tests are currently only valid when "
-  "LIBCXXABI_ENABLE_SHARED is on, no check target will be "
+if (LIBCXXABI_BUILT_STANDALONE AND NOT LIBCXXABI_ENABLE_SHARED)
+  # We can't reasonably test the system C++ library with a static libc++abi.
+  # We either need to be able to replace libc++abi at run time (with a shared
+  # libc++abi), or we need to be able to replace the C++ runtime (with a non-
+  # standalone build).
+  message(WARNING "The libc++abi tests aren't valid when 

Re: [PATCH] D16544: [libcxx] Framework to allow testing of static libc++abi

2016-04-18 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

In http://reviews.llvm.org/D16544#404283, @bcraig wrote:

> In http://reviews.llvm.org/D16544#403273, @EricWF wrote:
>
> > Just spitballing but have you considered simply passing the full path, 
> > including the library name, to LIT? Instead of needing `enable_shared` 
> > variables we would simply use the named library, be it DSO or archive.
>
>
> I agree that this would be nice.  I don't really like the nest of if / else 
> statements that I currently have in place.  However, I have now attempted to 
> do this, and failed.  My cmake-fu just isn't strong enough.


OK. Thanks for looking into this. I figured CMake would stand in our way. Last 
I looked into it CMake doesn't actually know the name of the library it's going 
to produce until way to late in the configuration process.

Lets go ahead with this.


http://reviews.llvm.org/D16544



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


Re: r265766 - [modules] Add a comment to explain why -E leaves some #includes in the preprocessed output.

2016-04-18 Thread Vassil Vassilev via cfe-commits

On 18/04/16 21:06, Richard Smith wrote:
On Mon, Apr 18, 2016 at 11:49 AM, Vassil Vassilev 
> wrote:


On 18/04/16 20:32, Richard Smith wrote:

On Mon, Apr 18, 2016 at 6:28 AM, Vassil Vassilev
> wrote:

On 08/04/16 03:24, Richard Smith via cfe-commits wrote:

Author: rsmith
Date: Thu Apr  7 20:23:59 2016
New Revision: 265766

URL: http://llvm.org/viewvc/llvm-project?rev=265766=rev
Log:
[modules] Add a comment to explain why -E leaves some
#includes in the preprocessed output.

Modified:
 cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
 cfe/trunk/test/Modules/preprocess.cpp

Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=265766=265765=265766=diff

==
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
(original)
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
Thu Apr  7 20:23:59 2016
@@ -336,7 +336,9 @@ void PrintPPOutputPPCallbacks::Inclusion
OS << "#include "
   << (IsAngled ? '<' : '"')
   << FileName
- << (IsAngled ? '>' : '"');
+ << (IsAngled ? '>' : '"')
+ << " /* clang -E: implicit import for module "
+ << Imported->getFullModuleName() << " */";

It seems that in some cases the FileName needs to be tweaked
to be able to compile the output back. For instance:
clang -I folder/ file.cxx
cat file.cxx
#include "subfolder/A.h"

cat folder/subfolder/A.h
#include "B.h"

B.h resides in folder/subfolder/ and FileName argument would
be B.h causing the printer to generate #include "B.h" /*
clang -E: implicit import for... */ which cannot be compiled
back.


Ugh, yeah, that makes sense.

It seems superficially that what we should do for a file found
relative to the current file (or in MSVC mode, for a file found
relative to a possibly-indirect includer of the current file) is
to prepend the path from that file's search path to the current
file. That is, if we find "foo/bar.h" in search path
"includes/x", and we find "baz/quux.h" relative to bar.h, we
should produce the path "foo/baz/quux.h" (to be found relative to
"includes/x"). However, that won't work if there is a prior
include path that also contains a "foo/baz/quux.h", so we would
need to also include the search path in the include path. And
*that* won't work if . is not a search path and one of the search
paths is a relative path.

:( at first looked like an easy, nice solution, but apparently
"twin peaks" killer phase is true again :)


I wonder whether the problem is really that we're handling
#include search paths incorrectly in the presence of #line markers.

I am not sure I understand this. Could you give an example?


Suppose we have:

foo/bar.h:
#include "baz.h"

foo/baz.h:
// ...

foo/module.modulemap
textual header "bar.h"
module Baz { header "baz.h" }

foo.cc:
#include "foo/bar.h"

We currently produce a preprocessed source file like this:

# 1 "foo/bar.h"
#include "baz.h"

This is, in some sense, "correct" -- the #include line from 
"foo/bar.h" did say "baz.h". But we'll look for "baz.h" relative to 
the current preprocessed source file, not relative to "foo/bar.h".


We could change the preprocessor so that in the above case it searches 
relative to "foo/" instead, but that will break a collection of other 
use cases (and is different from GCC's behavior, and breaks the common 
flow of deleting the #line markers when reducing a test case, and so 
on). So instead, we could provide a modified syntax for the above that 
requests that the #include of "baz.h" be found relative to 
"foo/bar.h". We would only need to do this in the narrow case that (a) 
the include names a module header, and (b) that module header was 
found relative to the including file, and (c) the including file was 
itself included into the main source file.


Another alternative would be to provide a module import keyword that 
works across languages. Given that the C++ Modules TS is making good 
progress, perhaps we can just ignore this problem for now (this change 
is at least not a regression) and solve it by generating an import 
once we implement the real syntax.

Okay, sounds reasonable to me.




Perhaps for the relative path search we should somehow instruct
clang to look for files relative to the presumed file rather 

Re: [PATCH] D16544: [libcxx] Framework to allow testing of static libc++abi

2016-04-18 Thread Ben Craig via cfe-commits
bcraig added a comment.

In http://reviews.llvm.org/D16544#403273, @EricWF wrote:

> Just spitballing but have you considered simply passing the full path, 
> including the library name, to LIT? Instead of needing `enable_shared` 
> variables we would simply use the named library, be it DSO or archive.


I agree that this would be nice.  I don't really like the nest of if / else 
statements that I currently have in place.  However, I have now attempted to do 
this, and failed.  My cmake-fu just isn't strong enough.

My approach was to populate variables like so...

  get_target_property(LIBCXXABI_FULL_LIB_PATH cxxabi_static LOCATION)
  get_target_property(LIBCXXABI_FULL_LIB_PATH cxxabi_shared LOCATION)
  get_target_property(LIBCXX_FULL_LIB_PATH cxx LOCATION)

... and then to plumb that through lit.site.cfg.in.  This would work great if 
the core of cxxabi and cxx were processed first, followed by their respective 
tests.  Unfortunately, cxxabi and it's tests get processed before cxx gets 
processed.  This means that I can't rely on cxx's CMakeLists.txt to populate a 
path on behalf of cxxabi.  I could attempt to rebuild the path from the pieces 
of information that I do have access to, but that seems really hacky.

Note that getting a full path in doesn't remove all the if / elif complexity in 
getting cxx[abi] to the link line.  If no desired path exists in the config, 
then something like -lc++ or -lc++abi still needs to be passed in.  This is to 
handle the case where someone is building one of libcxx[abi] without the 
counterpart being available.  We don't know the absolute path to the respective 
library, but it is (presumably) in the library path.


http://reviews.llvm.org/D16544



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


Re: [PATCH] D19072: [CodeGen] Split CGDebugInfo into CGDebugInfo and CGDebugDwarf

2016-04-18 Thread Adrian Prantl via cfe-commits
aprantl added inline comments.


Comment at: lib/CodeGen/CGDebugInfo.h:97
@@ -273,3 +96,3 @@
   /// Set the main CU's DwoId field to \p Signature.
-  void setDwoId(uint64_t Signature);
+  virtual void setDwoId(uint64_t Signature) = 0;
 

Why does this need to be virtual?


Comment at: lib/CodeGen/CGDebugInfo.h:298
@@ +297,3 @@
+  virtual llvm::DISubroutineType *
+  getOrCreateFunctionType(const Decl *D, QualType FnType, llvm::DIFile *F) = 0;
+

As you said, this isn't very clean. Can you outline how this can be improved 
later? Will CodeView still need some form of DISubroutineTypes?


Comment at: lib/CodeGen/CGDebugInfo.h:348
@@ -493,1 +347,3 @@
+  virtual llvm::DIType *EmitTypeForVarWithBlocksAttr(const VarDecl *VD,
+ uint64_t *OffSet) = 0;
 

Should this be part of CGDebugInfoDwarf?


Comment at: lib/CodeGen/CGDebugInfo.h:350
@@ -493,4 +349,3 @@
 
-  /// Get the vtable name for the given class.
-  StringRef getVTableName(const CXXRecordDecl *Decl);
+  virtual void retainType(void *OpaqueDecl) {};
 

1. Why does retainType need to be virtual?
2. I assume that the list of retained types is meaningless for CodeView? Could 
this be moved to CGDebugInfoDwarf instead?


Comment at: lib/CodeGen/CGDebugInfo.h:354
@@ -500,5 +353,3 @@
 
-  /// Get column number for the location. If location is
-  /// invalid then use current location.
-  /// \param Force  Assume DebugColumnInfo option is true.
-  unsigned getColumnNumber(SourceLocation Loc, bool Force = false);
+private:
+  /// Create new compile unit.

redundant private.


http://reviews.llvm.org/D19072



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


Re: [PATCH] D17815: [libc++abi] Use fallback_malloc to allocate __cxa_eh_globals in case of dynamic memory exhaustion.

2016-04-18 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Could you generate a diff against the normal directory layout? Your's is 
against "libcxxabi/trunk/" where 'trunk' is the actual libcxxabi directory.


http://reviews.llvm.org/D17815



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


Re: [PATCH] D19144: Handle TemplateArgument in DynTypedNode comparison operations.

2016-04-18 Thread Samuel Benzaquen via cfe-commits
sbenza added a comment.

Sent http://reviews.llvm.org/D19231 to fix the underlying bug in `hasAncestor`.
We can proceed with this change if you want, but it is not required anymore. I 
don't know whether we need the extra complexity of `TemplateArgumentLess`.


http://reviews.llvm.org/D19144



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


Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.

2016-04-18 Thread Alexey Bader via cfe-commits
bader added inline comments.


Comment at: lib/Headers/opencl.h:14476-14479
@@ +14475,6 @@
+
+#ifdef _HAS_READ_WRITE_IMAGE
+float4 __attribute__((overloadable)) read_imagef(read_write image2d_t image, 
sampler_t sampler, int2 coord);
+float4 __attribute__((overloadable)) read_imagef(read_write image2d_t image, 
sampler_t sampler, float2 coord);
+#endif //_HAS_READ_WRITE_IMAGE
+

According to OpenCL 2.0 (page 46 of 
https://www.khronos.org/registry/cl/specs/opencl-2.0-openclc.pdf):

The sampler-less read image and write image built-ins can be used with image 
declared with the __read_write (or read_write) qualifier. Calls to built-ins 
that read from an image using a sampler for images declared with the 
__read_write (or read_write) qualifier will be a compilation error.



http://reviews.llvm.org/D18369



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


Re: r265766 - [modules] Add a comment to explain why -E leaves some #includes in the preprocessed output.

2016-04-18 Thread Richard Smith via cfe-commits
On Mon, Apr 18, 2016 at 11:49 AM, Vassil Vassilev 
wrote:

> On 18/04/16 20:32, Richard Smith wrote:
>
> On Mon, Apr 18, 2016 at 6:28 AM, Vassil Vassilev <
> v.g.vassi...@gmail.com> wrote:
>
>> On 08/04/16 03:24, Richard Smith via cfe-commits wrote:
>>
>>> Author: rsmith
>>> Date: Thu Apr  7 20:23:59 2016
>>> New Revision: 265766
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=265766=rev
>>> Log:
>>> [modules] Add a comment to explain why -E leaves some #includes in the
>>> preprocessed output.
>>>
>>> Modified:
>>>  cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
>>>  cfe/trunk/test/Modules/preprocess.cpp
>>>
>>> Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=265766=265765=265766=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)
>>> +++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Thu Apr  7
>>> 20:23:59 2016
>>> @@ -336,7 +336,9 @@ void PrintPPOutputPPCallbacks::Inclusion
>>> OS << "#include "
>>><< (IsAngled ? '<' : '"')
>>><< FileName
>>> - << (IsAngled ? '>' : '"');
>>> + << (IsAngled ? '>' : '"')
>>> + << " /* clang -E: implicit import for module "
>>> + << Imported->getFullModuleName() << " */";
>>>
>> It seems that in some cases the FileName needs to be tweaked to be able
>> to compile the output back. For instance:
>> clang -I folder/ file.cxx
>> cat file.cxx
>> #include "subfolder/A.h"
>>
>> cat folder/subfolder/A.h
>> #include "B.h"
>>
>> B.h resides in folder/subfolder/ and FileName argument would be B.h
>> causing the printer to generate #include "B.h" /* clang -E: implicit import
>> for... */ which cannot be compiled back.
>
>
> Ugh, yeah, that makes sense.
>
> It seems superficially that what we should do for a file found relative to
> the current file (or in MSVC mode, for a file found relative to a
> possibly-indirect includer of the current file) is to prepend the path from
> that file's search path to the current file. That is, if we find
> "foo/bar.h" in search path "includes/x", and we find "baz/quux.h" relative
> to bar.h, we should produce the path "foo/baz/quux.h" (to be found relative
> to "includes/x"). However, that won't work if there is a prior include path
> that also contains a "foo/baz/quux.h", so we would need to also include the
> search path in the include path. And *that* won't work if . is not a search
> path and one of the search paths is a relative path.
>
> :( at first looked like an easy, nice solution, but apparently "twin
> peaks" killer phase is true again :)
>
>
> I wonder whether the problem is really that we're handling #include search
> paths incorrectly in the presence of #line markers.
>
> I am not sure I understand this. Could you give an example?
>

Suppose we have:

foo/bar.h:
#include "baz.h"

foo/baz.h:
// ...

foo/module.modulemap
textual header "bar.h"
module Baz { header "baz.h" }

foo.cc:
#include "foo/bar.h"

We currently produce a preprocessed source file like this:

# 1 "foo/bar.h"
#include "baz.h"

This is, in some sense, "correct" -- the #include line from "foo/bar.h" did
say "baz.h". But we'll look for "baz.h" relative to the current
preprocessed source file, not relative to "foo/bar.h".

We could change the preprocessor so that in the above case it searches
relative to "foo/" instead, but that will break a collection of other use
cases (and is different from GCC's behavior, and breaks the common flow of
deleting the #line markers when reducing a test case, and so on). So
instead, we could provide a modified syntax for the above that requests
that the #include of "baz.h" be found relative to "foo/bar.h". We would
only need to do this in the narrow case that (a) the include names a module
header, and (b) that module header was found relative to the including
file, and (c) the including file was itself included into the main source
file.

Another alternative would be to provide a module import keyword that works
across languages. Given that the C++ Modules TS is making good progress,
perhaps we can just ignore this problem for now (this change is at least
not a regression) and solve it by generating an import once we implement
the real syntax.


> Perhaps for the relative path search we should somehow instruct clang to
> look for files relative to the presumed file rather than the physical file?
>
> Could we detect that we are compiling a preprocessed file? I guess there
> are traces, eg. include stack push/pop values...
>
> That would match our intent for these files. However, this doesn't match
> the GCC behavior, so we probably can't do it by default. =/
>
>
>
>
>>   }
>>>   // Since we want a newline after the @import, but not a #,
>>> start a new
>>>   // line 

Re: [PATCH] D18868: [Sema] PR27155: Fix a template argument deduction bug with base classes

2016-04-18 Thread Erik Pilkington via cfe-commits
erik.pilkington added a comment.

Ping!


http://reviews.llvm.org/D18868



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


Re: [PATCH] D19072: [CodeGen] Split CGDebugInfo into CGDebugInfo and CGDebugDwarf

2016-04-18 Thread Reid Kleckner via cfe-commits
rnk added a comment.

ping


http://reviews.llvm.org/D19072



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


Re: r265766 - [modules] Add a comment to explain why -E leaves some #includes in the preprocessed output.

2016-04-18 Thread Vassil Vassilev via cfe-commits

On 18/04/16 20:32, Richard Smith wrote:
On Mon, Apr 18, 2016 at 6:28 AM, Vassil Vassilev 
> wrote:


On 08/04/16 03:24, Richard Smith via cfe-commits wrote:

Author: rsmith
Date: Thu Apr  7 20:23:59 2016
New Revision: 265766

URL: http://llvm.org/viewvc/llvm-project?rev=265766=rev
Log:
[modules] Add a comment to explain why -E leaves some
#includes in the preprocessed output.

Modified:
 cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
 cfe/trunk/test/Modules/preprocess.cpp

Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=265766=265765=265766=diff

==
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Thu
Apr  7 20:23:59 2016
@@ -336,7 +336,9 @@ void PrintPPOutputPPCallbacks::Inclusion
OS << "#include "
   << (IsAngled ? '<' : '"')
   << FileName
- << (IsAngled ? '>' : '"');
+ << (IsAngled ? '>' : '"')
+ << " /* clang -E: implicit import for module "
+ << Imported->getFullModuleName() << " */";

It seems that in some cases the FileName needs to be tweaked to be
able to compile the output back. For instance:
clang -I folder/ file.cxx
cat file.cxx
#include "subfolder/A.h"

cat folder/subfolder/A.h
#include "B.h"

B.h resides in folder/subfolder/ and FileName argument would be
B.h causing the printer to generate #include "B.h" /* clang -E:
implicit import for... */ which cannot be compiled back.


Ugh, yeah, that makes sense.

It seems superficially that what we should do for a file found 
relative to the current file (or in MSVC mode, for a file found 
relative to a possibly-indirect includer of the current file) is to 
prepend the path from that file's search path to the current file. 
That is, if we find "foo/bar.h" in search path "includes/x", and we 
find "baz/quux.h" relative to bar.h, we should produce the path 
"foo/baz/quux.h" (to be found relative to "includes/x"). However, that 
won't work if there is a prior include path that also contains a 
"foo/baz/quux.h", so we would need to also include the search path in 
the include path. And *that* won't work if . is not a search path and 
one of the search paths is a relative path.
:( at first looked like an easy, nice solution, but apparently "twin 
peaks" killer phase is true again :)


I wonder whether the problem is really that we're handling #include 
search paths incorrectly in the presence of #line markers.

I am not sure I understand this. Could you give an example?
Perhaps for the relative path search we should somehow instruct clang 
to look for files relative to the presumed file rather than the 
physical file?
Could we detect that we are compiling a preprocessed file? I guess there 
are traces, eg. include stack push/pop values...
That would match our intent for these files. However, this doesn't 
match the GCC behavior, so we probably can't do it by default. =/



}
  // Since we want a newline after the @import, but not a
#, start a new
  // line immediately.

Modified: cfe/trunk/test/Modules/preprocess.cpp
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/preprocess.cpp?rev=265766=265765=265766=diff

==
--- cfe/trunk/test/Modules/preprocess.cpp (original)
+++ cfe/trunk/test/Modules/preprocess.cpp Thu Apr  7 20:23:59 2016
@@ -1,6 +1,6 @@
  // RUN: rm -rf %t
  // RUN: %clang_cc1 -fmodules -fimplicit-module-maps
-fmodules-cache-path=%t -I %S/Inputs -x c++ -E %s | \
-// RUN:   FileCheck -strict-whitespace %s
--check-prefix=CHECK --check-prefix=CXX
+// RUN:   FileCheck -strict-whitespace %s
--check-prefix=CHECK --check-prefix=CXX --check-prefix=CXX-DASHE
  // RUN: %clang_cc1 -fmodules -fimplicit-module-maps
-fmodules-cache-path=%t -I %S/Inputs -x objective-c -E %s | \
  // RUN:   FileCheck -strict-whitespace %s
--check-prefix=CHECK --check-prefix=OBJC
  // RUN: %clang_cc1 -fmodules -fimplicit-module-maps
-fmodules-cache-path=%t -I %S/Inputs -x c++ -E
-frewrite-includes %s | \
@@ -14,7 +14,9 @@ foo bar baz
  // The weird {{ }} here is to prevent the -frewrite-includes
test from matching its own CHECK lines.
// CXX: #include{{ }}"dummy.h"
+// CXX-DASHE-SAME: /* clang -E: implicit import for module
  

r266648 - Block: Fix a crash when we have type attributes or qualifiers with omitted

2016-04-18 Thread Manman Ren via cfe-commits
Author: mren
Date: Mon Apr 18 13:40:51 2016
New Revision: 266648

URL: http://llvm.org/viewvc/llvm-project?rev=266648=rev
Log:
Block: Fix a crash when we have type attributes or qualifiers with omitted
return type.

Emit a warning instead of crashing in IR generation.

rdar://22762981

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

Added:
cfe/trunk/test/SemaObjC/block-omitted-return-type.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaOpenCL/invalid-block.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=266648=266647=266648=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Apr 18 13:40:51 
2016
@@ -8437,4 +8437,12 @@ def warn_objc_redundant_qualified_class_
   "parameterized class %0 already conforms to the protocols listed; did you "
   "forget a '*'?">, InGroup;
 
+def warn_block_literal_attributes_on_omitted_return_type : Warning<
+  "attribute %0 ignored, because it cannot be applied to omitted return type">,
+  InGroup;
+
+def warn_block_literal_qualifiers_on_omitted_return_type : Warning<
+  "'%0' qualifier on omitted return type %1 has no effect">,
+  InGroup;
+
 } // end of sema component.

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=266648=266647=266648=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Mon Apr 18 13:40:51 2016
@@ -734,6 +734,7 @@ static void diagnoseAndRemoveTypeQualifi
   // it; they probably didn't mean to specify a redundant qualifier.
   typedef std::pair QualLoc;
   for (QualLoc Qual : {QualLoc(DeclSpec::TQ_const, DS.getConstSpecLoc()),
+   QualLoc(DeclSpec::TQ_restrict, DS.getRestrictSpecLoc()),
QualLoc(DeclSpec::TQ_volatile, DS.getVolatileSpecLoc()),
QualLoc(DeclSpec::TQ_atomic, DS.getAtomicSpecLoc())}) {
 if (!(RemoveTQs & Qual.first))
@@ -750,6 +751,47 @@ static void diagnoseAndRemoveTypeQualifi
   }
 }
 
+/// Return true if this is omitted block return type. Also check type
+/// attributes and type qualifiers when returning true.
+static bool checkOmittedBlockReturnType(Sema , Declarator ,
+QualType Result) {
+  if (!isOmittedBlockReturnType(declarator))
+return false;
+
+  // Warn if we see type attributes for omitted return type on a block literal.
+  AttributeList * =
+  declarator.getMutableDeclSpec().getAttributes().getListRef();
+  AttributeList *prev = nullptr;
+  for (AttributeList *cur = attrs; cur; cur = cur->getNext()) {
+AttributeList  = *cur;
+// Skip attributes that were marked to be invalid or non-type
+// attributes.
+if (attr.isInvalid() || !attr.isTypeAttr()) {
+  prev = cur;
+  continue;
+}
+S.Diag(attr.getLoc(),
+   diag::warn_block_literal_attributes_on_omitted_return_type)
+<< attr.getName();
+// Remove cur from the list.
+if (prev) {
+  prev->setNext(cur->getNext());
+  prev = cur;
+} else {
+  attrs = cur->getNext();
+}
+  }
+
+  // Warn if we see type qualifiers for omitted return type on a block literal.
+  const DeclSpec  = declarator.getDeclSpec();
+  unsigned TypeQuals = DS.getTypeQualifiers();
+  diagnoseAndRemoveTypeQualifiers(S, DS, TypeQuals, Result, (unsigned)-1,
+  diag::warn_block_literal_qualifiers_on_omitted_return_type);
+  declarator.getMutableDeclSpec().ClearTypeQualifiers();
+
+  return true;
+}
+
 /// Apply Objective-C type arguments to the given type.
 static QualType applyObjCTypeArgs(Sema , SourceLocation loc, QualType type,
   ArrayRef typeArgs,
@@ -1266,7 +1308,8 @@ static QualType ConvertDeclSpecToType(Ty
   Result = Context.getAutoDeductType();
   break;
 } else if (declarator.getContext() == Declarator::LambdaExprContext ||
-   isOmittedBlockReturnType(declarator)) {
+   checkOmittedBlockReturnType(S, declarator,
+   Context.DependentTy)) {
   Result = Context.DependentTy;
   break;
 }

Added: cfe/trunk/test/SemaObjC/block-omitted-return-type.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/block-omitted-return-type.m?rev=266648=auto
==
--- cfe/trunk/test/SemaObjC/block-omitted-return-type.m (added)
+++ cfe/trunk/test/SemaObjC/block-omitted-return-type.m Mon Apr 18 13:40:51 2016
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 %s -fblocks 

Re: [PATCH] D18567: Block: Fix a crash when we have type attributes or qualifiers with omitted return type.

2016-04-18 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266648: Block: Fix a crash when we have type attributes or 
qualifiers with omitted (authored by mren).

Changed prior to commit:
  http://reviews.llvm.org/D18567?vs=52398=54090#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18567

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/SemaObjC/block-omitted-return-type.m
  cfe/trunk/test/SemaOpenCL/invalid-block.cl

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8437,4 +8437,12 @@
   "parameterized class %0 already conforms to the protocols listed; did you "
   "forget a '*'?">, InGroup;
 
+def warn_block_literal_attributes_on_omitted_return_type : Warning<
+  "attribute %0 ignored, because it cannot be applied to omitted return type">,
+  InGroup;
+
+def warn_block_literal_qualifiers_on_omitted_return_type : Warning<
+  "'%0' qualifier on omitted return type %1 has no effect">,
+  InGroup;
+
 } // end of sema component.
Index: cfe/trunk/test/SemaOpenCL/invalid-block.cl
===
--- cfe/trunk/test/SemaOpenCL/invalid-block.cl
+++ cfe/trunk/test/SemaOpenCL/invalid-block.cl
@@ -4,16 +4,15 @@
 
 // All blocks declarations must be const qualified and initialized.
 void f1() {
-  int (^bl1)() = ^() {}; // expected-error{{invalid block variable declaration - must be const qualified}}
+  int (^bl1)() = ^() {return 1;}; // expected-error{{invalid block variable declaration - must be const qualified}}
   int (^const bl2)(); // expected-error{{invalid block variable declaration - must be initialized}}
-  int (^const bl3)() = ^const(){
-  };
+  int (^const bl3)() = ^(){return 1;};
 }
 
 // A block with extern storage class is not allowed.
-extern int (^const bl)() = ^const(){}; // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
+extern int (^const bl)() = ^(){return 1;}; // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
 void f2() {
-  extern int (^const bl)() = ^const(){}; // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
+  extern int (^const bl)() = ^(){return 1;}; // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}}
 }
 
 // A block cannot be the return value of a function.
@@ -29,22 +28,22 @@
 }
 
 // A block with variadic argument is not allowed.
-int (^const bl)(int, ...) = ^const int(int I, ...) { // expected-error {{invalid block prototype, variadic arguments are not allowed in OpenCL}}
+int (^const bl)(int, ...) = ^int(int I, ...) { // expected-error {{invalid block prototype, variadic arguments are not allowed in OpenCL}}
   return 0;
 };
 
 // A block can't be used to declare an array
 typedef int (^const bl1_t)(int);
 void f5(int i) {
-  bl1_t bl1 = ^const(int i) {return 1;};
-  bl1_t bl2 = ^const(int i) {return 2;};
+  bl1_t bl1 = ^(int i) {return 1;};
+  bl1_t bl2 = ^(int i) {return 2;};
   bl1_t arr[] = {bl1, bl2}; // expected-error {{array of 'bl1_t' (aka 'int (^const)(int)') type is invalid in OpenCL}}
   int tmp = i ? bl1(i)  // expected-error {{block type cannot be used as expression in ternary expression in OpenCL}}
   : bl2(i); // expected-error {{block type cannot be used as expression in ternary expression in OpenCL}}
 }
 
 void f6(bl1_t * bl_ptr) {
-  bl1_t bl = ^const(int i) {return 1;};
+  bl1_t bl = ^(int i) {return 1;};
   bl1_t *p =  // expected-error {{invalid argument type 'bl1_t' (aka 'int (^const)(int)') to unary expression}}
   bl = *bl_ptr;  // expected-error {{dereferencing pointer of type '__generic bl1_t *' (aka 'int (^const __generic *)(int)') is not allowed in OpenCL}}
 }
Index: cfe/trunk/test/SemaObjC/block-omitted-return-type.m
===
--- cfe/trunk/test/SemaObjC/block-omitted-return-type.m
+++ cfe/trunk/test/SemaObjC/block-omitted-return-type.m
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 %s -fblocks -verify -fsyntax-only
+
+@interface NSObject
+@end
+
+@interface Test : NSObject
+- (void)test;
+@end
+
+@implementation Test
+- (void)test
+{
+  void (^simpleBlock)() = ^ _Nonnull { //expected-warning {{attribute '_Nonnull' ignored, because it cannot be applied to omitted return type}}
+return;
+  };
+  void (^simpleBlock2)() = ^ _Nonnull void { //expected-error {{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'void'}}
+return;
+  };
+  void (^simpleBlock3)() = ^ _Nonnull (void) {  //expected-warning {{attribute '_Nonnull' ignored, because it cannot be applied to omitted return type}}
+return;
+  };
+
+  void 

Re: [PATCH] D18584: Complete support for C++ Core Guidelines Type.6: Always initialize a member variable.

2016-04-18 Thread Michael Miller via cfe-commits
michael_miller added a comment.

In http://reviews.llvm.org/D18584#403872, @alexfh wrote:

> FYI, the check has started crashing after this patch. I'll try to provide a 
> minimal test case soon. The relevant part of the stack trace is:
>
>   @ 0x7fc9c255efa0  8  clang::Stmt::getLocStart()
>   @ 0x7fc9c48fdac1 64  clang::tidy::cppcoreguidelines::(anonymous 
> namespace)::IntializerInsertion::getLocation()
>   @ 0x7fc9c49026d5   1696  
> clang::tidy::cppcoreguidelines::ProTypeMemberInitCheck::checkMissingBaseClassInitializer()
>   @ 0x7fc9c490424f 96  
> clang::tidy::cppcoreguidelines::ProTypeMemberInitCheck::check()


Hmm... I can get this to crash in that location but only if I run with 
-fdelayed-template-parsing. I've got an easy fix and test case if that's the 
same issue you're running into. We should move the check at line 307 into 
ProTypeMemberInitCheck::check before both checks. I've got a test case I can 
add to cppcoreguidelines-pro-type-member-init-delayed.cpp that reproduces it. 
Let me know if I should write up a patch for this.


Repository:
  rL LLVM

http://reviews.llvm.org/D18584



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


r266647 - [Hexagon] Define macros __HVX__ and __HVXDBL__ when appropriate

2016-04-18 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Mon Apr 18 13:38:11 2016
New Revision: 266647

URL: http://llvm.org/viewvc/llvm-project?rev=266647=rev
Log:
[Hexagon] Define macros __HVX__ and __HVXDBL__ when appropriate

Added:
cfe/trunk/test/Preprocessor/hexagon-predefines.c
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=266647=266646=266647=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Apr 18 13:38:11 2016
@@ -5946,6 +5946,12 @@ void HexagonTargetInfo::getTargetDefines
 Builder.defineMacro("__QDSP6_V60__");
 Builder.defineMacro("__QDSP6_ARCH__", "60");
   }
+
+  if (hasFeature("hvx")) {
+Builder.defineMacro("__HVX__");
+if (hasFeature("hvx-double"))
+  Builder.defineMacro("__HVXDBL__");
+  }
 }
 
 bool HexagonTargetInfo::handleTargetFeatures(std::vector 
,

Added: cfe/trunk/test/Preprocessor/hexagon-predefines.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/hexagon-predefines.c?rev=266647=auto
==
--- cfe/trunk/test/Preprocessor/hexagon-predefines.c (added)
+++ cfe/trunk/test/Preprocessor/hexagon-predefines.c Mon Apr 18 13:38:11 2016
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv5 %s 
| FileCheck %s -check-prefix CHECK-V5
+
+// CHECK-V5: #define __HEXAGON_ARCH__ 5
+// CHECK-V5: #define __HEXAGON_V5__ 1
+// CHECK-V5: #define __hexagon__ 1
+
+// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv60 
%s | FileCheck %s -check-prefix CHECK-V60
+
+// CHECK-V60: #define __HEXAGON_ARCH__ 60
+// CHECK-V60: #define __HEXAGON_V60__ 1
+// CHECK-V60: #define __hexagon__ 1
+
+// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv60 
-target-feature +hvx %s | FileCheck %s -check-prefix CHECK-V60HVX
+
+// CHECK-V60HVX: #define __HEXAGON_ARCH__ 60
+// CHECK-V60HVX: #define __HEXAGON_V60__ 1
+// CHECK-V60HVX: #define __HVX__ 1
+
+// RUN: %clang_cc1 -E -dM -triple hexagon-unknown-elf -target-cpu hexagonv60 
-target-feature +hvx-double  %s | FileCheck %s -check-prefix CHECK-V60HVXD
+
+// CHECK-V60HVXD: #define __HEXAGON_ARCH__ 60
+// CHECK-V60HVXD: #define __HEXAGON_V60__ 1
+// CHECK-V60HVXD: #define __HVXDBL__ 1
+// CHECK-V60HVXD: #define __HVX__ 1
+// CHECK-V60HVXD: #define __hexagon__ 1
+


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


Re: [PATCH] D19175: Fix for PR27015 (variable template initialized with a generic lambda expression)

2016-04-18 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 54088.
ahatanak added a comment.

Address Richard's review comments and add a test case.

The test case currently asserts when fn0 is instantiated. This doesn't happen 
if I give the template parameter a name.

template  auto fn0 = [] {};

instead of

template  auto fn0 = [] {};

I can prevent the assert if I make changes in Sema::ActOnTypeParameter to call 
S->AddDecl(Param) regardless of whether Param has a name. I'm not sure this is 
the right fix at the moment.


http://reviews.llvm.org/D19175

Files:
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/SemaCXX/vartemplate-lambda.cpp

Index: test/SemaCXX/vartemplate-lambda.cpp
===
--- /dev/null
+++ test/SemaCXX/vartemplate-lambda.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+template  auto fn0 = [] {};
+template  void foo0() { fn0(); }
+
+template auto fn1 = [](auto a) { return a + T(1); };
+
+template 
+int foo2() {
+  X a = 0x61;
+  fn1(a);
+  return 0;
+}
+
+int main() {
+  foo2();
+}
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3896,9 +3896,14 @@
   PushExpressionEvaluationContext(Sema::PotentiallyEvaluated, OldVar);
 
 // Instantiate the initializer.
-ExprResult Init =
-SubstInitializer(OldVar->getInit(), TemplateArgs,
- OldVar->getInitStyle() == VarDecl::CallInit);
+ExprResult Init;
+
+{
+  ContextRAII SwitchContext(*this, Var->getDeclContext());
+  Init = SubstInitializer(OldVar->getInit(), TemplateArgs,
+  OldVar->getInitStyle() == VarDecl::CallInit);
+}
+
 if (!Init.isInvalid()) {
   bool TypeMayContainAuto = true;
   Expr *InitExpr = Init.get();


Index: test/SemaCXX/vartemplate-lambda.cpp
===
--- /dev/null
+++ test/SemaCXX/vartemplate-lambda.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+template  auto fn0 = [] {};
+template  void foo0() { fn0(); }
+
+template auto fn1 = [](auto a) { return a + T(1); };
+
+template 
+int foo2() {
+  X a = 0x61;
+  fn1(a);
+  return 0;
+}
+
+int main() {
+  foo2();
+}
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3896,9 +3896,14 @@
   PushExpressionEvaluationContext(Sema::PotentiallyEvaluated, OldVar);
 
 // Instantiate the initializer.
-ExprResult Init =
-SubstInitializer(OldVar->getInit(), TemplateArgs,
- OldVar->getInitStyle() == VarDecl::CallInit);
+ExprResult Init;
+
+{
+  ContextRAII SwitchContext(*this, Var->getDeclContext());
+  Init = SubstInitializer(OldVar->getInit(), TemplateArgs,
+  OldVar->getInitStyle() == VarDecl::CallInit);
+}
+
 if (!Init.isInvalid()) {
   bool TypeMayContainAuto = true;
   Expr *InitExpr = Init.get();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r266645 - [Parser][ObjC] Make sure c++11 in-class initialization is done when the

2016-04-18 Thread Richard Smith via cfe-commits
On Mon, Apr 18, 2016 at 11:19 AM, Akira Hatanaka via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ahatanak
> Date: Mon Apr 18 13:19:45 2016
> New Revision: 266645
>
> URL: http://llvm.org/viewvc/llvm-project?rev=266645=rev
> Log:
> [Parser][ObjC] Make sure c++11 in-class initialization is done when the
> constructor's definition is in an implementation block.
>

This doesn't just fix the C++11 case, it also fixes this:

struct Q { Q(); };
struct S { S(); Q q;  };

@implementation I
S::S() {}
@end

We previously did not run the Q default constructor from the S default
constructor.

Can you also add that to the test, please?

Without this commit, ptr doesn't get initialized to null in the
> following code:
>
> struct S {
>   S();
>   void *ptr = nullptr;
> };
>
> @implementation I
>   S::S() {}
> @end
>
> rdar://problem/25693624
>
> Added:
> cfe/trunk/test/Parser/objc-default-ctor-init.mm
> Modified:
> cfe/trunk/lib/Parse/ParseObjc.cpp
>
> Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=266645=266644=266645=diff
>
> ==
> --- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseObjc.cpp Mon Apr 18 13:19:45 2016
> @@ -3651,6 +3651,8 @@ void Parser::ParseLexedObjCMethodDefs(Le
>else {
>  if (Tok.is(tok::colon))
>ParseConstructorInitializer(MCDecl);
> +else
> +  Actions.ActOnDefaultCtorInitializers(MCDecl);
>  ParseFunctionStatementBody(MCDecl, BodyScope);
>}
>
>
> Added: cfe/trunk/test/Parser/objc-default-ctor-init.mm
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-default-ctor-init.mm?rev=266645=auto
>
> ==
> --- cfe/trunk/test/Parser/objc-default-ctor-init.mm (added)
> +++ cfe/trunk/test/Parser/objc-default-ctor-init.mm Mon Apr 18 13:19:45
> 2016
> @@ -0,0 +1,17 @@
> +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10 -std=c++11 -ast-dump
> %s | FileCheck %s
> +// CHECK: CXXCtorInitializer Field {{.*}} 'ptr' 'void *'
> +
> +@interface NSObject
> +@end
> +
> +@interface I : NSObject
> +@end
> +
> +struct S {
> +  S();
> +  void *ptr = nullptr;
> +};
> +
> +@implementation I
> +S::S() {}
> +@end
>
>
> ___
> 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] D19231: [ASTMatchers] Do not try to memoize nodes we can't compare.

2016-04-18 Thread Samuel Benzaquen via cfe-commits
sbenza created this revision.
sbenza added a reviewer: alexfh.
sbenza added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Prevent hasAncestor from comparing nodes that are not supported.
hasDescendant was fixed some time ago to avoid this problem.
I'm applying the same fix to hasAncestor: if any object in the Builder map is
not comparable, skip the cache.

http://reviews.llvm.org/D19231

Files:
  lib/ASTMatchers/ASTMatchFinder.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -708,6 +708,19 @@
   decl(anyOf(hasDescendant(RD), hasDescendant(VD);
 }
 
+TEST(DeclarationMatcher, HasAncestorMemoization) {
+  // This triggers an hasAncestor with a TemplateArgument in the bound nodes.
+  // That node can't be memoized so we have to check for it before trying to put
+  // it on the cache.
+  DeclarationMatcher CannotMemoize = classTemplateSpecializationDecl(
+  hasAnyTemplateArgument(templateArgument().bind("targ")),
+  forEach(fieldDecl(hasAncestor(forStmt();
+
+  EXPECT_TRUE(notMatches("template  struct S;"
+ "template <> struct S{ int i; int j; };",
+ CannotMemoize));
+}
+
 TEST(DeclarationMatcher, HasAttr) {
   EXPECT_TRUE(matches("struct __attribute__((warn_unused)) X {};",
   decl(hasAttr(clang::attr::WarnUnused;
Index: lib/ASTMatchers/ASTMatchFinder.cpp
===
--- lib/ASTMatchers/ASTMatchFinder.cpp
+++ lib/ASTMatchers/ASTMatchFinder.cpp
@@ -616,6 +616,10 @@
 ActiveASTContext->getTranslationUnitDecl())
   return false;
 
+// For AST-nodes that don't have an identity, we can't memoize.
+if (!Builder->isComparable())
+  return matchesAncestorOfRecursively(Node, Matcher, Builder, MatchMode);
+
 MatchKey Key;
 Key.MatcherID = Matcher.getID();
 Key.Node = Node;
@@ -630,22 +634,34 @@
 }
 
 MemoizedMatchResult Result;
-Result.ResultOfMatch = false;
 Result.Nodes = *Builder;
+Result.ResultOfMatch =
+matchesAncestorOfRecursively(Node, Matcher, , MatchMode);
+
+MemoizedMatchResult  = ResultCache[Key];
+CachedResult = std::move(Result);
+
+*Builder = CachedResult.Nodes;
+return CachedResult.ResultOfMatch;
+  }
 
+  bool matchesAncestorOfRecursively(const ast_type_traits::DynTypedNode ,
+const DynTypedMatcher ,
+BoundNodesTreeBuilder *Builder,
+AncestorMatchMode MatchMode) {
 const auto  = ActiveASTContext->getParents(Node);
 assert(!Parents.empty() && "Found node that is not in the parent map.");
 if (Parents.size() == 1) {
   // Only one parent - do recursive memoization.
   const ast_type_traits::DynTypedNode Parent = Parents[0];
-  if (Matcher.matches(Parent, this, )) {
-Result.ResultOfMatch = true;
-  } else if (MatchMode != ASTMatchFinder::AMM_ParentOnly) {
-// Reset the results to not include the bound nodes from the failed
-// match above.
-Result.Nodes = *Builder;
-Result.ResultOfMatch = memoizedMatchesAncestorOfRecursively(
-Parent, Matcher, , MatchMode);
+  BoundNodesTreeBuilder BuilderCopy = *Builder;
+  if (Matcher.matches(Parent, this, )) {
+*Builder = std::move(BuilderCopy);
+return true;
+  }
+  if (MatchMode != ASTMatchFinder::AMM_ParentOnly) {
+return memoizedMatchesAncestorOfRecursively(Parent, Matcher, Builder,
+MatchMode);
 // Once we get back from the recursive call, the result will be the
 // same as the parent's result.
   }
@@ -655,10 +671,10 @@
   std::deque Queue(Parents.begin(),
   Parents.end());
   while (!Queue.empty()) {
-Result.Nodes = *Builder;
-if (Matcher.matches(Queue.front(), this, )) {
-  Result.ResultOfMatch = true;
-  break;
+BoundNodesTreeBuilder BuilderCopy = *Builder;
+if (Matcher.matches(Queue.front(), this, )) {
+  *Builder = std::move(BuilderCopy);
+  return true;
 }
 if (MatchMode != ASTMatchFinder::AMM_ParentOnly) {
   for (const auto  :
@@ -673,12 +689,7 @@
 Queue.pop_front();
   }
 }
-
-MemoizedMatchResult  = ResultCache[Key];
-CachedResult = std::move(Result);
-
-*Builder = CachedResult.Nodes;
-return CachedResult.ResultOfMatch;
+return false;
   }
 
   // Implements a BoundNodesTree::Visitor that calls a MatchCallback with
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

Re: r265766 - [modules] Add a comment to explain why -E leaves some #includes in the preprocessed output.

2016-04-18 Thread Richard Smith via cfe-commits
On Mon, Apr 18, 2016 at 6:28 AM, Vassil Vassilev 
wrote:

> On 08/04/16 03:24, Richard Smith via cfe-commits wrote:
>
>> Author: rsmith
>> Date: Thu Apr  7 20:23:59 2016
>> New Revision: 265766
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=265766=rev
>> Log:
>> [modules] Add a comment to explain why -E leaves some #includes in the
>> preprocessed output.
>>
>> Modified:
>>  cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
>>  cfe/trunk/test/Modules/preprocess.cpp
>>
>> Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=265766=265765=265766=diff
>>
>> ==
>> --- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)
>> +++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Thu Apr  7
>> 20:23:59 2016
>> @@ -336,7 +336,9 @@ void PrintPPOutputPPCallbacks::Inclusion
>> OS << "#include "
>><< (IsAngled ? '<' : '"')
>><< FileName
>> - << (IsAngled ? '>' : '"');
>> + << (IsAngled ? '>' : '"')
>> + << " /* clang -E: implicit import for module "
>> + << Imported->getFullModuleName() << " */";
>>
> It seems that in some cases the FileName needs to be tweaked to be able to
> compile the output back. For instance:
> clang -I folder/ file.cxx
> cat file.cxx
> #include "subfolder/A.h"
>
> cat folder/subfolder/A.h
> #include "B.h"
>
> B.h resides in folder/subfolder/ and FileName argument would be B.h
> causing the printer to generate #include "B.h" /* clang -E: implicit import
> for... */ which cannot be compiled back.


Ugh, yeah, that makes sense.

It seems superficially that what we should do for a file found relative to
the current file (or in MSVC mode, for a file found relative to a
possibly-indirect includer of the current file) is to prepend the path from
that file's search path to the current file. That is, if we find
"foo/bar.h" in search path "includes/x", and we find "baz/quux.h" relative
to bar.h, we should produce the path "foo/baz/quux.h" (to be found relative
to "includes/x"). However, that won't work if there is a prior include path
that also contains a "foo/baz/quux.h", so we would need to also include the
search path in the include path. And *that* won't work if . is not a search
path and one of the search paths is a relative path.

I wonder whether the problem is really that we're handling #include search
paths incorrectly in the presence of #line markers. Perhaps for the
relative path search we should somehow instruct clang to look for files
relative to the presumed file rather than the physical file? That would
match our intent for these files. However, this doesn't match the GCC
behavior, so we probably can't do it by default. =/


>   }
>>   // Since we want a newline after the @import, but not a #,
>> start a new
>>   // line immediately.
>>
>> Modified: cfe/trunk/test/Modules/preprocess.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/preprocess.cpp?rev=265766=265765=265766=diff
>>
>> ==
>> --- cfe/trunk/test/Modules/preprocess.cpp (original)
>> +++ cfe/trunk/test/Modules/preprocess.cpp Thu Apr  7 20:23:59 2016
>> @@ -1,6 +1,6 @@
>>   // RUN: rm -rf %t
>>   // RUN: %clang_cc1 -fmodules -fimplicit-module-maps
>> -fmodules-cache-path=%t -I %S/Inputs -x c++ -E %s | \
>> -// RUN:   FileCheck -strict-whitespace %s --check-prefix=CHECK
>> --check-prefix=CXX
>> +// RUN:   FileCheck -strict-whitespace %s --check-prefix=CHECK
>> --check-prefix=CXX --check-prefix=CXX-DASHE
>>   // RUN: %clang_cc1 -fmodules -fimplicit-module-maps
>> -fmodules-cache-path=%t -I %S/Inputs -x objective-c -E %s | \
>>   // RUN:   FileCheck -strict-whitespace %s --check-prefix=CHECK
>> --check-prefix=OBJC
>>   // RUN: %clang_cc1 -fmodules -fimplicit-module-maps
>> -fmodules-cache-path=%t -I %S/Inputs -x c++ -E -frewrite-includes %s | \
>> @@ -14,7 +14,9 @@ foo bar baz
>>   // The weird {{ }} here is to prevent the -frewrite-includes test from
>> matching its own CHECK lines.
>> // CXX: #include{{ }}"dummy.h"
>> +// CXX-DASHE-SAME: /* clang -E: implicit import for module dummy */
>>   // CXX: #include{{ }}"dummy.h"
>> +// CXX-DASHE-SAME: /* clang -E: implicit import for module dummy */
>>   // CXX: foo bar baz
>> // OBJC: @import{{ }}dummy; /* clang
>>
>>
>> ___
>> 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


r266645 - [Parser][ObjC] Make sure c++11 in-class initialization is done when the

2016-04-18 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon Apr 18 13:19:45 2016
New Revision: 266645

URL: http://llvm.org/viewvc/llvm-project?rev=266645=rev
Log:
[Parser][ObjC] Make sure c++11 in-class initialization is done when the
constructor's definition is in an implementation block.

Without this commit, ptr doesn't get initialized to null in the
following code:

struct S {
  S();
  void *ptr = nullptr;
};

@implementation I
  S::S() {}
@end

rdar://problem/25693624

Added:
cfe/trunk/test/Parser/objc-default-ctor-init.mm
Modified:
cfe/trunk/lib/Parse/ParseObjc.cpp

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=266645=266644=266645=diff
==
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Mon Apr 18 13:19:45 2016
@@ -3651,6 +3651,8 @@ void Parser::ParseLexedObjCMethodDefs(Le
   else {
 if (Tok.is(tok::colon))
   ParseConstructorInitializer(MCDecl);
+else
+  Actions.ActOnDefaultCtorInitializers(MCDecl);
 ParseFunctionStatementBody(MCDecl, BodyScope);
   }
   

Added: cfe/trunk/test/Parser/objc-default-ctor-init.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-default-ctor-init.mm?rev=266645=auto
==
--- cfe/trunk/test/Parser/objc-default-ctor-init.mm (added)
+++ cfe/trunk/test/Parser/objc-default-ctor-init.mm Mon Apr 18 13:19:45 2016
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10 -std=c++11 -ast-dump %s | 
FileCheck %s
+// CHECK: CXXCtorInitializer Field {{.*}} 'ptr' 'void *'
+
+@interface NSObject
+@end
+
+@interface I : NSObject
+@end
+
+struct S {
+  S();
+  void *ptr = nullptr;
+};
+
+@implementation I
+S::S() {}
+@end


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


Re: [PATCH] D16396: Warn if variable cannot be implicitly instantiated

2016-04-18 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Thanks!


http://reviews.llvm.org/D16396



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


r266644 - Clarifying the wording of this diagnostic; it confused parameter and argument.

2016-04-18 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Apr 18 13:10:53 2016
New Revision: 266644

URL: http://llvm.org/viewvc/llvm-project?rev=266644=rev
Log:
Clarifying the wording of this diagnostic; it confused parameter and argument.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/varargs-x86-64.c
cfe/trunk/test/Sema/varargs.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=266644=266643=266644=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Apr 18 13:10:53 
2016
@@ -7411,8 +7411,9 @@ def err_va_start_used_in_wrong_abi_funct
   "'va_start' used in %select{System V|Win64}0 ABI function">;
 def err_ms_va_start_used_in_sysv_function : Error<
   "'__builtin_ms_va_start' used in System V ABI function">;
-def warn_second_parameter_of_va_start_not_last_named_argument : Warning<
-  "second parameter of 'va_start' not last named argument">, InGroup;
+def warn_second_arg_of_va_start_not_last_named_param : Warning<
+  "second argument to 'va_start' is not the last named parameter">,
+  InGroup;
 def warn_va_start_of_reference_type_is_undefined : Warning<
   "'va_start' has undefined behavior with reference types">, InGroup;
 def err_first_argument_to_va_arg_not_of_type_va_list : Error<

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=266644=266643=266644=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Apr 18 13:10:53 2016
@@ -2723,7 +2723,7 @@ bool Sema::SemaBuiltinVAStartImpl(CallEx
 
   if (!SecondArgIsLastNamedArgument)
 Diag(TheCall->getArg(1)->getLocStart(),
- diag::warn_second_parameter_of_va_start_not_last_named_argument);
+ diag::warn_second_arg_of_va_start_not_last_named_param);
   else if (Type->isReferenceType()) {
 Diag(Arg->getLocStart(),
  diag::warn_va_start_of_reference_type_is_undefined);

Modified: cfe/trunk/test/Sema/varargs-x86-64.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/varargs-x86-64.c?rev=266644=266643=266644=diff
==
--- cfe/trunk/test/Sema/varargs-x86-64.c (original)
+++ cfe/trunk/test/Sema/varargs-x86-64.c Mon Apr 18 13:10:53 2016
@@ -21,8 +21,8 @@ void __attribute__((ms_abi)) g1(int a) {
 void __attribute__((ms_abi)) g2(int a, int b, ...) {
   __builtin_ms_va_list ap;
 
-  __builtin_ms_va_start(ap, 10); // expected-warning {{second parameter of 
'va_start' not last named argument}}
-  __builtin_ms_va_start(ap, a); // expected-warning {{second parameter of 
'va_start' not last named argument}}
+  __builtin_ms_va_start(ap, 10); // expected-warning {{second argument to 
'va_start' is not the last named parameter}}
+  __builtin_ms_va_start(ap, a); // expected-warning {{second argument to 
'va_start' is not the last named parameter}}
   __builtin_ms_va_start(ap, b);
 }
 

Modified: cfe/trunk/test/Sema/varargs.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/varargs.c?rev=266644=266643=266644=diff
==
--- cfe/trunk/test/Sema/varargs.c (original)
+++ cfe/trunk/test/Sema/varargs.c Mon Apr 18 13:10:53 2016
@@ -4,7 +4,7 @@
 void f1(int a)
 {
 __builtin_va_list ap;
-
+
 __builtin_va_start(ap, a, a); // expected-error {{too many arguments to 
function}}
 __builtin_va_start(ap, a); // expected-error {{'va_start' used in function 
with fixed args}}
 }
@@ -12,16 +12,16 @@ void f1(int a)
 void f2(int a, int b, ...)
 {
 __builtin_va_list ap;
-
-__builtin_va_start(ap, 10); // expected-warning {{second parameter of 
'va_start' not last named argument}}
-__builtin_va_start(ap, a); // expected-warning {{second parameter of 
'va_start' not last named argument}}
+
+__builtin_va_start(ap, 10); // expected-warning {{second argument to 
'va_start' is not the last named parameter}}
+__builtin_va_start(ap, a); // expected-warning {{second argument to 
'va_start' is not the last named parameter}}
 __builtin_va_start(ap, b);
 }
 
 void f3(float a, ...)
 {
 __builtin_va_list ap;
-
+
 __builtin_va_start(ap, a);
 __builtin_va_start(ap, (a));
 }


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


Re: [PATCH] D16396: Warn if variable cannot be implicitly instantiated

2016-04-18 Thread Serge Pavlov via cfe-commits
sepavloff updated this revision to Diff 54085.
sepavloff added a comment.

Updated patch

Changed text of messages as proposed by reviewer. As a result, printing
template parameters is not needed anymore, related code is removed.


http://reviews.llvm.org/D16396

Files:
  include/clang/AST/DeclBase.h
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/DeclBase.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CXX/temp/temp.decls/temp.mem/p1.cpp
  test/OpenMP/parallel_ast_print.cpp
  test/OpenMP/parallel_sections_ast_print.cpp
  test/OpenMP/target_parallel_ast_print.cpp
  test/OpenMP/task_ast_print.cpp
  test/OpenMP/teams_ast_print.cpp
  test/OpenMP/threadprivate_ast_print.cpp
  test/SemaCXX/PR10177.cpp
  test/SemaCXX/undefined-internal.cpp
  test/SemaTemplate/undefined-template.cpp

Index: test/SemaTemplate/undefined-template.cpp
===
--- /dev/null
+++ test/SemaTemplate/undefined-template.cpp
@@ -0,0 +1,139 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 -Wundefined-func-template %s
+
+template  struct C1 {
+  static char s_var_1;   // expected-note{{forward declaration of template entity is here}}
+  static char s_var_2;   // expected-note{{forward declaration of template entity is here}}
+  static void s_func_1();// expected-note{{forward declaration of template entity is here}}
+  static void s_func_2();// expected-note{{forward declaration of template entity is here}}
+  void meth_1(); // expected-note2{{forward declaration of template entity is here}}
+  void meth_2();
+  template  static char s_tvar_2;  // expected-note{{forward declaration of template entity is here}}
+  template  static void s_tfunc_2();   // expected-note{{forward declaration of template entity is here}}
+  template struct C2 {
+static char s_var_2; // expected-note{{forward declaration of template entity is here}}
+static void s_func_2();  // expected-note{{forward declaration of template entity is here}}
+void meth_2();   // expected-note{{forward declaration of template entity is here}}
+template  static char s_tvar_2;// expected-note{{forward declaration of template entity is here}}
+template  void tmeth_2();  // expected-note{{forward declaration of template entity is here}}
+  };
+};
+
+extern template char C1::s_var_2;
+extern template void C1::s_func_2();
+extern template void C1::meth_2();
+extern template char C1::s_tvar_2;
+extern template void C1::s_tfunc_2();
+extern template void C1::C2::s_var_2;
+extern template void C1::C2::s_func_2();
+extern template void C1::C2::meth_2();
+extern template char C1::C2::s_tvar_2;
+extern template void C1::C2::tmeth_2();
+
+char func_01() {
+  return C1::s_var_2;
+}
+
+char func_02() {
+  return C1::s_var_1; // expected-warning{{instantiation of variable 'C1::s_var_1' required here, but no definition is available}}
+   // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::s_var_1' is explicitly instantiated in another translation unit}}
+}
+
+char func_03() {
+  return C1::s_var_2; // expected-warning{{instantiation of variable 'C1::s_var_2' required here, but no definition is available}}
+// expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::s_var_2' is explicitly instantiated in another translation unit}}
+}
+
+void func_04() {
+  C1::s_func_1(); // expected-warning{{instantiation of function 'C1::s_func_1' required here, but no definition is available}}
+   // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::s_func_1' is explicitly instantiated in another translation unit}}
+}
+
+void func_05() {
+  C1::s_func_2();
+}
+
+void func_06() {
+  C1::s_func_2(); // expected-warning{{instantiation of function 'C1::s_func_2' required here, but no definition is available}}
+// expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::s_func_2' is explicitly instantiated in another translation unit}}
+}
+
+void func_07(C1 *x) {
+  x->meth_1();  // expected-warning{{instantiation of function 'C1::meth_1' required here, but no definition is available}}
+// expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::meth_1' is explicitly instantiated in another translation unit}}
+}
+
+void func_08(C1 *x) {
+  x->meth_2();
+}
+
+void func_09(C1 *x) {
+  x->meth_1();  // expected-warning{{instantiation of function 'C1::meth_1' required here, but no definition is available}}
+// expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::meth_1' is explicitly instantiated in another translation 

r266641 - NFC: unify clang / LLVM atomic ordering

2016-04-18 Thread JF Bastien via cfe-commits
Author: jfb
Date: Mon Apr 18 13:01:49 2016
New Revision: 266641

URL: http://llvm.org/viewvc/llvm-project?rev=266641=rev
Log:
NFC: unify clang / LLVM atomic ordering

This makes the C11 / C++11 *ABI* atomic ordering accessible from LLVM,
as discussed in http://reviews.llvm.org/D18200#inline-151433

This re-applies r266574 which I had reverted in r266575.

Depends on http://reviews.llvm.org/D18875

Original review: http://reviews.llvm.org/D18876

Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/CodeGen/CGAtomic.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=266641=266640=266641=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Mon Apr 18 13:01:49 2016
@@ -29,6 +29,7 @@
 #include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/AtomicOrdering.h"
 #include "llvm/Support/Compiler.h"
 
 namespace clang {
@@ -4830,16 +4831,6 @@ public:
 BI_First = 0
   };
 
-  // The ABI values for various atomic memory orderings.
-  enum AtomicOrderingKind {
-AO_ABI_memory_order_relaxed = 0,
-AO_ABI_memory_order_consume = 1,
-AO_ABI_memory_order_acquire = 2,
-AO_ABI_memory_order_release = 3,
-AO_ABI_memory_order_acq_rel = 4,
-AO_ABI_memory_order_seq_cst = 5
-  };
-
 private:
   enum { PTR, ORDER, VAL1, ORDER_FAIL, VAL2, WEAK, END_EXPR };
   Stmt* SubExprs[END_EXPR];

Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=266641=266640=266641=diff
==
--- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Mon Apr 18 13:01:49 2016
@@ -243,11 +243,6 @@ namespace {
 /// Materialize an atomic r-value in atomic-layout memory.
 Address materializeRValue(RValue rvalue) const;
 
-/// \brief Translates LLVM atomic ordering to GNU atomic ordering for
-/// libcalls.
-static AtomicExpr::AtomicOrderingKind
-translateAtomicOrdering(const llvm::AtomicOrdering AO);
-
 /// \brief Creates temp alloca for intermediate operations on atomic value.
 Address CreateTempAlloca() const;
   private:
@@ -292,25 +287,6 @@ namespace {
   };
 }
 
-AtomicExpr::AtomicOrderingKind
-AtomicInfo::translateAtomicOrdering(const llvm::AtomicOrdering AO) {
-  switch (AO) {
-  case llvm::AtomicOrdering::Unordered:
-  case llvm::AtomicOrdering::NotAtomic:
-  case llvm::AtomicOrdering::Monotonic:
-return AtomicExpr::AO_ABI_memory_order_relaxed;
-  case llvm::AtomicOrdering::Acquire:
-return AtomicExpr::AO_ABI_memory_order_acquire;
-  case llvm::AtomicOrdering::Release:
-return AtomicExpr::AO_ABI_memory_order_release;
-  case llvm::AtomicOrdering::AcquireRelease:
-return AtomicExpr::AO_ABI_memory_order_acq_rel;
-  case llvm::AtomicOrdering::SequentiallyConsistent:
-return AtomicExpr::AO_ABI_memory_order_seq_cst;
-  }
-  llvm_unreachable("Unhandled AtomicOrdering");
-}
-
 Address AtomicInfo::CreateTempAlloca() const {
   Address TempAlloca = CGF.CreateMemTemp(
   (LVal.isBitField() && ValueSizeInBits > AtomicSizeInBits) ? ValueTy
@@ -427,34 +403,39 @@ static void emitAtomicCmpXchg(CodeGenFun
 /// instructions to cope with the provided (but possibly only dynamically 
known)
 /// FailureOrder.
 static void emitAtomicCmpXchgFailureSet(CodeGenFunction , AtomicExpr *E,
-bool IsWeak, Address Dest,
-Address Ptr, Address Val1,
-Address Val2,
+bool IsWeak, Address Dest, Address Ptr,
+Address Val1, Address Val2,
 llvm::Value *FailureOrderVal,
 uint64_t Size,
 llvm::AtomicOrdering SuccessOrder) {
   llvm::AtomicOrdering FailureOrder;
   if (llvm::ConstantInt *FO = dyn_cast(FailureOrderVal)) {
-switch (FO->getSExtValue()) {
-default:
+auto FOS = FO->getSExtValue();
+if (!llvm::isValidAtomicOrderingCABI(FOS))
   FailureOrder = llvm::AtomicOrdering::Monotonic;
-  break;
-case AtomicExpr::AO_ABI_memory_order_consume:
-case AtomicExpr::AO_ABI_memory_order_acquire:
-  FailureOrder = llvm::AtomicOrdering::Acquire;
-  break;
-case AtomicExpr::AO_ABI_memory_order_seq_cst:
-  FailureOrder = llvm::AtomicOrdering::SequentiallyConsistent;
-  break;
-}
+else
+  switch ((llvm::AtomicOrderingCABI)FOS) {
+  case llvm::AtomicOrderingCABI::relaxed:
+  case llvm::AtomicOrderingCABI::release:
+  case llvm::AtomicOrderingCABI::acq_rel:

Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.

2016-04-18 Thread Alexey Bader via cfe-commits
bader added inline comments.


Comment at: lib/Headers/opencl.h:14473-14474
@@ +14472,4 @@
+
+float4 __const_func __attribute__((overloadable)) read_imagef(read_only 
image2d_t image, sampler_t sampler, int2 coord);
+float4 __const_func __attribute__((overloadable)) read_imagef(read_only 
image2d_t image, sampler_t sampler, float2 coord);
+

'const' attribute can't be applied to the read_image* functions, because 
image2d_t it's handle to the image that located in global memory:

"Basically this is just slightly more strict class than the pure attribute 
below, since function is not allowed to read global memory.
Note that a function that has pointer arguments and examines the data pointed 
to must not be declared const. Likewise, a function that calls a non-const 
function usually must not be const"

https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes

Please, apply 'pure' attribute.



http://reviews.llvm.org/D18369



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


Re: [PATCH] D18398: Compilation for Intel MCU (Part 1/3)

2016-04-18 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

LGTM


http://reviews.llvm.org/D18398



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


Re: [PATCH] D19225: [ARM] predefines __ELF__ macro for arm-none-eabi

2016-04-18 Thread Weiming Zhao via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266625: [ARM] predefines __ELF__ macro for arm-none-eabi 
(authored by weimingz).

Changed prior to commit:
  http://reviews.llvm.org/D19225?vs=54070=54074#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19225

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Preprocessor/init.c

Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -2162,6 +2162,9 @@
 // ARM-NETBSD:#define __arm 1
 // ARM-NETBSD:#define __arm__ 1
 
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-eabi < /dev/null | 
FileCheck -match-full-lines -check-prefix ARM-NONE-EABI %s
+// ARM-NONE-EABI: #define __ELF__ 1
+
 // RUN: %clang -target arm-apple-darwin-eabi -arch armv7s -x c -E -dM %s -o - 
| FileCheck -match-full-lines --check-prefix=ARM-DARWIN-NO-EABI %s
 // RUN: %clang -target arm-apple-darwin-eabi -arch armv6m -x c -E -dM %s -o - 
| FileCheck -match-full-lines --check-prefix=ARM-DARWIN-EABI %s
 // RUN: %clang -target arm-apple-darwin-eabi -arch armv7m -x c -E -dM %s -o - 
| FileCheck -match-full-lines --check-prefix=ARM-DARWIN-EABI %s
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -4847,6 +4847,10 @@
 // Target identification.
 Builder.defineMacro("__arm");
 Builder.defineMacro("__arm__");
+// For bare-metal none-eabi.
+if (getTriple().getOS() == llvm::Triple::UnknownOS &&
+getTriple().getEnvironment() == llvm::Triple::EABI)
+  Builder.defineMacro("__ELF__");
 
 // Target properties.
 Builder.defineMacro("__REGISTER_PREFIX__", "");


Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -2162,6 +2162,9 @@
 // ARM-NETBSD:#define __arm 1
 // ARM-NETBSD:#define __arm__ 1
 
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-eabi < /dev/null | FileCheck -match-full-lines -check-prefix ARM-NONE-EABI %s
+// ARM-NONE-EABI: #define __ELF__ 1
+
 // RUN: %clang -target arm-apple-darwin-eabi -arch armv7s -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARM-DARWIN-NO-EABI %s
 // RUN: %clang -target arm-apple-darwin-eabi -arch armv6m -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARM-DARWIN-EABI %s
 // RUN: %clang -target arm-apple-darwin-eabi -arch armv7m -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARM-DARWIN-EABI %s
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -4847,6 +4847,10 @@
 // Target identification.
 Builder.defineMacro("__arm");
 Builder.defineMacro("__arm__");
+// For bare-metal none-eabi.
+if (getTriple().getOS() == llvm::Triple::UnknownOS &&
+getTriple().getEnvironment() == llvm::Triple::EABI)
+  Builder.defineMacro("__ELF__");
 
 // Target properties.
 Builder.defineMacro("__REGISTER_PREFIX__", "");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r266625 - [ARM] predefines __ELF__ macro for arm-none-eabi

2016-04-18 Thread Weiming Zhao via cfe-commits
Author: weimingz
Date: Mon Apr 18 11:25:46 2016
New Revision: 266625

URL: http://llvm.org/viewvc/llvm-project?rev=266625=rev
Log:
[ARM] predefines __ELF__ macro for arm-none-eabi

Summary: predefines __ELF__ macro for arm-none-eabi

Reviewers: silviu.baranga, rengolin

Subscribers: aemerson, rengolin, cfe-commits

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=266625=266624=266625=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Apr 18 11:25:46 2016
@@ -4847,6 +4847,10 @@ public:
 // Target identification.
 Builder.defineMacro("__arm");
 Builder.defineMacro("__arm__");
+// For bare-metal none-eabi.
+if (getTriple().getOS() == llvm::Triple::UnknownOS &&
+getTriple().getEnvironment() == llvm::Triple::EABI)
+  Builder.defineMacro("__ELF__");
 
 // Target properties.
 Builder.defineMacro("__REGISTER_PREFIX__", "");

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=266625=266624=266625=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Mon Apr 18 11:25:46 2016
@@ -2162,6 +2162,9 @@
 // ARM-NETBSD:#define __arm 1
 // ARM-NETBSD:#define __arm__ 1
 
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-eabi < /dev/null | 
FileCheck -match-full-lines -check-prefix ARM-NONE-EABI %s
+// ARM-NONE-EABI: #define __ELF__ 1
+
 // RUN: %clang -target arm-apple-darwin-eabi -arch armv7s -x c -E -dM %s -o - 
| FileCheck -match-full-lines --check-prefix=ARM-DARWIN-NO-EABI %s
 // RUN: %clang -target arm-apple-darwin-eabi -arch armv6m -x c -E -dM %s -o - 
| FileCheck -match-full-lines --check-prefix=ARM-DARWIN-EABI %s
 // RUN: %clang -target arm-apple-darwin-eabi -arch armv7m -x c -E -dM %s -o - 
| FileCheck -match-full-lines --check-prefix=ARM-DARWIN-EABI %s


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


[PATCH] D19225: [ARM] predefines __ELF__ macro for arm-none-eabi

2016-04-18 Thread Weiming Zhao via cfe-commits
weimingz created this revision.
weimingz added reviewers: rengolin, silviu.baranga.
weimingz added a subscriber: cfe-commits.
Herald added subscribers: rengolin, aemerson.

redefines __ELF__ macro for arm-none-eabi

http://reviews.llvm.org/D19225

Files:
  lib/Basic/Targets.cpp
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -2162,6 +2162,9 @@
 // ARM-NETBSD:#define __arm 1
 // ARM-NETBSD:#define __arm__ 1
 
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-eabi < /dev/null | 
FileCheck -match-full-lines -check-prefix ARM-NONE-EABI %s
+// ARM-NONE-EABI: #define __ELF__ 1
+
 // RUN: %clang -target arm-apple-darwin-eabi -arch armv7s -x c -E -dM %s -o - 
| FileCheck -match-full-lines --check-prefix=ARM-DARWIN-NO-EABI %s
 // RUN: %clang -target arm-apple-darwin-eabi -arch armv6m -x c -E -dM %s -o - 
| FileCheck -match-full-lines --check-prefix=ARM-DARWIN-EABI %s
 // RUN: %clang -target arm-apple-darwin-eabi -arch armv7m -x c -E -dM %s -o - 
| FileCheck -match-full-lines --check-prefix=ARM-DARWIN-EABI %s
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -4817,6 +4817,10 @@
 // Target identification.
 Builder.defineMacro("__arm");
 Builder.defineMacro("__arm__");
+// For bare-metal none-eabi.
+if (getTriple().getOS() == llvm::Triple::UnknownOS &&
+getTriple().getEnvironment() == llvm::Triple::EABI)
+  Builder.defineMacro("__ELF__");
 
 // Target properties.
 Builder.defineMacro("__REGISTER_PREFIX__", "");


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -2162,6 +2162,9 @@
 // ARM-NETBSD:#define __arm 1
 // ARM-NETBSD:#define __arm__ 1
 
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-eabi < /dev/null | FileCheck -match-full-lines -check-prefix ARM-NONE-EABI %s
+// ARM-NONE-EABI: #define __ELF__ 1
+
 // RUN: %clang -target arm-apple-darwin-eabi -arch armv7s -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARM-DARWIN-NO-EABI %s
 // RUN: %clang -target arm-apple-darwin-eabi -arch armv6m -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARM-DARWIN-EABI %s
 // RUN: %clang -target arm-apple-darwin-eabi -arch armv7m -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=ARM-DARWIN-EABI %s
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -4817,6 +4817,10 @@
 // Target identification.
 Builder.defineMacro("__arm");
 Builder.defineMacro("__arm__");
+// For bare-metal none-eabi.
+if (getTriple().getOS() == llvm::Triple::UnknownOS &&
+getTriple().getEnvironment() == llvm::Triple::EABI)
+  Builder.defineMacro("__ELF__");
 
 // Target properties.
 Builder.defineMacro("__REGISTER_PREFIX__", "");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17815: [libc++abi] Use fallback_malloc to allocate __cxa_eh_globals in case of dynamic memory exhaustion.

2016-04-18 Thread Igor Kudrin via cfe-commits
ikudrin added a comment.

Ping! Could anyone check this patch, please?


http://reviews.llvm.org/D17815



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


Re: [PATCH] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

2016-04-18 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: lib/Format/Format.cpp:1450
@@ -1447,3 +1449,3 @@
 public:
-  Formatter(const FormatStyle , SourceManager , FileID ID,
-ArrayRef Ranges)
+  CodeProcessor(const FormatStyle , SourceManager , FileID ID,
+ArrayRef Ranges)

After pondering a bit more, it seems like CodeProcessor is too generic: this is 
more something that runs analyses based on annotated tokens, so I'd call it 
TokenAnalyzer or something. That would also make it obvious to push some of the 
duplicated functionality from Formatter and Cleaner down (namely everything up 
to where we have generated the annotated tokens).

I'm still not completely convinced either way regarding inheritance vs. 
composition, but if we have a TokenAnalyzer, we'd also have a nice is-a 
relationship. While I generally agree to prefer composition, I also think we 
need to look out for where inheritance actually makes things clearer.


http://reviews.llvm.org/D18551



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


Re: [PATCH] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

2016-04-18 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include/clang/Format/Format.h:769
@@ -768,1 +768,3 @@
 
+/// \brief Returns the replacements corresponding to applying \p Replaces and
+/// cleaning up the code after that.

cleanupAroundReplacements sounds good.


Comment at: lib/Format/Format.cpp:1466
@@ -1464,1 +1465,3 @@
+  template 
+  tooling::Replacements process(T Callable, bool *IncompleteFormat) {
 tooling::Replacements Result;

Nit: I think it's idiomatic to call this a "Callback".


Comment at: lib/Format/Format.cpp:2143
@@ +2142,3 @@
+
+  CodeProcessor Processor(Expanded, SourceMgr, ID, Ranges);
+  auto Callable =

This is unexpected: I'd not have expected the CodeProcessor to be used to keep 
state apart from what's used during a Process() run. I think we'll need a 
different name.


Comment at: lib/Format/Format.cpp:2176
@@ +2175,3 @@
+   bool *IncompleteFormat) -> tooling::Replacements {
+Cleaner Cleaner(Processor);
+return Cleaner.runCleanup(Tokens, AnnotatedLines);

The way the Processor is passed into the callbacks so they can call stuff on 
the processor again makes me think this is really tightly coupled and should 
use inheritance.

Alternatively, we might want to try to break up the CodeProcessor into a part 
that just runs the callback and keeps the state for running the callback 
around, and an interface that is used by the callbacks - I'll need to look more 
closely into this though.


http://reviews.llvm.org/D18551



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


Re: [PATCH] D19184: Remove MaxFunctionCount module flag annotation

2016-04-18 Thread Vedant Kumar via cfe-commits
vsk added a comment.

Lgtm


http://reviews.llvm.org/D19184



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


Re: [PATCH] D19144: Handle TemplateArgument in DynTypedNode comparison operations.

2016-04-18 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D19144#402853, @sbenza wrote:

> I think the bug is coming from `memoizedMatchesAncestorOfRecursively`.
>  `memoizedMatchesRecursively` has a special case at the top to skip the cache 
> if the node is not sortable. The other function should do that too.
>  Although the check is stale also because it is only checking for 
> memoizationData and not whether the node itself works for < and ==.
>
> Note that adding TemplateArgument to the function is ok, but that won't fix 
> the bug because we still have other nodes that are not comparable.


With this I would be entering "I have no idea what I'm doing" land ;) Might 
make sense for you to take over the patch, if you know how to fix the issue. 
WDYT?


http://reviews.llvm.org/D19144



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


Re: [PATCH] D18694: [ClangTidy] Add an 'explain-checks' option to diagnose where each checks comes from.

2016-04-18 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Looks better now, thanks!



Comment at: clang-tidy/ClangTidyOptions.cpp:163
@@ +162,3 @@
+DefaultOptionsProvider::getRawOptions(llvm::StringRef FileName) {
+  return {OptionsSource(DefaultOptions, OptionsSourceTypeDefaultBinary)};
+}

I'm not sure this will compile on VS2013.


Comment at: clang-tidy/ClangTidyOptions.cpp:179
@@ +178,3 @@
+  DefaultOptionsProvider::getRawOptions(FileName);
+  RawOptions.push_back(OptionsSource(ConfigOptions, 
OptionsSourceTypeConfigCommandLineOption));
+  RawOptions.push_back(OptionsSource(OverrideOptions, 
OptionsSourceTypeCheckCommandLineOption));

Maybe `emplace_back`?


Comment at: clang-tidy/ClangTidyOptions.h:129
@@ +128,3 @@
+ClangTidyOptions Result;
+for (const auto : getRawOptions(FileName))
+  Result = Result.mergeWith(Source.first);

Clang-format, please.


Comment at: clang-tidy/ClangTidyOptions.h:245
@@ -205,3 +244,3 @@
   /// \c ConfigHandlers.
-  llvm::Optional TryReadConfigFile(llvm::StringRef 
Directory);
+  llvm::Optional TryReadConfigFile(llvm::StringRef Directory);
 

nit: Name should start with a lower-case letter.


Comment at: clang-tidy/tool/ClangTidyMain.cpp:326
@@ +325,3 @@
+  for (auto It = RawOptions.rbegin(); It != RawOptions.rend(); ++It) {
+if (It->first.Checks && GlobList(*(It->first.Checks)).contains(Check)) 
{
+  llvm::outs() << "'" << Check << "' is enabled in the " << It->second

No need for parentheses around `It->first.Checks`.


http://reviews.llvm.org/D18694



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


Re: [PATCH] D18136: boost-use-to-string check

2016-04-18 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/boost/UseToStringCheck.cpp:53
@@ +52,3 @@
+  CharType->isSpecificBuiltinType(BuiltinType::Char_U))
+// Is CharType 'char'.
+StringType = "string";

These comments don't seem to be useful, but if you want to leave them, please 
surround the bodies with braces, since they are longer than one line.


Comment at: clang-tidy/boost/UseToStringCheck.cpp:60
@@ +59,3 @@
+  else
+return;
+

Please add a reduced test case for this.


http://reviews.llvm.org/D18136



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


Re: [PATCH] D18575: [clang-tidy] New checker to replace deprecated throw() specifications

2016-04-18 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
This revision now requires changes to proceed.


Comment at: clang-tidy/modernize/UseNoexceptCheck.cpp:18
@@ +17,3 @@
+
+// FIXME: Move to ASTMatchers.h on acceptance.
+namespace ast_matchers {

Please send a separate patch adding this matcher to ASTMatchers.h (with tests 
and docs).


Comment at: clang-tidy/modernize/UseNoexceptCheck.cpp:74
@@ +73,3 @@
+  SourceLocation ReplaceEnd;
+  std::string Replacement{ReplacementStr};
+  unsigned TokenLength{0};

http://llvm.org/docs/CodingStandards.html#do-not-use-braced-initializer-lists-to-call-a-constructor

Use the least powerful tool for the job: `std::string Replacement = 
ReplacementStr;`, this syntax makes it obvious that `ReplacementStr` is a 
`std::string` (or is implicitly converted to `std::string`).

Same elsewhere.


Comment at: clang-tidy/modernize/UseNoexceptCheck.cpp:80
@@ +79,3 @@
+  auto TokensEnd = Tokens.rend();
+  for (auto it = Tokens.rbegin(); it != TokensEnd; ++it) {
+SourceLocation Loc = it->getLocation();

1. Variable names should be CamelCase. 
2. It's more common to use `I` for array indices or iterators in LLVM.


Comment at: clang-tidy/modernize/UseNoexceptCheck.cpp:109
@@ +108,3 @@
+  }
+} else if (++it == TokensEnd)
+  return;

Braces should be used consistently on both sides of `else if`.


Comment at: clang-tidy/modernize/UseNoexceptCheck.cpp:115
@@ +114,3 @@
+  if (ReplaceStart.isValid() && ReplaceEnd.isValid()) {
+std::pair beginInfo = SM.getDecomposedLoc(ReplaceStart);
+std::pair endInfo = SM.getDecomposedLoc(ReplaceEnd);

CamelCase


Comment at: clang-tidy/modernize/UseNoexceptCheck.cpp:117
@@ +116,3 @@
+std::pair endInfo = SM.getDecomposedLoc(ReplaceEnd);
+if (beginInfo.first != endInfo.first || beginInfo.second > endInfo.second)
+  return;

Looks like `Lexer::makeFileCharRange` will do this job better.


Comment at: clang-tidy/modernize/UseNoexceptCheck.cpp:122
@@ +121,3 @@
+  "specification '%1'; use '%2' instead")
+<< FuncDecl->getNameInfo().getAsString()
+<< StringRef(SM.getCharacterData(ReplaceStart), Len) << Replacement

Just `FuncDecl` should be enough.


Comment at: clang-tidy/modernize/UseNoexceptCheck.h:22
@@ +21,3 @@
+/// \brief Replace dynamic exception specifications, with
+/// noexcept (or user-defined macro) or noexcept(true).
+/// \code

Please enclose inline code snippets in backquotes.


Comment at: docs/clang-tidy/checks/modernize-use-noexcept.rst:32
@@ +31,3 @@
+``throw(false)``.  Additinally, users can also use
+:option:``ReplacementString`` to specify a macro to use instead of
+``noexcept``.  This is useful when maintaining source code that must

There's an alternative approach: the appropriate compatibility macro can be 
detected automatically using the `Preprocessor::getLastMacroWithSpelling` 
method. This approach will only work, if the header defining the macro is 
already included. However, if it's not included, the check must also add the 
corresponding #include statement to avoid breaking the code.

Also, if you detect the macro name automatically, you can provide a default 
macro by the means of the command line options 
(`-extra-arg=-DNOEXCEPT=noexcept(false)` or the same via the configuration 
file).


http://reviews.llvm.org/D18575



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


Re: [PATCH] D17410: [libcxxabi] Respect LIBCXXABI_LIBDIR_SUFFIX before an install

2016-04-18 Thread Ben Craig via cfe-commits
bcraig closed this revision.
bcraig added a comment.

r266611


http://reviews.llvm.org/D17410



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


[libcxxabi] r266611 - Respect LIBCXXABI_LIBDIR_SUFFIX before an install

2016-04-18 Thread Ben Craig via cfe-commits
Author: bcraig
Date: Mon Apr 18 08:30:38 2016
New Revision: 266611

URL: http://llvm.org/viewvc/llvm-project?rev=266611=rev
Log:
Respect LIBCXXABI_LIBDIR_SUFFIX before an install

Prior to this patch, setting LIBCXXABI_LIBDIR_SUFFIX would confuse the
check-libcxxabi target. libc++abi.* would get output to lib instead of
lib${LIBCXXABI_LIBDIR_SUFFIX}, but the tests would look in the suffixed
directory.

Now, we match what libcxx does, and set the CMAKE_*_OUTPUT_DIRECTORY to the
LIBRARY_DIR.

http://reviews.llvm.org/D17410

Modified:
libcxxabi/trunk/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=266611=266610=266611=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Mon Apr 18 08:30:38 2016
@@ -96,9 +96,6 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   set(LIBCXXABI_LIBDIR_SUFFIX "" CACHE STRING
   "Define suffix of library directory name (32/64)")
 
-  set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
-  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
-
   set(LIBCXXABI_BUILT_STANDALONE 1)
 else()
   set(LLVM_MAIN_SRC_DIR "${CMAKE_SOURCE_DIR}" CACHE PATH "Path to LLVM source 
tree")
@@ -182,6 +179,9 @@ set(LIBCXXABI_SOURCE_DIR  ${CMAKE_CURREN
 set(LIBCXXABI_BINARY_DIR  ${CMAKE_CURRENT_BINARY_DIR})
 set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
 
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
+
 
#===
 # Setup Compiler Flags
 
#===


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


Re: [PATCH] D17410: [libcxxabi] Respect LIBCXXABI_LIBDIR_SUFFIX before an install

2016-04-18 Thread Ben Craig via cfe-commits
bcraig added a comment.

In http://reviews.llvm.org/D17410#403263, @EricWF wrote:

> So we already do this for the standalone builds but not for in-tree builds. 
>  Before committing please make sure to remove the code on CMakeLists.txt line 
> 99 that does this same thing.


Done

> I'm assuming changing these CMake variables doesn't propagate upwards to 
> other in-tree projects?


libcxx has an almost identical line in its top level CMakeLists.txt at the same 
scope.  Seems that if it's ok there, it should be fine here.


http://reviews.llvm.org/D17410



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


Re: [PATCH] D18694: [ClangTidy] Add an 'explain-checks' option to diagnose where each checks comes from.

2016-04-18 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 54056.
hokein added a comment.

Export SourceType.


http://reviews.llvm.org/D18694

Files:
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/ClangTidyOptions.h
  clang-tidy/tool/ClangTidyMain.cpp
  test/clang-tidy/Inputs/explain-config/.clang-tidy
  test/clang-tidy/explain-checks.cpp

Index: test/clang-tidy/explain-checks.cpp
===
--- /dev/null
+++ test/clang-tidy/explain-checks.cpp
@@ -0,0 +1,14 @@
+// RUN: clang-tidy -checks=-*,modernize-use-nullptr -explain-config | FileCheck --check-prefix=CHECK-MESSAGE1 %s
+// RUN: clang-tidy -config="{Checks: '-*,modernize-use-nullptr'}" -explain-config | FileCheck --check-prefix=CHECK-MESSAGE2 %s
+// RUN: clang-tidy -checks=modernize-use-nullptr -config="{Checks: '-*,modernize-use-nullptr'}" -explain-config | FileCheck --check-prefix=CHECK-MESSAGE3 %s
+// RUN: clang-tidy -checks=modernize-use-nullptr -config="{Checks: '-*,-modernize-use-nullptr'}" %S/Inputs/explain-config/a.cc -explain-config | FileCheck --check-prefix=CHECK-MESSAGE4 %s
+// RUN: clang-tidy -checks=modernize-use-nullptr -config="{Checks: '-*,modernize-*'}" -explain-config | FileCheck --check-prefix=CHECK-MESSAGE5 %s
+// RUN: clang-tidy -checks=modernize-use-nullptr -explain-config | FileCheck --check-prefix=CHECK-MESSAGE6 %s
+// RUN: clang-tidy -explain-config %S/Inputs/explain-config/a.cc | grep "'modernize-use-nullptr' is enabled in the %S/Inputs/explain-config/.clang-tidy."
+
+// CHECK-MESSAGE1: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
+// CHECK-MESSAGE2: 'modernize-use-nullptr' is enabled in the command-line option '-config'.
+// CHECK-MESSAGE3: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
+// CHECK-MESSAGE4: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
+// CHECK-MESSAGE5: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
+// CHECK-MESSAGE6: 'clang-analyzer-unix.API' is enabled in the clang-tidy binary.
Index: test/clang-tidy/Inputs/explain-config/.clang-tidy
===
--- /dev/null
+++ test/clang-tidy/Inputs/explain-config/.clang-tidy
@@ -0,0 +1 @@
+Checks: '-*,modernize-use-nullptr'
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -128,6 +128,12 @@
 )"),
 cl::init(false), cl::cat(ClangTidyCategory));
 
+static cl::opt ExplainConfig("explain-config", cl::desc(R"(
+for each enabled check explains, where it is enabled, i.e. in clang-tidy binary,
+command line or a specific configuration file.
+)"),
+   cl::init(false), cl::cat(ClangTidyCategory));
+
 static cl::opt Config("config", cl::desc(R"(
 Specifies a configuration in YAML/JSON format:
   -config="{Checks: '*',
@@ -280,11 +286,10 @@
   if (!Config.empty()) {
 if (llvm::ErrorOr ParsedConfig =
 parseConfiguration(Config)) {
-  return llvm::make_unique(
-  GlobalOptions, ClangTidyOptions::getDefaults()
- .mergeWith(DefaultOptions)
- .mergeWith(*ParsedConfig)
- .mergeWith(OverrideOptions));
+  return llvm::make_unique(
+  GlobalOptions,
+  ClangTidyOptions::getDefaults().mergeWith(DefaultOptions),
+  *ParsedConfig, OverrideOptions);
 } else {
   llvm::errs() << "Error: invalid configuration specified.\n"
<< ParsedConfig.getError().message() << "\n";
@@ -311,6 +316,23 @@
   ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FileName);
   std::vector EnabledChecks = getCheckNames(EffectiveOptions);
 
+  if (ExplainConfig) {
+// FIXME: Figure out a more elegant way to show other ClangTidyOptions'
+// fields like ExtraArg.
+std::vector
+RawOptions = OptionsProvider->getRawOptions(FileName);
+for (const std::string  : EnabledChecks) {
+  for (auto It = RawOptions.rbegin(); It != RawOptions.rend(); ++It) {
+if (It->first.Checks && GlobList(*(It->first.Checks)).contains(Check)) {
+  llvm::outs() << "'" << Check << "' is enabled in the " << It->second
+   << ".\n";
+  break;
+}
+  }
+}
+return 0;
+  }
+
   if (ListChecks) {
 llvm::outs() << "Enabled checks:";
 for (auto CheckName : EnabledChecks)
Index: clang-tidy/ClangTidyOptions.h
===
--- clang-tidy/ClangTidyOptions.h
+++ clang-tidy/ClangTidyOptions.h
@@ -99,14 +99,37 @@
 /// \brief Abstract interface for retrieving various ClangTidy options.
 class ClangTidyOptionsProvider {
 public:
+  static constexpr char OptionsSourceTypeDefaultBinary[] = "clang-tidy binary";
+  static constexpr char 

Re: r265766 - [modules] Add a comment to explain why -E leaves some #includes in the preprocessed output.

2016-04-18 Thread Vassil Vassilev via cfe-commits

On 08/04/16 03:24, Richard Smith via cfe-commits wrote:

Author: rsmith
Date: Thu Apr  7 20:23:59 2016
New Revision: 265766

URL: http://llvm.org/viewvc/llvm-project?rev=265766=rev
Log:
[modules] Add a comment to explain why -E leaves some #includes in the 
preprocessed output.

Modified:
 cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
 cfe/trunk/test/Modules/preprocess.cpp

Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=265766=265765=265766=diff
==
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Thu Apr  7 20:23:59 2016
@@ -336,7 +336,9 @@ void PrintPPOutputPPCallbacks::Inclusion
OS << "#include "
   << (IsAngled ? '<' : '"')
   << FileName
- << (IsAngled ? '>' : '"');
+ << (IsAngled ? '>' : '"')
+ << " /* clang -E: implicit import for module "
+ << Imported->getFullModuleName() << " */";
It seems that in some cases the FileName needs to be tweaked to be able 
to compile the output back. For instance:

clang -I folder/ file.cxx
cat file.cxx
#include "subfolder/A.h"

cat folder/subfolder/A.h
#include "B.h"

B.h resides in folder/subfolder/ and FileName argument would be B.h 
causing the printer to generate #include "B.h" /* clang -E: implicit 
import for... */ which cannot be compiled back.

  }
  // Since we want a newline after the @import, but not a #, start a 
new
  // line immediately.

Modified: cfe/trunk/test/Modules/preprocess.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/preprocess.cpp?rev=265766=265765=265766=diff
==
--- cfe/trunk/test/Modules/preprocess.cpp (original)
+++ cfe/trunk/test/Modules/preprocess.cpp Thu Apr  7 20:23:59 2016
@@ -1,6 +1,6 @@
  // RUN: rm -rf %t
  // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t 
-I %S/Inputs -x c++ -E %s | \
-// RUN:   FileCheck -strict-whitespace %s --check-prefix=CHECK 
--check-prefix=CXX
+// RUN:   FileCheck -strict-whitespace %s --check-prefix=CHECK 
--check-prefix=CXX --check-prefix=CXX-DASHE
  // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t 
-I %S/Inputs -x objective-c -E %s | \
  // RUN:   FileCheck -strict-whitespace %s --check-prefix=CHECK 
--check-prefix=OBJC
  // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t 
-I %S/Inputs -x c++ -E -frewrite-includes %s | \
@@ -14,7 +14,9 @@ foo bar baz
  // The weird {{ }} here is to prevent the -frewrite-includes test from 
matching its own CHECK lines.
  
  // CXX: #include{{ }}"dummy.h"

+// CXX-DASHE-SAME: /* clang -E: implicit import for module dummy */
  // CXX: #include{{ }}"dummy.h"
+// CXX-DASHE-SAME: /* clang -E: implicit import for module dummy */
  // CXX: foo bar baz
  
  // OBJC: @import{{ }}dummy; /* clang



___
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] D18398: Compilation for Intel MCU (Part 1/3)

2016-04-18 Thread Andrey Turetskiy via cfe-commits
aturetsk added a comment.

Ping.


http://reviews.llvm.org/D18398



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


Re: [PATCH] D18442: A clang-tidy check for std:accumulate.

2016-04-18 Thread Clement Courbet via cfe-commits
courbet added a comment.

Thanks, PTAL.



Comment at: clang-tidy/misc/FoldInitTypeCheck.cpp:21
@@ +20,3 @@
+/// Returns the value_type for an InputIterator type.
+static QualType getInputIteratorValueType(const Type ,
+  const ASTContext ) {

aaron.ballman wrote:
> alexfh wrote:
> > I suspect, a significant part of this could be done in the matcher. I might 
> > be wrong, but it seems worth trying. The resulting code is usually much 
> > shorter and cleaner.
> I kind of wonder if it would be generally useful as a matcher helper utility 
> -- expose everything from `std::iterator_traits` with a nice AST matcher 
> interface. Something that can be used like: 
> `iteratorTrait(hasValueType(), hasPointerType())` Or is that 
> overkill?
That would be cool, but I'm afraid it would give the false sense of covering 
all cases. Unfortunately the user can specialize iterator_traits for their 
iterator type, which would not be easy to cover.


Comment at: clang-tidy/misc/FoldInitTypeCheck.cpp:21
@@ +20,3 @@
+/// Returns the value_type for an InputIterator type.
+static QualType getInputIteratorValueType(const Type ,
+  const ASTContext ) {

courbet wrote:
> aaron.ballman wrote:
> > alexfh wrote:
> > > I suspect, a significant part of this could be done in the matcher. I 
> > > might be wrong, but it seems worth trying. The resulting code is usually 
> > > much shorter and cleaner.
> > I kind of wonder if it would be generally useful as a matcher helper 
> > utility -- expose everything from `std::iterator_traits` with a nice AST 
> > matcher interface. Something that can be used like: 
> > `iteratorTrait(hasValueType(), hasPointerType())` Or is that 
> > overkill?
> That would be cool, but I'm afraid it would give the false sense of covering 
> all cases. Unfortunately the user can specialize iterator_traits for their 
> iterator type, which would not be easy to cover.
Done, and that's indeed much nicer to read.


Comment at: clang-tidy/misc/FoldInitTypeCheck.cpp:79
@@ +78,3 @@
+  callExpr(callee(functionDecl(
+   hasName("std::accumulate"),
+   hasParameter(0, parmVarDecl().bind("iterator")),

aaron.ballman wrote:
> Are there plans to apply this to other STL algorithms, like `inner_product`, 
> `reduce`, etc? If so, it may be good to add a chunk of those up front.
> 
> Also, the name we should check should be `::std::accumulate`. May want to 
> include a test like:
> ```
> namespace blah {
> namespace std {
> template 
> T accumulate(Iter, Iter, T); // We should not care about this one.
> }
> }
> ```
Added a test, thanks for the catch !


http://reviews.llvm.org/D18442



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


Re: [PATCH] D18442: A clang-tidy check for std:accumulate.

2016-04-18 Thread Clement Courbet via cfe-commits
courbet updated the summary for this revision.
courbet updated this revision to Diff 54045.
courbet marked 7 inline comments as done.
courbet added a comment.

- Use matchers for most of the check logic,
- Implement checking for reduce and inner_product,
- more tests.


http://reviews.llvm.org/D18442

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/FoldInitTypeCheck.cpp
  clang-tidy/misc/FoldInitTypeCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-fold-init-type.rst
  test/clang-tidy/misc-fold-init-type.cpp

Index: test/clang-tidy/misc-fold-init-type.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-fold-init-type.cpp
@@ -0,0 +1,158 @@
+// RUN: %check_clang_tidy %s misc-fold-init-type %t
+
+namespace std {
+template 
+T accumulate(InputIt first, InputIt last, T init);
+
+template 
+T reduce(InputIt first, InputIt last, T init);
+template 
+T reduce(ExecutionPolicy &,
+ InputIt first, InputIt last, T init);
+
+struct parallel_execution_policy {};
+constexpr parallel_execution_policy par{};
+
+template 
+T inner_product(InputIt1 first1, InputIt1 last1,
+InputIt2 first2, T value);
+
+template 
+T inner_product(ExecutionPolicy &, InputIt1 first1, InputIt1 last1,
+InputIt2 first2, T value);
+
+} // namespace std
+
+struct FloatIterator {
+  typedef float value_type;
+};
+template 
+struct TypedefTemplateIterator { typedef ValueType value_type; };
+template 
+struct UsingTemplateIterator { using value_type = ValueType; };
+template 
+struct DependentTypedefTemplateIterator { typedef typename ValueType::value_type value_type; };
+template 
+struct DependentUsingTemplateIterator : public TypedefTemplateIterator { using typename TypedefTemplateIterator::value_type; };
+using TypedeffedIterator = FloatIterator;
+
+// Positives.
+
+int accumulatePositive1() {
+  float a[1] = {0.5f};
+  return std::accumulate(a, a + 1, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'float' into type 'int'
+}
+
+int accumulatePositive2() {
+  FloatIterator it;
+  return std::accumulate(it, it, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'float' into type 'int'
+}
+
+int accumulatePositive3() {
+  double a[1] = {0.0};
+  return std::accumulate(a, a + 1, 0.0f);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'double' into type 'float'
+}
+
+int accumulatePositive4() {
+  TypedefTemplateIterator it;
+  return std::accumulate(it, it, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'unsigned int' into type 'int'
+}
+
+int accumulatePositive5() {
+  UsingTemplateIterator it;
+  return std::accumulate(it, it, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'unsigned int' into type 'int'
+}
+
+int accumulatePositive6() {
+  DependentTypedefTemplateIterator it;
+  return std::accumulate(it, it, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'unsigned int' into type 'int'
+}
+
+int accumulatePositive7() {
+  TypedeffedIterator it;
+  return std::accumulate(it, it, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'float' into type 'int'
+}
+
+int accumulatePositive8() {
+  DependentUsingTemplateIterator it;
+  return std::accumulate(it, it, 0);
+  // FIXME: this one should trigger too.
+}
+
+int reducePositive1() {
+  float a[1] = {0.5f};
+  return std::reduce(a, a + 1, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'float' into type 'int'
+}
+
+int reducePositive2() {
+  float a[1] = {0.5f};
+  return std::reduce(std::par, a, a + 1, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'float' into type 'int'
+}
+
+int innerProductPositive1() {
+  float a[1] = {0.5f};
+  int b[1] = {1};
+  return std::inner_product(std::par, a, a + 1, b, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'float' into type 'int'
+}
+
+int innerProductPositive2() {
+  float a[1] = {0.5f};
+  int b[1] = {1};
+  return std::inner_product(std::par, a, a + 1, b, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'float' into type 'int'
+}
+
+// Negatives.
+
+int negative1() {
+  float a[1] = {0.5f};
+  // This is OK because types match.
+  return std::accumulate(a, a + 1, 0.0);
+}
+
+int negative2() {
+  float a[1] = {0.5f};
+  // This is OK because double is bigger than float.
+  return std::accumulate(a, a + 1, 0.0);
+}
+
+int negative3() {
+  float a[1] = {0.5f};
+  // This is OK because the user explicitly specified T.
+  return std::accumulate(a, a + 1, 0);
+}
+
+int negative4() {
+  TypedefTemplateIterator it;
+  // For now this is OK.
+  return std::accumulate(it, it, 0.0);
+}
+
+int negative5() {
+  float a[1] = {0.5f};
+  float b[1] = {1.0f};
+  return std::inner_product(std::par, a, a + 1, b, 0.0f);
+}
+
+namespace blah {
+namespace std {
+template 
+T accumulate(InputIt, InputIt, T); // We should not 

Re: [PATCH] D18584: Complete support for C++ Core Guidelines Type.6: Always initialize a member variable.

2016-04-18 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

FYI, the check has started crashing after this patch. I'll try to provide a 
minimal test case soon. The relevant part of the stack trace is:

  @ 0x7fc9c255efa0  8  clang::Stmt::getLocStart()
  @ 0x7fc9c48fdac1 64  clang::tidy::cppcoreguidelines::(anonymous 
namespace)::IntializerInsertion::getLocation()
  @ 0x7fc9c49026d5   1696  
clang::tidy::cppcoreguidelines::ProTypeMemberInitCheck::checkMissingBaseClassInitializer()
  @ 0x7fc9c490424f 96  
clang::tidy::cppcoreguidelines::ProTypeMemberInitCheck::check()


Repository:
  rL LLVM

http://reviews.llvm.org/D18584



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


r266599 - clang-format: Improve heuristics to detect function declarations/definitions.

2016-04-18 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Apr 18 06:31:21 2016
New Revision: 266599

URL: http://llvm.org/viewvc/llvm-project?rev=266599=rev
Log:
clang-format: Improve heuristics to detect function declarations/definitions.

Specifically understand ellipses in parameter lists and treat trailing
reference qualifiers and the "{" as signals.

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=266599=266598=266599=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Apr 18 06:31:21 2016
@@ -1553,7 +1553,8 @@ void TokenAnnotator::annotate(AnnotatedL
 
 // This function heuristically determines whether 'Current' starts the name of 
a
 // function declaration.
-static bool isFunctionDeclarationName(const FormatToken ) {
+static bool isFunctionDeclarationName(const FormatToken ,
+  const AnnotatedLine ) {
   auto skipOperatorName = [](const FormatToken* Next) -> const FormatToken* {
 for (; Next; Next = Next->Next) {
   if (Next->is(TT_OverloadedOperatorLParen))
@@ -1573,6 +1574,7 @@ static bool isFunctionDeclarationName(co
 return nullptr;
   };
 
+  // Find parentheses of parameter list.
   const FormatToken *Next = Current.Next;
   if (Current.is(tok::kw_operator)) {
 if (Current.Previous && Current.Previous->is(tok::coloncolon))
@@ -1602,14 +1604,22 @@ static bool isFunctionDeclarationName(co
 }
   }
 
-  if (!Next || !Next->is(tok::l_paren))
+  // Check whether parameter list can be long to a function declaration.
+  if (!Next || !Next->is(tok::l_paren) || !Next->MatchingParen)
 return false;
+  // If the lines ends with "{", this is likely an function definition.
+  if (Line.Last->is(tok::l_brace))
+return true;
   if (Next->Next == Next->MatchingParen)
+return true; // Empty parentheses.
+  // If there is an &/&& after the r_paren, this is likely a function.
+  if (Next->MatchingParen->Next &&
+  Next->MatchingParen->Next->is(TT_PointerOrReference))
 return true;
   for (const FormatToken *Tok = Next->Next; Tok && Tok != Next->MatchingParen;
Tok = Tok->Next) {
 if (Tok->is(tok::kw_const) || Tok->isSimpleTypeSpecifier() ||
-Tok->isOneOf(TT_PointerOrReference, TT_StartOfName))
+Tok->isOneOf(TT_PointerOrReference, TT_StartOfName, tok::ellipsis))
   return true;
 if (Tok->isOneOf(tok::l_brace, tok::string_literal, TT_ObjCMethodExpr) ||
 Tok->Tok.isLiteral())
@@ -1655,7 +1665,7 @@ void TokenAnnotator::calculateFormatting
   FormatToken *Current = Line.First->Next;
   bool InFunctionDecl = Line.MightBeFunctionDecl;
   while (Current) {
-if (isFunctionDeclarationName(*Current))
+if (isFunctionDeclarationName(*Current, Line))
   Current->Type = TT_FunctionDeclarationName;
 if (Current->is(TT_LineComment)) {
   if (Current->Previous->BlockKind == BK_BracedInit &&

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=266599=266598=266599=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Apr 18 06:31:21 2016
@@ -5621,6 +5621,10 @@ TEST_F(FormatTest, UnderstandsFunctionRe
AlignLeft);
   verifyFormat("Deleted& operator=(const Deleted&) &;", AlignLeft);
   verifyFormat("SomeType MemberFunction(const Deleted&) &;", AlignLeft);
+  verifyFormat("auto Function(T t) & -> void {}", AlignLeft);
+  verifyFormat("auto Function(T... t) & -> void {}", AlignLeft);
+  verifyFormat("auto Function(T) & -> void {}", AlignLeft);
+  verifyFormat("auto Function(T) & -> void;", AlignLeft);
 
   FormatStyle Spaces = getLLVMStyle();
   Spaces.SpacesInCStyleCastParentheses = true;
@@ -6119,6 +6123,10 @@ TEST_F(FormatTest, BreaksLongDeclaration
"LooongFunctionDefinition() 
{}");
   verifyFormat("decltype(LngName)\n"
"LooongFunctionDefinition() 
{}");
+  verifyFormat("LngReturnType\n"
+   "LooongFunctionDeclaration(T... t);");
+  verifyFormat("LngReturnType\n"
+   "LooongFunctionDeclaration(T /*t*/) 
{}");
   FormatStyle Indented = getLLVMStyle();
   Indented.IndentWrappedFunctionNames = true;
   verifyFormat("LngReturnType\n"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org

Re: [PATCH] D18694: [ClangTidy] Add an 'explain-checks' option to diagnose where each checks comes from.

2016-04-18 Thread Haojian Wu via cfe-commits
hokein marked an inline comment as done.
hokein added a comment.

http://reviews.llvm.org/D18694



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


Re: [PATCH] D18694: [ClangTidy] Add an 'explain-checks' option to diagnose where each checks comes from.

2016-04-18 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 54043.
hokein added a comment.

Update.


http://reviews.llvm.org/D18694

Files:
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/ClangTidyOptions.h
  clang-tidy/tool/ClangTidyMain.cpp
  test/clang-tidy/Inputs/explain-config/.clang-tidy
  test/clang-tidy/explain-checks.cpp

Index: test/clang-tidy/explain-checks.cpp
===
--- /dev/null
+++ test/clang-tidy/explain-checks.cpp
@@ -0,0 +1,14 @@
+// RUN: clang-tidy -checks=-*,modernize-use-nullptr -explain-config | FileCheck --check-prefix=CHECK-MESSAGE1 %s
+// RUN: clang-tidy -config="{Checks: '-*,modernize-use-nullptr'}" -explain-config | FileCheck --check-prefix=CHECK-MESSAGE2 %s
+// RUN: clang-tidy -checks=modernize-use-nullptr -config="{Checks: '-*,modernize-use-nullptr'}" -explain-config | FileCheck --check-prefix=CHECK-MESSAGE3 %s
+// RUN: clang-tidy -checks=modernize-use-nullptr -config="{Checks: '-*,-modernize-use-nullptr'}" %S/Inputs/explain-config/a.cc -explain-config | FileCheck --check-prefix=CHECK-MESSAGE4 %s
+// RUN: clang-tidy -checks=modernize-use-nullptr -config="{Checks: '-*,modernize-*'}" -explain-config | FileCheck --check-prefix=CHECK-MESSAGE5 %s
+// RUN: clang-tidy -checks=modernize-use-nullptr -explain-config | FileCheck --check-prefix=CHECK-MESSAGE6 %s
+// RUN: clang-tidy -explain-config %S/Inputs/explain-config/a.cc | grep "'modernize-use-nullptr' is enabled in the %S/Inputs/explain-config/.clang-tidy."
+
+// CHECK-MESSAGE1: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
+// CHECK-MESSAGE2: 'modernize-use-nullptr' is enabled in the command-line option '-config'.
+// CHECK-MESSAGE3: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
+// CHECK-MESSAGE4: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
+// CHECK-MESSAGE5: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
+// CHECK-MESSAGE6: 'clang-analyzer-unix.API' is enabled in the clang-tidy binary.
Index: test/clang-tidy/Inputs/explain-config/.clang-tidy
===
--- /dev/null
+++ test/clang-tidy/Inputs/explain-config/.clang-tidy
@@ -0,0 +1 @@
+Checks: '-*,modernize-use-nullptr'
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -128,6 +128,12 @@
 )"),
 cl::init(false), cl::cat(ClangTidyCategory));
 
+static cl::opt ExplainConfig("explain-config", cl::desc(R"(
+for each enabled check explains, where it is enabled, i.e. in clang-tidy binary,
+command line or a specific configuration file.
+)"),
+   cl::init(false), cl::cat(ClangTidyCategory));
+
 static cl::opt Config("config", cl::desc(R"(
 Specifies a configuration in YAML/JSON format:
   -config="{Checks: '*',
@@ -280,11 +286,10 @@
   if (!Config.empty()) {
 if (llvm::ErrorOr ParsedConfig =
 parseConfiguration(Config)) {
-  return llvm::make_unique(
-  GlobalOptions, ClangTidyOptions::getDefaults()
- .mergeWith(DefaultOptions)
- .mergeWith(*ParsedConfig)
- .mergeWith(OverrideOptions));
+  return llvm::make_unique(
+  GlobalOptions,
+  ClangTidyOptions::getDefaults().mergeWith(DefaultOptions),
+  *ParsedConfig, OverrideOptions);
 } else {
   llvm::errs() << "Error: invalid configuration specified.\n"
<< ParsedConfig.getError().message() << "\n";
@@ -311,6 +316,23 @@
   ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FileName);
   std::vector EnabledChecks = getCheckNames(EffectiveOptions);
 
+  if (ExplainConfig) {
+// FIXME: Figure out a more elegant way to show other ClangTidyOptions'
+// fields like ExtraArg.
+std::vector
+RawOptions = OptionsProvider->getRawOptions(FileName);
+for (const std::string  : EnabledChecks) {
+  for (auto It = RawOptions.rbegin(); It != RawOptions.rend(); ++It) {
+if (It->first.Checks && GlobList(*(It->first.Checks)).contains(Check)) {
+  llvm::outs() << "'" << Check << "' is enabled in the " << It->second
+   << ".\n";
+  break;
+}
+  }
+}
+return 0;
+  }
+
   if (ListChecks) {
 llvm::outs() << "Enabled checks:";
 for (auto CheckName : EnabledChecks)
Index: clang-tidy/ClangTidyOptions.h
===
--- clang-tidy/ClangTidyOptions.h
+++ clang-tidy/ClangTidyOptions.h
@@ -104,9 +104,26 @@
   /// \brief Returns global options, which are independent of the file.
   virtual const ClangTidyGlobalOptions () = 0;
 
+  /// \brief ClangTidyOptions and its source.
+  //
+  /// clang-tidy has 3 types of the sources (from low to top):
+  

Re: [PATCH] D18694: [ClangTidy] Add an 'explain-checks' option to diagnose where each checks comes from.

2016-04-18 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 54042.
hokein added a comment.

Use a more elegant solution to track ClangTidyOptions.


http://reviews.llvm.org/D18694

Files:
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/ClangTidyOptions.h
  clang-tidy/tool/ClangTidyMain.cpp
  test/clang-tidy/Inputs/explain-config/.clang-tidy
  test/clang-tidy/explain-checks.cpp

Index: test/clang-tidy/explain-checks.cpp
===
--- /dev/null
+++ test/clang-tidy/explain-checks.cpp
@@ -0,0 +1,14 @@
+// RUN: clang-tidy -checks=-*,modernize-use-nullptr -explain-config | FileCheck --check-prefix=CHECK-MESSAGE1 %s
+// RUN: clang-tidy -config="{Checks: '-*,modernize-use-nullptr'}" -explain-config | FileCheck --check-prefix=CHECK-MESSAGE2 %s
+// RUN: clang-tidy -checks=modernize-use-nullptr -config="{Checks: '-*,modernize-use-nullptr'}" -explain-config | FileCheck --check-prefix=CHECK-MESSAGE3 %s
+// RUN: clang-tidy -checks=modernize-use-nullptr -config="{Checks: '-*,-modernize-use-nullptr'}" %S/Inputs/explain-config/a.cc -explain-config | FileCheck --check-prefix=CHECK-MESSAGE4 %s
+// RUN: clang-tidy -checks=modernize-use-nullptr -config="{Checks: '-*,modernize-*'}" -explain-config | FileCheck --check-prefix=CHECK-MESSAGE5 %s
+// RUN: clang-tidy -checks=modernize-use-nullptr -explain-config | FileCheck --check-prefix=CHECK-MESSAGE6 %s
+// RUN: clang-tidy -explain-config %S/Inputs/explain-config/a.cc | grep "'modernize-use-nullptr' is enabled in the %S/Inputs/explain-config/.clang-tidy."
+
+// CHECK-MESSAGE1: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
+// CHECK-MESSAGE2: 'modernize-use-nullptr' is enabled in the command-line option '-config'.
+// CHECK-MESSAGE3: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
+// CHECK-MESSAGE4: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
+// CHECK-MESSAGE5: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
+// CHECK-MESSAGE6: 'clang-analyzer-unix.API' is enabled in the clang-tidy binary.
Index: test/clang-tidy/Inputs/explain-config/.clang-tidy
===
--- /dev/null
+++ test/clang-tidy/Inputs/explain-config/.clang-tidy
@@ -0,0 +1 @@
+Checks: '-*,modernize-use-nullptr'
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -128,6 +128,12 @@
 )"),
 cl::init(false), cl::cat(ClangTidyCategory));
 
+static cl::opt ExplainConfig("explain-config", cl::desc(R"(
+for each enabled check explains, where it is enabled, i.e. in clang-tidy binary,
+command line or a specific configuration file.
+)"),
+   cl::init(false), cl::cat(ClangTidyCategory));
+
 static cl::opt Config("config", cl::desc(R"(
 Specifies a configuration in YAML/JSON format:
   -config="{Checks: '*',
@@ -280,11 +286,10 @@
   if (!Config.empty()) {
 if (llvm::ErrorOr ParsedConfig =
 parseConfiguration(Config)) {
-  return llvm::make_unique(
-  GlobalOptions, ClangTidyOptions::getDefaults()
- .mergeWith(DefaultOptions)
- .mergeWith(*ParsedConfig)
- .mergeWith(OverrideOptions));
+  return llvm::make_unique(
+  GlobalOptions,
+  ClangTidyOptions::getDefaults().mergeWith(DefaultOptions),
+  *ParsedConfig, OverrideOptions);
 } else {
   llvm::errs() << "Error: invalid configuration specified.\n"
<< ParsedConfig.getError().message() << "\n";
@@ -311,6 +316,23 @@
   ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FileName);
   std::vector EnabledChecks = getCheckNames(EffectiveOptions);
 
+  if (ExplainConfig) {
+// FIXME: Figure out a more elegant way to show other ClangTidyOptions'
+// fields like ExtraArg.
+std::vector
+RawOptions = OptionsProvider->getRawOptions(FileName);
+for (const std::string  : EnabledChecks) {
+  for (auto It = RawOptions.rbegin(); It != RawOptions.rend(); ++It) {
+if (It->first.Checks && GlobList(*(It->first.Checks)).contains(Check)) {
+  llvm::outs() << "'" << Check << "' is enabled in the " << It->second
+   << ".\n";
+  break;
+}
+  }
+}
+return 0;
+  }
+
   if (ListChecks) {
 llvm::outs() << "Enabled checks:";
 for (auto CheckName : EnabledChecks)
Index: clang-tidy/ClangTidyOptions.h
===
--- clang-tidy/ClangTidyOptions.h
+++ clang-tidy/ClangTidyOptions.h
@@ -104,9 +104,26 @@
   /// \brief Returns global options, which are independent of the file.
   virtual const ClangTidyGlobalOptions () = 0;
 
+  /// \brief ClangTidyOptions and its source.
+  //
+  /// clang-tidy has 

Re: [PATCH] D10834: Added functions to retrieve information about whether a vardecl is local in libclang and its python bindings.

2016-04-18 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10834



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


Re: [PATCH] D10833: Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface

2016-04-18 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 added a comment.

Ping


http://reviews.llvm.org/D10833



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


r266594 - Add missing include for StringRef (NFC)

2016-04-18 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Mon Apr 18 04:08:59 2016
New Revision: 266594

URL: http://llvm.org/viewvc/llvm-project?rev=266594=rev
Log:
Add missing include for StringRef (NFC)

From: Mehdi Amini 

Modified:
cfe/trunk/lib/Format/Encoding.h

Modified: cfe/trunk/lib/Format/Encoding.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Encoding.h?rev=266594=266593=266594=diff
==
--- cfe/trunk/lib/Format/Encoding.h (original)
+++ cfe/trunk/lib/Format/Encoding.h Mon Apr 18 04:08:59 2016
@@ -17,6 +17,7 @@
 #define LLVM_CLANG_LIB_FORMAT_ENCODING_H
 
 #include "clang/Basic/LLVM.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/Unicode.h"
 


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


[libcxx] r266592 - Mark P0152R1 as complete.

2016-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Apr 18 01:58:50 2016
New Revision: 266592

URL: http://llvm.org/viewvc/llvm-project?rev=266592=rev
Log:
Mark P0152R1 as complete.

Modified:
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=266592=266591=266592=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Mon Apr 18 01:58:50 2016
@@ -84,7 +84,7 @@
http://wg21.link/P0218R1;>P0218R1LWGAdopt the File 
System TS for C++17Jacksonville  
http://wg21.link/P0033R1;>P0033R1LWGRe-enabling 
shared_from_thisJacksonville
http://wg21.link/P0005R4;>P0005R4LWGAdopt not_fn 
from Library Fundamentals 2 for 
C++17Jacksonville
-   http://wg21.link/P0152R1;>P0152R1LWGconstexpr 
atomic::is_always_lock_freeJacksonville
+   http://wg21.link/P0152R1;>P0152R1LWGconstexpr 
atomic::is_always_lock_freeJacksonvilleComplete3.9
http://wg21.link/P0185R1;>P0185R1LWGAdding 
[nothrow-]swappable traitsJacksonville
http://wg21.link/P0253R1;>P0253R1LWGFixing a design 
mistake in the searchers 
interfaceJacksonvilleComplete3.9
http://wg21.link/P0025R0;>P0025R0LWGAn algorithm to 
"clamp" a value between a pair of boundary 
valuesJacksonvilleComplete3.9


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


[libcxx] r266591 - Mark LWG issue 2469 as done. Also simplify try_emplace and insert_or_assign implementations in unordered_map

2016-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Apr 18 01:51:33 2016
New Revision: 266591

URL: http://llvm.org/viewvc/llvm-project?rev=266591=rev
Log:
Mark LWG issue 2469 as done. Also simplify try_emplace and insert_or_assign 
implementations in unordered_map

Modified:
libcxx/trunk/include/unordered_map
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/unordered_map
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/unordered_map?rev=266591=266590=266591=diff
==
--- libcxx/trunk/include/unordered_map (original)
+++ libcxx/trunk/include/unordered_map Mon Apr 18 01:51:33 2016
@@ -984,118 +984,86 @@ public:
 #endif  // _LIBCPP_CXX03_LANG
 
 #if _LIBCPP_STD_VER > 14
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#ifndef _LIBCPP_HAS_NO_VARIADICS
 template 
 _LIBCPP_INLINE_VISIBILITY
 pair try_emplace(const key_type& __k, _Args&&... 
__args)
 {
-iterator __p = __table_.find(__k);
-if ( __p != end())
-return _VSTD::make_pair(__p, false);
-else
-return _VSTD::make_pair(
-  emplace_hint(__p, 
-_VSTD::piecewise_construct, 
_VSTD::forward_as_tuple(__k), 
-
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)),
-  true);
+return __table_.__emplace_unique_key_args(__k, 
_VSTD::piecewise_construct,
+_VSTD::forward_as_tuple(__k),
+_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
 }
 
 template 
 _LIBCPP_INLINE_VISIBILITY
 pair try_emplace(key_type&& __k, _Args&&... __args)
 {
-iterator __p = __table_.find(__k);
-if ( __p != end())
-return _VSTD::make_pair(__p, false);
-else
-return _VSTD::make_pair(
-  emplace_hint(__p, 
-_VSTD::piecewise_construct, 
_VSTD::forward_as_tuple(_VSTD::move(__k)), 
-
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)),
-  true);
+return __table_.__emplace_unique_key_args(__k, 
_VSTD::piecewise_construct,
+_VSTD::forward_as_tuple(_VSTD::move(__k)),
+_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
 }
 
 template 
 _LIBCPP_INLINE_VISIBILITY
 iterator try_emplace(const_iterator __h, const key_type& __k, 
_Args&&... __args)
 {
-iterator __p = __table_.find(__k);
-if ( __p != end())
-return __p;
-else
-return emplace_hint(__h, 
-  _VSTD::piecewise_construct, 
_VSTD::forward_as_tuple(__k), 
-  
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
+#if _LIBCPP_DEBUG_LEVEL >= 2
+_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
+"unordered_map::try_emplace(const_iterator, key, args...) called 
with an iterator not"
+" referring to this unordered_map");
+#endif
+return try_emplace(__k, _VSTD::forward<_Args>(__args)...).first;
 }
 
 template 
 _LIBCPP_INLINE_VISIBILITY
 iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... 
__args)
 {
-iterator __p = __table_.find(__k);
-if ( __p != end())
-return __p;
-else
-return emplace_hint(__h, 
-  _VSTD::piecewise_construct, 
_VSTD::forward_as_tuple(_VSTD::move(__k)), 
-  
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
+#if _LIBCPP_DEBUG_LEVEL >= 2
+_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
+"unordered_map::try_emplace(const_iterator, key, args...) called 
with an iterator not"
+" referring to this unordered_map");
+#endif
+return try_emplace(_VSTD::move(__k), 
_VSTD::forward<_Args>(__args)...).first;
 }
 
 template 
 _LIBCPP_INLINE_VISIBILITY
 pair insert_or_assign(const key_type& __k, _Vp&& __v)
 {
-iterator __p = __table_.find(__k);
-if ( __p != end())
-{
-__p->second = _VSTD::move(__v);
-return _VSTD::make_pair(__p, false);
+pair __res = __table_.__emplace_unique_key_args(__k,
+__k, _VSTD::forward<_Vp>(__v));
+if (!__res.second) {
+__res.first->second = _VSTD::forward<_Vp>(__v);
 }
-return _VSTD::make_pair(emplace_hint(__p, __k, 
_VSTD::forward<_Vp>(__v)), true);
+return __res;
 }
-
+
 template 
 _LIBCPP_INLINE_VISIBILITY
 pair insert_or_assign(key_type&& __k, _Vp&& __v)
 {
-iterator __p = __table_.find(__k);
-if ( __p != end())
-{
-__p->second = _VSTD::move(__v);
-return 

[libcxx] r266590 - Implement LWG issue 2219 - support reference_wrapper in INVOKE

2016-04-18 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Apr 18 01:17:30 2016
New Revision: 266590

URL: http://llvm.org/viewvc/llvm-project?rev=266590=rev
Log:
Implement LWG issue 2219 - support reference_wrapper in INVOKE

Added:

libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_1_2_3.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_4_5_6.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_7.pass.cpp
Removed:

libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_1_and_2.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_3_and_4.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.require/bullet_5.pass.cpp
Modified:
libcxx/trunk/include/__functional_base
libcxx/trunk/include/type_traits
libcxx/trunk/include/utility
libcxx/trunk/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.require/invoke_helpers.h

libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp

libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/__functional_base
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__functional_base?rev=266590=266589=266590=diff
==
--- libcxx/trunk/include/__functional_base (original)
+++ libcxx/trunk/include/__functional_base Mon Apr 18 01:17:30 2016
@@ -322,6 +322,17 @@ __invoke(_Fp&& __f, _A0&& __a0, _Args&&
 return (_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...);
 }
 
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+auto
+__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
+-> decltype((__a0.get().*__f)(_VSTD::forward<_Args>(__args)...))
+{
+return (__a0.get().*__f)(_VSTD::forward<_Args>(__args)...);
+}
+
 template 
 inline _LIBCPP_INLINE_VISIBILITY
@@ -344,6 +355,17 @@ __invoke(_Fp&& __f, _A0&& __a0)
 return _VSTD::forward<_A0>(__a0).*__f;
 }
 
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+auto
+__invoke(_Fp&& __f, _A0&& __a0)
+-> decltype(__a0.get().*__f)
+{
+return __a0.get().*__f;
+}
+
 template 
 inline _LIBCPP_INLINE_VISIBILITY
@@ -577,10 +599,6 @@ public:
 #endif // _LIBCPP_HAS_NO_VARIADICS
 };
 
-template  struct __is_reference_wrapper_impl : public false_type {};
-template  struct __is_reference_wrapper_impl 
> : public true_type {};
-template  struct __is_reference_wrapper
-: public __is_reference_wrapper_impl::type> {};
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=266590=266589=266590=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Mon Apr 18 01:17:30 2016
@@ -369,6 +369,7 @@ namespace std
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template  struct _LIBCPP_TYPE_VIS_ONLY pair;
+template  class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
 
 template 
 struct __void_t { typedef void type; };
@@ -3965,6 +3966,11 @@ template  _LIBCPP_CONSTEXPR b
 = is_trivial<_Tp>::value;
 #endif
 
+template  struct __is_reference_wrapper_impl : public false_type {};
+template  struct __is_reference_wrapper_impl 
> : public true_type {};
+template  struct __is_reference_wrapper
+: public __is_reference_wrapper_impl::type> {};
+
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 
 // Check for complete types
@@ -4111,6 +4117,15 @@ struct __check_complete<_Rp _Class::*>
 {
 };
 
+
+template 
+using __arg_is_base_of_ptm =
+is_base_of::type>::_ClassType>::type,
+   typename remove_reference<_A0>::type>;
+
+template 
+using __arg_is_reference_wrapper = __is_reference_wrapper::type>;
+
 // __invoke forward declarations
 
 // fall back - none of the bullets
@@ -4120,14 +4135,13 @@ auto
 __invoke(__any, _Args&& ...__args)
 -> __nat;
 
-// bullets 1 and 2
+// bullets 1, 2 and 3
 
 template ::type>::value &&
-is_base_of::type>::_ClassType>::type,
-   typename remove_reference<_A0>::type>::value
+__arg_is_base_of_ptm<_Fp, _A0>::value
 >::type
  >
 _LIBCPP_INLINE_VISIBILITY
@@ -4135,12 +4149,25 @@ auto
 __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
 -> 
decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...));
 
+
 template ::type>::value &&
-!is_base_of::type>::_ClassType>::type,
-   typename remove_reference<_A0>::type>::value
+__arg_is_reference_wrapper<_A0>::value
+>::type
+ >
+_LIBCPP_INLINE_VISIBILITY
+auto
+__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
+->