[PATCH] D30591: Introduce the feature "linux" for tests only for linux

2017-03-03 Thread Taewook Oh via Phabricator via cfe-commits
twoh abandoned this revision.
twoh added a comment.

@inglorion That makes a lot of sense. Maybe we don't even need -g, because -S 
-emit-llvm shows source_filename. I'll run some more experiments with 
relpath/abspath and debug locations, and submit a revised patch. Thanks for the 
comment!


https://reviews.llvm.org/D30591



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


[PATCH] D30599: [ubsan] Extend the nonnull argument check to ObjC

2017-03-03 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs accepted this revision.
jroelofs added a comment.
This revision is now accepted and ready to land.

LGTM, by the way.


https://reviews.llvm.org/D30599



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


[PATCH] D30599: [ubsan] Extend the nonnull argument check to ObjC

2017-03-03 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

In https://reviews.llvm.org/D30599#692210, @jroelofs wrote:

> Can the null check be performed in the callee?


Yes, but I think that would result in perplexing diagnostics, because we 
wouldn't be able to report the source location of the buggy calls.

> That'd make this check work for a few more cases that this patch doesn't 
> cover:
> 
> - `performSelector:` messages
> - messages to `id`.

That's a good point, but sadly I don't see a way to diagnose these situations 
well with the current check. I think the best we can do is to check for 
nullability violations on assignment/return. I will upload a nullability 
"sanitizer" for review soon that does this.


https://reviews.llvm.org/D30599



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


[PATCH] D30599: [ubsan] Extend the nonnull argument check to ObjC

2017-03-03 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

Can the null check be performed in the callee?

That'd make this check work for a few more cases that this patch doesn't cover:

- `performSelector:` messages
- messages to `id`.


https://reviews.llvm.org/D30599



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


[PATCH] D30599: [ubsan] Extend the nonnull argument check to ObjC

2017-03-03 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.

UBSan's nonnull argument check applies when a parameter has the
"nonnull" attribute. The check currently works for FunctionDecls, but
not for ObjCMethodDecls. This patch extends the check to work for ObjC.

To do this, I introduced a new AbstractCallee class to represent the
logical callee in a generic "call", and added a use of AbstractCallee to
CGObjC.cpp. This does not affect IRGen except to fix the UBSan check.

I opted not to reuse CGCalleeInfo for this because: 1) it isn't meant to
represent the callee itself, 2) it carries around an extra pointer for
the callee prototype, and 3) it's a bit tricky to repurpose (i.e it
really "wants" to live in CGCall.h).

Testing: check-clang, check-ubsan


https://reviews.llvm.org/D30599

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenObjC/ubsan-nonnull.m

Index: test/CodeGenObjC/ubsan-nonnull.m
===
--- /dev/null
+++ test/CodeGenObjC/ubsan-nonnull.m
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -x objective-c -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=nonnull-attribute %s -o - -w | FileCheck %s
+
+@interface A
+
+-(void) one_arg: (__attribute__((nonnull)) int *) arg1;
+
+-(void) varargs: (__attribute__((nonnull)) int *) arg1, ...;
+
++(void) clsmethod: (__attribute__((nonnull)) int *) arg1;
+
+@end
+
+@implementation A
+
+// CHECK-LABEL: define internal void @"\01-[A one_arg:]"
+// CHECK-SAME: i32* nonnull
+-(void) one_arg: (__attribute__((nonnull)) int *) arg1 {}
+
+// CHECK-LABEL: define internal void @"\01-[A varargs:]"
+// CHECK-SAME: i32* nonnull
+-(void) varargs: (__attribute__((nonnull)) int *) arg1, ... {}
+
+// CHECK-LABEL: define internal void @"\01+[A clsmethod:]"
+// CHECK-SAME: i32* nonnull
++(void) clsmethod: (__attribute__((nonnull)) int *) arg1 {}
+
+@end
+
+// CHECK-LABEL: define void @call_A
+void call_A(A *a, int *p) {
+  // CHECK: [[ICMP:%.*]] = icmp ne i32* [[P1:%.*]], null, !nosanitize
+  // CHECK: br i1 [[ICMP]], {{.*}}, !nosanitize
+  // CHECK: call void @__ubsan_handle_nonnull_arg{{.*}} !nosanitize
+  // CHECK: call void {{.*}} @objc_msgSend {{.*}} ({{.*}}, i32* [[P1]])
+  [a one_arg: p];
+
+  // CHECK: [[ICMP:%.*]] = icmp ne i32* [[P2:%.*]], null, !nosanitize
+  // CHECK: br i1 [[ICMP]], {{.*}}, !nosanitize
+  // CHECK: call void @__ubsan_handle_nonnull_arg{{.*}} !nosanitize
+  // CHECK: call void {{.*}} @objc_msgSend {{.*}} ({{.*}}, i32* [[P2]], {{.*}})
+  [a varargs: p, p];
+
+  // CHECK: [[ICMP:%.*]] = icmp ne i32* [[P3:%.*]], null, !nosanitize
+  // CHECK: br i1 [[ICMP]], {{.*}}, !nosanitize
+  // CHECK: call void @__ubsan_handle_nonnull_arg{{.*}} !nosanitize
+  // CHECK: call void {{.*}} @objc_msgSend {{.*}} ({{.*}}, i32* [[P3]])
+  [A clsmethod: p];
+}
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -305,6 +305,31 @@
 ~CGCapturedStmtRAII() { CGF.CapturedStmtInfo = PrevCapturedStmtInfo; }
   };
 
+  /// \brief An abstract representation of regular/ObjC call/message targets.
+  class AbstractCallee {
+/// \brief The function declaration of the callee.
+const Decl *CalleeDecl;
+
+  public:
+AbstractCallee() : CalleeDecl(nullptr) {}
+AbstractCallee(const FunctionDecl *FD) : CalleeDecl(FD) {}
+AbstractCallee(const ObjCMethodDecl *OMD) : CalleeDecl(OMD) {}
+bool hasFunctionDecl() const {
+  return dyn_cast_or_null(CalleeDecl);
+}
+const Decl *getDecl() const { return CalleeDecl; }
+unsigned getNumParams() const {
+  if (const auto *FD = dyn_cast(CalleeDecl))
+return FD->getNumParams();
+  return cast(CalleeDecl)->param_size();
+}
+const ParmVarDecl *getParamDecl(unsigned I) const {
+  if (const auto *FD = dyn_cast(CalleeDecl))
+return FD->getParamDecl(I);
+  return *(cast(CalleeDecl)->param_begin() + I);
+}
+  };
+
   /// \brief Sanitizers enabled for this function.
   SanitizerSet SanOpts;
 
@@ -3467,7 +3492,7 @@
   /// \brief Create a check for a function parameter that may potentially be
   /// declared as non-null.
   void EmitNonNullArgCheck(RValue RV, QualType ArgType, SourceLocation ArgLoc,
-   const FunctionDecl *FD, unsigned ParmNum);
+   AbstractCallee AC, unsigned ParmNum);
 
   /// EmitCallArg - Emit a single call argument.
   void EmitCallArg(CallArgList , const Expr *E, QualType ArgType);
@@ -3569,7 +3594,7 @@
   template 
   void EmitCallArgs(CallArgList , const T *CallArgTypeInfo,
 llvm::iterator_range ArgRange,
-const FunctionDecl *CalleeDecl = nullptr,
+AbstractCallee AC = AbstractCallee(),
 unsigned ParamsToSkip = 0,
 EvaluationOrder Order = EvaluationOrder::Default) {
 

Re: [libcxxabi] r296940 - Fix PR25874 - Detect features required for cxa_thread_atexit_test.pass.cpp

2017-03-03 Thread Jonathan Roelofs via cfe-commits



On 3/3/17 7:45 PM, Eric Fiselier wrote:
LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL should be set by 
`check_library_exists` at the bottom of `config-ix.cmake`.

Ah, cool.


Jon



On Fri, Mar 3, 2017 at 7:22 PM, Jonathan Roelofs 
> wrote:




On 3/3/17 6:26 PM, Eric Fiselier via cfe-commits wrote:

Author: ericwf
Date: Fri Mar  3 19:26:41 2017
New Revision: 296940

URL: http://llvm.org/viewvc/llvm-project?rev=296940=rev

Log:
Fix PR25874 - Detect features required for
cxa_thread_atexit_test.pass.cpp

Modified:
libcxxabi/trunk/test/CMakeLists.txt
libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp
libcxxabi/trunk/test/libcxxabi/test/config.py
libcxxabi/trunk/test/lit.site.cfg.in 

Modified: libcxxabi/trunk/test/CMakeLists.txt
URL:

http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/CMakeLists.txt?rev=296940=296939=296940=diff



==
--- libcxxabi/trunk/test/CMakeLists.txt (original)
+++ libcxxabi/trunk/test/CMakeLists.txt Fri Mar  3 19:26:41 2017
@@ -18,6 +18,7 @@ pythonize_bool(LIBCXXABI_ENABLE_THREADS)
 pythonize_bool(LIBCXXABI_ENABLE_EXCEPTIONS)
 pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
 pythonize_bool(LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
+pythonize_bool(LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL)


AFAIU, this is only allows specifying it at build time and not
auto-detection of it. Did you intend on setting this via something
like a CHECK_CXX_SOURCE_COMPILES check?


Jon


-- 
Jon Roelofs

jonat...@codesourcery.com 
CodeSourcery / Mentor Embedded




--
Jon Roelofs
jonat...@codesourcery.com
CodeSourcery / Mentor Embedded

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


[libcxxabi] r296960 - Fully Reformat fallback_malloc.cpp

2017-03-03 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Mar  3 21:23:15 2017
New Revision: 296960

URL: http://llvm.org/viewvc/llvm-project?rev=296960=rev
Log:
Fully Reformat fallback_malloc.cpp

This patch fully reformats fallback_malloc.cpp. Previously the test
was a mess of different styles and indentations. This made it very
hard to work in and read. Therefore I felt it was best to re-format
the whole thing.

Unfortuantly this means some history will be lost, but hopefully
much of it will still be accessible after ignoring whitespace changes.

Added:
libcxxabi/trunk/.clang-format
Modified:
libcxxabi/trunk/src/fallback_malloc.cpp

Added: libcxxabi/trunk/.clang-format
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/.clang-format?rev=296960=auto
==
--- libcxxabi/trunk/.clang-format (added)
+++ libcxxabi/trunk/.clang-format Fri Mar  3 21:23:15 2017
@@ -0,0 +1,12 @@
+BasedOnStyle: LLVM
+
+---
+Language: Cpp
+
+AlwaysBreakTemplateDeclarations: true
+PointerAlignment: Left
+
+# Disable formatting options which may break tests.
+SortIncludes: false
+ReflowComments: false
+---

Modified: libcxxabi/trunk/src/fallback_malloc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/fallback_malloc.cpp?rev=296960=296959=296960=diff
==
--- libcxxabi/trunk/src/fallback_malloc.cpp (original)
+++ libcxxabi/trunk/src/fallback_malloc.cpp Fri Mar  3 21:23:15 2017
@@ -32,216 +32,222 @@ namespace {
 _LIBCPP_SAFE_STATIC
 static std::__libcpp_mutex_t heap_mutex = _LIBCPP_MUTEX_INITIALIZER;
 #else
-static void * heap_mutex = 0;
+static void* heap_mutex = 0;
 #endif
 
 class mutexor {
 public:
 #ifndef _LIBCXXABI_HAS_NO_THREADS
-mutexor ( std::__libcpp_mutex_t *m ) : mtx_(m) {
-  std::__libcpp_mutex_lock ( mtx_ );
-}
-~mutexor () { std::__libcpp_mutex_unlock ( mtx_ ); }
+  mutexor(std::__libcpp_mutex_t* m) : mtx_(m) {
+std::__libcpp_mutex_lock(mtx_);
+  }
+  ~mutexor() { std::__libcpp_mutex_unlock(mtx_); }
 #else
-mutexor ( void * ) {}
-~mutexor () {}
+  mutexor(void*) {}
+  ~mutexor() {}
 #endif
 private:
-mutexor ( const mutexor  );
-mutexor & operator = ( const mutexor  );
+  mutexor(const mutexor& rhs);
+  mutexor& operator=(const mutexor& rhs);
 #ifndef _LIBCXXABI_HAS_NO_THREADS
-std::__libcpp_mutex_t *mtx_;
+  std::__libcpp_mutex_t* mtx_;
 #endif
 };
 
-
 static const size_t HEAP_SIZE = 512;
-char heap [ HEAP_SIZE ] __attribute__((aligned));
+char heap[HEAP_SIZE] __attribute__((aligned));
 
 typedef unsigned short heap_offset;
 typedef unsigned short heap_size;
 
 struct heap_node {
-heap_offset next_node;  // offset into heap
-heap_size   len;// size in units of "sizeof(heap_node)"
+  heap_offset next_node; // offset into heap
+  heap_size len; // size in units of "sizeof(heap_node)"
 };
 
-static const heap_node *list_end = (heap_node *) (  [ HEAP_SIZE ] );   // 
one past the end of the heap
-static heap_node *freelist = NULL;
+static const heap_node* list_end =
+(heap_node*)([HEAP_SIZE]); // one past the end of the heap
+static heap_node* freelist = NULL;
 
-heap_node *node_from_offset ( const heap_offset offset )
-{ return (heap_node *) ( heap + ( offset * sizeof (heap_node))); }
+heap_node* node_from_offset(const heap_offset offset) {
+  return (heap_node*)(heap + (offset * sizeof(heap_node)));
+}
 
-heap_offset offset_from_node ( const heap_node *ptr )
-{ return 
static_cast(static_cast(reinterpret_cast(ptr) - heap)  / sizeof (heap_node)); }
+heap_offset offset_from_node(const heap_node* ptr) {
+  return static_cast(
+  static_cast(reinterpret_cast(ptr) - heap) /
+  sizeof(heap_node));
+}
 
-void init_heap () {
-freelist = (heap_node *) heap;
-freelist->next_node = offset_from_node ( list_end );
-freelist->len = HEAP_SIZE / sizeof (heap_node);
-}
+void init_heap() {
+  freelist = (heap_node*)heap;
+  freelist->next_node = offset_from_node(list_end);
+  freelist->len = HEAP_SIZE / sizeof(heap_node);
+}
 
 //  How big a chunk we allocate
-size_t alloc_size (size_t len)
-{ return (len + sizeof(heap_node) - 1) / sizeof(heap_node) + 1; }
+size_t alloc_size(size_t len) {
+  return (len + sizeof(heap_node) - 1) / sizeof(heap_node) + 1;
+}
+
+bool is_fallback_ptr(void* ptr) {
+  return ptr >= heap && ptr < (heap + HEAP_SIZE);
+}
+
+void* fallback_malloc(size_t len) {
+  heap_node *p, *prev;
+  const size_t nelems = alloc_size(len);
+  mutexor mtx(_mutex);
+
+  if (NULL == freelist)
+init_heap();
 
-bool is_fallback_ptr ( void *ptr )
-{ return ptr >= heap && ptr < ( heap + HEAP_SIZE ); }
+  //  Walk the free list, looking for a "big enough" chunk
+  for (p = freelist, prev = 0; p && p != list_end;
+   prev = p, p = node_from_offset(p->next_node)) {
 
-void *fallback_malloc(size_t len) {
-heap_node *p, *prev;
-const size_t nelems = alloc_size ( len );
-

r296958 - [ODRHash] Try again to fix build bot.

2017-03-03 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Mar  3 21:04:15 2017
New Revision: 296958

URL: http://llvm.org/viewvc/llvm-project?rev=296958=rev
Log:
[ODRHash] Try again to fix build bot.

Modified:
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=296958=296957=296958=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Fri Mar  3 21:04:15 2017
@@ -312,12 +312,12 @@ S2 s2;
 #if defined(FIRST)
 struct S3 {
   static void A() {}
-  void B() {}
+  void A(int) {}
 };
 #elif defined(SECOND)
 struct S3 {
-  void A() {}
-  static void B() {}
+  void A(int) {}
+  static void A() {}
 };
 #else
 S3 s3;


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


[libcxxabi] r296957 - Add missing UNSUPPORTED for -fno-exception mode

2017-03-03 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Mar  3 21:03:27 2017
New Revision: 296957

URL: http://llvm.org/viewvc/llvm-project?rev=296957=rev
Log:
Add missing UNSUPPORTED for -fno-exception mode

Modified:
libcxxabi/trunk/test/test_exception_address_alignment.pass.cpp

Modified: libcxxabi/trunk/test/test_exception_address_alignment.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_exception_address_alignment.pass.cpp?rev=296957=296956=296957=diff
==
--- libcxxabi/trunk/test/test_exception_address_alignment.pass.cpp (original)
+++ libcxxabi/trunk/test/test_exception_address_alignment.pass.cpp Fri Mar  3 
21:03:27 2017
@@ -7,6 +7,7 @@
 //
 
//===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
 // UNSUPPORTED: c++98, c++03
 
 // The system unwind.h on OS X provides an incorrectly aligned 
_Unwind_Exception


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


r296956 - Handle null QualType better in Stmt::Profile

2017-03-03 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Mar  3 20:42:41 2017
New Revision: 296956

URL: http://llvm.org/viewvc/llvm-project?rev=296956=rev
Log:
Handle null QualType better in Stmt::Profile

If the QualType is null, calling ASTContext::getCanonicalType on it will lead
to an assert.  This was found while testing a new use for Stmt::Profile, so
there is no test case for this.

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

Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=296956=296955=296956=diff
==
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Fri Mar  3 20:42:41 2017
@@ -128,7 +128,7 @@ namespace {
 }
 
 void VisitType(QualType T) override {
-  if (Canonical)
+  if (Canonical && !T.isNull())
 T = Context.getCanonicalType(T);
 
   ID.AddPointer(T.getAsOpaquePtr());


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


Re: [libcxxabi] r296940 - Fix PR25874 - Detect features required for cxa_thread_atexit_test.pass.cpp

2017-03-03 Thread Eric Fiselier via cfe-commits
LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL should be set by
`check_library_exists` at the bottom of `config-ix.cmake`.

On Fri, Mar 3, 2017 at 7:22 PM, Jonathan Roelofs 
wrote:

>
>
> On 3/3/17 6:26 PM, Eric Fiselier via cfe-commits wrote:
>
>> Author: ericwf
>> Date: Fri Mar  3 19:26:41 2017
>> New Revision: 296940
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=296940=rev
>> Log:
>> Fix PR25874 - Detect features required for cxa_thread_atexit_test.pass.cp
>> p
>>
>> Modified:
>> libcxxabi/trunk/test/CMakeLists.txt
>> libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp
>> libcxxabi/trunk/test/libcxxabi/test/config.py
>> libcxxabi/trunk/test/lit.site.cfg.in
>>
>> Modified: libcxxabi/trunk/test/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/CMa
>> keLists.txt?rev=296940=296939=296940=diff
>> 
>> ==
>> --- libcxxabi/trunk/test/CMakeLists.txt (original)
>> +++ libcxxabi/trunk/test/CMakeLists.txt Fri Mar  3 19:26:41 2017
>> @@ -18,6 +18,7 @@ pythonize_bool(LIBCXXABI_ENABLE_THREADS)
>>  pythonize_bool(LIBCXXABI_ENABLE_EXCEPTIONS)
>>  pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
>>  pythonize_bool(LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
>> +pythonize_bool(LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL)
>>
>
> AFAIU, this is only allows specifying it at build time and not
> auto-detection of it. Did you intend on setting this via something like a
> CHECK_CXX_SOURCE_COMPILES check?
>
>
> Jon
>
>
> --
> Jon Roelofs
> jonat...@codesourcery.com
> CodeSourcery / Mentor Embedded
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r296955 - Attempt to suppress test failures on OS X

2017-03-03 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Mar  3 20:29:25 2017
New Revision: 296955

URL: http://llvm.org/viewvc/llvm-project?rev=296955=rev
Log:
Attempt to suppress test failures on OS X

Modified:
libcxxabi/trunk/test/libcxxabi/test/config.py
libcxxabi/trunk/test/test_exception_address_alignment.pass.cpp

Modified: libcxxabi/trunk/test/libcxxabi/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/libcxxabi/test/config.py?rev=296955=296954=296955=diff
==
--- libcxxabi/trunk/test/libcxxabi/test/config.py (original)
+++ libcxxabi/trunk/test/libcxxabi/test/config.py Fri Mar  3 20:29:25 2017
@@ -48,6 +48,8 @@ class Configuration(LibcxxConfiguration)
 if not self.get_lit_bool('has_cxa_thread_atexit_impl', True):
 self.config.available_features.add(
 'libcxxabi-no-cxa-thread-atexit-impl')
+if not self.get_lit_bool('llvm_unwinder', False):
+self.config.available_features.add('libcxxabi-has-system-unwinder')
 
 def configure_compile_flags(self):
 self.cxx.compile_flags += ['-DLIBCXXABI_NO_TIMER']

Modified: libcxxabi/trunk/test/test_exception_address_alignment.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_exception_address_alignment.pass.cpp?rev=296955=296954=296955=diff
==
--- libcxxabi/trunk/test/test_exception_address_alignment.pass.cpp (original)
+++ libcxxabi/trunk/test/test_exception_address_alignment.pass.cpp Fri Mar  3 
20:29:25 2017
@@ -7,13 +7,25 @@
 //
 
//===--===//
 
+// UNSUPPORTED: c++98, c++03
+
+// The system unwind.h on OS X provides an incorrectly aligned 
_Unwind_Exception
+// type. That causes these tests to fail. This XFAIL is my best attempt at
+// working around this failure.
+// XFAIL: darwin && libcxxabi-has-system-unwinder
+
 // Test that the address of the exception object is properly aligned to the
 // largest supported alignment for the system.
 
 #include 
 #include 
 
+#include 
+
 struct __attribute__((aligned)) AlignedType {};
+static_assert(alignof(AlignedType) == alignof(_Unwind_Exception),
+  "_Unwind_Exception is incorrectly aligned. This test is expected to fail");
+
 struct MinAligned {  };
 static_assert(alignof(MinAligned) == 1 && sizeof(MinAligned) == 1, "");
 


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


Re: [libcxxabi] r296940 - Fix PR25874 - Detect features required for cxa_thread_atexit_test.pass.cpp

2017-03-03 Thread Jonathan Roelofs via cfe-commits



On 3/3/17 6:26 PM, Eric Fiselier via cfe-commits wrote:

Author: ericwf
Date: Fri Mar  3 19:26:41 2017
New Revision: 296940

URL: http://llvm.org/viewvc/llvm-project?rev=296940=rev
Log:
Fix PR25874 - Detect features required for cxa_thread_atexit_test.pass.cpp

Modified:
libcxxabi/trunk/test/CMakeLists.txt
libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp
libcxxabi/trunk/test/libcxxabi/test/config.py
libcxxabi/trunk/test/lit.site.cfg.in

Modified: libcxxabi/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/CMakeLists.txt?rev=296940=296939=296940=diff
==
--- libcxxabi/trunk/test/CMakeLists.txt (original)
+++ libcxxabi/trunk/test/CMakeLists.txt Fri Mar  3 19:26:41 2017
@@ -18,6 +18,7 @@ pythonize_bool(LIBCXXABI_ENABLE_THREADS)
 pythonize_bool(LIBCXXABI_ENABLE_EXCEPTIONS)
 pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
 pythonize_bool(LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
+pythonize_bool(LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL)


AFAIU, this is only allows specifying it at build time and not 
auto-detection of it. Did you intend on setting this via something like 
a CHECK_CXX_SOURCE_COMPILES check?



Jon


--
Jon Roelofs
jonat...@codesourcery.com
CodeSourcery / Mentor Embedded
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r296954 - Fix CMake configuration errors on OS X

2017-03-03 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Mar  3 20:15:37 2017
New Revision: 296954

URL: http://llvm.org/viewvc/llvm-project?rev=296954=rev
Log:
Fix CMake configuration errors on OS X

Modified:
libcxxabi/trunk/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=296954=296953=296954=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Fri Mar  3 20:15:37 2017
@@ -416,13 +416,16 @@ if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)
   endif()
 endif()
 
-set(LIBCXXABI_HAS_UNDEFINED_SYMBOLS ((NOT 
LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS)
-OR (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXXABI_ENABLE_SHARED)))
+set(LIBCXXABI_HAS_UNDEFINED_SYMBOLS OFF)
+if ((NOT LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS)
+OR (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXXABI_ENABLE_SHARED))
+  set(LIBCXXABI_HAS_UNDEFINED_SYMBOLS ON)
+endif()
 
 if (LIBCXXABI_HAS_UNDEFINED_SYMBOLS)
   # Need to allow unresolved symbols if this is to work with shared library 
builds
   if (APPLE)
-add_link_flags("-undefined dynamic_lookup")
+list(APPEND LIBCXXABI_LINK_FLAGS "-undefined dynamic_lookup")
   else()
 # Relax this restriction from HandleLLVMOptions
 string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS 
"${CMAKE_SHARED_LINKER_FLAGS}")


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


r296953 - [ODRHash] Change test to try to appease buildbot.

2017-03-03 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Mar  3 20:05:13 2017
New Revision: 296953

URL: http://llvm.org/viewvc/llvm-project?rev=296953=rev
Log:
[ODRHash] Change test to try to appease buildbot.

Modified:
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=296953=296952=296953=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Fri Mar  3 20:05:13 2017
@@ -312,10 +312,12 @@ S2 s2;
 #if defined(FIRST)
 struct S3 {
   static void A() {}
+  void B() {}
 };
 #elif defined(SECOND)
 struct S3 {
   void A() {}
+  static void B() {}
 };
 #else
 S3 s3;


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


[libcxxabi] r296952 - [libcxxabi] Fix alignment of allocated exceptions in 32 bit builds

2017-03-03 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Mar  3 20:04:45 2017
New Revision: 296952

URL: http://llvm.org/viewvc/llvm-project?rev=296952=rev
Log:
[libcxxabi] Fix alignment of allocated exceptions in 32 bit builds

Summary:
In 32 bit builds on a 64 bit system `std::malloc` does not return correctly 
aligned memory.  This leads to undefined behavior.

This patch switches to using `posix_memalign` to allocate correctly aligned 
memory instead.

Reviewers: mclow.lists, danalbert, jroelofs, compnerd

Reviewed By: compnerd

Subscribers: cfe-commits

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

Added:
libcxxabi/trunk/test/test_exception_address_alignment.pass.cpp
Modified:
libcxxabi/trunk/src/cxa_exception.cpp
libcxxabi/trunk/src/fallback_malloc.cpp
libcxxabi/trunk/src/fallback_malloc.h

Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=296952=296951=296952=diff
==
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Fri Mar  3 20:04:45 2017
@@ -63,12 +63,16 @@ cxa_exception_from_exception_unwind_exce
 return cxa_exception_from_thrown_object(unwind_exception + 1 );
 }
 
-static
-inline
-size_t
-cxa_exception_size_from_exception_thrown_size(size_t size)
-{
-return size + sizeof (__cxa_exception);
+// Round s up to next multiple of a.
+static inline
+size_t aligned_allocation_size(size_t s, size_t a) {
+return (s + a - 1) & ~(a - 1);
+}
+
+static inline
+size_t cxa_exception_size_from_exception_thrown_size(size_t size) {
+return aligned_allocation_size(size + sizeof (__cxa_exception),
+   alignof(__cxa_exception));
 }
 
 static void setExceptionClass(_Unwind_Exception* unwind_exception) {
@@ -140,7 +144,7 @@ extern "C" {
 void *__cxa_allocate_exception(size_t thrown_size) throw() {
 size_t actual_size = 
cxa_exception_size_from_exception_thrown_size(thrown_size);
 __cxa_exception *exception_header =
-static_cast<__cxa_exception *>(__malloc_with_fallback(actual_size));
+static_cast<__cxa_exception 
*>(__aligned_malloc_with_fallback(actual_size));
 if (NULL == exception_header)
 std::terminate();
 std::memset(exception_header, 0, actual_size);
@@ -150,7 +154,7 @@ void *__cxa_allocate_exception(size_t th
 
 //  Free a __cxa_exception object allocated with __cxa_allocate_exception.
 void __cxa_free_exception(void *thrown_object) throw() {
-__free_with_fallback(cxa_exception_from_thrown_object(thrown_object));
+
__aligned_free_with_fallback(cxa_exception_from_thrown_object(thrown_object));
 }
 
 
@@ -159,7 +163,7 @@ void __cxa_free_exception(void *thrown_o
 //  Otherwise, it will work like __cxa_allocate_exception.
 void * __cxa_allocate_dependent_exception () {
 size_t actual_size = sizeof(__cxa_dependent_exception);
-void *ptr = __malloc_with_fallback(actual_size);
+void *ptr = __aligned_malloc_with_fallback(actual_size);
 if (NULL == ptr)
 std::terminate();
 std::memset(ptr, 0, actual_size);
@@ -170,7 +174,7 @@ void * __cxa_allocate_dependent_exceptio
 //  This function shall free a dependent_exception.
 //  It does not affect the reference count of the primary exception.
 void __cxa_free_dependent_exception (void * dependent_exception) {
-__free_with_fallback(dependent_exception);
+__aligned_free_with_fallback(dependent_exception);
 }
 
 

Modified: libcxxabi/trunk/src/fallback_malloc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/fallback_malloc.cpp?rev=296952=296951=296952=diff
==
--- libcxxabi/trunk/src/fallback_malloc.cpp (original)
+++ libcxxabi/trunk/src/fallback_malloc.cpp Fri Mar  3 20:04:45 2017
@@ -194,13 +194,26 @@ size_t print_free_list () {
 
 namespace __cxxabiv1 {
 
-void * __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;
+struct __attribute__((aligned)) __aligned_type  {};
+
+void * __aligned_malloc_with_fallback(size_t size) {
+#if defined(_WIN32)
+if (void *dest = _aligned_malloc(size, alignof(__aligned_type)))
+  return dest;
+#elif defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
+if (void* dest = std::malloc(size))
+  return dest;
+#else
+if (size == 0)
+size = 1;
+void* dest;
+if (::posix_memalign(, alignof(__aligned_type), size) == 0)
+return dest;
+#endif
+return fallback_malloc(size);
 }
 
+
 void * __calloc_with_fallback(size_t count, size_t size) {
 void *ptr = std::calloc(count, size);
 if (NULL != ptr)
@@ -212,6 +225,18 @@ void * __calloc_with_fallback(size_t cou
 return ptr;
 }
 
+void __aligned_free_with_fallback(void* ptr) {
+  if (is_fallback_ptr(ptr))

[PATCH] D25417: [libcxxabi] Fix alignment of allocated exceptions in 32 bit builds

2017-03-03 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 90561.
EricWF added a comment.

Merge with master


https://reviews.llvm.org/D25417

Files:
  src/cxa_exception.cpp
  src/fallback_malloc.cpp
  src/fallback_malloc.h
  test/test_exception_address_alignment.pass.cpp

Index: test/test_exception_address_alignment.pass.cpp
===
--- /dev/null
+++ test/test_exception_address_alignment.pass.cpp
@@ -0,0 +1,28 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// Test that the address of the exception object is properly aligned to the
+// largest supported alignment for the system.
+
+#include 
+#include 
+
+struct __attribute__((aligned)) AlignedType {};
+struct MinAligned {  };
+static_assert(alignof(MinAligned) == 1 && sizeof(MinAligned) == 1, "");
+
+int main() {
+  for (int i=0; i < 10; ++i) {
+try {
+  throw MinAligned{};
+} catch (MinAligned const& ref) {
+  assert(reinterpret_cast() % alignof(AlignedType) == 0);
+}
+  }
+}
Index: src/fallback_malloc.h
===
--- src/fallback_malloc.h
+++ src/fallback_malloc.h
@@ -16,11 +16,12 @@
 namespace __cxxabiv1 {
 
 // Allocate some memory from _somewhere_
-_LIBCXXABI_HIDDEN void * __malloc_with_fallback(size_t size);
+_LIBCXXABI_HIDDEN void * __aligned_malloc_with_fallback(size_t size);
 
 // Allocate and zero-initialize memory from _somewhere_
 _LIBCXXABI_HIDDEN void * __calloc_with_fallback(size_t count, size_t size);
 
+_LIBCXXABI_HIDDEN void __aligned_free_with_fallback(void *ptr);
 _LIBCXXABI_HIDDEN void __free_with_fallback(void *ptr);
 
 } // namespace __cxxabiv1
Index: src/fallback_malloc.cpp
===
--- src/fallback_malloc.cpp
+++ src/fallback_malloc.cpp
@@ -194,13 +194,26 @@
 
 namespace __cxxabiv1 {
 
-void * __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;
+struct __attribute__((aligned)) __aligned_type  {};
+
+void * __aligned_malloc_with_fallback(size_t size) {
+#if defined(_WIN32)
+if (void *dest = _aligned_malloc(size, alignof(__aligned_type)))
+  return dest;
+#elif defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
+if (void* dest = std::malloc(size))
+  return dest;
+#else
+if (size == 0)
+size = 1;
+void* dest;
+if (::posix_memalign(, alignof(__aligned_type), size) == 0)
+return dest;
+#endif
+return fallback_malloc(size);
 }
 
+
 void * __calloc_with_fallback(size_t count, size_t size) {
 void *ptr = std::calloc(count, size);
 if (NULL != ptr)
@@ -212,6 +225,18 @@
 return ptr;
 }
 
+void __aligned_free_with_fallback(void* ptr) {
+  if (is_fallback_ptr(ptr))
+fallback_free(ptr);
+  else {
+#if defined(_WIN32)
+::_aligned_free(ptr);
+#else
+std::free(ptr);
+#endif
+  }
+}
+
 void __free_with_fallback(void *ptr) {
 if (is_fallback_ptr(ptr))
 fallback_free(ptr);
Index: src/cxa_exception.cpp
===
--- src/cxa_exception.cpp
+++ src/cxa_exception.cpp
@@ -63,12 +63,16 @@
 return cxa_exception_from_thrown_object(unwind_exception + 1 );
 }
 
-static
-inline
-size_t
-cxa_exception_size_from_exception_thrown_size(size_t size)
-{
-return size + sizeof (__cxa_exception);
+// Round s up to next multiple of a.
+static inline
+size_t aligned_allocation_size(size_t s, size_t a) {
+return (s + a - 1) & ~(a - 1);
+}
+
+static inline
+size_t cxa_exception_size_from_exception_thrown_size(size_t size) {
+return aligned_allocation_size(size + sizeof (__cxa_exception),
+   alignof(__cxa_exception));
 }
 
 static void setExceptionClass(_Unwind_Exception* unwind_exception) {
@@ -140,7 +144,7 @@
 void *__cxa_allocate_exception(size_t thrown_size) throw() {
 size_t actual_size = cxa_exception_size_from_exception_thrown_size(thrown_size);
 __cxa_exception *exception_header =
-static_cast<__cxa_exception *>(__malloc_with_fallback(actual_size));
+static_cast<__cxa_exception *>(__aligned_malloc_with_fallback(actual_size));
 if (NULL == exception_header)
 std::terminate();
 std::memset(exception_header, 0, actual_size);
@@ -150,16 +154,16 @@
 
 //  Free a __cxa_exception object allocated with __cxa_allocate_exception.
 void __cxa_free_exception(void *thrown_object) throw() {
-__free_with_fallback(cxa_exception_from_thrown_object(thrown_object));
+

[PATCH] D30593: Add correct "-isystem"/"-isysroot" warning handling to static analysis' BugReporter.

2017-03-03 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added reviewers: zaks.anna, NoQ.
dcoughlin added a comment.

The analyzer has two different kinds of diagnostics: AST-based and 
path-sensitive. AST-based diagnostics are similar to the diagnostics that clang 
performs in Sema in that they can usually be localized to a single program 
point. For AST-based checks, we follow clang's policy and never report a 
diagnostic in system headers.

In contrast, path-sensitive diagnostics describe errors that occur along a 
particular path through the program and so they involve multiple program 
points.  Even when these paths *end* in system headers, they may start in 
application code and ultimately be the application code's fault. For example, 
if the application passes NULL to an inline function in a C++ header that then 
dereferences that pointer, we do want to emit a diagnostic even though the 
location of the diagnostic is in a system header. In this case the application 
programmer can do something about it: they should not pass NULL to the function.

By design the analyzer doesn't ever *start* a path-sensitive check in a header 
(either user or system) -- but if a path starts in an application source file 
and eventually calls into a header and does something bad, we do report it 
under the assumption that the application code is violating a header 
precondition.

This can lead to false positives when the analyzer doesn't understand the 
system headers properly. In those cases we have custom heuristics to suppress 
to known patterns the analyzer doesn't handle.

What specific diagnostics in headers are you seeing? Are these in libcxx? We 
know we have at least one issue in  that isn't being properly 
suppressed. But if there are others we'd love to hear about them.


Repository:
  rL LLVM

https://reviews.llvm.org/D30593



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


[libcxx] r296942 - teach LIT how to detect the glibc version

2017-03-03 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Mar  3 19:29:51 2017
New Revision: 296942

URL: http://llvm.org/viewvc/llvm-project?rev=296942=rev
Log:
teach LIT how to detect the glibc version

Modified:
libcxx/trunk/utils/libcxx/test/config.py

Modified: libcxx/trunk/utils/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=296942=296941=296942=diff
==
--- libcxx/trunk/utils/libcxx/test/config.py (original)
+++ libcxx/trunk/utils/libcxx/test/config.py Fri Mar  3 19:29:51 2017
@@ -401,6 +401,14 @@ class Configuration(object):
 if self.is_windows:
 self.config.available_features.add('windows')
 
+# Attempt to detect the glibc version by querying
+macros = self.cxx.dumpMacros(flags=['-include', 'features.h'])
+if macros is not None and '__GLIBC__' in macros:
+maj_v, min_v = (macros['__GLIBC__'], macros['__GLIBC_MINOR__'])
+self.config.available_features.add('glibc')
+self.config.available_features.add('glibc-%s' % maj_v)
+self.config.available_features.add('glibc-%s.%s' % (maj_v, min_v))
+
 def configure_compile_flags(self):
 no_default_flags = self.get_lit_bool('no_default_flags', False)
 if not no_default_flags:


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


[libcxxabi] r296940 - Fix PR25874 - Detect features required for cxa_thread_atexit_test.pass.cpp

2017-03-03 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Mar  3 19:26:41 2017
New Revision: 296940

URL: http://llvm.org/viewvc/llvm-project?rev=296940=rev
Log:
Fix PR25874 - Detect features required for cxa_thread_atexit_test.pass.cpp

Modified:
libcxxabi/trunk/test/CMakeLists.txt
libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp
libcxxabi/trunk/test/libcxxabi/test/config.py
libcxxabi/trunk/test/lit.site.cfg.in

Modified: libcxxabi/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/CMakeLists.txt?rev=296940=296939=296940=diff
==
--- libcxxabi/trunk/test/CMakeLists.txt (original)
+++ libcxxabi/trunk/test/CMakeLists.txt Fri Mar  3 19:26:41 2017
@@ -18,6 +18,7 @@ pythonize_bool(LIBCXXABI_ENABLE_THREADS)
 pythonize_bool(LIBCXXABI_ENABLE_EXCEPTIONS)
 pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
 pythonize_bool(LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
+pythonize_bool(LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL)
 set(LIBCXXABI_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
 "TargetInfo to use when setting up test environment.")
 set(LIBCXXABI_EXECUTOR "None" CACHE STRING

Modified: libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp?rev=296940=296939=296940=diff
==
--- libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp (original)
+++ libcxxabi/trunk/test/cxa_thread_atexit_test.pass.cpp Fri Mar  3 19:26:41 
2017
@@ -10,6 +10,11 @@
 // UNSUPPORTED: libcxxabi-no-threads
 // REQUIRES: linux
 
+// this test will only work if CMake detects a real __cxa_thread_atexit_impl
+// at configure time. This function, however, was added only in glibc 2.18,
+// and there are still plenty of systems only using 2.17 (Ex RHEL 7).
+// XFAIL: libcxxabi-no-cxa-thread-atexit-impl
+
 #include 
 #include 
 

Modified: libcxxabi/trunk/test/libcxxabi/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/libcxxabi/test/config.py?rev=296940=296939=296940=diff
==
--- libcxxabi/trunk/test/libcxxabi/test/config.py (original)
+++ libcxxabi/trunk/test/libcxxabi/test/config.py Fri Mar  3 19:26:41 2017
@@ -45,6 +45,9 @@ class Configuration(LibcxxConfiguration)
 # test_exception_storage_nodynmem.pass.cpp fails under this specific 
configuration
 if self.get_lit_bool('cxx_ext_threads', False) and 
self.get_lit_bool('libcxxabi_shared', False):
 
self.config.available_features.add('libcxxabi-shared-externally-threaded')
+if not self.get_lit_bool('has_cxa_thread_atexit_impl', True):
+self.config.available_features.add(
+'libcxxabi-no-cxa-thread-atexit-impl')
 
 def configure_compile_flags(self):
 self.cxx.compile_flags += ['-DLIBCXXABI_NO_TIMER']

Modified: libcxxabi/trunk/test/lit.site.cfg.in
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/lit.site.cfg.in?rev=296940=296939=296940=diff
==
--- libcxxabi/trunk/test/lit.site.cfg.in (original)
+++ libcxxabi/trunk/test/lit.site.cfg.in Fri Mar  3 19:26:41 2017
@@ -20,6 +20,7 @@ config.host_triple  = "@LLVM
 config.target_triple= "@TARGET_TRIPLE@"
 config.use_target   = len("@LIBCXXABI_TARGET_TRIPLE@") > 0
 config.cxx_ext_threads  = "@LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY@"
+config.has_cxa_thread_atexit_impl = "@LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL@"
 
 # Let the main config do the real work.
 lit_config.load_config(config, "@LIBCXXABI_SOURCE_DIR@/test/lit.cfg")


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


r296937 - [scan-build-py] create decorator for compiler wrapper methods

2017-03-03 Thread Laszlo Nagy via cfe-commits
Author: rizsotto
Date: Fri Mar  3 19:08:05 2017
New Revision: 296937

URL: http://llvm.org/viewvc/llvm-project?rev=296937=rev
Log:
[scan-build-py] create decorator for compiler wrapper methods

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

Modified:
cfe/trunk/tools/scan-build-py/bin/analyze-c++
cfe/trunk/tools/scan-build-py/bin/analyze-cc
cfe/trunk/tools/scan-build-py/bin/intercept-c++
cfe/trunk/tools/scan-build-py/bin/intercept-cc
cfe/trunk/tools/scan-build-py/libscanbuild/__init__.py
cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py
cfe/trunk/tools/scan-build-py/libscanbuild/intercept.py

Modified: cfe/trunk/tools/scan-build-py/bin/analyze-c++
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/bin/analyze-c%2B%2B?rev=296937=296936=296937=diff
==
--- cfe/trunk/tools/scan-build-py/bin/analyze-c++ (original)
+++ cfe/trunk/tools/scan-build-py/bin/analyze-c++ Fri Mar  3 19:08:05 2017
@@ -10,5 +10,5 @@ import os.path
 this_dir = os.path.dirname(os.path.realpath(__file__))
 sys.path.append(os.path.dirname(this_dir))
 
-from libscanbuild.analyze import analyze_build_wrapper
-sys.exit(analyze_build_wrapper(True))
+from libscanbuild.analyze import analyze_compiler_wrapper
+sys.exit(analyze_compiler_wrapper())

Modified: cfe/trunk/tools/scan-build-py/bin/analyze-cc
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/bin/analyze-cc?rev=296937=296936=296937=diff
==
--- cfe/trunk/tools/scan-build-py/bin/analyze-cc (original)
+++ cfe/trunk/tools/scan-build-py/bin/analyze-cc Fri Mar  3 19:08:05 2017
@@ -10,5 +10,5 @@ import os.path
 this_dir = os.path.dirname(os.path.realpath(__file__))
 sys.path.append(os.path.dirname(this_dir))
 
-from libscanbuild.analyze import analyze_build_wrapper
-sys.exit(analyze_build_wrapper(False))
+from libscanbuild.analyze import analyze_compiler_wrapper
+sys.exit(analyze_compiler_wrapper())

Modified: cfe/trunk/tools/scan-build-py/bin/intercept-c++
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/bin/intercept-c%2B%2B?rev=296937=296936=296937=diff
==
--- cfe/trunk/tools/scan-build-py/bin/intercept-c++ (original)
+++ cfe/trunk/tools/scan-build-py/bin/intercept-c++ Fri Mar  3 19:08:05 2017
@@ -10,5 +10,5 @@ import os.path
 this_dir = os.path.dirname(os.path.realpath(__file__))
 sys.path.append(os.path.dirname(this_dir))
 
-from libscanbuild.intercept import intercept_build_wrapper
-sys.exit(intercept_build_wrapper(True))
+from libscanbuild.intercept import intercept_compiler_wrapper
+sys.exit(intercept_compiler_wrapper())

Modified: cfe/trunk/tools/scan-build-py/bin/intercept-cc
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/bin/intercept-cc?rev=296937=296936=296937=diff
==
--- cfe/trunk/tools/scan-build-py/bin/intercept-cc (original)
+++ cfe/trunk/tools/scan-build-py/bin/intercept-cc Fri Mar  3 19:08:05 2017
@@ -10,5 +10,5 @@ import os.path
 this_dir = os.path.dirname(os.path.realpath(__file__))
 sys.path.append(os.path.dirname(this_dir))
 
-from libscanbuild.intercept import intercept_build_wrapper
-sys.exit(intercept_build_wrapper(False))
+from libscanbuild.intercept import intercept_compiler_wrapper
+sys.exit(intercept_compiler_wrapper())

Modified: cfe/trunk/tools/scan-build-py/libscanbuild/__init__.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/libscanbuild/__init__.py?rev=296937=296936=296937=diff
==
--- cfe/trunk/tools/scan-build-py/libscanbuild/__init__.py (original)
+++ cfe/trunk/tools/scan-build-py/libscanbuild/__init__.py Fri Mar  3 19:08:05 
2017
@@ -4,13 +4,21 @@
 # This file is distributed under the University of Illinois Open Source
 # License. See LICENSE.TXT for details.
 """ This module is a collection of methods commonly used in this project. """
+import collections
 import functools
+import json
 import logging
 import os
 import os.path
+import re
+import shlex
 import subprocess
 import sys
 
+ENVIRONMENT_KEY = 'INTERCEPT_BUILD'
+
+Execution = collections.namedtuple('Execution', ['pid', 'cwd', 'cmd'])
+
 
 def duplicate_check(method):
 """ Predicate to detect duplicated entries.
@@ -75,31 +83,53 @@ def run_command(command, cwd=None):
 raise ex
 
 
-def initialize_logging(verbose_level):
-""" Output content controlled by the verbosity level. """
+def reconfigure_logging(verbose_level):
+""" Reconfigure logging level and format based on the verbose flag.
 
-level = logging.WARNING - min(logging.WARNING, (10 * verbose_level))
+:param verbose_level: number of `-v` flags received by the command
+:return: no 

[libcxxabi] r296936 - Turn on -Wunused-function and cleanup occurances

2017-03-03 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Mar  3 19:02:35 2017
New Revision: 296936

URL: http://llvm.org/viewvc/llvm-project?rev=296936=rev
Log:
Turn on -Wunused-function and cleanup occurances

Modified:
libcxxabi/trunk/CMakeLists.txt
libcxxabi/trunk/cmake/config-ix.cmake
libcxxabi/trunk/src/cxa_guard.cpp

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=296936=296935=296936=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Fri Mar  3 19:02:35 2017
@@ -322,7 +322,7 @@ append_if(LIBCXXABI_COMPILE_FLAGS LIBCXX
 append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_HAS_WMISMATCHED_TAGS_FLAG 
-Wmismatched-tags)
 append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_HAS_WMISSING_BRACES_FLAG 
-Wmissing-braces)
 append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_HAS_WNEWLINE_EOF_FLAG 
-Wnewline-eof)
-append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_HAS_WNO_UNUSED_FUNCTION_FLAG 
-Wno-unused-function)
+append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_HAS_WUNUSED_FUNCTION_FLAG 
-Wunused-function)
 append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_HAS_WSHADOW_FLAG -Wshadow)
 append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_HAS_WSHORTEN_64_TO_32_FLAG 
-Wshorten-64-to-32)
 append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_HAS_WSIGN_COMPARE_FLAG 
-Wsign-compare)

Modified: libcxxabi/trunk/cmake/config-ix.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/cmake/config-ix.cmake?rev=296936=296935=296936=diff
==
--- libcxxabi/trunk/cmake/config-ix.cmake (original)
+++ libcxxabi/trunk/cmake/config-ix.cmake Fri Mar  3 19:02:35 2017
@@ -12,7 +12,7 @@ check_cxx_compiler_flag(-nodefaultlibs
 check_cxx_compiler_flag(-nostdinc++   LIBCXXABI_HAS_NOSTDINCXX_FLAG)
 check_cxx_compiler_flag(-Wall LIBCXXABI_HAS_WALL_FLAG)
 check_cxx_compiler_flag(-WLIBCXXABI_HAS_W_FLAG)
-check_cxx_compiler_flag(-Wno-unused-function  
LIBCXXABI_HAS_WNO_UNUSED_FUNCTION_FLAG)
+check_cxx_compiler_flag(-Wunused-function 
LIBCXXABI_HAS_WUNUSED_FUNCTION_FLAG)
 check_cxx_compiler_flag(-Wunused-variable 
LIBCXXABI_HAS_WUNUSED_VARIABLE_FLAG)
 check_cxx_compiler_flag(-Wunused-parameter
LIBCXXABI_HAS_WUNUSED_PARAMETER_FLAG)
 check_cxx_compiler_flag(-Wstrict-aliasing 
LIBCXXABI_HAS_WSTRICT_ALIASING_FLAG)

Modified: libcxxabi/trunk/src/cxa_guard.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_guard.cpp?rev=296936=296935=296936=diff
==
--- libcxxabi/trunk/src/cxa_guard.cpp (original)
+++ libcxxabi/trunk/src/cxa_guard.cpp Fri Mar  3 19:02:35 2017
@@ -113,9 +113,10 @@ set_lock(uint64_t& x, lock_type y)
 
 typedef bool lock_type;
 
-inline
-lock_type
-get_lock(uint64_t x)
+#if !defined(__arm__)
+static_assert(std::is_same::value, "");
+
+inline lock_type get_lock(uint64_t x)
 {
 union
 {
@@ -125,9 +126,7 @@ get_lock(uint64_t x)
 return f.lock[1] != 0;
 }
 
-inline
-void
-set_lock(uint64_t& x, lock_type y)
+inline void set_lock(uint64_t& x, lock_type y)
 {
 union
 {
@@ -137,10 +136,10 @@ set_lock(uint64_t& x, lock_type y)
 f.lock[1] = y;
 x = f.guard;
 }
+#else // defined(__arm__)
+static_assert(std::is_same::value, "");
 
-inline
-lock_type
-get_lock(uint32_t x)
+inline lock_type get_lock(uint32_t x)
 {
 union
 {
@@ -150,9 +149,7 @@ get_lock(uint32_t x)
 return f.lock[1] != 0;
 }
 
-inline
-void
-set_lock(uint32_t& x, lock_type y)
+inline void set_lock(uint32_t& x, lock_type y)
 {
 union
 {
@@ -163,7 +160,9 @@ set_lock(uint32_t& x, lock_type y)
 x = f.guard;
 }
 
-#endif  // __APPLE__
+#endif // !defined(__arm__)
+
+#endif  // __APPLE__ && !__arm__
 
 }  // unnamed namespace
 


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


[PATCH] D30597: [libc++] Attempt to improve diagnostics about Hash requirement violations

2017-03-03 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.

This is my attempt to improve the diagnostic messages emitted from the 
unordered containers when the supplied hash doesn't meet the `Hash` 
requirements.

Unfortunately producing reasonable diagnostics is tricky and it requires a 
bunch of meta-programming to get right.

@thakis Does this look more reasonable to you?


https://reviews.llvm.org/D30597

Files:
  include/__hash_table
  include/utility
  test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp

Index: test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
===
--- test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
+++ test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
@@ -10,18 +10,16 @@
 // REQUIRES: diagnose-if-support
 // UNSUPPORTED: c++98, c++03
 
-// Libc++ only provides a defined primary template for std::hash in C++14 and
-// newer.
-// UNSUPPORTED: c++11
-
 // 
 
 // Test that we generate a reasonable diagnostic when the specified hash is
 // not enabled.
 
 #include 
 #include 
 
+#include "test_macros.h"
+
 using VT = std::pair;
 
 struct BadHashNoCopy {
@@ -47,21 +45,22 @@
 
   {
 using Set = std::unordered_set;
-Set s; // expected-error@__hash_table:* {{the specified hash does not meet the Hash requirements}}
-
-
-  // FIXME: It would be great to suppress the below diagnostic all together.
-  //but for now it's sufficient that it appears last. However there is
-  //currently no way to test the order diagnostics are issued.
-  // expected-error@memory:* {{call to implicitly-deleted default constructor of 'std::__1::hash >'}}
+Set s; // expected-error@utility:* {{no matching specialization for std::hash}}
+#if TEST_STD_VER == 11
+// expected-error@type_traits:* {{implicit instantiation of undefined template}}
+// expected-error@memory:* {{no member named 'value'}}
+// expected-error@memory:* {{multiple overloads of '__compressed_pair'}}
+#else
+// expected-error@memory:* {{call to implicitly-deleted default constructor}}
+#endif
   }
   {
 using Set = std::unordered_set;
-Set s; // expected-error@__hash_table:* {{the specified hash does not meet the Hash requirements}}
+Set s; // expected-error@utility:* {{the specified hash is required to be copy constructible}}
   }
   {
 using Set = std::unordered_set;
-Set s; // expected-error@__hash_table:* {{the specified hash does not meet the Hash requirements}}
+Set s; // expected-error@utility:* {{the specified hash is required to be callable type}}
   }
   {
 using Set = std::unordered_set;
Index: include/utility
===
--- include/utility
+++ include/utility
@@ -1535,6 +1535,7 @@
 };
 template 
 struct _LIBCPP_TEMPLATE_VIS __enum_hash<_Tp, false> {
+using __is_invalid_std_hash = true_type;
 __enum_hash() = delete;
 __enum_hash(__enum_hash const&) = delete;
 __enum_hash& operator=(__enum_hash const&) = delete;
@@ -1560,16 +1561,90 @@
 #endif
 
 #ifndef _LIBCPP_CXX03_LANG
+#if _LIBCPP_STD_VER > 11
+template 
+struct __is_invalid_std_hash : false_type {};
+
+template 
+struct __is_invalid_std_hash<
+_Arg,
+typename __void_t::type
+> : true_type {};
+#else
+template 
+struct __is_hash_specialization : false_type {};
+
+template 
+struct __is_hash_specialization> : true_type {};
+
+template 
+struct __is_invalid_std_hash
+: integral_constant::value> {};
+
+template 
+struct __is_invalid_std_hash,
+typename __void_t)>>::type
+> : false_type {};
+
+
+#endif
+
+template ::value,
+  class = typename enable_if<_IsStdHashInvalid>::type>
+constexpr bool __check_hash_requirements() {
+  static_assert(!_IsStdHashInvalid || !_EnableAssertions,
+"no matching specialization for std::hash");
+  return false;
+}
+
+template ,
+  class = typename enable_if::type,
+  bool _IsCopyConstructible = is_copy_constructible<_Hash>::value,
+  bool _IsMoveConstructible = is_move_constructible<_Hash>::value,
+  bool _HasCallOperator = __invokable<_Hash, _Key const&>::value,
+  bool _HasCorrectReturnType = __invokable_r::value,
+  bool _IsGood = _IsCopyConstructible
+  && _IsMoveConstructible && _HasCallOperator
+  && _HasCorrectReturnType>
+constexpr bool __check_hash_requirements() {
+  static_assert(_IsCopyConstructible || !_EnableAssertions,
+"the specified hash is required to be copy constructible");
+  static_assert(_IsMoveConstructible  || !_IsCopyConstructible || !_EnableAssertions,
+"the specified hash is required to be copy and move 

r296932 - [ODRHash] Add support for detecting different method properties.

2017-03-03 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Mar  3 18:08:58 2017
New Revision: 296932

URL: http://llvm.org/viewvc/llvm-project?rev=296932=rev
Log:
[ODRHash] Add support for detecting different method properties.

Now print diagnostics for static, virtual, inline, volatile, and const
differences in methods.  Also use DeclarationName instead of IdentifierInfo
for additional robustness in diagnostic printing.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=296932=296931=296932=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Fri Mar  3 
18:08:58 2017
@@ -140,7 +140,13 @@ def err_module_odr_violation_mismatch_de
   "%select{non-|}5mutable field %4|"
   "field %4 with %select{no|an}5 initalizer|"
   "field %4 with an initializer|"
-  "method %4}3">;
+  "method %4|"
+  "method %4 is %select{not deleted|deleted}5|"
+  "method %4 is %select{|pure }5%select{not virtual|virtual}6|"
+  "method %4 is %select{not static|static}5|"
+  "method %4 is %select{not volatile|volatile}5|"
+  "method %4 is %select{not const|const}5|"
+  "method %4 is %select{not inline|inline}5}3">;
 
 def note_module_odr_violation_mismatch_decl_diff : Note<"but in '%0' found "
   "%select{"
@@ -154,7 +160,13 @@ def note_module_odr_violation_mismatch_d
   "%select{non-|}3mutable field %2|"
   "field %2 with %select{no|an}3 initializer|"
   "field %2 with a different initializer|"
-  "method %2}1">;
+  "method %2|"
+  "method %2 is %select{not deleted|deleted}3|"
+  "method %2 is %select{|pure }3%select{not virtual|virtual}4|"
+  "method %2 is %select{not static|static}3|"
+  "method %2 is %select{not volatile|volatile}3|"
+  "method %2 is %select{not const|const}3|"
+  "method %2 is %select{not inline|inline}3}1">;
 
 def warn_module_uses_date_time : Warning<
   "%select{precompiled header|module}0 uses __DATE__ or __TIME__">,

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=296932=296931=296932=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Mar  3 18:08:58 2017
@@ -160,7 +160,7 @@ public:
   }
 
   void VisitNamedDecl(const NamedDecl *D) {
-AddIdentifierInfo(D->getIdentifier());
+Hash.AddDeclarationName(D->getDeclName());
 Inherited::VisitNamedDecl(D);
   }
 
@@ -196,10 +196,19 @@ public:
   }
 
   void VisitFunctionDecl(const FunctionDecl *D) {
+ID.AddInteger(D->getStorageClass());
+Hash.AddBoolean(D->isInlineSpecified());
+Hash.AddBoolean(D->isVirtualAsWritten());
+Hash.AddBoolean(D->isPure());
+Hash.AddBoolean(D->isDeletedAsWritten());
+
 Inherited::VisitFunctionDecl(D);
   }
 
   void VisitCXXMethodDecl(const CXXMethodDecl *D) {
+Hash.AddBoolean(D->isConst());
+Hash.AddBoolean(D->isVolatile());
+
 Inherited::VisitCXXMethodDecl(D);
   }
 };

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=296932=296931=296932=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Mar  3 18:08:58 2017
@@ -9067,6 +9067,12 @@ void ASTReader::diagnoseOdrViolations()
 FieldSingleInitializer,
 FieldDifferentInitializers,
 MethodName,
+MethodDeleted,
+MethodVirtual,
+MethodStatic,
+MethodVolatile,
+MethodConst,
+MethodInline,
   };
 
   // These lambdas have the common portions of the ODR diagnostics.  This
@@ -9290,16 +9296,103 @@ void ASTReader::diagnoseOdrViolations()
   case CXXMethod: {
 const CXXMethodDecl *FirstMethod = cast(FirstDecl);
 const CXXMethodDecl *SecondMethod = cast(SecondDecl);
-IdentifierInfo *FirstII = FirstMethod->getIdentifier();
-IdentifierInfo *SecondII = SecondMethod->getIdentifier();
-if (FirstII->getName() != SecondII->getName()) {
+auto FirstName = FirstMethod->getDeclName();
+auto SecondName = SecondMethod->getDeclName();
+if (FirstName != SecondName) {
   ODRDiagError(FirstMethod->getLocation(),
FirstMethod->getSourceRange(), MethodName)
-  << FirstII;
+  << FirstName;
   ODRDiagNote(SecondMethod->getLocation(),
   SecondMethod->getSourceRange(), MethodName)
-  

r296929 - Restrict test arch-specific-libdir.c to Linux

2017-03-03 Thread Pirama Arumuga Nainar via cfe-commits
Author: pirama
Date: Fri Mar  3 17:48:15 2017
New Revision: 296929

URL: http://llvm.org/viewvc/llvm-project?rev=296929=rev
Log:
Restrict test arch-specific-libdir.c to Linux

Summary: This fails on Windows due to dependence on path separators.

Reviewers: rnk, srhines

Subscribers: llvm-commits

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

Modified:
cfe/trunk/test/Driver/arch-specific-libdir.c

Modified: cfe/trunk/test/Driver/arch-specific-libdir.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arch-specific-libdir.c?rev=296929=296928=296929=diff
==
--- cfe/trunk/test/Driver/arch-specific-libdir.c (original)
+++ cfe/trunk/test/Driver/arch-specific-libdir.c Fri Mar  3 17:48:15 2017
@@ -1,6 +1,8 @@
 // Test that the driver adds an arch-specific subdirectory in
 // {RESOURCE_DIR}/lib/linux to the search path.
 //
+// REQUIRES: linux
+//
 // RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefixes=FILEPATH,ARCHDIR-i386 %s


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


Re: [libcxx] r296919 - Fix hash requirements check in __hash_table.

2017-03-03 Thread Eric Fiselier via cfe-commits
On Fri, Mar 3, 2017 at 4:01 PM, Nico Weber  wrote:

> "the specified hash does not meet the Hash requirements" isn't a very
> actionable diagnostic.
>

True, For now I was only trying to out-diagnose template barf when I wrote
it initially. So in that regard it's a bit more actionable that it was, at
least I hope.

I'm planning to create some machinery to check and diagnose every hash
requirement separately, but I was going to do that separately. For instance
some requirements could be diagnosed as warnings instead of hard errors,
allowing users to keep their code compiling until they have time to fix it.

Of course patches are always welcome :-P

/Eric



> Is it possible to use some warning text that lets people know what they
> need to do to make the compiler happy, instead of just telling them that
> the compiler is unhappy?
>
> On Fri, Mar 3, 2017 at 5:35 PM, Eric Fiselier via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ericwf
>> Date: Fri Mar  3 16:35:58 2017
>> New Revision: 296919
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=296919=rev
>> Log:
>> Fix hash requirements check in __hash_table.
>>
>> r296565 attempted to add better diagnostics when an unordered container
>> is instantiated with a hash that doesn't meet the Hash requirements.
>>
>> However I mistakenly checked the wrong set of requirements. Specifically
>> it checked if the hash met the requirements for specializations of
>> std::hash. However these requirements are stricter than the generic
>> Hash requirements.
>>
>> This patch fixes the assertions to only check the Hash requirements.
>>
>> Modified:
>> libcxx/trunk/include/__hash_table
>> libcxx/trunk/include/utility
>> libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_
>> hash_specialization.fail.cpp
>>
>> Modified: libcxx/trunk/include/__hash_table
>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__
>> hash_table?rev=296919=296918=296919=diff
>> 
>> ==
>> --- libcxx/trunk/include/__hash_table (original)
>> +++ libcxx/trunk/include/__hash_table Fri Mar  3 16:35:58 2017
>> @@ -871,16 +871,15 @@ public:
>>  template 
>>  struct __diagnose_hash_table_helper {
>>static constexpr bool __trigger_diagnostics()
>> -_LIBCPP_DIAGNOSE_WARNING(__has_enabled_hash<_Key, _Hash>::value
>> +_LIBCPP_DIAGNOSE_WARNING(__check_hash_requirements<_Key,
>> _Hash>::value
>>   && !__invokable<_Hash const&, _Key
>> const&>::value,
>>"the specified hash functor does not provide a const call
>> operator")
>>  _LIBCPP_DIAGNOSE_WARNING(is_copy_constructible<_Equal>::value
>>&& !__invokable<_Equal const&, _Key const&,
>> _Key const&>::value,
>>"the specified comparator type does not provide a const call
>> operator")
>>{
>> -static_assert(__has_enabled_hash<_Key, _Hash>::value,
>> -  "the specified hash functor does not meet the requirements for an "
>> -  "enabled hash");
>> +static_assert(__check_hash_requirements<_Key, _Hash>::value,
>> +  "the specified hash does not meet the Hash requirements");
>>  static_assert(is_copy_constructible<_Equal>::value,
>>"the specified comparator is required to be copy constructible");
>>  return true;
>>
>> Modified: libcxx/trunk/include/utility
>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/uti
>> lity?rev=296919=296918=296919=diff
>> 
>> ==
>> --- libcxx/trunk/include/utility (original)
>> +++ libcxx/trunk/include/utility Fri Mar  3 16:35:58 2017
>> @@ -1560,14 +1560,19 @@ struct _LIBCPP_TEMPLATE_VIS hash>  #endif
>>
>>  #ifndef _LIBCPP_CXX03_LANG
>> -template  >
>> -using __has_enabled_hash = integral_constant> -is_default_constructible<_Hash>::value &&
>> +template 
>> +using __check_hash_requirements = integral_constant>  is_copy_constructible<_Hash>::value &&
>>  is_move_constructible<_Hash>::value &&
>>  __invokable_r::value
>>  >;
>>
>> +template  >
>> +using __has_enabled_hash = integral_constant> +__check_hash_requirements<_Key, _Hash>::value &&
>> +is_default_constructible<_Hash>::value
>> +>;
>> +
>>  #if _LIBCPP_STD_VER > 14
>>  template 
>>  using __enable_hash_helper_imp = _Type;
>>
>> Modified: libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_
>> hash_specialization.fail.cpp
>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx
>> /containers/unord/unord.set/missing_hash_specialization.
>> fail.cpp?rev=296919=296918=296919=diff
>> 
>> ==
>> --- 
>> libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
>> (original)
>> +++ 
>> 

[PATCH] D30592: [clang-tidy] Fix diag message for catch-by-value

2017-03-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added a comment.
This revision now requires changes to proceed.

This change is missing test cases.


https://reviews.llvm.org/D30592



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


[PATCH] D30015: Add arch-specific directory to search path

2017-03-03 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

Committed.  Thanks for the reviews!


Repository:
  rL LLVM

https://reviews.llvm.org/D30015



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


[PATCH] D30015: Add arch-specific directory to search path

2017-03-03 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296927: Add arch-specific directory to search path (authored 
by pirama).

Changed prior to commit:
  https://reviews.llvm.org/D30015?vs=90532=90545#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30015

Files:
  cfe/trunk/include/clang/Driver/ToolChain.h
  cfe/trunk/lib/Driver/ToolChain.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  
cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/.keep
  cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/.keep
  
cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i386/.keep
  
cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/.keep
  cfe/trunk/test/Driver/arch-specific-libdir-rpath.c
  cfe/trunk/test/Driver/arch-specific-libdir.c
  cfe/trunk/test/lit.cfg

Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -10,6 +10,7 @@
 #include "clang/Driver/ToolChain.h"
 #include "Tools.h"
 #include "clang/Basic/ObjCRuntime.h"
+#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Action.h"
 #include "clang/Driver/Driver.h"
@@ -74,6 +75,10 @@
 if (!isThreadModelSupported(A->getValue()))
   D.Diag(diag::err_drv_invalid_thread_model_for_target)
   << A->getValue() << A->getAsString(Args);
+
+  std::string CandidateLibPath = getArchSpecificLibPath();
+  if (getVFS().exists(CandidateLibPath))
+getFilePaths().push_back(CandidateLibPath);
 }
 
 ToolChain::~ToolChain() {
@@ -320,6 +325,14 @@
   return Args.MakeArgString(getCompilerRT(Args, Component, Shared));
 }
 
+std::string ToolChain::getArchSpecificLibPath() const {
+  SmallString<128> Path(getDriver().ResourceDir);
+  StringRef OSLibName = getTriple().isOSFreeBSD() ? "freebsd" : getOS();
+  llvm::sys::path::append(Path, "lib", OSLibName,
+  llvm::Triple::getArchTypeName(getArch()));
+  return Path.str();
+}
+
 bool ToolChain::needsProfileRT(const ArgList ) {
   if (Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs,
false) ||
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -14,6 +14,7 @@
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Basic/Version.h"
+#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Action.h"
 #include "clang/Driver/Compilation.h"
@@ -238,8 +239,9 @@
 
   // LIBRARY_PATH - included following the user specified library paths.
   //and only supported on native toolchains.
-  if (!TC.isCrossCompiling())
+  if (!TC.isCrossCompiling()) {
 addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
+  }
 }
 
 /// Add OpenMP linker script arguments at the end of the argument list so that
@@ -2000,6 +2002,19 @@
   }
 }
 
+static void addArchSpecificRPath(const ToolChain , const ArgList ,
+ ArgStringList ) {
+  // In the cross-compilation case, arch-specific library path is likely
+  // unavailable at runtime.
+  if (TC.isCrossCompiling()) return;
+
+  std::string CandidateRPath = TC.getArchSpecificLibPath();
+  if (TC.getVFS().exists(CandidateRPath)) {
+CmdArgs.push_back("-rpath");
+CmdArgs.push_back(Args.MakeArgString(CandidateRPath.c_str()));
+  }
+}
+
 static void addOpenMPRuntime(ArgStringList , const ToolChain ,
   const ArgList ) {
   if (!Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
@@ -2020,6 +2035,8 @@
 // Already diagnosed.
 break;
   }
+
+  addArchSpecificRPath(TC, Args, CmdArgs);
 }
 
 static void addSanitizerRuntime(const ToolChain , const ArgList ,
@@ -2030,6 +2047,10 @@
   if (IsWhole) CmdArgs.push_back("-whole-archive");
   CmdArgs.push_back(TC.getCompilerRTArgString(Args, Sanitizer, IsShared));
   if (IsWhole) CmdArgs.push_back("-no-whole-archive");
+
+  if (IsShared) {
+addArchSpecificRPath(TC, Args, CmdArgs);
+  }
 }
 
 // Tries to use a file with the list of dynamic symbols that need to be exported
@@ -9002,6 +9023,8 @@
 }
 if (JA.isHostOffloading(Action::OFK_OpenMP))
   CmdArgs.push_back("-lomptarget");
+
+addArchSpecificRPath(ToolChain, Args, CmdArgs);
   }
 
   AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
Index: cfe/trunk/include/clang/Driver/ToolChain.h
===
--- cfe/trunk/include/clang/Driver/ToolChain.h
+++ cfe/trunk/include/clang/Driver/ToolChain.h
@@ -299,6 +299,11 @@
   const char *getCompilerRTArgString(const llvm::opt::ArgList ,
  StringRef Component,
 

r296927 - Add arch-specific directory to search path

2017-03-03 Thread Pirama Arumuga Nainar via cfe-commits
Author: pirama
Date: Fri Mar  3 17:20:49 2017
New Revision: 296927

URL: http://llvm.org/viewvc/llvm-project?rev=296927=rev
Log:
Add arch-specific directory to search path

Summary:

This change adds an arch-specific subdirectory in /lib/
to the linker search path.  This path also gets added as '-rpath' for
native compilation if a runtime is linked in as a shared object.  This
allows arch-specific libraries to be installed alongside clang.

Reviewers: danalbert, cbergstrom, javed.absar

Subscribers: srhines

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

Added:
cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/
cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/
cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/

cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/

cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/.keep
cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/

cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/.keep
cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i386/

cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i386/.keep
cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/

cfe/trunk/test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/.keep
cfe/trunk/test/Driver/arch-specific-libdir-rpath.c
cfe/trunk/test/Driver/arch-specific-libdir.c
Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/lit.cfg

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=296927=296926=296927=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Fri Mar  3 17:20:49 2017
@@ -299,6 +299,11 @@ public:
   const char *getCompilerRTArgString(const llvm::opt::ArgList ,
  StringRef Component,
  bool Shared = false) const;
+
+  // Returns /lib//.  This is used by runtimes (such
+  // as OpenMP) to find arch-specific libraries.
+  std::string getArchSpecificLibPath() const;
+
   /// needsProfileRT - returns true if instrumentation profile is on.
   static bool needsProfileRT(const llvm::opt::ArgList );
 

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=296927=296926=296927=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Fri Mar  3 17:20:49 2017
@@ -10,6 +10,7 @@
 #include "clang/Driver/ToolChain.h"
 #include "Tools.h"
 #include "clang/Basic/ObjCRuntime.h"
+#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Action.h"
 #include "clang/Driver/Driver.h"
@@ -74,6 +75,10 @@ ToolChain::ToolChain(const Driver , co
 if (!isThreadModelSupported(A->getValue()))
   D.Diag(diag::err_drv_invalid_thread_model_for_target)
   << A->getValue() << A->getAsString(Args);
+
+  std::string CandidateLibPath = getArchSpecificLibPath();
+  if (getVFS().exists(CandidateLibPath))
+getFilePaths().push_back(CandidateLibPath);
 }
 
 ToolChain::~ToolChain() {
@@ -320,6 +325,14 @@ const char *ToolChain::getCompilerRTArgS
   return Args.MakeArgString(getCompilerRT(Args, Component, Shared));
 }
 
+std::string ToolChain::getArchSpecificLibPath() const {
+  SmallString<128> Path(getDriver().ResourceDir);
+  StringRef OSLibName = getTriple().isOSFreeBSD() ? "freebsd" : getOS();
+  llvm::sys::path::append(Path, "lib", OSLibName,
+  llvm::Triple::getArchTypeName(getArch()));
+  return Path.str();
+}
+
 bool ToolChain::needsProfileRT(const ArgList ) {
   if (Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs,
false) ||

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=296927=296926=296927=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Mar  3 17:20:49 2017
@@ -14,6 +14,7 @@
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Basic/Version.h"
+#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Action.h"
 #include "clang/Driver/Compilation.h"
@@ -238,8 +239,9 @@ static void AddLinkerInputs(const ToolCh
 
   // LIBRARY_PATH - included following the user specified library paths.
   //

[PATCH] D30591: Introduce the feature "linux" for tests only for linux

2017-03-03 Thread Bob Haarman via Phabricator via cfe-commits
inglorion added a comment.

Checking for linux when really you want to check for ELF doesn't seem right. In 
this case, I think there is an better way to do it; instead of relying on 
llvm-objdump, could you emit an LLVM assembly file and check that for presence 
of the string you want? I think if you compile with clang -g -S -emit-llvm, it 
will give you LLVM assembly with metadata for the records you need and you 
won't need to generate an object file.


https://reviews.llvm.org/D30591



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


[PATCH] D30593: Add correct "-isystem"/"-isysroot" warning handling to static analysis' BugReporter.

2017-03-03 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

http://llvm-cs.pcc.me.uk/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h/risInSystemHeader
 suggests that the analyzer has some plumbing for this, so I added dcoughlin as 
reviewer, who has touched some of those lines before. dcoughlin, as background: 
We're playing with running the analyzer on chromium, and we were pretty 
surprised that it defaults to printing diagnostics for system headers. That's 
different from what regular clang does, and there isn't much applications can 
do about diagnostics in system headers. kmarshall wrote a script to manually 
filter out diagnostics from system headers, but we figured it'd make more sense 
if the analyzer didn't emit those diagnostics in the first place -- probably by 
default, but maybe behind some flag. Are you familiar with the design behind 
the current behavior? Does it make sense to change this? Are we missing some 
existing flag?

(kmarshall: In the future, please send some context lines with your diffs, see 
http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface.)


Repository:
  rL LLVM

https://reviews.llvm.org/D30593



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


[PATCH] D30593: Add correct "-isystem" warning handling to static analysis' BugReporter.

2017-03-03 Thread Kevin Marshall via Phabricator via cfe-commits
kmarshall created this revision.

The Clang static analyzer doesn't follow the warning suppression semantics of 
the "-isystem" command line flag. This patch adds a check to BugReporter which 
causes it to drop any BugReports which originated from a system header 
(descendant of an -isystem path).


Repository:
  rL LLVM

https://reviews.llvm.org/D30593

Files:
  lib/StaticAnalyzer/Core/BugReporter.cpp


Index: lib/StaticAnalyzer/Core/BugReporter.cpp
===
--- lib/StaticAnalyzer/Core/BugReporter.cpp
+++ lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -3251,6 +3251,12 @@
   return;
   }

+  // Suppress BugReports which originate from system headers (located beneath
+  // an -isystem include path).
+  if (getSourceManager().isInSystemHeader(
+  R->getLocation(getSourceManager()).asLocation()))
+return;
+
   bool ValidSourceLoc = R->getLocation(getSourceManager()).isValid();
   assert(ValidSourceLoc);
   // If we mess up in a release build, we'd still prefer to just drop the bug


Index: lib/StaticAnalyzer/Core/BugReporter.cpp
===
--- lib/StaticAnalyzer/Core/BugReporter.cpp
+++ lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -3251,6 +3251,12 @@
   return;
   }

+  // Suppress BugReports which originate from system headers (located beneath
+  // an -isystem include path).
+  if (getSourceManager().isInSystemHeader(
+  R->getLocation(getSourceManager()).asLocation()))
+return;
+
   bool ValidSourceLoc = R->getLocation(getSourceManager()).isValid();
   assert(ValidSourceLoc);
   // If we mess up in a release build, we'd still prefer to just drop the bug
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30593: Add correct "-isystem" warning handling to static analysis' BugReporter.

2017-03-03 Thread Kevin Marshall via Phabricator via cfe-commits
kmarshall added a comment.

Note to reviewers:  this diff is relative to "llvm/cfe" - I couldn't find a way 
to specify a repository subpath to use for this diff.


Repository:
  rL LLVM

https://reviews.llvm.org/D30593



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


Re: [libcxx] r296919 - Fix hash requirements check in __hash_table.

2017-03-03 Thread Nico Weber via cfe-commits
"the specified hash does not meet the Hash requirements" isn't a very
actionable diagnostic. Is it possible to use some warning text that lets
people know what they need to do to make the compiler happy, instead of
just telling them that the compiler is unhappy?

On Fri, Mar 3, 2017 at 5:35 PM, Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ericwf
> Date: Fri Mar  3 16:35:58 2017
> New Revision: 296919
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296919=rev
> Log:
> Fix hash requirements check in __hash_table.
>
> r296565 attempted to add better diagnostics when an unordered container
> is instantiated with a hash that doesn't meet the Hash requirements.
>
> However I mistakenly checked the wrong set of requirements. Specifically
> it checked if the hash met the requirements for specializations of
> std::hash. However these requirements are stricter than the generic
> Hash requirements.
>
> This patch fixes the assertions to only check the Hash requirements.
>
> Modified:
> libcxx/trunk/include/__hash_table
> libcxx/trunk/include/utility
> libcxx/trunk/test/libcxx/containers/unord/unord.set/
> missing_hash_specialization.fail.cpp
>
> Modified: libcxx/trunk/include/__hash_table
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/_
> _hash_table?rev=296919=296918=296919=diff
> 
> ==
> --- libcxx/trunk/include/__hash_table (original)
> +++ libcxx/trunk/include/__hash_table Fri Mar  3 16:35:58 2017
> @@ -871,16 +871,15 @@ public:
>  template 
>  struct __diagnose_hash_table_helper {
>static constexpr bool __trigger_diagnostics()
> -_LIBCPP_DIAGNOSE_WARNING(__has_enabled_hash<_Key, _Hash>::value
> +_LIBCPP_DIAGNOSE_WARNING(__check_hash_requirements<_Key,
> _Hash>::value
>   && !__invokable<_Hash const&, _Key
> const&>::value,
>"the specified hash functor does not provide a const call operator")
>  _LIBCPP_DIAGNOSE_WARNING(is_copy_constructible<_Equal>::value
>&& !__invokable<_Equal const&, _Key const&,
> _Key const&>::value,
>"the specified comparator type does not provide a const call
> operator")
>{
> -static_assert(__has_enabled_hash<_Key, _Hash>::value,
> -  "the specified hash functor does not meet the requirements for an "
> -  "enabled hash");
> +static_assert(__check_hash_requirements<_Key, _Hash>::value,
> +  "the specified hash does not meet the Hash requirements");
>  static_assert(is_copy_constructible<_Equal>::value,
>"the specified comparator is required to be copy constructible");
>  return true;
>
> Modified: libcxx/trunk/include/utility
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/
> utility?rev=296919=296918=296919=diff
> 
> ==
> --- libcxx/trunk/include/utility (original)
> +++ libcxx/trunk/include/utility Fri Mar  3 16:35:58 2017
> @@ -1560,14 +1560,19 @@ struct _LIBCPP_TEMPLATE_VIS hash  #endif
>
>  #ifndef _LIBCPP_CXX03_LANG
> -template  >
> -using __has_enabled_hash = integral_constant -is_default_constructible<_Hash>::value &&
> +template 
> +using __check_hash_requirements = integral_constant  is_copy_constructible<_Hash>::value &&
>  is_move_constructible<_Hash>::value &&
>  __invokable_r::value
>  >;
>
> +template  >
> +using __has_enabled_hash = integral_constant +__check_hash_requirements<_Key, _Hash>::value &&
> +is_default_constructible<_Hash>::value
> +>;
> +
>  #if _LIBCPP_STD_VER > 14
>  template 
>  using __enable_hash_helper_imp = _Type;
>
> Modified: libcxx/trunk/test/libcxx/containers/unord/unord.set/
> missing_hash_specialization.fail.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/
> libcxx/containers/unord/unord.set/missing_hash_
> specialization.fail.cpp?rev=296919=296918=296919=diff
> 
> ==
> --- libcxx/trunk/test/libcxx/containers/unord/unord.set/
> missing_hash_specialization.fail.cpp (original)
> +++ libcxx/trunk/test/libcxx/containers/unord/unord.set/
> missing_hash_specialization.fail.cpp Fri Mar  3 16:35:58 2017
> @@ -23,14 +23,48 @@
>  #include 
>
>  using VT = std::pair;
> -using Set = std::unordered_set;
> +
> +struct BadHashNoCopy {
> +  BadHashNoCopy() = default;
> +  BadHashNoCopy(BadHashNoCopy const&) = delete;
> +
> +  template 
> +  size_t operator()(T const&) const { return 0; }
> +};
> +
> +struct BadHashNoCall {
> +
> +};
> +
> +
> +struct GoodHashNoDefault {
> +  explicit GoodHashNoDefault(void*) {}
> +  template 
> +  size_t operator()(T const&) const { return 0; }
> +};
>
>  int main() {
>
> -  Set s; // expected-error@__hash_table:* {{the specified hash functor
> does not meet the requirements for an enabled hash}}
> +  {
> 

[libcxx] r296922 - Remove the buildit and testit scripts; they haven't been supported in years

2017-03-03 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Mar  3 16:47:45 2017
New Revision: 296922

URL: http://llvm.org/viewvc/llvm-project?rev=296922=rev
Log:
Remove the buildit and testit scripts; they haven't been supported in years

Removed:
libcxx/trunk/lib/buildit
libcxx/trunk/test/testit

Removed: libcxx/trunk/lib/buildit
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/buildit?rev=296921=auto
==
--- libcxx/trunk/lib/buildit (original)
+++ libcxx/trunk/lib/buildit (removed)
@@ -1,189 +0,0 @@
-#! /bin/sh
-#
-# Set the $TRIPLE environment variable to your system's triple before
-# running this script.  If you set $CXX, that will be used to compile
-# the library.  Otherwise we'll use clang++.
-
-set -e
-
-echo "-- WARNING --"
-echo "buildit is no longer supported and will be removed in the next week!"
-echo "please contact the libc++ maintainers if you have any concerns"
-echo ""
-
-if [ `basename $(pwd)` != "lib" ]
-then
-echo "current directory must be lib"
-exit 1
-fi
-
-if [ -z "$CXX" ]
-then
-CXX=clang++
-fi
-
-if [ -z "$CXX_LANG" ]
-then
-CXX_LANG=c++11
-fi
-
-if [ -z "$CC" ]
-then
-CC=clang
-fi
-
-if [ -z "$MACOSX_DEPLOYMENT_TARGET" ]
-then
-if [ -z "$IPHONEOS_DEPLOYMENT_TARGET" ]
-then
-MACOSX_DEPLOYMENT_TARGET=10.7
-fi
-fi
-
-if [ -z "$RC_ProjectSourceVersion" ]
-then
-  RC_ProjectSourceVersion=1
-fi
-
-EXTRA_FLAGS="-nostdinc++ -std=${CXX_LANG} -fstrict-aliasing -Wall -Wextra 
-Wshadow -Wconversion \
- -Wstrict-aliasing=2 -Wstrict-overflow=4 
-D_LIBCPP_BUILDING_LIBRARY "
-
-case $TRIPLE in
-  *-apple-*)
-if [ -z $RC_XBS ]
-then
-  RC_CFLAGS="-arch i386 -arch x86_64"
-fi
-SOEXT=dylib
-if [ "$MACOSX_DEPLOYMENT_TARGET" = "10.6" ]
-then
-EXTRA_FLAGS="-nostdinc++ -std=c++11 -U__STRICT_ANSI__"
-LDSHARED_FLAGS="-o libc++.1.dylib \
--dynamiclib -nodefaultlibs -current_version 1 \
--compatibility_version 1 \
--install_name /usr/lib/libc++.1.dylib \
--Wl,-reexport_library,/usr/lib/libc++abi.dylib \
--Wl,-unexported_symbols_list,libc++unexp.exp  \
-/usr/lib/libSystem.B.dylib"
-else
-if [ -n "$SDKROOT" ]
-then
-EXTRA_FLAGS+="-isysroot ${SDKROOT} "
-if echo "${RC_ARCHS}" | grep -q "armv7"  
-then
-RE_EXPORT_LINE="${SDKROOT}/usr/lib/libc++abi.dylib 
-Wl,-reexported_symbols_list,libc++sjlj-abi.exp"
-else
-
RE_EXPORT_LINE="-Wl,-reexport_library,${SDKROOT}/usr/lib/libc++abi.dylib"
-fi
-CXX=`xcrun -sdk "${SDKROOT}"  -find clang++`
-CC=`xcrun -sdk "${SDKROOT}"  -find clang`
-else
-# Check if we have _LIBCPPABI_VERSION, to determine the reexport 
list to use.
-if (echo "#include " | $CXX -E -dM -x c++ - | \
-grep _LIBCPPABI_VERSION > /dev/null)
-then
-RE_EXPORT_LINE="/usr/lib/libc++abi.dylib 
-Wl,-reexported_symbols_list,libc++abi2.exp"
-else
-RE_EXPORT_LINE="/usr/lib/libc++abi.dylib 
-Wl,-reexported_symbols_list,libc++abi.exp"
-fi
-fi
-LDSHARED_FLAGS="-o libc++.1.dylib \
--dynamiclib -nodefaultlibs  \
--current_version ${RC_ProjectSourceVersion} \
--compatibility_version 1 \
--install_name /usr/lib/libc++.1.dylib \
--lSystem  \
--Wl,-unexported_symbols_list,libc++unexp.exp  \
-${RE_EXPORT_LINE}  \
--Wl,-force_symbols_not_weak_list,notweak.exp \
--Wl,-force_symbols_weak_list,weak.exp"
-fi
-;;
-  *-*-mingw*)
-# FIXME: removing libgcc and libsupc++ dependencies means porting libcxxrt 
and LLVM/compiler-rt
-SOEXT=dll
-LDSHARED_FLAGS="-o libc++.dll \
--shared -nodefaultlibs -Wl,--export-all-symbols 
-Wl,--allow-multiple-definition -Wl,--out-implib,libc++.dll.a \
--lsupc++ -lpthread -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex 
-lmsvcr100 -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc 
-lmoldname -lmingwex -lmsvcrt"
-;;
-  *-ibm-*)
-hostOS=`uname`
-hostOS=`echo $hostOS | sed -e "s/\s+$//"`
-hostOS=`echo $hostOS | tr '[A-Z]' '[a-z]'`
-
-if [ $hostOS = "linux" ]
-then
-  LDSHARED_FLAGS="-o libc++.so.1 \
--qmkshrobj -Wl,-soname,libc++.so.1 \
--lpthread -lrt -lc -lstdc++"
-  EXTRA_FLAGS="-qlanglvl=extended0x -D__GLIBCXX__=1"
-else
-  LDSHARED_FLAGS="-o shr.o -qmkshrobj -lpthread -bnoquiet"
-  EXTRA_FLAGS="-qlanglvl=extended0x"
-fi
-RC_CFLAGS="-qpic=large"
-;;
-  *)
-RC_CFLAGS="-fPIC"
-SOEXT=so
-LDSHARED_FLAGS="-o libc++.so.1.0 \
--shared -nodefaultlibs -Wl,-soname,libc++.so.1 \
--lpthread -lrt -lc -lstdc++"
-;;
-esac
-
-if [ -z "$RC_XBS" ]
-then
-rm 

[PATCH] D30489: [analyzer] catch out of bounds for VLA

2017-03-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In https://reviews.llvm.org/D30489#691475, @danielmarjamaki wrote:

> Do you agree that this is the problem? Would it be a good idea to try to keep 
> the sz in the ProgramState?


Environment stores values only temporarily. It's kind of a scratch pad for 
temporary symbolic calculations: we compute sub-expressions, put them in the 
Environment, compute the expression itself, then throw the sub-expressions away 
immediately. Store, on the other hand, is a permanent storage.

Also, in your state dumps no information is actually lost. The fact that the 
value of variable `sz` is `reg_$0` is trivial: you could ask the Store 
what's the value of the variable `sz` and it'd say `reg_$0` if there are no 
bindings over it.

Or, alternatively, you see the same value in the dump of the ElementRegion as 
its index.

P.S. I'd agree that it's better to merge the two versions of the checker than 
trying to fix one of them to be at least as good as the other, through 
different approaches.


Repository:
  rL LLVM

https://reviews.llvm.org/D30489



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


[libcxx] r296919 - Fix hash requirements check in __hash_table.

2017-03-03 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Mar  3 16:35:58 2017
New Revision: 296919

URL: http://llvm.org/viewvc/llvm-project?rev=296919=rev
Log:
Fix hash requirements check in __hash_table.

r296565 attempted to add better diagnostics when an unordered container
is instantiated with a hash that doesn't meet the Hash requirements.

However I mistakenly checked the wrong set of requirements. Specifically
it checked if the hash met the requirements for specializations of
std::hash. However these requirements are stricter than the generic
Hash requirements.

This patch fixes the assertions to only check the Hash requirements.

Modified:
libcxx/trunk/include/__hash_table
libcxx/trunk/include/utility

libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp

Modified: libcxx/trunk/include/__hash_table
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=296919=296918=296919=diff
==
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Fri Mar  3 16:35:58 2017
@@ -871,16 +871,15 @@ public:
 template 
 struct __diagnose_hash_table_helper {
   static constexpr bool __trigger_diagnostics()
-_LIBCPP_DIAGNOSE_WARNING(__has_enabled_hash<_Key, _Hash>::value
+_LIBCPP_DIAGNOSE_WARNING(__check_hash_requirements<_Key, _Hash>::value
  && !__invokable<_Hash const&, _Key const&>::value,
   "the specified hash functor does not provide a const call operator")
 _LIBCPP_DIAGNOSE_WARNING(is_copy_constructible<_Equal>::value
   && !__invokable<_Equal const&, _Key const&, _Key 
const&>::value,
   "the specified comparator type does not provide a const call operator")
   {
-static_assert(__has_enabled_hash<_Key, _Hash>::value,
-  "the specified hash functor does not meet the requirements for an "
-  "enabled hash");
+static_assert(__check_hash_requirements<_Key, _Hash>::value,
+  "the specified hash does not meet the Hash requirements");
 static_assert(is_copy_constructible<_Equal>::value,
   "the specified comparator is required to be copy constructible");
 return true;

Modified: libcxx/trunk/include/utility
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=296919=296918=296919=diff
==
--- libcxx/trunk/include/utility (original)
+++ libcxx/trunk/include/utility Fri Mar  3 16:35:58 2017
@@ -1560,14 +1560,19 @@ struct _LIBCPP_TEMPLATE_VIS hash >
-using __has_enabled_hash = integral_constant::value &&
+template 
+using __check_hash_requirements = integral_constant::value &&
 is_move_constructible<_Hash>::value &&
 __invokable_r::value
 >;
 
+template  >
+using __has_enabled_hash = integral_constant::value &&
+is_default_constructible<_Hash>::value
+>;
+
 #if _LIBCPP_STD_VER > 14
 template 
 using __enable_hash_helper_imp = _Type;

Modified: 
libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp?rev=296919=296918=296919=diff
==
--- 
libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp
 Fri Mar  3 16:35:58 2017
@@ -23,14 +23,48 @@
 #include 
 
 using VT = std::pair;
-using Set = std::unordered_set;
+
+struct BadHashNoCopy {
+  BadHashNoCopy() = default;
+  BadHashNoCopy(BadHashNoCopy const&) = delete;
+
+  template 
+  size_t operator()(T const&) const { return 0; }
+};
+
+struct BadHashNoCall {
+
+};
+
+
+struct GoodHashNoDefault {
+  explicit GoodHashNoDefault(void*) {}
+  template 
+  size_t operator()(T const&) const { return 0; }
+};
 
 int main() {
 
-  Set s; // expected-error@__hash_table:* {{the specified hash functor does 
not meet the requirements for an enabled hash}}
+  {
+using Set = std::unordered_set;
+Set s; // expected-error@__hash_table:* {{the specified hash does not meet 
the Hash requirements}}
+
 
   // FIXME: It would be great to suppress the below diagnostic all together.
   //but for now it's sufficient that it appears last. However there is
   //currently no way to test the order diagnostics are issued.
   // expected-error@memory:* {{call to implicitly-deleted default constructor 
of 'std::__1::hash >'}}
+  }
+  {
+using Set = std::unordered_set;
+Set s; // expected-error@__hash_table:* {{the specified hash does not 

[PATCH] D30341: [analyzer] clarify error messages about uninitialized function arguments

2017-03-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

The code looks good to me, but i'm expressing a tiny doubt: regardless of the 
output format, the user always has the relevant argument highlighted anyway 
(column number, tilde-underlined in command line, blue-ish box in scan-build, 
etc.), so the only significant clarification i see is on test files, where the 
column is not obvious.

If having that information duplicated to the warning message is considered 
useful (easier to read, catchy), i'm ok with it :)

The definitive document on this debate is 
https://clang.llvm.org/diagnostics.html : it begins with explicitly encouraging 
highlights through column numbers and underlines, but it doesn't provide an 
opinion on including this info in the warning message. So i'm confused.


Repository:
  rL LLVM

https://reviews.llvm.org/D30341



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


[PATCH] D30589: [ExprInspectionChecker] Improve usability for C

2017-03-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Thanks! This bugged me as well, but i didn't think of this trick :)


https://reviews.llvm.org/D30589



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


[PATCH] D30015: Add arch-specific directory to search path

2017-03-03 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama marked an inline comment as done.
pirama added inline comments.



Comment at: lib/Driver/Tools.cpp:2007-2009
+  // In the cross-compilation case, arch-specific library path is likely
+  // unavailable at runtime.
+  if (TC.isCrossCompiling()) return;

rnk wrote:
> This seems like a really poor heuristic for "will the user ship this binary 
> to another computer that doesn't have clang installed in the same location", 
> but the convenience of not having to add clang's unpredictably named resource 
> library directory to LD_LIBRARY_PATH seems worth baking in a possibly-wrong 
> rpath.
This is indeed poor, but a good check that omits rpath when it is definitely 
useless but leave it in case it might be useful.


https://reviews.llvm.org/D30015



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


[PATCH] D30239: enable -flto=thin in clang-cl

2017-03-03 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

In https://reviews.llvm.org/D30239#691972, @rnk wrote:

> Do you guys think that maybe -flto should imply -fuse-ld=lld, or is that too 
> much magic?


I don't know enough about windows, but I would think it may be surprising for a 
user that -flto changes the linker behind his back?

I'm biased but as a user I rather have to opt-in instead of the compiler doing 
stuff without me knowing about it.


Repository:
  rL LLVM

https://reviews.llvm.org/D30239



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


[PATCH] D30015: Add arch-specific directory to search path

2017-03-03 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 90532.
pirama edited the summary of this revision.
pirama added a comment.

Fixed comment in test and added a test for -fsanitize=address without 
-shared-libasan.


https://reviews.llvm.org/D30015

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/Tools.cpp
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i386/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/.keep
  test/Driver/arch-specific-libdir-rpath.c
  test/Driver/arch-specific-libdir.c
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -392,6 +392,10 @@
 if config.host_triple == config.target_triple:
 config.available_features.add("native")
 
+# Test Driver/arch-specific-libdir-rpath.c is restricted to x86_64-linux
+if re.match(r'^x86_64.*-linux', config.target_triple):
+config.available_features.add("x86_64-linux")
+
 # Case-insensitive file system
 def is_filesystem_case_insensitive():
 handle, path = tempfile.mkstemp(prefix='case-test', dir=config.test_exec_root)
Index: test/Driver/arch-specific-libdir.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir.c
@@ -0,0 +1,53 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the search path.
+//
+// RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,ARCHDIR-i386 %s
+//
+// RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,ARCHDIR-i386 %s
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,ARCHDIR-x86_64 %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,ARCHDIR-arm %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,ARCHDIR-aarch64 %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,NO-ARCHDIR %s
+//
+//
+// FILEPATH: "-x" "c" "[[FILE_PATH:.*]]/{{.*}}.c"
+// ARCHDIR-i386:-L[[FILE_PATH]]/Inputs/resource_dir_with_arch_subdir/lib/linux/i386
+// ARCHDIR-x86_64:  -L[[FILE_PATH]]/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64
+// ARCHDIR-arm: -L[[FILE_PATH]]/Inputs/resource_dir_with_arch_subdir/lib/linux/arm
+// ARCHDIR-aarch64: -L[[FILE_PATH]]/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64
+//
+// Have a stricter check for no-archdir - that the driver doesn't add any
+// subdirectory from the provided resource directory.
+// NO-ARCHDIR-NOT: -L[[FILE_PATH]]/Inputs/resource_dir
Index: test/Driver/arch-specific-libdir-rpath.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir-rpath.c
@@ -0,0 +1,50 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' for native
+// compilations.
+//
+// -rpath only gets added during native compilation.  To keep the test simple,
+// just test for x86_64-linux native compilation.
+// REQUIRES: x86_64-linux
+//
+// Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan
+// RUN: %clang %s -### 2>&1 -fsanitize=undefined \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefixes=FILEPATH,LIBPATH,NO-RPATH %s
+//
+// Add LIBPATH, RPATH for -fsanitize=address -shared-libasan
+// RUN: %clang %s -### 2>&1 -target x86_64-linux \
+// RUN: 

[PATCH] D30592: [clang-tidy] Fix diag message for catch-by-value

2017-03-03 Thread Florian Gross via Phabricator via cfe-commits
fgross created this revision.
Herald added a subscriber: JDevlieghere.

  catch (std::exception ex)
  {
  }

Was flagged with "catch handler catches a pointer value".


https://reviews.llvm.org/D30592

Files:
  clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp


Index: clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
===
--- clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
+++ clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
@@ -131,22 +131,24 @@
 
 void ThrowByValueCatchByReferenceCheck::diagnoseCatchLocations(
 const CXXCatchStmt *catchStmt, ASTContext ) {
-  const char *diagMsgCatchReference = "catch handler catches a pointer value; "
-  "should throw a non-pointer value and "
-  "catch by reference instead";
   if (!catchStmt)
 return;
   auto caughtType = catchStmt->getCaughtType();
   if (caughtType.isNull())
 return;
   auto *varDecl = catchStmt->getExceptionDecl();
   if (const auto *PT = caughtType.getCanonicalType()->getAs()) {
+const char *diagMsgCatchReference = "catch handler catches a pointer 
value; "
+"should throw a non-pointer value and "
+"catch by reference instead";
 // We do not diagnose when catching pointer to strings since we also allow
 // throwing string literals.
 if (!PT->getPointeeType()->isAnyCharacterType())
   diag(varDecl->getLocStart(), diagMsgCatchReference);
   } else if (!caughtType->isReferenceType()) {
-// If it's not a pointer and not a reference then it must be thrown "by
+const char *diagMsgCatchReference = "catch handler catches by value; "
+"should catch by reference instead";
+// If it's not a pointer and not a reference then it must be caught "by
 // value". In this case we should emit a diagnosis message unless the type
 // is trivial.
 if (!caughtType.isTrivialType(context))


Index: clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
===
--- clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
+++ clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
@@ -131,22 +131,24 @@
 
 void ThrowByValueCatchByReferenceCheck::diagnoseCatchLocations(
 const CXXCatchStmt *catchStmt, ASTContext ) {
-  const char *diagMsgCatchReference = "catch handler catches a pointer value; "
-  "should throw a non-pointer value and "
-  "catch by reference instead";
   if (!catchStmt)
 return;
   auto caughtType = catchStmt->getCaughtType();
   if (caughtType.isNull())
 return;
   auto *varDecl = catchStmt->getExceptionDecl();
   if (const auto *PT = caughtType.getCanonicalType()->getAs()) {
+const char *diagMsgCatchReference = "catch handler catches a pointer value; "
+"should throw a non-pointer value and "
+"catch by reference instead";
 // We do not diagnose when catching pointer to strings since we also allow
 // throwing string literals.
 if (!PT->getPointeeType()->isAnyCharacterType())
   diag(varDecl->getLocStart(), diagMsgCatchReference);
   } else if (!caughtType->isReferenceType()) {
-// If it's not a pointer and not a reference then it must be thrown "by
+const char *diagMsgCatchReference = "catch handler catches by value; "
+"should catch by reference instead";
+// If it's not a pointer and not a reference then it must be caught "by
 // value". In this case we should emit a diagnosis message unless the type
 // is trivial.
 if (!caughtType.isTrivialType(context))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30239: enable -flto=thin in clang-cl

2017-03-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Do you guys think that maybe -flto should imply -fuse-ld=lld, or is that too 
much magic?


Repository:
  rL LLVM

https://reviews.llvm.org/D30239



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


[PATCH] D30015: Add arch-specific directory to search path

2017-03-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.

Looks good with a minor comment about a comment in the test case.




Comment at: lib/Driver/Tools.cpp:2007-2009
+  // In the cross-compilation case, arch-specific library path is likely
+  // unavailable at runtime.
+  if (TC.isCrossCompiling()) return;

This seems like a really poor heuristic for "will the user ship this binary to 
another computer that doesn't have clang installed in the same location", but 
the convenience of not having to add clang's unpredictably named resource 
library directory to LD_LIBRARY_PATH seems worth baking in a possibly-wrong 
rpath.



Comment at: test/Driver/arch-specific-libdir-rpath.c:9
+//
+// Add LIBPATH but no RPATH for -fsanitize=address
+// RUN: %clang %s -### 2>&1 -target x86_64-linux \

This comment seems wrong, with -shared-libasan we add it to rpath. It's really, 
only add rpath if we are using shared libraries.


https://reviews.llvm.org/D30015



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


[PATCH] D30591: Introduce the feature "linux" for tests only for linux

2017-03-03 Thread Taewook Oh via Phabricator via cfe-commits
twoh created this revision.

This feature is needed to re-enable https://reviews.llvm.org/rL293004, which 
resembles gcc's behavior in
finding the input file name from a preprocessed source. The patch has been
reverted in https://reviews.llvm.org/rL293032, because the test checks FILE 
symbol of ELF file, which is
not valid on OSes not using ELF. With the patch, we can add "REQUIRES: linux"
to the tests on ELF files, or tests that require any linux-specific features.


https://reviews.llvm.org/D30591

Files:
  test/lit.cfg


Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -427,6 +427,10 @@
 if not re.match(r'.*-(cygwin)$', config.target_triple):
 config.available_features.add('clang-driver')
 
+# Set on linux environment
+if re.match(r'.*-linux', config.target_triple):
+config.available_features.add("linux")
+
 # [PR18856] Depends to remove opened file. On win32, a file could be removed
 # only if all handles were closed.
 if platform.system() not in ['Windows']:


Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -427,6 +427,10 @@
 if not re.match(r'.*-(cygwin)$', config.target_triple):
 config.available_features.add('clang-driver')
 
+# Set on linux environment
+if re.match(r'.*-linux', config.target_triple):
+config.available_features.add("linux")
+
 # [PR18856] Depends to remove opened file. On win32, a file could be removed
 # only if all handles were closed.
 if platform.system() not in ['Windows']:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28543: Eliminates uninitialized warning for volatile variables.

2017-03-03 Thread CJ DiMeglio via Phabricator via cfe-commits
lethalantidote added a comment.

Is there any subgroup that one could suggest for this warning to fall under?


https://reviews.llvm.org/D28543



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


[PATCH] D30590: Don't assume cleanup emission preserves dominance in expr evaluation

2017-03-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.

Because of the existence branches out of GNU statement expressions, it
is possible that emitting cleanups for a full expression may cause the
new insertion point to not be dominated by the result of the inner
expression. Consider this example:

  struct Foo { Foo(); ~Foo(); int x; };
  int g(Foo, int);
  int f(bool cond) {
int n = g(Foo(), ({ if (cond) return 0; 42; }));
return n;
  }

Before this change, result of the call to 'g' did not dominate its use
in the store to 'n'. The early return exit from the statement expression
branches to a shared cleanup block, which ends in a switch between the
fallthrough destination (the assignment to 'n') or the function exit
block.

This change solves the problem by spilling and reloading expression
evaluation results when any of the active cleanups have branches.

I audited the other call sites of enterFullExpression, and they don't
appear to keep and Values live across the site of the cleanup, except in
ARC code. I wasn't able to create a test case for ARC that exhibits this
problem, though.


https://reviews.llvm.org/D30590

Files:
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenCXX/stmtexpr.cpp

Index: test/CodeGenCXX/stmtexpr.cpp
===
--- test/CodeGenCXX/stmtexpr.cpp
+++ test/CodeGenCXX/stmtexpr.cpp
@@ -80,3 +80,64 @@
   y = ({ A a(1); if (b) goto G; a.i; });
   G: return y;
 }
+
+// When we emit a full expression with cleanups that contains branches out of
+// the full expression, the result of the inner expression (the call to
+// call_with_cleanups in this case) may not dominate the fallthrough destination
+// of the shared cleanup block.
+//
+// In this case the CFG will be a sequence of two diamonds, but the only
+// dynamically possible execution paths are both left hand branches and both
+// right hand branches. The first diamond LHS will call bar, and the second
+// diamond LHS will assign the result to v, but the call to bar does not
+// dominate the assignment.
+int bar(A, int);
+extern "C" int full_expr_branch(bool b) {
+  int v = bar(A(1), ({ if (b) return 42; 13; }));
+  return v;
+}
+
+// CHECK-LABEL: define i32 @full_expr_branch({{.*}})
+// CHECK: call {{.*}} @_ZN1AC1Ei
+//Spill after bar.
+// CHECK: %[[v:[^ ]*]] = call i32 @_Z3bar1Ai({{.*}})
+// CHECK-NEXT: store i32 %[[v]], i32* %[[tmp:[^, ]*]]
+//Do cleanup.
+// CHECK: call {{.*}} @_ZN1AD1Ev
+// CHECK: switch
+//Reload before v assignment.
+// CHECK: %[[v:[^ ]*]] = load i32, i32* %[[tmp]]
+// CHECK-NEXT: store i32 %[[v]], i32* %v
+
+// We handle ExprWithCleanups for complex evaluation type separately, and it had
+// the same bug.
+_Complex float bar_complex(A, int);
+extern "C" int full_expr_branch_complex(bool b) {
+  _Complex float v = bar_complex(A(1), ({ if (b) return 42; 13; }));
+  return v;
+}
+
+// CHECK-LABEL: define i32 @full_expr_branch_complex({{.*}})
+// CHECK: call {{.*}} @_ZN1AC1Ei
+//Spill after bar.
+// CHECK: call {{.*}} @_Z11bar_complex1Ai({{.*}})
+// CHECK: store float %{{.*}}, float* %[[tmp1:[^, ]*]]
+// CHECK: store float %{{.*}}, float* %[[tmp2:[^, ]*]]
+//Do cleanup.
+// CHECK: call {{.*}} @_ZN1AD1Ev
+// CHECK: switch
+//Reload before v assignment.
+// CHECK: %[[v1:[^ ]*]] = load float, float* %[[tmp1]]
+// CHECK: %[[v2:[^ ]*]] = load float, float* %[[tmp2]]
+// CHECK: store float %[[v1]], float* %v.realp
+// CHECK: store float %[[v2]], float* %v.imagp
+
+// No need to spill when the expression result is a constant, constants don't
+// have dominance problems.
+extern "C" int full_expr_branch_constant(bool b) {
+  int v = (A(1), (void)({ if (b) return 42; 0; }), 13);
+  return v;
+}
+
+// CHECK-LABEL: define i32 @full_expr_branch_constant({{.*}})
+// CHECK: store i32 13, i32* %v
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -536,6 +536,7 @@
   protected:
 bool PerformCleanup;
   private:
+SmallVector ValuesToReload;
 
 RunCleanupsScope(const RunCleanupsScope &) = delete;
 void operator=(const RunCleanupsScope &) = delete;
@@ -555,28 +556,33 @@
   CGF.DidCallStackSave = false;
 }
 
-/// \brief Exit this cleanup scope, emitting any accumulated
-/// cleanups.
+/// \brief Exit this cleanup scope, emitting any accumulated cleanups.
 ~RunCleanupsScope() {
-  if (PerformCleanup) {
-CGF.DidCallStackSave = OldDidCallStackSave;
-CGF.PopCleanupBlocks(CleanupStackDepth,
- LifetimeExtendedCleanupStackSize);
-  }
+  if (PerformCleanup)
+ForceCleanup();
 }
 
 /// \brief Determine whether this scope requires any cleanups.
 bool requiresCleanups() const {
   return CGF.EHStack.stable_begin() != CleanupStackDepth;
 }
 
+/// 

[PATCH] D30589: [ExprInspectionChecker] Improve usability for C

2017-03-03 Thread Keno Fischer via Phabricator via cfe-commits
loladiro created this revision.

Some of the magic functions take arguments of arbitrary type. However,
for semantic correctness, the compiler still requires a declaration
of these functions with the correct type. Since C does not have
argument-type-overloaded function, this made those functions hard to
use in C code. Improve this situation by allowing arbitrary suffixes
in the affected magic functions' names, thus allowing the user to
create different declarations for different types.


https://reviews.llvm.org/D30589

Files:
  docs/analyzer/DebugChecks.rst
  lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  test/Analysis/explain-svals.c


Index: test/Analysis/explain-svals.c
===
--- /dev/null
+++ test/Analysis/explain-svals.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze 
-analyzer-checker=core.builtin,debug.ExprInspection,unix.cstring -verify %s
+
+struct S {
+  int z;
+};
+
+void clang_analyzer_explain_int(int);
+void clang_analyzer_explain_voidp(void *);
+void clang_analyzer_explain_S(struct S);
+
+int glob;
+
+void test_1(int param, void *ptr) {
+  clang_analyzer_explain_voidp(); // expected-warning-re^pointer to 
global variable 'glob'$
+  clang_analyzer_explain_int(param);   // expected-warning-re^argument 
'param'$
+  clang_analyzer_explain_voidp(ptr);   // expected-warning-re^argument 
'ptr'$
+  if (param == 42)
+clang_analyzer_explain_int(param); // expected-warning-re^signed 
32-bit integer '42'$
+}
+
+void test_2(struct S s) {
+  clang_analyzer_explain_S(s);  //expected-warning-re^lazily frozen 
compound value of parameter 's'$
+  clang_analyzer_explain_voidp(); // expected-warning-re^pointer to 
parameter 's'$
+  clang_analyzer_explain_int(s.z);  // expected-warning-re^initial value 
of field 'z' of parameter 's'$
+}
Index: lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
+++ lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
@@ -72,8 +72,8 @@
   ::analyzerWarnIfReached)
 .Case("clang_analyzer_warnOnDeadSymbol",
   ::analyzerWarnOnDeadSymbol)
-.Case("clang_analyzer_explain", ::analyzerExplain)
-.Case("clang_analyzer_dump", ::analyzerDump)
+.StartsWith("clang_analyzer_explain", 
::analyzerExplain)
+.StartsWith("clang_analyzer_dump", ::analyzerDump)
 .Case("clang_analyzer_getExtent", 
::analyzerGetExtent)
 .Case("clang_analyzer_printState",
   ::analyzerPrintState)
Index: docs/analyzer/DebugChecks.rst
===
--- docs/analyzer/DebugChecks.rst
+++ docs/analyzer/DebugChecks.rst
@@ -178,15 +178,21 @@
   This function explains the value of its argument in a human-readable manner
   in the warning message. You can make as many overrides of its prototype
   in the test code as necessary to explain various integral, pointer,
-  or even record-type values.
+  or even record-type values. To simplify usage in C code (where overloading
+  the function declaration is not allowed), you may append an arbitrary suffix
+  to the function name, without affecting functionality.
 
   Example usage::
 
 void clang_analyzer_explain(int);
 void clang_analyzer_explain(void *);
 
+// Useful in C code
+void clang_analyzer_explain_int(int);
+
 void foo(int param, void *ptr) {
   clang_analyzer_explain(param); // expected-warning{{argument 'param'}}
+  clang_analyzer_explain_int(param); // expected-warning{{argument 
'param'}}
   if (!ptr)
 clang_analyzer_explain(ptr); // expected-warning{{memory address '0'}}
 }


Index: test/Analysis/explain-svals.c
===
--- /dev/null
+++ test/Analysis/explain-svals.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core.builtin,debug.ExprInspection,unix.cstring -verify %s
+
+struct S {
+  int z;
+};
+
+void clang_analyzer_explain_int(int);
+void clang_analyzer_explain_voidp(void *);
+void clang_analyzer_explain_S(struct S);
+
+int glob;
+
+void test_1(int param, void *ptr) {
+  clang_analyzer_explain_voidp(); // expected-warning-re^pointer to global variable 'glob'$
+  clang_analyzer_explain_int(param);   // expected-warning-re^argument 'param'$
+  clang_analyzer_explain_voidp(ptr);   // expected-warning-re^argument 'ptr'$
+  if (param == 42)
+clang_analyzer_explain_int(param); // expected-warning-re^signed 32-bit integer '42'$
+}
+
+void test_2(struct S s) {
+  clang_analyzer_explain_S(s);  //expected-warning-re^lazily frozen compound value of parameter 's'$
+  clang_analyzer_explain_voidp(); // expected-warning-re^pointer to parameter 's'$
+  clang_analyzer_explain_int(s.z);  // 

[PATCH] D27387: [libc++] Add a key function for bad_function_call

2017-03-03 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai updated this revision to Diff 90524.
smeenai added a comment.

Address comments


https://reviews.llvm.org/D27387

Files:
  include/__config
  include/functional
  lib/CMakeLists.txt
  src/functional.cpp


Index: src/functional.cpp
===
--- /dev/null
+++ src/functional.cpp
@@ -0,0 +1,26 @@
+//===--- functional.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 "functional"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+bad_function_call::~bad_function_call() _NOEXCEPT
+{
+}
+
+const char*
+bad_function_call::what() const _NOEXCEPT
+{
+return "std::bad_function_call";
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -178,7 +178,7 @@
 split_list(LIBCXX_COMPILE_FLAGS)
 split_list(LIBCXX_LINK_FLAGS)
 
-# Add a object library that contains the compiled source files.
+# Add an object library that contains the compiled source files.
 add_library(cxx_objects OBJECT ${exclude_from_all} ${LIBCXX_SOURCES} 
${LIBCXX_HEADERS})
 if(WIN32 AND NOT MINGW)
   target_compile_definitions(cxx_objects
Index: include/functional
===
--- include/functional
+++ include/functional
@@ -1388,6 +1388,12 @@
 class _LIBCPP_EXCEPTION_ABI bad_function_call
 : public exception
 {
+#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+public:
+virtual ~bad_function_call() _NOEXCEPT;
+
+virtual const char* what() const _NOEXCEPT;
+#endif
 };
 
 _LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -59,6 +59,10 @@
 // `pointer_safety` and `get_pointer_safety()` will no longer be available
 // in C++03.
 #define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
+// Define a key function for `bad_function_call` in the library, to centralize
+// its vtable and typeinfo to libc++ rather than having all other libraries
+// using that class define their own copies.
+#define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
 #elif _LIBCPP_ABI_VERSION == 1
 #if !defined(_WIN32)
 // Enable compiling copies of now inline methods into the dylib to support


Index: src/functional.cpp
===
--- /dev/null
+++ src/functional.cpp
@@ -0,0 +1,26 @@
+//===--- functional.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 "functional"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+bad_function_call::~bad_function_call() _NOEXCEPT
+{
+}
+
+const char*
+bad_function_call::what() const _NOEXCEPT
+{
+return "std::bad_function_call";
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -178,7 +178,7 @@
 split_list(LIBCXX_COMPILE_FLAGS)
 split_list(LIBCXX_LINK_FLAGS)
 
-# Add a object library that contains the compiled source files.
+# Add an object library that contains the compiled source files.
 add_library(cxx_objects OBJECT ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
 if(WIN32 AND NOT MINGW)
   target_compile_definitions(cxx_objects
Index: include/functional
===
--- include/functional
+++ include/functional
@@ -1388,6 +1388,12 @@
 class _LIBCPP_EXCEPTION_ABI bad_function_call
 : public exception
 {
+#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+public:
+virtual ~bad_function_call() _NOEXCEPT;
+
+virtual const char* what() const _NOEXCEPT;
+#endif
 };
 
 _LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -59,6 +59,10 @@
 // `pointer_safety` and `get_pointer_safety()` will no longer be available
 // in C++03.
 #define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
+// Define a key function for `bad_function_call` in the library, to centralize
+// its vtable and typeinfo to libc++ rather than having all other libraries
+// using that class define their own copies.
+#define 

Re: [libcxx] r296840 - Work around test failure on 32 bit OS X

2017-03-03 Thread Adrian Prantl via cfe-commits
Does that mean there is a bug in libcxx that should be documented somewhere?

-- adrian
> On Mar 2, 2017, at 3:18 PM, Eric Fiselier via cfe-commits 
>  wrote:
> 
> Author: ericwf
> Date: Thu Mar  2 17:18:40 2017
> New Revision: 296840
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=296840=rev
> Log:
> Work around test failure on 32 bit OS X
> 
> Modified:
>
> libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp
> 
> Modified: 
> libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp?rev=296840=296839=296840=diff
> ==
> --- 
> libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp
>  (original)
> +++ 
> libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp
>  Thu Mar  2 17:18:40 2017
> @@ -29,16 +29,22 @@ test(S s, typename S::size_type pos1, ty
>  SV sv, typename S::size_type pos2, typename S::size_type n2,
>  S expected)
> {
> +typedef typename S::size_type SizeT;
> static_assert((!std::is_same::value), "");
> -const typename S::size_type old_size = s.size();
> +
> +// String and string_view may not always share the same size type,
> +// but both types should have the same size (ex. int vs long)
> +static_assert(sizeof(SizeT) == sizeof(typename SV::size_type), "");
> +
> +const SizeT old_size = s.size();
> S s0 = s;
> if (pos1 <= old_size && pos2 <= sv.size())
> {
> s.replace(pos1, n1, sv, pos2, n2);
> LIBCPP_ASSERT(s.__invariants());
> assert(s == expected);
> -typename S::size_type xlen = std::min(n1, old_size - pos1);
> -typename S::size_type rlen = std::min(n2, sv.size() - pos2);
> +SizeT xlen = std::min(n1, old_size - pos1);
> +SizeT rlen = std::min(n2, sv.size() - pos2);
> assert(s.size() == old_size - xlen + rlen);
> }
> #ifndef TEST_HAS_NO_EXCEPTIONS
> @@ -64,16 +70,17 @@ test_npos(S s, typename S::size_type pos
>   SV sv, typename S::size_type pos2,
>   S expected)
> {
> +typedef typename S::size_type SizeT;
> static_assert((!std::is_same::value), "");
> -const typename S::size_type old_size = s.size();
> +const SizeT old_size = s.size();
> S s0 = s;
> if (pos1 <= old_size && pos2 <= sv.size())
> {
> s.replace(pos1, n1, sv, pos2);
> LIBCPP_ASSERT(s.__invariants());
> assert(s == expected);
> -typename S::size_type xlen = std::min(n1, old_size - pos1);
> -typename S::size_type rlen = std::min(S::npos, sv.size() - pos2);
> +SizeT xlen = std::min(n1, old_size - pos1);
> +SizeT rlen = std::min(S::npos, sv.size() - pos2);
> assert(s.size() == old_size - xlen + rlen);
> }
> #ifndef TEST_HAS_NO_EXCEPTIONS
> 
> 
> ___
> 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] D30551: [AMDGPU] Add builtin functions readlane ds_permute mov_dpp

2017-03-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 90520.
yaxunl marked 3 inline comments as done.
yaxunl added a comment.

remove redundant code.
make mov_dpp target builtin.


https://reviews.llvm.org/D30551

Files:
  include/clang/Basic/BuiltinsAMDGPU.def
  lib/Basic/Targets.cpp
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGenOpenCL/builtins-amdgcn-vi.cl
  test/CodeGenOpenCL/builtins-amdgcn.cl
  test/SemaOpenCL/builtins-amdgcn-error.cl

Index: test/SemaOpenCL/builtins-amdgcn-error.cl
===
--- test/SemaOpenCL/builtins-amdgcn-error.cl
+++ test/SemaOpenCL/builtins-amdgcn-error.cl
@@ -1,16 +1,17 @@
 // REQUIRES: amdgpu-registered-target
 // RUN: %clang_cc1 -triple amdgcn-- -target-cpu tahiti -verify -S -o - %s
 
-// FIXME: We only get one error if the functions are the other order in the
-// file.
-
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 typedef unsigned long ulong;
 typedef unsigned int uint;
 
-ulong test_s_memrealtime()
+// To get all errors for feature checking we need to put them in one function
+// since Clang will stop codegen for the next function if it finds error during
+// codegen of the previous function.
+void test_target_builtin(global int* out, int a)
 {
-  return __builtin_amdgcn_s_memrealtime(); // expected-error {{'__builtin_amdgcn_s_memrealtime' needs target feature s-memrealtime}}
+  __builtin_amdgcn_s_memrealtime(); // expected-error {{'__builtin_amdgcn_s_memrealtime' needs target feature s-memrealtime}}
+  *out = __builtin_amdgcn_mov_dpp(a, 0, 0, 0, false); // expected-error {{'__builtin_amdgcn_mov_dpp' needs target feature dpp}}
 }
 
 void test_s_sleep(int x)
@@ -92,3 +93,12 @@
 {
   *out = __builtin_amdgcn_s_getreg(a); // expected-error {{argument to '__builtin_amdgcn_s_getreg' must be a constant integer}}
 }
+
+void test_mov_dpp2(global int* out, int a, int b, int c, int d, bool e)
+{
+  *out = __builtin_amdgcn_mov_dpp(a, b, 0, 0, false); // expected-error {{argument to '__builtin_amdgcn_mov_dpp' must be a constant integer}}
+  *out = __builtin_amdgcn_mov_dpp(a, 0, c, 0, false); // expected-error {{argument to '__builtin_amdgcn_mov_dpp' must be a constant integer}}
+  *out = __builtin_amdgcn_mov_dpp(a, 0, 0, d, false); // expected-error {{argument to '__builtin_amdgcn_mov_dpp' must be a constant integer}}
+  *out = __builtin_amdgcn_mov_dpp(a, 0, 0, 0, e); // expected-error {{argument to '__builtin_amdgcn_mov_dpp' must be a constant integer}}
+}
+
Index: test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn.cl
+++ test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -235,6 +235,34 @@
   *out = __builtin_amdgcn_ds_swizzle(a, 32);
 }
 
+// CHECK-LABEL: @test_ds_permute
+// CHECK: call i32 @llvm.amdgcn.ds.permute(i32 %a, i32 %b)
+void test_ds_permute(global int* out, int a, int b)
+{
+  out[0] = __builtin_amdgcn_ds_permute(a, b);
+}
+
+// CHECK-LABEL: @test_ds_bpermute
+// CHECK: call i32 @llvm.amdgcn.ds.bpermute(i32 %a, i32 %b)
+void test_ds_bpermute(global int* out, int a, int b)
+{
+  *out = __builtin_amdgcn_ds_bpermute(a, b);
+}
+
+// CHECK-LABEL: @test_readfirstlane
+// CHECK: call i32 @llvm.amdgcn.readfirstlane(i32 %a)
+void test_readfirstlane(global int* out, int a)
+{
+  *out = __builtin_amdgcn_readfirstlane(a);
+}
+
+// CHECK-LABEL: @test_readlane
+// CHECK: call i32 @llvm.amdgcn.readlane(i32 %a, i32 %b)
+void test_readlane(global int* out, int a, int b)
+{
+  *out = __builtin_amdgcn_readlane(a, b);
+}
+
 // CHECK-LABEL: @test_fcmp_f32
 // CHECK: call i64 @llvm.amdgcn.fcmp.f32(float %a, float %b, i32 5)
 void test_fcmp_f32(global ulong* out, float a, float b)
Index: test/CodeGenOpenCL/builtins-amdgcn-vi.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn-vi.cl
+++ test/CodeGenOpenCL/builtins-amdgcn-vi.cl
@@ -81,3 +81,11 @@
 {
   *out = __builtin_amdgcn_s_memrealtime();
 }
+
+// CHECK-LABEL: @test_mov_dpp
+// CHECK: call i32 @llvm.amdgcn.mov.dpp.i32(i32 %src, i32 0, i32 0, i32 0, i1 false)
+void test_mov_dpp(global int* out, int src)
+{
+  *out = __builtin_amdgcn_mov_dpp(src, 0, 0, 0, false);
+}
+
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -8388,6 +8388,14 @@
 
   case AMDGPU::BI__builtin_amdgcn_ds_swizzle:
 return emitBinaryBuiltin(*this, E, Intrinsic::amdgcn_ds_swizzle);
+  case AMDGPU::BI__builtin_amdgcn_mov_dpp: {
+llvm::SmallVector Args;
+for (unsigned I = 0; I != 5; ++I)
+  Args.push_back(EmitScalarExpr(E->getArg(I)));
+Value *F = CGM.getIntrinsic(Intrinsic::amdgcn_mov_dpp,
+Args[0]->getType());
+return Builder.CreateCall(F, Args);
+  }
   case AMDGPU::BI__builtin_amdgcn_div_fixup:
   case AMDGPU::BI__builtin_amdgcn_div_fixupf:
   case AMDGPU::BI__builtin_amdgcn_div_fixuph:
Index: lib/Basic/Targets.cpp

[PATCH] D30565: [analyzer] Terminate analysis on OpenMP code instead of crashing

2017-03-03 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

@zaks.anna: What do you think? Should we try to get this into clang 4.0?


Repository:
  rL LLVM

https://reviews.llvm.org/D30565



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


[PATCH] D28297: [StaticAnalyzer] Fix crash in CastToStructChecker

2017-03-03 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

Thanks. looks good.


https://reviews.llvm.org/D28297



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


[libcxx] r296889 - Fix libc++ test to pass in C++03 mode

2017-03-03 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Fri Mar  3 11:24:29 2017
New Revision: 296889

URL: http://llvm.org/viewvc/llvm-project?rev=296889=rev
Log:
Fix libc++ test to pass in C++03 mode

Was hitting: "error: scalar initializer cannot be empty"

Modified:
libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp
libcxx/trunk/test/std/input.output/file.streams/c.files/cstdio.pass.cpp

Modified: libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp?rev=296889=296888=296889=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp Fri Mar  3 
11:24:29 2017
@@ -107,7 +107,7 @@
 int main()
 {
 FILE* fp = 0;
-fpos_t fpos = {};
+fpos_t fpos = fpos_t();
 size_t s = 0;
 char* cp = 0;
 char arr[] = {'a', 'b'};

Modified: 
libcxx/trunk/test/std/input.output/file.streams/c.files/cstdio.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/file.streams/c.files/cstdio.pass.cpp?rev=296889=296888=296889=diff
==
--- libcxx/trunk/test/std/input.output/file.streams/c.files/cstdio.pass.cpp 
(original)
+++ libcxx/trunk/test/std/input.output/file.streams/c.files/cstdio.pass.cpp Fri 
Mar  3 11:24:29 2017
@@ -89,7 +89,7 @@
 int main()
 {
 std::FILE* fp = 0;
-std::fpos_t fpos = {};
+std::fpos_t fpos = std::fpos_t();
 std::size_t s = 0;
 char* cp = 0;
 std::va_list va;


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


[clang-tools-extra] r296888 - [clang-tidy] Yet another docs fixes

2017-03-03 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Fri Mar  3 11:16:11 2017
New Revision: 296888

URL: http://llvm.org/viewvc/llvm-project?rev=296888=rev
Log:
[clang-tidy] Yet another docs fixes

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst?rev=296888=296887=296888=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst 
Fri Mar  3 11:16:11 2017
@@ -69,7 +69,7 @@ exception safe. In this case the calls o
 
 This is because replacing it with ``emplace_back`` could cause a leak of this
 pointer if ``emplace_back`` would throw exception before emplacement (e.g. not
-enough memory to add new element).
+enough memory to add a new element).
 
 For more info read item 42 - "Consider emplacement instead of insertion." of
 Scott Meyers "Effective Modern C++".
@@ -79,14 +79,15 @@ The default smart pointers that are cons
 other classes use the :option:`SmartPointers` option.
 
 
-Check also fires if any argument of constructor call would be:
+Check also doesn't fire if any argument of the constructor call would be:
 
-  - bitfield (bitfields can't bind to rvalue/universal reference)
+  - a bit-field (bit-fields can't bind to rvalue/universal reference)
 
-  - ``new`` expression (to avoid leak) or if the argument would be converted 
via
-derived-to-base cast.
+  - a ``new`` expression (to avoid leak)
 
-This check requires C++11 of higher to run.
+  - if the argument would be converted via derived-to-base cast.
+
+This check requires C++11 or higher to run.
 
 Options
 ---


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


[PATCH] D30565: [analyzer] Terminate analysis on OpenMP code instead of crashing

2017-03-03 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Thank you Devin. Should we submit this to 4.0? I guess there are not many users 
of both CSA and OpenMP but PR you pointed is already the second report about 
this issue I see.


Repository:
  rL LLVM

https://reviews.llvm.org/D30565



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


[PATCH] D30565: [analyzer] Terminate analysis on OpenMP code instead of crashing

2017-03-03 Thread Aleksei Sidorin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296884: [Analyzer] Terminate analysis on OpenMP code instead 
of assertion crash (authored by a.sidorin).

Changed prior to commit:
  https://reviews.llvm.org/D30565?vs=90441=90499#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30565

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
  cfe/trunk/test/Analysis/openmp-unsupported.c


Index: cfe/trunk/test/Analysis/openmp-unsupported.c
===
--- cfe/trunk/test/Analysis/openmp-unsupported.c
+++ cfe/trunk/test/Analysis/openmp-unsupported.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze 
-analyzer-checker=core.builtin -fopenmp -verify %s
+// expected-no-diagnostics
+
+void openmp_parallel_crash_test() {
+#pragma omp parallel
+  ;
+}
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -777,7 +777,7 @@
   assert(!isa(S) || S == cast(S)->IgnoreParens());
 
   switch (S->getStmtClass()) {
-// C++ and ARC stuff we don't support yet.
+// C++, OpenMP and ARC stuff we don't support yet.
 case Expr::ObjCIndirectCopyRestoreExprClass:
 case Stmt::CXXDependentScopeMemberExprClass:
 case Stmt::CXXInheritedCtorInitExprClass:
@@ -805,36 +805,7 @@
 case Stmt::SEHTryStmtClass:
 case Stmt::SEHExceptStmtClass:
 case Stmt::SEHLeaveStmtClass:
-case Stmt::SEHFinallyStmtClass: {
-  const ExplodedNode *node = Bldr.generateSink(S, Pred, Pred->getState());
-  Engine.addAbortedBlock(node, currBldrCtx->getBlock());
-  break;
-}
-
-case Stmt::ParenExprClass:
-  llvm_unreachable("ParenExprs already handled.");
-case Stmt::GenericSelectionExprClass:
-  llvm_unreachable("GenericSelectionExprs already handled.");
-// Cases that should never be evaluated simply because they shouldn't
-// appear in the CFG.
-case Stmt::BreakStmtClass:
-case Stmt::CaseStmtClass:
-case Stmt::CompoundStmtClass:
-case Stmt::ContinueStmtClass:
-case Stmt::CXXForRangeStmtClass:
-case Stmt::DefaultStmtClass:
-case Stmt::DoStmtClass:
-case Stmt::ForStmtClass:
-case Stmt::GotoStmtClass:
-case Stmt::IfStmtClass:
-case Stmt::IndirectGotoStmtClass:
-case Stmt::LabelStmtClass:
-case Stmt::NoStmtClass:
-case Stmt::NullStmtClass:
-case Stmt::SwitchStmtClass:
-case Stmt::WhileStmtClass:
-case Expr::MSDependentExistsStmtClass:
-case Stmt::CapturedStmtClass:
+case Stmt::SEHFinallyStmtClass:
 case Stmt::OMPParallelDirectiveClass:
 case Stmt::OMPSimdDirectiveClass:
 case Stmt::OMPForDirectiveClass:
@@ -882,6 +853,36 @@
 case Stmt::OMPTargetTeamsDistributeParallelForDirectiveClass:
 case Stmt::OMPTargetTeamsDistributeParallelForSimdDirectiveClass:
 case Stmt::OMPTargetTeamsDistributeSimdDirectiveClass:
+case Stmt::CapturedStmtClass:
+{
+  const ExplodedNode *node = Bldr.generateSink(S, Pred, Pred->getState());
+  Engine.addAbortedBlock(node, currBldrCtx->getBlock());
+  break;
+}
+
+case Stmt::ParenExprClass:
+  llvm_unreachable("ParenExprs already handled.");
+case Stmt::GenericSelectionExprClass:
+  llvm_unreachable("GenericSelectionExprs already handled.");
+// Cases that should never be evaluated simply because they shouldn't
+// appear in the CFG.
+case Stmt::BreakStmtClass:
+case Stmt::CaseStmtClass:
+case Stmt::CompoundStmtClass:
+case Stmt::ContinueStmtClass:
+case Stmt::CXXForRangeStmtClass:
+case Stmt::DefaultStmtClass:
+case Stmt::DoStmtClass:
+case Stmt::ForStmtClass:
+case Stmt::GotoStmtClass:
+case Stmt::IfStmtClass:
+case Stmt::IndirectGotoStmtClass:
+case Stmt::LabelStmtClass:
+case Stmt::NoStmtClass:
+case Stmt::NullStmtClass:
+case Stmt::SwitchStmtClass:
+case Stmt::WhileStmtClass:
+case Expr::MSDependentExistsStmtClass:
   llvm_unreachable("Stmt should not be in analyzer evaluation loop");
 
 case Stmt::ObjCSubscriptRefExprClass:


Index: cfe/trunk/test/Analysis/openmp-unsupported.c
===
--- cfe/trunk/test/Analysis/openmp-unsupported.c
+++ cfe/trunk/test/Analysis/openmp-unsupported.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core.builtin -fopenmp -verify %s
+// expected-no-diagnostics
+
+void openmp_parallel_crash_test() {
+#pragma omp parallel
+  ;
+}
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -777,7 +777,7 @@
   assert(!isa(S) || S == 

r296884 - [Analyzer] Terminate analysis on OpenMP code instead of assertion crash

2017-03-03 Thread Aleksei Sidorin via cfe-commits
Author: a.sidorin
Date: Fri Mar  3 10:58:53 2017
New Revision: 296884

URL: http://llvm.org/viewvc/llvm-project?rev=296884=rev
Log:
[Analyzer] Terminate analysis on OpenMP code instead of assertion crash

* ExprEngine assumes that OpenMP statements should never appear in CFG.
  However, current CFG doesn't know anything about OpenMP and passes
  such statements as CFG nodes causing "UNREACHABLE executed!" crashes.
  Since there is no OpenMP implementation in ExprEngine or CFG,
  we stop the analysis on OpenMP statements to avoid crashes.

This fixes PR31835.

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

Added:
cfe/trunk/test/Analysis/openmp-unsupported.c
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=296884=296883=296884=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Fri Mar  3 10:58:53 2017
@@ -777,7 +777,7 @@ void ExprEngine::Visit(const Stmt *S, Ex
   assert(!isa(S) || S == cast(S)->IgnoreParens());
 
   switch (S->getStmtClass()) {
-// C++ and ARC stuff we don't support yet.
+// C++, OpenMP and ARC stuff we don't support yet.
 case Expr::ObjCIndirectCopyRestoreExprClass:
 case Stmt::CXXDependentScopeMemberExprClass:
 case Stmt::CXXInheritedCtorInitExprClass:
@@ -805,36 +805,7 @@ void ExprEngine::Visit(const Stmt *S, Ex
 case Stmt::SEHTryStmtClass:
 case Stmt::SEHExceptStmtClass:
 case Stmt::SEHLeaveStmtClass:
-case Stmt::SEHFinallyStmtClass: {
-  const ExplodedNode *node = Bldr.generateSink(S, Pred, Pred->getState());
-  Engine.addAbortedBlock(node, currBldrCtx->getBlock());
-  break;
-}
-
-case Stmt::ParenExprClass:
-  llvm_unreachable("ParenExprs already handled.");
-case Stmt::GenericSelectionExprClass:
-  llvm_unreachable("GenericSelectionExprs already handled.");
-// Cases that should never be evaluated simply because they shouldn't
-// appear in the CFG.
-case Stmt::BreakStmtClass:
-case Stmt::CaseStmtClass:
-case Stmt::CompoundStmtClass:
-case Stmt::ContinueStmtClass:
-case Stmt::CXXForRangeStmtClass:
-case Stmt::DefaultStmtClass:
-case Stmt::DoStmtClass:
-case Stmt::ForStmtClass:
-case Stmt::GotoStmtClass:
-case Stmt::IfStmtClass:
-case Stmt::IndirectGotoStmtClass:
-case Stmt::LabelStmtClass:
-case Stmt::NoStmtClass:
-case Stmt::NullStmtClass:
-case Stmt::SwitchStmtClass:
-case Stmt::WhileStmtClass:
-case Expr::MSDependentExistsStmtClass:
-case Stmt::CapturedStmtClass:
+case Stmt::SEHFinallyStmtClass:
 case Stmt::OMPParallelDirectiveClass:
 case Stmt::OMPSimdDirectiveClass:
 case Stmt::OMPForDirectiveClass:
@@ -882,6 +853,36 @@ void ExprEngine::Visit(const Stmt *S, Ex
 case Stmt::OMPTargetTeamsDistributeParallelForDirectiveClass:
 case Stmt::OMPTargetTeamsDistributeParallelForSimdDirectiveClass:
 case Stmt::OMPTargetTeamsDistributeSimdDirectiveClass:
+case Stmt::CapturedStmtClass:
+{
+  const ExplodedNode *node = Bldr.generateSink(S, Pred, Pred->getState());
+  Engine.addAbortedBlock(node, currBldrCtx->getBlock());
+  break;
+}
+
+case Stmt::ParenExprClass:
+  llvm_unreachable("ParenExprs already handled.");
+case Stmt::GenericSelectionExprClass:
+  llvm_unreachable("GenericSelectionExprs already handled.");
+// Cases that should never be evaluated simply because they shouldn't
+// appear in the CFG.
+case Stmt::BreakStmtClass:
+case Stmt::CaseStmtClass:
+case Stmt::CompoundStmtClass:
+case Stmt::ContinueStmtClass:
+case Stmt::CXXForRangeStmtClass:
+case Stmt::DefaultStmtClass:
+case Stmt::DoStmtClass:
+case Stmt::ForStmtClass:
+case Stmt::GotoStmtClass:
+case Stmt::IfStmtClass:
+case Stmt::IndirectGotoStmtClass:
+case Stmt::LabelStmtClass:
+case Stmt::NoStmtClass:
+case Stmt::NullStmtClass:
+case Stmt::SwitchStmtClass:
+case Stmt::WhileStmtClass:
+case Expr::MSDependentExistsStmtClass:
   llvm_unreachable("Stmt should not be in analyzer evaluation loop");
 
 case Stmt::ObjCSubscriptRefExprClass:

Added: cfe/trunk/test/Analysis/openmp-unsupported.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/openmp-unsupported.c?rev=296884=auto
==
--- cfe/trunk/test/Analysis/openmp-unsupported.c (added)
+++ cfe/trunk/test/Analysis/openmp-unsupported.c Fri Mar  3 10:58:53 2017
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze 
-analyzer-checker=core.builtin -fopenmp -verify %s
+// expected-no-diagnostics
+
+void openmp_parallel_crash_test() {
+#pragma omp parallel

[PATCH] D30582: [Driver] Restructure handling of -ffast-math and similar options

2017-03-03 Thread John Brawn via Phabricator via cfe-commits
john.brawn created this revision.

The way -ffast-math and the various related options to tweak floating-point 
handling are handled is inflexible and rather confusing. This patch 
restructures things so that we go through the options adjusting our idea of 
what's enabled as we go, instead of trying to figure each individual thing out 
by working backwards from the end, as this makes the behaviour of each 
individual option more clear.

Doing it this way also means we get gcc-compatible behaviour for when the 
__FAST_MATH__ and __FINITE_MATH_ONLY__ macros are defined, as they should 
depend on the final set of features that are enabled and not just on 
-ffast-math and -ffinite-math-only specifically.


Repository:
  rL LLVM

https://reviews.llvm.org/D30582

Files:
  lib/Driver/Tools.cpp
  test/Driver/fast-math.c

Index: test/Driver/fast-math.c
===
--- test/Driver/fast-math.c
+++ test/Driver/fast-math.c
@@ -148,20 +148,35 @@
 //
 // One umbrella flag is *really* weird and also changes the semantics of the
 // program by adding a special preprocessor macro. Check that the frontend flag
-// modeling this semantic change is provided. Also check that the semantic
-// impact remains even if every optimization is disabled.
+// modeling this semantic change is provided. Also check that the flag is not
+// present if any of the optimization is disabled.
 // RUN: %clang -### -ffast-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-FAST-MATH %s
 // RUN: %clang -### -fno-fast-math -ffast-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-FAST-MATH %s
-// RUN: %clang -### -ffast-math -fno-finite-math-only \
-// RUN: -fno-unsafe-math-optimizations -fmath-errno -c %s 2>&1 \
+// RUN: %clang -### -funsafe-math-optimizations -ffinite-math-only \
+// RUN: -fno-math-errno -ffp-contract=fast -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FAST-MATH %s
+// RUN: %clang -### -fhonor-infinities -fhonor-nans -fno-math-errno \
+// RUN: -fassociative-math -freciprocal-math -fno-signed-zeros \
+// RUN: -fno-trapping-math -ffp-contract=fast -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-FAST-MATH %s
 // CHECK-FAST-MATH: "-cc1"
 // CHECK-FAST-MATH: "-ffast-math"
+// CHECK-FAST-MATH: "-ffinite-math-only"
 //
 // RUN: %clang -### -ffast-math -fno-fast-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s
+// RUN: %clang -### -ffast-math -fno-finite-math-only -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s
+// RUN: %clang -### -ffast-math -fno-unsafe-math-optimizations -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s
+// RUN: %clang -### -ffast-math -fmath-errno -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s
+// RUN: %clang -### -ffast-math -ffp-contract=on -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s
+// RUN: %clang -### -ffast-math -ffp-contract=off -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s
 // CHECK-NO-FAST-MATH: "-cc1"
 // CHECK-NO-FAST-MATH-NOT: "-ffast-math"
 //
@@ -179,6 +194,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NO-NO-INFS %s
 // CHECK-NO-NO-INFS: "-cc1"
 // CHECK-NO-NO-INFS-NOT: "-menable-no-infs"
+// CHECK-NO-NO-INFS-NOT: "-ffinite-math-only"
 // CHECK-NO-NO-INFS: "-o"
 //
 // RUN: %clang -### -fno-honor-nans -fhonor-nans -c %s 2>&1 \
@@ -193,6 +209,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NO-NO-NANS %s
 // CHECK-NO-NO-NANS: "-cc1"
 // CHECK-NO-NO-NANS-NOT: "-menable-no-nans"
+// CHECK-NO-NO-NANS-NOT: "-ffinite-math-only"
 // CHECK-NO-NO-NANS: "-o"
 //
 // RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3302,98 +3302,129 @@
   if (Args.hasArg(options::OPT_fsplit_stack))
 CmdArgs.push_back("-split-stacks");
 
-  // If -Ofast is the optimization level, then -ffast-math should be enabled.
-  // This alias option is being used to simplify the getLastArg logic.
-  OptSpecifier FastMathAliasOption =
-  OFastEnabled ? options::OPT_Ofast : options::OPT_ffast_math;
-
   // Handle various floating point optimization flags, mapping them to the
-  // appropriate LLVM code generation flags. The pattern for all of these is to
-  // default off the codegen optimizations, and if any flag enables them and no
-  // flag disables them after the flag enabling them, enable the codegen
-  // optimization. This is complicated by several "umbrella" flags.
-  if (Arg *A = Args.getLastArg(
-  options::OPT_ffast_math, FastMathAliasOption,
-  options::OPT_fno_fast_math, options::OPT_ffinite_math_only,
-  options::OPT_fno_finite_math_only, options::OPT_fhonor_infinities,
-  options::OPT_fno_honor_infinities))
-if (A->getOption().getID() != 

[PATCH] D30565: [analyzer] Terminate analysis on OpenMP code instead of crashing

2017-03-03 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

Thanks for fixing this! It looks like this is tracked by PR31835. 
https://bugs.llvm.org//show_bug.cgi?id=31835


https://reviews.llvm.org/D30565



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


[PATCH] D30373: [analyzer] NFC: Update test infrastructure to support multiple constraint managers

2017-03-03 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

Looks great. Thanks!!


https://reviews.llvm.org/D30373



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


[PATCH] D30532: Add examples to clang-format configuration

2017-03-03 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru updated this revision to Diff 90486.
sylvestre.ledru added a comment.

updated => affected 
+ align the vs


https://reviews.llvm.org/D30532

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h

Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -100,6 +100,19 @@
 
   /// \brief If ``true``, aligns escaped newlines as far left as possible.
   /// Otherwise puts them into the right-most column.
+  /// \code
+  ///   true:
+  ///   #define A   \
+  /// int ; \
+  /// int b;\
+  /// int dd;
+  ///
+  ///   false:
+  ///   #define A  \
+  /// int ;\
+  /// int b;   \
+  /// int dd;
+  /// \endcode
   bool AlignEscapedNewlinesLeft;
 
   /// \brief If ``true``, horizontally align operands of binary and ternary
@@ -114,6 +127,11 @@
   bool AlignOperands;
 
   /// \brief If ``true``, aligns trailing comments.
+  /// \code
+  ///   true:   false:
+  ///   int a; // My comment a  vs. int a; // My comment a
+  ///   int b = 2; // comment  bint b = 2; // comment about b
+  /// \endcode
   bool AlignTrailingComments;
 
   /// \brief Allow putting all parameters of a function declaration onto
@@ -126,6 +144,16 @@
   bool AllowShortBlocksOnASingleLine;
 
   /// \brief If ``true``, short case labels will be contracted to a single line.
+  /// \code
+  ///   true:   false:
+  ///   switch (a) {vs. switch (a) {
+  ///   case 1: x = 1; break;   case 1:
+  ///   case 2: return;   x = 1;
+  ///   } break;
+  ///   case 2:
+  /// return;
+  ///   }
+  /// \endcode
   bool AllowShortCaseLabelsOnASingleLine;
 
   /// \brief Different styles for merging short functions containing at most one
@@ -192,10 +220,21 @@
   /// in a file look more consistent. Thus, it will only take effect if wrapping
   /// the string at that point leads to it being indented
   /// ``ContinuationIndentWidth`` spaces from the start of the line.
+  /// \code
+  ///true:  false:
+  /// = vs.  = ""
+  ///"""";
+  ///"";
+  /// \endcode
   bool AlwaysBreakBeforeMultilineStrings;
 
   /// \brief If ``true``, always break after the ``template<...>`` of a template
   /// declaration.
+  /// \code
+  ///true:  false:
+  ///template   vs. template  class C {};
+  ///class C {};
+  /// \endcode
   bool AlwaysBreakTemplateDeclarations;
 
   /// \brief If ``false``, a function call's arguments will either be all on the
@@ -284,6 +323,13 @@
 
   /// \brief Always break constructor initializers before commas and align
   /// the commas with the colon.
+  /// \code
+  ///true:  false:
+  ///SomeClass::Constructor()   vs. SomeClass::Constructor() : a(a),
+  ///: a(a)   b(b),
+  ///, b(b)   c(c) {}
+  ///, c(c) {}
+  /// \endcode
   bool BreakConstructorInitializersBeforeComma;
 
   /// \brief Break after each annotation on a field in Java files.
@@ -351,6 +397,12 @@
 
   /// \brief If ``true``, clang-format adds missing namespace end comments and
   /// fixes invalid existing ones.
+  /// \code
+  ///true:  false:
+  ///namespace a {  vs. namespace a {
+  ///foo(); foo();
+  ///} // namespace a;  }
+  /// \endcode
   bool FixNamespaceComments;
 
   /// \brief A vector of macros that should be interpreted as foreach loops
@@ -557,9 +609,18 @@
   bool SpaceAfterCStyleCast;
 
   /// \brief If \c true, a space will be inserted after the 'template' keyword.
+  /// \code
+  ///true:  false:
+  ///template  void foo(); vs. template void foo();
+  /// \endcode
   bool SpaceAfterTemplateKeyword;
 
   /// \brief If ``false``, spaces will be removed before assignment operators.
+  /// \code
+  ///true:  false:
+  ///int a = 5; vs. int a=5;
+  ///a += 42a+=42;
+  /// \endcode
   bool SpaceBeforeAssignmentOperators;
 
   /// \brief 

[PATCH] D27753: [analyzer] alpha.security.DirtyScalar Checker

2017-03-03 Thread Zoltán Gera via Phabricator via cfe-commits
gerazo marked an inline comment as done.
gerazo added a comment.

Hmm... I am thinking on this issue for a week now...

I've played with the idea of implementing cleansing rules in 
GenericTaintChecker. It would be elegant but unfortunately, I have to think 
they are not general. Cleansing of a string (because it has no terminating null 
at the end) is very different from integral type cleansing. A signed value has 
to be lower bound checked as well, an unsigned only gets upper bound treatment. 
It also turns out that the type itself also can't give enough information about 
the needed cleansing rule. A number used for array indexing can be properly 
bound checked on the region extents while a simple number can only be checked 
in a way that any upper bound checking was done at all on it... All this leads 
to the need of several types of taintednesses (string taintedness, array 
taintedness, general bound check taintedness) because the cleansing can only 
take down one type of taintedness at a time. That would be the only way for a 
checker to be able to access that the taintedness type specific to the checker 
is still there or was already cleansed by the central logic. For me it shows 
that cleansing rules belong to specific checkers and cannot be efficiently 
generalized even in case of a single int type.

About the ArrayBoundCheckerV2: I agree that no redundant checks should be done 
system-wide. I would also extend ArrayBoundCheckV2 or put array checking into a 
separate checker. Currently that checker and the one implemented here do not 
give the same results. ArrayBoundCheckerV2 knows more about the array but is 
not willing to give a warning without knowing region information for the array. 
The easiest way would be to use one checker's code from the other and find out 
if the other is active and would already give a warning anyway... but I 
understand that it is against current architectural policies.


https://reviews.llvm.org/D27753



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


[PATCH] D30492: [clang-format] Allow all but the first string literal in a sequence to be put on a newline

2017-03-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir abandoned this revision.
krasimir added a comment.

This patch is superseded by https://reviews.llvm.org/D30575.


https://reviews.llvm.org/D30492



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


[PATCH] D30532: Add examples to clang-format configuration

2017-03-03 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru updated this revision to Diff 90482.
sylvestre.ledru added a comment.

With the changes requested by Daniel. This is much better indeed!


https://reviews.llvm.org/D30532

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h

Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -100,6 +100,19 @@
 
   /// \brief If ``true``, aligns escaped newlines as far left as possible.
   /// Otherwise puts them into the right-most column.
+  /// \code
+  ///   true:
+  ///   #define A   \
+  /// int ; \
+  /// int b;\
+  /// int dd;
+  ///
+  ///   false:
+  ///   #define A  \
+  /// int ;\
+  /// int b;   \
+  /// int dd;
+  /// \endcode
   bool AlignEscapedNewlinesLeft;
 
   /// \brief If ``true``, horizontally align operands of binary and ternary
@@ -114,6 +127,11 @@
   bool AlignOperands;
 
   /// \brief If ``true``, aligns trailing comments.
+  /// \code
+  ///   true:   false:
+  ///   int a; // My comment a  vs. int a; // My comment a
+  ///   int b = 2; // comment  bint b = 2; // comment about b
+  /// \endcode
   bool AlignTrailingComments;
 
   /// \brief Allow putting all parameters of a function declaration onto
@@ -126,6 +144,16 @@
   bool AllowShortBlocksOnASingleLine;
 
   /// \brief If ``true``, short case labels will be contracted to a single line.
+  /// \code
+  ///   true:   false:
+  ///   switch (a) {vs. switch (a) {
+  ///   case 1: x = 1; break;   case 1:
+  ///   case 2: return;   x = 1;
+  ///   } break;
+  ///   case 2:
+  /// return;
+  ///   }
+  /// \endcode
   bool AllowShortCaseLabelsOnASingleLine;
 
   /// \brief Different styles for merging short functions containing at most one
@@ -192,10 +220,21 @@
   /// in a file look more consistent. Thus, it will only take effect if wrapping
   /// the string at that point leads to it being indented
   /// ``ContinuationIndentWidth`` spaces from the start of the line.
+  /// \code
+  ///true:  false:
+  /// = vs.  = ""
+  ///"""";
+  ///"";
+  /// \endcode
   bool AlwaysBreakBeforeMultilineStrings;
 
   /// \brief If ``true``, always break after the ``template<...>`` of a template
   /// declaration.
+  /// \code
+  ///true:  false:
+  ///template   vs. template  class C {};
+  ///class C {};
+  /// \endcode
   bool AlwaysBreakTemplateDeclarations;
 
   /// \brief If ``false``, a function call's arguments will either be all on the
@@ -284,6 +323,13 @@
 
   /// \brief Always break constructor initializers before commas and align
   /// the commas with the colon.
+  /// \code
+  ///true:  false:
+  ///SomeClass::Constructor()  vs.  SomeClass::Constructor() : a(a),
+  ///: a(a)b(b),
+  ///, b(b)c(c) {}
+  ///, c(c) {}
+  /// \endcode
   bool BreakConstructorInitializersBeforeComma;
 
   /// \brief Break after each annotation on a field in Java files.
@@ -351,6 +397,12 @@
 
   /// \brief If ``true``, clang-format adds missing namespace end comments and
   /// fixes invalid existing ones.
+  /// \code
+  ///true:  false:
+  ///namespace a {  vs. namespace a {
+  ///foo(); foo();
+  ///} // namespace a;  }
+  /// \endcode
   bool FixNamespaceComments;
 
   /// \brief A vector of macros that should be interpreted as foreach loops
@@ -557,9 +609,18 @@
   bool SpaceAfterCStyleCast;
 
   /// \brief If \c true, a space will be inserted after the 'template' keyword.
+  /// \code
+  ///true:  false:
+  ///template  void foo(); vs. template void foo();
+  /// \endcode
   bool SpaceAfterTemplateKeyword;
 
   /// \brief If ``false``, spaces will be removed before assignment operators.
+  /// \code
+  ///true:  false:
+  ///int a = 5; vs. int a=5;
+  ///a += 42a+=42;
+  /// \endcode
   bool 

[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration

2017-03-03 Thread Andi via Phabricator via cfe-commits
Abpostelnicu updated this revision to Diff 90480.
Abpostelnicu added a comment.

corrected some format issues.


Repository:
  rL LLVM

https://reviews.llvm.org/D30487

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -1029,6 +1029,17 @@
   verifyFormat("class ::A::B {};");
 }
 
+TEST_F(FormatTest, BreakInhertianceBeforeColonAndComma) {
+  FormatStyle StyleWithInheritanceBreak = getLLVMStyle();
+  LocalStyle.BreakInhertianceBeforeColonAndComma = true;
+
+  verifyFormat("class MyClass : public X {}", LocalStyle);
+  verifyFormat("class MyClass\n"
+   ": public X\n"
+   ", public Y {}",
+   StyleWithInheritanceBreak);
+}
+
 TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) {
   verifyFormat("class A {\n} a, b;");
   verifyFormat("struct A {\n} a, b;");
@@ -8491,6 +8502,7 @@
   CHECK_PARSE_BOOL(BreakBeforeTernaryOperators);
   CHECK_PARSE_BOOL(BreakConstructorInitializersBeforeComma);
   CHECK_PARSE_BOOL(BreakStringLiterals);
+  CHECK_PARSE_BOOL(BreakInhertianceBeforeColonAndComma)
   CHECK_PARSE_BOOL(ConstructorInitializerAllOnOneLineOrOnePerLine);
   CHECK_PARSE_BOOL(DerivePointerAlignment);
   CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding");
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -676,6 +676,8 @@
 case tok::comma:
   if (Contexts.back().InCtorInitializer)
 Tok->Type = TT_CtorInitializerComma;
+  else if (Contexts.back().InInhertianceList)
+Tok->Type = TT_InheritanceComma;
   else if (Contexts.back().FirstStartOfName &&
(Contexts.size() == 1 || Line.startsWith(tok::kw_for))) {
 Contexts.back().FirstStartOfName->PartOfMultiVariableDeclStmt = true;
@@ -945,6 +947,7 @@
 bool CanBeExpression = true;
 bool InTemplateArgument = false;
 bool InCtorInitializer = false;
+bool InInhertianceList = false;
 bool CaretFound = false;
 bool IsForEachMacro = false;
   };
@@ -1004,6 +1007,9 @@
Current.Previous->is(TT_CtorInitializerColon)) {
   Contexts.back().IsExpression = true;
   Contexts.back().InCtorInitializer = true;
+} else if (Current.Previous &&
+   Current.Previous->is(TT_InheritanceColon)) {
+  Contexts.back().InInhertianceList = true;
 } else if (Current.isOneOf(tok::r_paren, tok::greater, tok::comma)) {
   for (FormatToken *Previous = Current.Previous;
Previous && Previous->isOneOf(tok::star, tok::amp);
@@ -2473,6 +2479,10 @@
   Style.BreakConstructorInitializersBeforeComma &&
   !Style.ConstructorInitializerAllOnOneLineOrOnePerLine)
 return true;
+  // Break only if we have multiple inheritance.
+  if (Style.BreakInhertianceBeforeColonAndComma &&
+  Right.is(TT_InheritanceComma))
+   return true;
   if (Right.is(tok::string_literal) && Right.TokenText.startswith("R\""))
 // Raw string literals are special wrt. line breaks. The author has made a
 // deliberate choice and might have aligned the contents of the string
@@ -2652,6 +2662,12 @@
   if (Right.is(TT_CtorInitializerComma) &&
   Style.BreakConstructorInitializersBeforeComma)
 return true;
+  if (Left.is(TT_InheritanceComma) &&
+  Style.BreakInhertianceBeforeColonAndComma)
+return false;
+  if (Right.is(TT_InheritanceComma) &&
+  Style.BreakInhertianceBeforeColonAndComma)
+return true;
   if ((Left.is(tok::greater) && Right.is(tok::greater)) ||
   (Left.is(tok::less) && Right.is(tok::less)))
 return false;
Index: lib/Format/FormatToken.h
===
--- lib/Format/FormatToken.h
+++ lib/Format/FormatToken.h
@@ -48,6 +48,7 @@
   TYPE(FunctionTypeLParen) \
   TYPE(ImplicitStringLiteral) \
   TYPE(InheritanceColon) \
+  TYPE(InheritanceComma) \
   TYPE(InlineASMBrace) \
   TYPE(InlineASMColon) \
   TYPE(JavaAnnotation) \
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -521,6 +521,7 @@
  false, false, false, false, false};
   LLVMStyle.BreakAfterJavaFieldAnnotations = false;
   LLVMStyle.BreakConstructorInitializersBeforeComma = false;
+  LLVMStyle.BreakInhertianceBeforeColonAndComma = false;
   LLVMStyle.BreakStringLiterals = true;
   LLVMStyle.ColumnLimit = 80;
   LLVMStyle.CommentPragmas = "^ IWYU pragma:";
@@ -674,6 +675,7 @@
   MozillaStyle.BinPackArguments = false;
   MozillaStyle.BreakBeforeBraces = 

[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration

2017-03-03 Thread Andi via Phabricator via cfe-commits
Abpostelnicu updated this revision to Diff 90475.

Repository:
  rL LLVM

https://reviews.llvm.org/D30487

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -1029,6 +1029,17 @@
   verifyFormat("class ::A::B {};");
 }
 
+TEST_F(FormatTest, BreakInhertianceBeforeColonAndComma) {
+  FormatStyle StyleWithInheritanceBreak = getLLVMStyle();
+  LocalStyle.BreakInhertianceBeforeColonAndComma = true;
+
+  verifyFormat("class MyClass : public X {}", LocalStyle);
+  verifyFormat("class MyClass\n"
+   ": public X\n"
+   ", public Y {}",
+   StyleWithInheritanceBreak);
+}
+
 TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) {
   verifyFormat("class A {\n} a, b;");
   verifyFormat("struct A {\n} a, b;");
@@ -8491,6 +8502,7 @@
   CHECK_PARSE_BOOL(BreakBeforeTernaryOperators);
   CHECK_PARSE_BOOL(BreakConstructorInitializersBeforeComma);
   CHECK_PARSE_BOOL(BreakStringLiterals);
+  CHECK_PARSE_BOOL(BreakInhertianceBeforeColonAndComma)
   CHECK_PARSE_BOOL(ConstructorInitializerAllOnOneLineOrOnePerLine);
   CHECK_PARSE_BOOL(DerivePointerAlignment);
   CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding");
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -676,6 +676,8 @@
 case tok::comma:
   if (Contexts.back().InCtorInitializer)
 Tok->Type = TT_CtorInitializerComma;
+  else if (Contexts.back().InInhertianceList)
+Tok->Type = TT_InheritanceComma;
   else if (Contexts.back().FirstStartOfName &&
(Contexts.size() == 1 || Line.startsWith(tok::kw_for))) {
 Contexts.back().FirstStartOfName->PartOfMultiVariableDeclStmt = true;
@@ -945,6 +947,7 @@
 bool CanBeExpression = true;
 bool InTemplateArgument = false;
 bool InCtorInitializer = false;
+bool InInhertianceList = false;
 bool CaretFound = false;
 bool IsForEachMacro = false;
   };
@@ -1004,6 +1007,9 @@
Current.Previous->is(TT_CtorInitializerColon)) {
   Contexts.back().IsExpression = true;
   Contexts.back().InCtorInitializer = true;
+} else if (Current.Previous &&
+   Current.Previous->is(TT_InheritanceColon)) {
+  Contexts.back().InInhertianceList = true;
 } else if (Current.isOneOf(tok::r_paren, tok::greater, tok::comma)) {
   for (FormatToken *Previous = Current.Previous;
Previous && Previous->isOneOf(tok::star, tok::amp);
@@ -2473,6 +2479,10 @@
   Style.BreakConstructorInitializersBeforeComma &&
   !Style.ConstructorInitializerAllOnOneLineOrOnePerLine)
 return true;
+  // Break only if we have multiple inheritance.
+  if (Style.BreakInhertianceBeforeColonAndComma &&
+  Right.is(TT_InheritanceComma))
+   return true;
   if (Right.is(tok::string_literal) && Right.TokenText.startswith("R\""))
 // Raw string literals are special wrt. line breaks. The author has made a
 // deliberate choice and might have aligned the contents of the string
@@ -2652,6 +2662,12 @@
   if (Right.is(TT_CtorInitializerComma) &&
   Style.BreakConstructorInitializersBeforeComma)
 return true;
+  if (Left.is(TT_InheritanceComma) &&
+  Style.BreakInhertianceBeforeColonAndComma)
+return false;
+  if (Right.is(TT_InheritanceComma) &&
+  Style.BreakInhertianceBeforeColonAndComma)
+return true;
   if ((Left.is(tok::greater) && Right.is(tok::greater)) ||
   (Left.is(tok::less) && Right.is(tok::less)))
 return false;
Index: lib/Format/FormatToken.h
===
--- lib/Format/FormatToken.h
+++ lib/Format/FormatToken.h
@@ -48,6 +48,7 @@
   TYPE(FunctionTypeLParen) \
   TYPE(ImplicitStringLiteral) \
   TYPE(InheritanceColon) \
+  TYPE(InheritanceComma) \
   TYPE(InlineASMBrace) \
   TYPE(InlineASMColon) \
   TYPE(JavaAnnotation) \
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -521,6 +521,7 @@
  false, false, false, false, false};
   LLVMStyle.BreakAfterJavaFieldAnnotations = false;
   LLVMStyle.BreakConstructorInitializersBeforeComma = false;
+  LLVMStyle.BreakInhertianceBeforeColonAndComma = false;
   LLVMStyle.BreakStringLiterals = true;
   LLVMStyle.ColumnLimit = 80;
   LLVMStyle.CommentPragmas = "^ IWYU pragma:";
@@ -674,6 +675,7 @@
   MozillaStyle.BinPackArguments = false;
   MozillaStyle.BreakBeforeBraces = FormatStyle::BS_Mozilla;
   

[PATCH] D30174: [Sema][ObjC] Warn about 'performSelector' calls with selectors that return record types

2017-03-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 90473.
arphaman marked 3 inline comments as done.
arphaman added a comment.

The updated diff:

- Warns for vector types.
- Addresses Akira's comments.


Repository:
  rL LLVM

https://reviews.llvm.org/D30174

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/DeclObjC.cpp
  lib/Basic/IdentifierTable.cpp
  lib/Sema/SemaExprObjC.cpp
  test/SemaObjC/unsafe-perform-selector.m

Index: test/SemaObjC/unsafe-perform-selector.m
===
--- /dev/null
+++ test/SemaObjC/unsafe-perform-selector.m
@@ -0,0 +1,127 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
+// rdar://12056271
+
+@class Thread;
+
+__attribute__((objc_root_class))
+@interface NSObject
+
+- (id)performSelector:(SEL)sel;
+- (void)performSelectorInBackground:(SEL)sel withObject:(id)arg;
+- (void)performSelectorOnMainThread:(SEL)sel;
+
+- (void)performSelectorOnMainThread:(SEL)aSelector
+   onThread:(Thread *)thread
+ withObject:(id)arg
+  waitUntilDone:(int)wait
+  modes:(id *)array;
+
+@end
+
+typedef struct { int x; int y; int width; int height; } Rectangle;
+
+struct Struct { Rectangle r; };
+
+typedef union { int x; float f; } Union;
+
+@interface Base : NSObject
+
+- (struct Struct)returnsStruct2; // expected-note {{method 'returnsStruct2' that returns 'struct Struct' declared here}}
+- (Union)returnsId;
+
+@end
+
+@protocol IP
+
+- (Union)returnsUnion; // expected-note 2 {{method 'returnsUnion' that returns 'Union' declared here}}
+
+@end
+
+typedef __attribute__((__ext_vector_type__(3))) float float3;
+typedef int int4 __attribute__ ((vector_size (16)));
+
+@interface I : Base
+
+- (Rectangle)returnsStruct; // expected-note 4 {{method 'returnsStruct' that returns 'Rectangle' declared here}}
+- (id)returnsId; // shadows base 'returnsId'
+- (int)returnsInt;
+- (I *)returnPtr;
+- (float3)returnsExtVector; // expected-note {{method 'returnsExtVector' that returns 'float3' (vector of 3 'float' values) declared here}}
+- (int4)returnsVector; // expected-note {{method 'returnsVector' that returns 'int4' (vector of 4 'int' values) declared here}}
+
++ (Rectangle)returnsStructClass; // expected-note 2 {{method 'returnsStructClass' that returns 'Rectangle' declared here}}
++ (void)returnsUnion; // Not really
+
+@end
+
+void foo(I *i) {
+  [i performSelector: @selector(returnsStruct)]; // expected-warning {{'performSelector:' is incompatible with selectors that return a struct type}}
+  [i performSelectorInBackground: @selector(returnsStruct) withObject:0]; // expected-warning {{'performSelectorInBackground:withObject:' is incompatible with selectors that return a struct type}}
+  [i performSelector: ((@selector(returnsUnion)))]; // expected-warning {{'performSelector:' is incompatible with selectors that return a union type}}
+  [i performSelectorOnMainThread: @selector(returnsStruct2)]; // expected-warning {{'performSelectorOnMainThread:' is incompatible with selectors that return a struct type}}
+  [I performSelector: (@selector(returnsStructClass))]; // expected-warning {{'performSelector:' is incompatible with selectors that return a struct type}}
+
+  [i performSelector: @selector(returnsId)];
+  [i performSelector: @selector(returnsInt)];
+  [i performSelector: @selector(returnsPtr)];
+  [I performSelector: @selector(returnsUnion)]; // No warning expected
+
+  id obj = i;
+  [obj performSelector: @selector(returnsId)];
+  [obj performSelector: @selector(returnsStruct)];
+}
+
+@interface SubClass: I
+
+@end
+
+@interface SubClass ()
+- (struct Struct)returnsSubStructExt; // expected-note {{method 'returnsSubStructExt' that returns 'struct Struct' declared here}} expected-note {{method 'returnsSubStructExt' declared here}}
+@end
+
+@implementation SubClass // expected-warning {{method definition for 'returnsSubStructExt' not found}}
+
+- (struct Struct)returnsSubStructImpl { // expected-note {{method 'returnsSubStructImpl' that returns 'struct Struct' declared here}}
+  struct Struct Result;
+  return Result;
+}
+
+- (void)checkPrivateCalls {
+  [self performSelector: @selector(returnsSubStructExt)]; // expected-warning {{'performSelector:' is incompatible with selectors that return a struct type}}
+  [self performSelector: @selector(returnsSubStructImpl)]; // expected-warning {{'performSelector:' is incompatible with selectors that return a struct type}}
+}
+
+- (void)checkSuperCalls {
+  [super performSelector: @selector(returnsStruct)]; // expected-warning {{'performSelector:' is incompatible with selectors that return a struct type}}
+  [super performSelectorInBackground: @selector(returnsUnion) withObject: self]; // expected-warning {{'performSelectorInBackground:withObject:' is incompatible with selectors that return a union type}}
+  [super performSelector: @selector(returnsId)];
+}
+
++ (struct 

[PATCH] D30174: [Sema][ObjC] Warn about 'performSelector' calls with selectors that return record types

2017-03-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman marked 3 inline comments as done.
arphaman added inline comments.



Comment at: lib/AST/DeclObjC.cpp:987
   unsigned noParams = param_size();
   if (noParams < 1 || noParams > 3)
 family = OMF_None;

ahatanak wrote:
> It seems like this code would set "family" to OMF_None for some of the 
> performSelector functions. For example:
> 
> https://developer.apple.com/reference/objectivec/nsobject/1411637-performselectoronmainthread?language=objc
> https://developer.apple.com/reference/objectivec/nsobject/1417922-performselector?language=objc
> 
> Do those functions belong to the performSelector family of methods?
Good catch! Yes, we should be more inclusive here.



Comment at: lib/Sema/SemaExprObjC.cpp:2280
+ImpliedMethod =
+OPT->getInterfaceDecl()->lookupInstanceMethod(SE->getSelector());
+  } else {

ahatanak wrote:
> Do you need to check if OPT->getInterfaceDecl() returns null here? What 
> happens if OPT is id?
You're right, my mistake.



Comment at: lib/Sema/SemaExprObjC.cpp:2499
   checkCocoaAPI(*this, Result);
+if (Method)
+  checkFoundationAPI(*this, SelLoc, Method, makeArrayRef(Args, NumArgs),

ahatanak wrote:
> I'm not sure why checkFoundationAPI has to be called inside the else 
> statement. Was there a reason you didn't or couldn't move it outside?
We should check for 'super' calls as wells, you're right.


Repository:
  rL LLVM

https://reviews.llvm.org/D30174



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


[PATCH] D30341: [analyzer] clarify error messages about uninitialized function arguments

2017-03-03 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki updated this revision to Diff 90471.
danielmarjamaki added a comment.

Fix review comment


Repository:
  rL LLVM

https://reviews.llvm.org/D30341

Files:
  lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
  test/Analysis/NewDelete-checker-test.cpp
  test/Analysis/diagnostics/undef-value-param.m
  test/Analysis/malloc.m
  test/Analysis/misc-ps-region-store.m
  test/Analysis/misc-ps.m
  test/Analysis/null-deref-ps.c
  test/Analysis/nullptr.cpp
  test/Analysis/uninit-const.c
  test/Analysis/uninit-const.cpp
  test/Analysis/uninit-msg-expr.m
  test/Analysis/uninit-vals-ps.c
  test/Analysis/uninit-vals.cpp

Index: test/Analysis/uninit-vals.cpp
===
--- test/Analysis/uninit-vals.cpp
+++ test/Analysis/uninit-vals.cpp
@@ -27,7 +27,7 @@
   // case with undefined values, too.
   c1.b.a = c2->b.a;
 #else
-  c1.b.a = c2->b.a; // expected-warning{{Function call argument is an uninitialized value}}
+  c1.b.a = c2->b.a; // expected-warning{{1st function call argument is an uninitialized value}}
 #endif
 }
 }
Index: test/Analysis/uninit-vals-ps.c
===
--- test/Analysis/uninit-vals-ps.c
+++ test/Analysis/uninit-vals-ps.c
@@ -14,7 +14,7 @@
 
 int f1_b() {
   int x;
-  return bar(x)+1;  // expected-warning{{Function call argument is an uninitialized value}}
+  return bar(x)+1;  // expected-warning{{1st function call argument is an uninitialized value}}
 }
 
 int f2() {
Index: test/Analysis/uninit-msg-expr.m
===
--- test/Analysis/uninit-msg-expr.m
+++ test/Analysis/uninit-msg-expr.m
@@ -52,5 +52,5 @@
 void f3() {
   NSMutableArray *aArray = [NSArray array];
   NSString *aString;
-  [aArray addObject:aString]; // expected-warning {{Argument in message expression is an uninitialized value}}
+  [aArray addObject:aString]; // expected-warning {{1st argument in message expression is an uninitialized value}}
 }
Index: test/Analysis/uninit-const.cpp
===
--- test/Analysis/uninit-const.cpp
+++ test/Analysis/uninit-const.cpp
@@ -66,8 +66,8 @@
   int  = t;
   int  = p;
   int  = s;  //expected-note {{'q' initialized here}}
-  doStuff6(q); //expected-warning {{Function call argument is an uninitialized value}}
-   //expected-note@-1 {{Function call argument is an uninitialized value}}
+  doStuff6(q); //expected-warning {{1st function call argument is an uninitialized value}}
+   //expected-note@-1 {{1st function call argument is an uninitialized value}}
 }
 
 void doStuff6_3(int& q_, int *ptr_) {}
@@ -78,32 +78,32 @@
   int  = t;
   int  = p;
   int  = s;
-  doStuff6_3(q,ptr); //expected-warning {{Function call argument is an uninitialized value}}
-   //expected-note@-1 {{Function call argument is an uninitialized value}}
+  doStuff6_3(q,ptr); //expected-warning {{2nd function call argument is an uninitialized value}}
+   //expected-note@-1 {{2nd function call argument is an uninitialized value}}
 
 }
 
 void f6(void) {
   int k;   // expected-note {{'k' declared without an initial value}}
-  doStuff6(k); // expected-warning {{Function call argument is an uninitialized value}}
-   // expected-note@-1 {{Function call argument is an uninitialized value}}
+  doStuff6(k); // expected-warning {{1st function call argument is an uninitialized value}}
+   // expected-note@-1 {{1st function call argument is an uninitialized value}}
 
 }
 
 
 
 void f5(void) {
   int t;
   int* tp = // expected-note {{'tp' initialized here}}
-  doStuff_uninit(tp);  // expected-warning {{Function call argument is a pointer to uninitialized value}}
-   // expected-note@-1 {{Function call argument is a pointer to uninitialized value}}
+  doStuff_uninit(tp);  // expected-warning {{1st function call argument is a pointer to uninitialized value}}
+   // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
 
 
 void f4(void) {
   int y;// expected-note {{'y' declared without an initial value}}
-  doStuff4(y);  // expected-warning {{Function call argument is an uninitialized value}}
-// expected-note@-1 {{Function call argument is an uninitialized value}}
+  doStuff4(y);  // expected-warning {{1st function call argument is an uninitialized value}}
+// expected-note@-1 {{1st function call argument is an uninitialized value}}
 }
 
 void f3(void) {
@@ -123,6 +123,6 @@
 
 void f_uninit(void) {
   int x;
-  doStuff_uninit();  // expected-warning {{Function call argument is a pointer to uninitialized value}}
-   // expected-note@-1 {{Function call argument is a pointer to uninitialized value}}
+  doStuff_uninit();  // expected-warning {{1st function call 

[PATCH] D30569: [clang-tidy] misc-use-after-move: Fix failing assertion

2017-03-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: test/clang-tidy/misc-use-after-move.cpp:285
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE-3]]:6: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:7: note: move occurred here
 }

mboehme wrote:
> alexfh wrote:
> > mboehme wrote:
> > > mboehme wrote:
> > > > I've seen this column number flapping back and forth between 6 and 7 
> > > > before.
> > > > 
> > > > This seems to be unrelated to my fix and instead is triggered simply by 
> > > > adding the extra test case below; even with my fix present, this 
> > > > reverts back to 7 if I remove the test case. Looks like an obscure bug 
> > > > in the way the column number is computed...
> > > Should be "reverts back to 6"
> > Interesting. Are you sure there's nothing else here in play? Like non-ascii 
> > characters or weird line endings?
> I just checked -- nothing I can find. The file doesn't contain any bytes with 
> the high bit set, and there aren't any '\r' either.
Anyway, the patch LG. We can take a look at the column glitch offline.


https://reviews.llvm.org/D30569



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


[PATCH] D15090: [Static Analyzer] New checker hook: checkInitialState

2017-03-03 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In the meantime CheckBeginFunction has been implemented separately. I think you 
should "abandon" this revision so it is shown as closed.


https://reviews.llvm.org/D15090



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


[PATCH] D30569: [clang-tidy] misc-use-after-move: Fix failing assertion

2017-03-03 Thread Martin Böhme via Phabricator via cfe-commits
mboehme marked an inline comment as done.
mboehme added inline comments.



Comment at: test/clang-tidy/misc-use-after-move.cpp:285
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE-3]]:6: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:7: note: move occurred here
 }

alexfh wrote:
> mboehme wrote:
> > mboehme wrote:
> > > I've seen this column number flapping back and forth between 6 and 7 
> > > before.
> > > 
> > > This seems to be unrelated to my fix and instead is triggered simply by 
> > > adding the extra test case below; even with my fix present, this reverts 
> > > back to 7 if I remove the test case. Looks like an obscure bug in the way 
> > > the column number is computed...
> > Should be "reverts back to 6"
> Interesting. Are you sure there's nothing else here in play? Like non-ascii 
> characters or weird line endings?
I just checked -- nothing I can find. The file doesn't contain any bytes with 
the high bit set, and there aren't any '\r' either.


https://reviews.llvm.org/D30569



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


[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration

2017-03-03 Thread Andi via Phabricator via cfe-commits
Abpostelnicu added a comment.

In https://reviews.llvm.org/D30487#691535, @djasper wrote:

> Hm. Unfortunately, this seems to have been implemented to support Webkit 
> style and Webkit style is explicit about wanting this 
> (https://webkit.org/code-style-guidelines/) :(.
>
> But maybe the solution to that is to add an extra flag like 
> AlwaysWrapInitializerList. Really not sure how best to organize this. Any 
> thoughts? (I personally care about neither of these styles, so maybe I am not 
> the best to judge)
>
> At any rate, to move forward, could you remove the hasMultipleInheritance 
> function and instead use the alternative approach discussed?


Sure will drop hasMultipleInheritance and use the variable that you mentioned 
and i won't touch the rest of the patch. After that i will repost it here.


Repository:
  rL LLVM

https://reviews.llvm.org/D30487



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


[PATCH] D30567: [clang-tidy] Fix treating non-space whitespaces in checks list.

2017-03-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

What's the practical use of newlines and tab characters in the glob list?


https://reviews.llvm.org/D30567



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


[PATCH] D30569: [clang-tidy] misc-use-after-move: Fix failing assertion

2017-03-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG. Thanks!




Comment at: test/clang-tidy/misc-use-after-move.cpp:285
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE-3]]:6: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:7: note: move occurred here
 }

mboehme wrote:
> mboehme wrote:
> > I've seen this column number flapping back and forth between 6 and 7 before.
> > 
> > This seems to be unrelated to my fix and instead is triggered simply by 
> > adding the extra test case below; even with my fix present, this reverts 
> > back to 7 if I remove the test case. Looks like an obscure bug in the way 
> > the column number is computed...
> Should be "reverts back to 6"
Interesting. Are you sure there's nothing else here in play? Like non-ascii 
characters or weird line endings?


https://reviews.llvm.org/D30569



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


Re: [clang-tools-extra] r296867 - [clang-tidy] Fix modernize-use-emplace docs

2017-03-03 Thread Malcolm Parsons via cfe-commits
On 3 March 2017 at 12:42, Piotr Padlewski via cfe-commits
 wrote:
>  w.emplace_back(std::make_pair(21L, 37L);

Unbalanced ().

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


[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration

2017-03-03 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Hm. Unfortunately, this seems to have been implemented to support Webkit style 
and Webkit style is explicit about wanting this 
(https://webkit.org/code-style-guidelines/) :(.

But maybe the solution to that is to add an extra flag like 
AlwaysWrapInitializerList. Really not sure how best to organize this. Any 
thoughts? (I personally care about neither of these styles, so maybe I am not 
the best to judge)

At any rate, to move forward, could you remove the hasMultipleInheritance 
function and instead use the alternative approach discussed?


Repository:
  rL LLVM

https://reviews.llvm.org/D30487



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


[PATCH] D30569: [clang-tidy] misc-use-after-move: Fix failing assertion

2017-03-03 Thread Martin Böhme via Phabricator via cfe-commits
mboehme marked an inline comment as done.
mboehme added inline comments.



Comment at: test/clang-tidy/misc-use-after-move.cpp:285
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE-3]]:6: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:7: note: move occurred here
 }

mboehme wrote:
> I've seen this column number flapping back and forth between 6 and 7 before.
> 
> This seems to be unrelated to my fix and instead is triggered simply by 
> adding the extra test case below; even with my fix present, this reverts back 
> to 7 if I remove the test case. Looks like an obscure bug in the way the 
> column number is computed...
Should be "reverts back to 6"


https://reviews.llvm.org/D30569



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


[PATCH] D30569: [clang-tidy] misc-use-after-move: Fix failing assertion

2017-03-03 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added inline comments.



Comment at: test/clang-tidy/misc-use-after-move.cpp:285
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE-3]]:6: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:7: note: move occurred here
 }

I've seen this column number flapping back and forth between 6 and 7 before.

This seems to be unrelated to my fix and instead is triggered simply by adding 
the extra test case below; even with my fix present, this reverts back to 7 if 
I remove the test case. Looks like an obscure bug in the way the column number 
is computed...


https://reviews.llvm.org/D30569



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


[PATCH] D30569: [clang-tidy] misc-use-after-move: Fix failing assertion

2017-03-03 Thread Martin Böhme via Phabricator via cfe-commits
mboehme created this revision.
Herald added a subscriber: JDevlieghere.

I've added a test case that (without the fix) triggers the assertion,
which happens when a move happens in an implicitly called conversion
operator.


https://reviews.llvm.org/D30569

Files:
  clang-tidy/misc/UseAfterMoveCheck.cpp
  test/clang-tidy/misc-use-after-move.cpp


Index: test/clang-tidy/misc-use-after-move.cpp
===
--- test/clang-tidy/misc-use-after-move.cpp
+++ test/clang-tidy/misc-use-after-move.cpp
@@ -282,7 +282,7 @@
   S s{std::move(a)};
   a.foo();
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE-3]]:6: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:7: note: move occurred here
 }
 
 void lambdas() {
@@ -397,6 +397,21 @@
 }
 template void movedTypeIsDependentType();
 
+// We handle the case correctly where the move consists of an implicit call
+// to a conversion operator.
+void implicitConversionOperator() {
+  struct Convertible {
+operator A() && { return A(); }
+  };
+  void takeA(A a);
+
+  Convertible convertible;
+  takeA(std::move(convertible));
+  convertible;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'convertible' used after it was 
moved
+  // CHECK-MESSAGES: [[@LINE-3]]:9: note: move occurred here
+}
+
 // Using decltype on an expression is not a use.
 void decltypeIsNotUse() {
   A a;
Index: clang-tidy/misc/UseAfterMoveCheck.cpp
===
--- clang-tidy/misc/UseAfterMoveCheck.cpp
+++ clang-tidy/misc/UseAfterMoveCheck.cpp
@@ -398,7 +398,7 @@
   const auto *MovingCall = Result.Nodes.getNodeAs("moving-call");
   const auto *Arg = Result.Nodes.getNodeAs("arg");
 
-  if (!MovingCall)
+  if (!MovingCall || !MovingCall->getExprLoc().isValid())
 MovingCall = CallMove;
 
   Stmt *FunctionBody = nullptr;


Index: test/clang-tidy/misc-use-after-move.cpp
===
--- test/clang-tidy/misc-use-after-move.cpp
+++ test/clang-tidy/misc-use-after-move.cpp
@@ -282,7 +282,7 @@
   S s{std::move(a)};
   a.foo();
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
-  // CHECK-MESSAGES: [[@LINE-3]]:6: note: move occurred here
+  // CHECK-MESSAGES: [[@LINE-3]]:7: note: move occurred here
 }
 
 void lambdas() {
@@ -397,6 +397,21 @@
 }
 template void movedTypeIsDependentType();
 
+// We handle the case correctly where the move consists of an implicit call
+// to a conversion operator.
+void implicitConversionOperator() {
+  struct Convertible {
+operator A() && { return A(); }
+  };
+  void takeA(A a);
+
+  Convertible convertible;
+  takeA(std::move(convertible));
+  convertible;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'convertible' used after it was moved
+  // CHECK-MESSAGES: [[@LINE-3]]:9: note: move occurred here
+}
+
 // Using decltype on an expression is not a use.
 void decltypeIsNotUse() {
   A a;
Index: clang-tidy/misc/UseAfterMoveCheck.cpp
===
--- clang-tidy/misc/UseAfterMoveCheck.cpp
+++ clang-tidy/misc/UseAfterMoveCheck.cpp
@@ -398,7 +398,7 @@
   const auto *MovingCall = Result.Nodes.getNodeAs("moving-call");
   const auto *Arg = Result.Nodes.getNodeAs("arg");
 
-  if (!MovingCall)
+  if (!MovingCall || !MovingCall->getExprLoc().isValid())
 MovingCall = CallMove;
 
   Stmt *FunctionBody = nullptr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration

2017-03-03 Thread Andi via Phabricator via cfe-commits
Abpostelnicu added a comment.

In https://reviews.llvm.org/D30487#691517, @djasper wrote:

> Do you know whether that is intentional? The style guide isn't really 
> conclusive.


Well i'm not sure, because as you said the document is not clear but i think 
that when we have a single initialiser it should be on the same line as the 
ctor declaration. In this way it would be consistent with the style for 
inheritance list. The actual implementation for inheritance list breaking was 
tailored from the `BreakConstructorInitializersBeforeComma` flag.


Repository:
  rL LLVM

https://reviews.llvm.org/D30487



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


[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration

2017-03-03 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added inline comments.



Comment at: lib/Format/TokenAnnotator.cpp:2486
   Style.BreakConstructorInitializersBeforeComma &&
   !Style.ConstructorInitializerAllOnOneLineOrOnePerLine)

At any rate, I think this is what makes single-item ctor init lists be split. 
So everything except for this spot could still share the implementation.


Repository:
  rL LLVM

https://reviews.llvm.org/D30487



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


[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration

2017-03-03 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Do you know whether that is intentional? The style guide isn't really 
conclusive.


Repository:
  rL LLVM

https://reviews.llvm.org/D30487



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


[clang-tools-extra] r296867 - [clang-tidy] Fix modernize-use-emplace docs

2017-03-03 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Fri Mar  3 06:42:22 2017
New Revision: 296867

URL: http://llvm.org/viewvc/llvm-project?rev=296867=rev
Log:
[clang-tidy] Fix modernize-use-emplace docs

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst?rev=296867=296866=296867=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst 
Fri Mar  3 06:42:22 2017
@@ -36,7 +36,7 @@ After:
 
 std::vector> w;
 w.emplace_back(21, 37);
-// This will be fixed to w.push_back(21, 37); in next version
+// This will be fixed to w.emplace_back(21L, 37L); in next version
 w.emplace_back(std::make_pair(21L, 37L);
 
 The other situation is when we pass arguments that will be converted to a type


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


[PATCH] D30565: [analyzer] Terminate analysis on OpenMP code instead of crashing

2017-03-03 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

`git blame` shows that OMP* statements were added to the switch block by 
different authors while OpenMP support in clang was implemented. Looks like 
they were put to "Should not appear" section instead of "Unsupported" by 
mistake.


https://reviews.llvm.org/D30565



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


[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration

2017-03-03 Thread Andi via Phabricator via cfe-commits
Abpostelnicu added a comment.

In https://reviews.llvm.org/D30487#691506, @djasper wrote:

> Before `'`? Can you give an example?


MY mistake, i wanted to write ``:`


Repository:
  rL LLVM

https://reviews.llvm.org/D30487



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


[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration

2017-03-03 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Before `'`? Can you give an example?


Repository:
  rL LLVM

https://reviews.llvm.org/D30487



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


[PATCH] D30487: ClangFormat - Add option to break before inheritance separation operator in class declaration

2017-03-03 Thread Andi via Phabricator via cfe-commits
Abpostelnicu added inline comments.



Comment at: lib/Format/TokenAnnotator.cpp:2400
+// Returns 'true' if there is an TT_InheritanceComma in the current token list.
+static bool hasMultipleInheritance(const FormatToken ) {
+  for (const FormatToken* nextTok = Tok.Next; nextTok; nextTok = nextTok->Next)

djasper wrote:
> Abpostelnicu wrote:
> > djasper wrote:
> > > I don't think you need this. If you set MustBreakBefore to true for the 
> > > InheritanceCommas and set NoLineBreak to true when adding the 
> > > InheritanceColon on the same line, then clang-format will already do the 
> > > right thing.
> > > 
> > > Fundamentally, this seems to be identical to how we wrap constructor 
> > > initializer lists in Mozilla style. So I think we should also implement 
> > > this the same way (if not even reusing the same implementation).
> > Now that i've seen the behaviour of NoLineBreak thanks for pointing it out 
> > to me, but still correct me if i'm wrong but shouldn't i use: 
> > ``NoLineBreakInOperand``. 
> > My guess is if i use NoLineBreak, than breaking on the current line where 
> > we would have : or , would be prohibited.
> Yes, that would be prohibited and that is intended. Remember that I'd set 
> this after placing the colon on the same line (and I should have written 
> explicitly) as the class name. After that, there must not be any further line 
> breaks.
> 
> But again, I think we should just have the exact same behavior and 
> implementation as for constructor initializer lists.
Yes we should have the exact behaviour like the constructor initialisation 
list, but that one is also controlled by this flag: 
``BreakConstructorInitializersBeforeComma``, that on our coding style is set to 
true.
But still the actual behaviour of initialiser list still breaks before ``'`` 
for only one item.


Repository:
  rL LLVM

https://reviews.llvm.org/D30487



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


[PATCH] D30532: Add examples to clang-format configuration

2017-03-03 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

I also think that examples for the flags are good. My use case is that while 
developing/debugging its nice to see a short example for a random flag in the 
documentation pop-up.


https://reviews.llvm.org/D30532



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


[PATCH] D30564: [clang-tidy] Format code around applied fixes

2017-03-03 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296864: [clang-tidy] Format code around applied fixes 
(authored by alexfh).

Changed prior to commit:
  https://reviews.llvm.org/D30564?vs=90452=90453#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30564

Files:
  clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
  clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/index.rst
  clang-tools-extra/trunk/test/clang-tidy/clean-up-code.cpp
  
clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-format.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/clean-up-code.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/clean-up-code.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/clean-up-code.cpp
@@ -1,4 +1,6 @@
 // RUN: %check_clang_tidy %s misc-unused-using-decls %t
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- -format-style=none --
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- -format-style=llvm --
 namespace a { class A {}; }
 namespace b {
 using a::A;
Index: clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-format.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-format.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-format.cpp
@@ -0,0 +1,33 @@
+// RUN: %check_clang_tidy %s readability-braces-around-statements %t -- -format-style="{IndentWidth: 3}" --
+
+void do_something(const char *) {}
+
+bool cond(const char *) {
+  return false;
+}
+
+void test() {
+  if (cond("if0") /*comment*/) do_something("same-line");
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: statement should be inside braces
+  // CHECK-FIXES: {{^}}   if (cond("if0") /*comment*/) {{{$}}
+  // CHECK-FIXES-NEXT: {{^}}  do_something("same-line");{{$}}
+  // CHECK-FIXES-NEXT: {{^}}   }{{$}}
+
+  if (1) while (2) if (3) for (;;) do ; while(false) /**/;/**/
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: statement should be inside braces
+  // CHECK-MESSAGES: :[[@LINE-2]]:19: warning: statement should be inside braces
+  // CHECK-MESSAGES: :[[@LINE-3]]:26: warning: statement should be inside braces
+  // CHECK-MESSAGES: :[[@LINE-4]]:35: warning: statement should be inside braces
+  // CHECK-MESSAGES: :[[@LINE-5]]:38: warning: statement should be inside braces
+  // CHECK-FIXES:  {{^}}   if (1) {{{$}}
+  // CHECK-FIXES-NEXT: {{^}}  while (2) {
+  // CHECK-FIXES-NEXT: {{^}} if (3) {
+  // CHECK-FIXES-NEXT: {{^}}for (;;) {
+  // CHECK-FIXES-NEXT: {{^}}   do {
+  // CHECK-FIXES-NEXT: {{^}}  ;
+  // CHECK-FIXES-NEXT: {{^}}   } while (false) /**/; /**/
+  // CHECK-FIXES-NEXT: {{^}}}
+  // CHECK-FIXES-NEXT: {{^}} }
+  // CHECK-FIXES-NEXT: {{^}}  }
+  // CHECK-FIXES-NEXT: {{^}}   }
+}
Index: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
@@ -60,7 +60,7 @@
 prefix add checks with matching names to the
 set, globs with the '-' prefix remove checks
 with matching names from the set of enabled
-checks.  This option's value is appended to the
+checks. This option's value is appended to the
 value of the 'Checks' option in .clang-tidy
 file, if any.
 )"),
@@ -120,12 +120,20 @@
 )"),
cl::init(false), cl::cat(ClangTidyCategory));
 
-static cl::opt FormatStyle("style", cl::desc(R"(
-Fallback style for reformatting after inserting fixes
-if there is no clang-format config file found.
+static cl::opt FormatStyle("format-style", cl::desc(R"(
+Style for formatting code around applied fixes:
+  - 'none' (default) turns off formatting
+  - 'file' (literally 'file', not a placeholder)
+uses .clang-format file in the closest parent
+directory
+  - '{  }' specifies options inline, e.g.
+-format-style='{BasedOnStyle: llvm, IndentWidth: 8}'
+  - 'llvm', 'google', 'webkit', 'mozilla'
+See clang-format documentation for the up-to-date
+information about formatting styles and options.
 )"),
-cl::init("llvm"),
-cl::cat(ClangTidyCategory));
+   cl::init("none"),
+   cl::cat(ClangTidyCategory));
 
 static cl::opt ListChecks("list-checks", cl::desc(R"(
 List all enabled checks and exit. Use with
@@ -189,7 +197,7 @@
 cl::cat(ClangTidyCategory));
 
 static cl::opt Quiet("quiet", cl::desc(R"(
-Run clang-tidy in quiet mode.  This suppresses
+Run 

[PATCH] D30489: [analyzer] catch out of bounds for VLA

2017-03-03 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment.

To me it seems that the extent is calculated properly in ArrayBoundsV2.

Existing code:

  DefinedOrUnknownSVal extentVal =
rawOffset.getRegion()->getExtent(svalBuilder);

This ugly little debug code will extract the needed VLA information from the 
extentVal...

  if (extentVal.getSubKind() == nonloc::SymbolValKind) {
SymbolRef SR = extentVal.castAs().getSymbol();
const SymbolExtent *SE = dyn_cast(SR);
const MemRegion *SEMR = SE->getRegion();
if (SEMR->getKind() == MemRegion::VarRegionKind) {
  const VarRegion *VR = cast(SEMR);
  QualType T = VR->getDecl()->getType();
  ASTContext  = checkerContext.getASTContext();
  const VariableArrayType *VLA = Ctx.getAsVariableArrayType(T);

A VLA->dump() after that will output:

  VariableArrayType 0x87f6a80 'char [sz]' variably_modified 
  |-BuiltinType 0x87f6480 'char'
  `-ImplicitCastExpr 0x87f6a70 'int' 
`-DeclRefExpr 0x87f6a58 'int' lvalue ParmVar 0x87f6948 'sz' 'int'

which is exactly what the corresponding VLA->dump() in the checkPreStmt() 
outputs.

As far as I see the problem is that the ProgramState does not keep the symbolic 
value for sz.

In checkPreStmt the state is:

  Expressions:
   (0xe4acb0,0xe04790) sz : reg_$0
   (0xe4acb0,0xe04828) array : 
   (0xe4acb0,0xe04840) sz : 
   (0xe4acb0,0xe04858) array : {array,0 S64b,char}
   (0xe4acb0,0xe04868) sz : reg_$0
   (0xe4acb0,0xe048b0) 1 : 1 S8b

in checkLocation() the state is:

  Expressions:
   (0xe4acb0,0xe04878) array[sz] : {array,reg_$0,char}
   (0xe4acb0,0xe048b0) 1 : 1 S8b
   (0xe4acb0,0xe048c0) array[sz] = 1 : 1 S8b
  Ranges of symbol values:
   reg_$0 : { [0, 2147483647] }

This little code works in checkPreStmt() but not in checkLocation():

  SVal sizeV = State->getSVal(VLA->getSizeExpr(), C.getLocationContext());

In checkPreStmt that returns "reg_$0" and in checkLocation() that 
returns "Unknown".

Do you agree that this is the problem? Would it be a good idea to try to keep 
the sz in the ProgramState?


Repository:
  rL LLVM

https://reviews.llvm.org/D30489



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


[clang-tools-extra] r296864 - [clang-tidy] Format code around applied fixes

2017-03-03 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Mar  3 05:16:34 2017
New Revision: 296864

URL: http://llvm.org/viewvc/llvm-project?rev=296864=rev
Log:
[clang-tidy] Format code around applied fixes

Summary:
Add -format option (disabled by default for now) to trigger formatting
of replacements.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: kimgr, malcolm.parsons, JDevlieghere, cfe-commits

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

Added:

clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements-format.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/index.rst
clang-tools-extra/trunk/test/clang-tidy/clean-up-code.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=296864=296863=296864=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Fri Mar  3 05:16:34 2017
@@ -183,7 +183,6 @@ public:
   }
 
   void Finish() {
-// FIXME: Run clang-format on changes.
 if (ApplyFixes && TotalFixes > 0) {
   Rewriter Rewrite(SourceMgr, LangOpts);
   for (const auto  : FileReplacements) {
@@ -197,19 +196,28 @@ public:
   continue;
 }
 StringRef Code = Buffer.get()->getBuffer();
-auto Style = format::getStyle("file", File, FormatStyle);
+auto Style = format::getStyle(FormatStyle, File, "none");
 if (!Style) {
   llvm::errs() << llvm::toString(Style.takeError()) << "\n";
   continue;
 }
-llvm::Expected CleanReplacements =
+llvm::Expected Replacements =
 format::cleanupAroundReplacements(Code, FileAndReplacements.second,
   *Style);
-if (!CleanReplacements) {
-  llvm::errs() << llvm::toString(CleanReplacements.takeError()) << 
"\n";
+if (!Replacements) {
+  llvm::errs() << llvm::toString(Replacements.takeError()) << "\n";
   continue;
 }
-if (!tooling::applyAllReplacements(CleanReplacements.get(), Rewrite)) {
+if (llvm::Expected FormattedReplacements =
+format::formatReplacements(Code, *Replacements, *Style)) {
+  Replacements = std::move(FormattedReplacements);
+  if (!Replacements)
+llvm_unreachable("!Replacements");
+} else {
+  llvm::errs() << llvm::toString(FormattedReplacements.takeError())
+   << ". Skipping formatting.\n";
+}
+if (!tooling::applyAllReplacements(Replacements.get(), Rewrite)) {
   llvm::errs() << "Can't apply replacements for file " << File << "\n";
 }
   }

Modified: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp?rev=296864=296863=296864=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Fri Mar  3 
05:16:34 2017
@@ -60,7 +60,7 @@ appearance in the list. Globs without '-
 prefix add checks with matching names to the
 set, globs with the '-' prefix remove checks
 with matching names from the set of enabled
-checks.  This option's value is appended to the
+checks. This option's value is appended to the
 value of the 'Checks' option in .clang-tidy
 file, if any.
 )"),
@@ -120,12 +120,20 @@ well.
 )"),
cl::init(false), cl::cat(ClangTidyCategory));
 
-static cl::opt FormatStyle("style", cl::desc(R"(
-Fallback style for reformatting after inserting fixes
-if there is no clang-format config file found.
+static cl::opt FormatStyle("format-style", cl::desc(R"(
+Style for formatting code around applied fixes:
+  - 'none' (default) turns off formatting
+  - 'file' (literally 'file', not a placeholder)
+uses .clang-format file in the closest parent
+directory
+  - '{  }' specifies options inline, e.g.
+-format-style='{BasedOnStyle: llvm, IndentWidth: 8}'
+  - 'llvm', 'google', 'webkit', 'mozilla'
+See clang-format documentation for the up-to-date
+information about formatting styles and options.
 )"),
-cl::init("llvm"),
-cl::cat(ClangTidyCategory));
+   cl::init("none"),
+   cl::cat(ClangTidyCategory));
 
 static cl::opt ListChecks("list-checks", cl::desc(R"(
 List all enabled checks and exit. Use with
@@ -189,7 +197,7 @@ code with clang-apply-replacements.
   

[PATCH] D30564: [clang-tidy] Format code around applied fixes

2017-03-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh updated this revision to Diff 90452.
alexfh added a comment.

Apply changes even when formatting fails.


https://reviews.llvm.org/D30564

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/tool/ClangTidyMain.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/clean-up-code.cpp
  test/clang-tidy/readability-braces-around-statements-format.cpp

Index: test/clang-tidy/readability-braces-around-statements-format.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-braces-around-statements-format.cpp
@@ -0,0 +1,33 @@
+// RUN: %check_clang_tidy %s readability-braces-around-statements %t -- -format-style="{IndentWidth: 3}" --
+
+void do_something(const char *) {}
+
+bool cond(const char *) {
+  return false;
+}
+
+void test() {
+  if (cond("if0") /*comment*/) do_something("same-line");
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: statement should be inside braces
+  // CHECK-FIXES: {{^}}   if (cond("if0") /*comment*/) {{{$}}
+  // CHECK-FIXES-NEXT: {{^}}  do_something("same-line");{{$}}
+  // CHECK-FIXES-NEXT: {{^}}   }{{$}}
+
+  if (1) while (2) if (3) for (;;) do ; while(false) /**/;/**/
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: statement should be inside braces
+  // CHECK-MESSAGES: :[[@LINE-2]]:19: warning: statement should be inside braces
+  // CHECK-MESSAGES: :[[@LINE-3]]:26: warning: statement should be inside braces
+  // CHECK-MESSAGES: :[[@LINE-4]]:35: warning: statement should be inside braces
+  // CHECK-MESSAGES: :[[@LINE-5]]:38: warning: statement should be inside braces
+  // CHECK-FIXES:  {{^}}   if (1) {{{$}}
+  // CHECK-FIXES-NEXT: {{^}}  while (2) {
+  // CHECK-FIXES-NEXT: {{^}} if (3) {
+  // CHECK-FIXES-NEXT: {{^}}for (;;) {
+  // CHECK-FIXES-NEXT: {{^}}   do {
+  // CHECK-FIXES-NEXT: {{^}}  ;
+  // CHECK-FIXES-NEXT: {{^}}   } while (false) /**/; /**/
+  // CHECK-FIXES-NEXT: {{^}}}
+  // CHECK-FIXES-NEXT: {{^}} }
+  // CHECK-FIXES-NEXT: {{^}}  }
+  // CHECK-FIXES-NEXT: {{^}}   }
+}
Index: test/clang-tidy/clean-up-code.cpp
===
--- test/clang-tidy/clean-up-code.cpp
+++ test/clang-tidy/clean-up-code.cpp
@@ -1,4 +1,6 @@
 // RUN: %check_clang_tidy %s misc-unused-using-decls %t
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- -format-style=none --
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- -format-style=llvm --
 namespace a { class A {}; }
 namespace b {
 using a::A;
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -158,6 +158,17 @@
errors were found. If compiler errors have
attached fix-its, clang-tidy will apply them as
well.
+-format-style=   -
+   Style for formatting code around applied fixes:
+ - 'none' (default) turns off formatting
+ - 'file' (literally 'file', not a placeholder)
+   uses .clang-format file in the closest parent
+   directory
+ - '{  }' specifies options inline, e.g.
+   -format-style='{BasedOnStyle: llvm, IndentWidth: 8}'
+ - 'llvm', 'google', 'webkit', 'mozilla'
+   See clang-format documentation for the up-to-date
+   information about formatting styles and options.
 -header-filter=  -
Regular expression matching the names of the
headers to output diagnostics from. Diagnostics
@@ -179,6 +190,11 @@
List all enabled checks and exit. Use with
-checks=* to list all available checks.
 -p=  - Build path
+-quiet   -
+   Run clang-tidy in quiet mode. This suppresses
+   printing statistics about ignored warnings and
+   warnings treated as errors if the respective
+   options are specified.
 -style=  -
Fallback style for reformatting after inserting fixes
if there is no clang-format config file found.
@@ -558,10 +574,10 @@
 against the fixed code (i.e., the code after generated fix-its are
 applied). In particular, ``CHECK-FIXES:`` can be used to check
 that code was not modified by fix-its, by checking that it is present

[PATCH] D30564: [clang-tidy] Format code around applied fixes

2017-03-03 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clang-tidy/ClangTidy.cpp:214
+  llvm::errs() << llvm::toString(Replacements.takeError()) << "\n";
+  continue;
+}

Maybe still apply the replacements if formatting fails?


https://reviews.llvm.org/D30564



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


[PATCH] D30564: [clang-tidy] Format code around applied fixes

2017-03-03 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

Lg


https://reviews.llvm.org/D30564



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


[PATCH] D30564: [clang-tidy] Format code around applied fixes

2017-03-03 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

LGTM.


https://reviews.llvm.org/D30564



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


[PATCH] D30564: [clang-tidy] Format code around applied fixes

2017-03-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

PTAL


https://reviews.llvm.org/D30564



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


  1   2   >